Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
import
Browse files Browse the repository at this point in the history
  • Loading branch information
MagerValp authored and MagerValp committed Oct 25, 2011
0 parents commit 13c4ec4
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README
@@ -0,0 +1,8 @@
iLife '11 repackaging script
============================

This creates a flat package suitable for deployment with InstaDMG, DeployStudio, Absolute Manage, and other management tools. To use it, mount an iLife '11 installer disc and run:

./repackage_ilife11.sh "/Volumes/iLife '11 Install DVD"

It'll run and hopefully create a 3 GB flat package with today's datestamp.
61 changes: 61 additions & 0 deletions flatten_dist.py
@@ -0,0 +1,61 @@
#!/usr/bin/python


import sys
import optparse
from xml.etree import ElementTree


def flatten_pkg_path(path):
path = path.rpartition("/")[2]
return "#" + path


def flatten_pkg_refs(dist):
packages = dict()

for pkgref in dist.findall("choice/pkg-ref"):
pkg_id = pkgref.get("id")
pkg_auth = pkgref.get("auth")
pkg_path = pkgref.text
packages[pkg_id] = {
"auth": "Root" if pkg_auth == "root" else pkg_auth,
"pkg": flatten_pkg_path(pkg_path)
}
del pkgref.attrib["auth"]
del pkgref.text

for pkgref in dist.findall("pkg-ref"):
pkg_id = pkgref.get("id")
pkgref.set("auth", packages[pkg_id]["auth"])
pkgref.text = packages[pkg_id]["pkg"]

return dist


def main(argv):
p = optparse.OptionParser()
p.set_usage("""Usage: %prog [options]""")
p.add_option("-v", "--verbose", action="store_true",
help="Verbose output.")
options, argv = p.parse_args(argv)
if len(argv) != 2:
print >>sys.stderr, p.get_usage()
return 1

dist_path = argv[1]

with open(dist_path) as f:
dist = ElementTree.parse(f)

flatten_pkg_refs(dist)

with open(dist_path, "w") as f:
dist.write(f, encoding="utf-8")

return 0


if __name__ == '__main__':
sys.exit(main(sys.argv))

68 changes: 68 additions & 0 deletions repackage_ilife11.sh
@@ -0,0 +1,68 @@
#!/bin/bash


SRCVOL="$1"
if [ ! -d "$SRCVOL" ]; then
echo "Usage: "`basename "$0"`" /Volumes/iLife\\ \\'11\\ Install\\ DVD"
exit 1
fi

PKGSRC="${SRCVOL%/}/Installer/Packages"
PKGNAME=`date +"iLife11-%Y%m%d.pkg"`


echo "* Checking media"

if [ ! -f "$PKGSRC/iLife.pkg" ]; then
echo "'$SRCVOL' is not an iLife '11 installer DVD"
exit 1
fi


echo "* Expanding iLife base package"

rm -rf iLife_pkg
pkgutil --expand "$PKGSRC/iLife.pkg" iLife_pkg
if [ $? -ne 0 ]; then
echo "Package expansion failed!"
exit 1
fi


echo "* Modifying Distribution"

./flatten_dist.py iLife_pkg/Distribution
if [ $? -ne 0 ]; then
echo "Distribution modification failed!"
exit 1
fi


echo "* Expanding sub-packages"

for pkg in "$PKGSRC"/*.pkg; do
pkgname=`basename "$pkg"`
if [ "$pkgname" != iLife.pkg ]; then
echo "Expanding $pkgname..."
pkgutil --expand "$pkg" "iLife_pkg/$pkgname"
if [ $? -ne 0 ]; then
echo "Package expansion failed!"
exit 1
fi
fi
done


echo "* Flattening packge"

pkgutil --flatten iLife_pkg "$PKGNAME"
if [ $? -ne 0 ]; then
echo "Flattening failed!"
exit 1
fi

open -R "$PKGNAME"
rm -rf iLife_pkg


echo "* Done"

0 comments on commit 13c4ec4

Please sign in to comment.