Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

import

  • Loading branch information...
commit 13c4ec41a2578950f78542209a48b1b52607fc7a 0 parents
MagerValp authored
Showing with 137 additions and 0 deletions.
  1. +8 −0 README
  2. +61 −0 flatten_dist.py
  3. +68 −0 repackage_ilife11.sh
8 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 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 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"

1 comment on commit 13c4ec4

@nbalonso

after downloading your script I had to remove the quarantine attribute of the python file.

xattr -r com.apple.quarantine flatten_dist.py

then worked fine

Please sign in to comment.
Something went wrong with that request. Please try again.