#!/usr/bin/python
"""
Script by Chris Barker (chrisb@sneezingdog.com) to generate lists of Apple's flat package format they use for os and security updates and makes some useful documentation
Copyright [2009] Chris Barker
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import commands, os, sys, shutil
from BeautifulSoup import BeautifulSoup
def unFlattenPKG(pkg):
dest = "/tmp/wtfupdate"
flatStatus = commands.getstatusoutput("/usr/sbin/pkgutil --expand \"%s\" \"%s\"" % (pkg, dest) )
#print flatStatus
return dest
def getSUDescription(pkg):
sud = open(pkg+'/Resources/English.lproj/SUDescription.html', 'r')
soup = BeautifulSoup(sud)
sud.close()
return soup.body
def getScripts(pkg, htmloutput):
#htmloutput.write("""
Scripts\n""")
for fileName in os.listdir(pkg):
if os.path.splitext(fileName)[1] == '.pkg':
htmloutput.write("""
%s Scripts\n""" % fileName)
for script in os.listdir(pkg + '/' + fileName + '/Scripts'):
if os.path.isfile(pkg + '/' + fileName + '/Scripts' + '/' + script):
htmloutput.write("""