`
xitong
  • 浏览: 6190301 次
文章分类
社区版块
存档分类
最新评论

OS X:实用脚本程序系列-17

 
阅读更多

下面的bash shell脚本可以用来将iLife '11的DVD安装盘,转换为一个可以用来发布的扁平化的安装文件,扁平化后也可以解决由于DVD安装文件的证书过期问题而造成的安装失败的问题。

#!/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"


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics