mirror of
https://github.com/munki/munki.git
synced 2026-04-24 05:49:42 -05:00
New make_munki_mpkg.sh script and pkgtemplate resources.
git-svn-id: http://munki.googlecode.com/svn/trunk@1122 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
+2
-2
@@ -3,8 +3,8 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IFPkgDescriptionTitle</key>
|
||||
<string>Munki Commandline Tools</string>
|
||||
<string>Munki core tools</string>
|
||||
<key>IFPkgDescriptionDescription</key>
|
||||
<string>Commandline tools used by munki runtime and administrators.</string>
|
||||
<string>Core command-line tools used by munki.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IFPkgDescriptionTitle</key>
|
||||
<string>Munki Agent</string>
|
||||
<string>Munki launchd agents</string>
|
||||
<key>IFPkgDescriptionDescription</key>
|
||||
<string>Munki launch daemons and launch agents.</string>
|
||||
</dict>
|
||||
+145
-70
@@ -77,6 +77,11 @@ MUNKIVERS=`defaults read "$MUNKIROOT/code/client/munkilib/version" CFBundleShort
|
||||
SVNREV=`svnversion $MUNKIROOT | cut -d: -f2 | tr -cd '[:digit:]'`
|
||||
VERSION=$MUNKIVERS.$SVNREV.0
|
||||
|
||||
# Get launchd version if different
|
||||
LAUNCHDVERSION=$VERSION
|
||||
if [ -e "$MUNKIROOT/launchd/version.plist" ]; then
|
||||
LAUNCHDVERSION=`defaults read "$MUNKIROOT/launchd/version" CFBundleShortVersionString`
|
||||
fi
|
||||
|
||||
# Configure flat or bundle package.
|
||||
if [ "$PKGTYPE" == "flat" ]; then
|
||||
@@ -115,7 +120,8 @@ echo " Package type: $PKGTYPE"
|
||||
echo " Bundle ID: $PKGID"
|
||||
echo " Munki root: $MUNKIROOT"
|
||||
echo " Output directory: $OUTPUTDIR"
|
||||
echo " Version: $VERSION"
|
||||
echo " munki tools version: $VERSION"
|
||||
echo " LaunchAgents/LaunchDaemons version: $LAUNCHDVERSION"
|
||||
echo
|
||||
|
||||
|
||||
@@ -230,42 +236,86 @@ EOF
|
||||
|
||||
# Pre-build cleanup.
|
||||
rm -rf "$MPKG"
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo "Error removing $MPKG before rebuilding it."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
# Create temporary directory
|
||||
PKGTMP=`mktemp -d -t munkipkg`
|
||||
|
||||
|
||||
######################
|
||||
## /usr/local/munki ##
|
||||
######################
|
||||
#########################################
|
||||
## core munki tools ##
|
||||
## /usr/local/munki, minus admin tools ##
|
||||
## plus /Library/Managed Installs ##
|
||||
#########################################
|
||||
|
||||
echo "Creating /usr package template..."
|
||||
echo "Creating core package template..."
|
||||
|
||||
# Create directory structure.
|
||||
USRROOT="$PKGTMP/munki_usr"
|
||||
mkdir -m 1775 "$USRROOT"
|
||||
mkdir -p "$USRROOT/usr/local/munki/munkilib"
|
||||
chmod -R 755 "$USRROOT/usr"
|
||||
COREROOT="$PKGTMP/munki_core"
|
||||
mkdir -m 1775 "$COREROOT"
|
||||
mkdir -p "$COREROOT/usr/local/munki/munkilib"
|
||||
chmod -R 755 "$COREROOT/usr"
|
||||
# Copy command line utilities.
|
||||
cp -X "$MUNKIROOT/code/client/"* "$USRROOT/usr/local/munki/" 2>&1 | grep -v "munkilib is a directory"
|
||||
# edit this if list of tools changes!
|
||||
for TOOL in launchapp managedsoftwareupdate supervisor
|
||||
do
|
||||
cp -X "$MUNKIROOT/code/client/$TOOL" "$COREROOT/usr/local/munki/" 2>&1
|
||||
done
|
||||
# Copy python library.
|
||||
cp -X "$MUNKIROOT/code/client/munkilib/"*.py "$USRROOT/usr/local/munki/munkilib/"
|
||||
cp -X "$MUNKIROOT/code/client/munkilib/"*.py "$COREROOT/usr/local/munki/munkilib/"
|
||||
# Copy munki version.
|
||||
cp -X "$MUNKIROOT/code/client/munkilib/version.plist" "$USRROOT/usr/local/munki/munkilib/"
|
||||
echo $SVNREV > "$USRROOT/usr/local/munki/munkilib/svnversion"
|
||||
# Don't include scripts in the package.
|
||||
rm -f "$USRROOT/usr/local/munki/preflight"
|
||||
rm -f "$USRROOT/usr/local/munki/postflight"
|
||||
rm -f "$USRROOT/usr/local/munki/report_broken_client"
|
||||
cp -X "$MUNKIROOT/code/client/munkilib/version.plist" "$COREROOT/usr/local/munki/munkilib/"
|
||||
echo $SVNREV > "$COREROOT/usr/local/munki/munkilib/svnversion"
|
||||
# Set permissions.
|
||||
chmod -R go-w "$USRROOT/usr/local/munki"
|
||||
chmod +x "$USRROOT/usr/local/munki"
|
||||
chmod +x "$USRROOT/usr/local/munki/munkilib/"*.py
|
||||
chmod -R go-w "$COREROOT/usr/local/munki"
|
||||
chmod +x "$COREROOT/usr/local/munki"
|
||||
#chmod +x "$COREROOT/usr/local/munki/munkilib/"*.py
|
||||
|
||||
# Create directory structure for /Library/Managed Installs.
|
||||
mkdir -m 1775 "$COREROOT/Library"
|
||||
mkdir -m 755 -p "$COREROOT/Library/Managed Installs"
|
||||
mkdir -m 750 -p "$COREROOT/Library/Managed Installs/Cache"
|
||||
mkdir -m 750 -p "$COREROOT/Library/Managed Installs/catalogs"
|
||||
mkdir -m 755 -p "$COREROOT/Library/Managed Installs/manifests"
|
||||
|
||||
|
||||
# Create package info file.
|
||||
USRSIZE=`du -sk $USRROOT | cut -f1`
|
||||
NFILES=$(echo `find $USRROOT/ | wc -l`)
|
||||
makeinfo usr "$PKGTMP/info" "$PKGID" "$VERSION" $USRSIZE $NFILES norestart
|
||||
CORESIZE=`du -sk $COREROOT | cut -f1`
|
||||
NFILES=$(echo `find $COREROOT/ | wc -l`)
|
||||
makeinfo core "$PKGTMP/info" "$PKGID" "$VERSION" $CORESIZE $NFILES norestart
|
||||
|
||||
|
||||
#########################################
|
||||
## admin munki tools ##
|
||||
## /usr/local/munki admin tools ##
|
||||
#########################################
|
||||
|
||||
echo "Creating admin package template..."
|
||||
|
||||
# Create directory structure.
|
||||
ADMINROOT="$PKGTMP/munki_admin"
|
||||
mkdir -m 1775 "$ADMINROOT"
|
||||
mkdir -p "$ADMINROOT/usr/local/munki"
|
||||
chmod -R 755 "$ADMINROOT/usr"
|
||||
# Copy command line admin utilities.
|
||||
# edit this if list of tools changes!
|
||||
for TOOL in makecatalogs makepkginfo munkiimport
|
||||
do
|
||||
cp -X "$MUNKIROOT/code/client/$TOOL" "$ADMINROOT/usr/local/munki/" 2>&1
|
||||
done
|
||||
# Set permissions.
|
||||
chmod -R go-w "$ADMINROOT/usr/local/munki"
|
||||
chmod +x "$ADMINROOT/usr/local/munki"
|
||||
|
||||
# Create package info file.
|
||||
ADMINSIZE=`du -sk $ADMINROOT | cut -f1`
|
||||
NFILES=$(echo `find $ADMINROOT/ | wc -l`)
|
||||
makeinfo admin "$PKGTMP/info" "$PKGID" "$VERSION" $ADMINSIZE $NFILES norestart
|
||||
|
||||
|
||||
|
||||
###################
|
||||
@@ -290,30 +340,26 @@ makeinfo app "$PKGTMP/info" "$PKGID" "$MSUVERSION" $APPSIZE $NFILES norestart
|
||||
|
||||
|
||||
##############
|
||||
## /Library ##
|
||||
## launchd ##
|
||||
##############
|
||||
|
||||
echo "Creating /Library package template..."
|
||||
echo "Creating launchd package template..."
|
||||
|
||||
# Create directory structure.
|
||||
LIBROOT="$PKGTMP/munki_lib"
|
||||
mkdir -m 1775 "$LIBROOT"
|
||||
mkdir -m 1775 "$LIBROOT/Library"
|
||||
mkdir -m 755 "$LIBROOT/Library/LaunchAgents"
|
||||
mkdir -m 755 "$LIBROOT/Library/LaunchDaemons"
|
||||
mkdir -m 755 -p "$LIBROOT/Library/Managed Installs"
|
||||
mkdir -m 750 -p "$LIBROOT/Library/Managed Installs/Cache"
|
||||
mkdir -m 750 -p "$LIBROOT/Library/Managed Installs/catalogs"
|
||||
mkdir -m 755 -p "$LIBROOT/Library/Managed Installs/manifests"
|
||||
LAUNCHDROOT="$PKGTMP/munki_launchd"
|
||||
mkdir -m 1775 "$LAUNCHDROOT"
|
||||
mkdir -m 1775 "$LAUNCHDROOT/Library"
|
||||
mkdir -m 755 "$LAUNCHDROOT/Library/LaunchAgents"
|
||||
mkdir -m 755 "$LAUNCHDROOT/Library/LaunchDaemons"
|
||||
# Copy launch daemons and launch agents.
|
||||
cp -X "$MUNKIROOT/launchd/LaunchAgents/"*.plist "$LIBROOT/Library/LaunchAgents/"
|
||||
chmod 644 "$LIBROOT/Library/LaunchAgents/"*
|
||||
cp -X "$MUNKIROOT/launchd/LaunchDaemons/"*.plist "$LIBROOT/Library/LaunchDaemons/"
|
||||
chmod 644 "$LIBROOT/Library/LaunchDaemons/"*
|
||||
cp -X "$MUNKIROOT/launchd/LaunchAgents/"*.plist "$LAUNCHDROOT/Library/LaunchAgents/"
|
||||
chmod 644 "$LAUNCHDROOT/Library/LaunchAgents/"*
|
||||
cp -X "$MUNKIROOT/launchd/LaunchDaemons/"*.plist "$LAUNCHDROOT/Library/LaunchDaemons/"
|
||||
chmod 644 "$LAUNCHDROOT/Library/LaunchDaemons/"*
|
||||
# Create package info file.
|
||||
LIBSIZE=`du -sk $LIBROOT | cut -f1`
|
||||
NFILES=$(echo `find $LIBROOT/ | wc -l`)
|
||||
makeinfo lib "$PKGTMP/info" "$PKGID" "$VERSION" $LIBSIZE $NFILES restart
|
||||
LAUNCHDSIZE=`du -sk $LAUNCHDROOT | cut -f1`
|
||||
NFILES=$(echo `find $LAUNCHDROOT/ | wc -l`)
|
||||
makeinfo launchd "$PKGTMP/info" "$PKGID" "$LAUNCHDVERSION" $LAUNCHDSIZE $NFILES restart
|
||||
|
||||
|
||||
#############################
|
||||
@@ -338,7 +384,7 @@ else
|
||||
mkdir -p "$METAROOT/Contents/Packages"
|
||||
# Copy Resources.
|
||||
cp -R "$MUNKIROOT/code/pkgtemplate/Resources" "$METAROOT/Contents/"
|
||||
find -d "$METAROOT" -name .svn -exec rm -rf {} \;
|
||||
find -d "$METAROOT" -name .svn -exec sudo rm -rf {} \;
|
||||
# Configure Distribution.dist.
|
||||
DISTFILE="$METAROOT/Contents/distribution.dist"
|
||||
PKGPREFIX="file:./Contents/Packages/"
|
||||
@@ -346,17 +392,19 @@ else
|
||||
PKGDEST="$METAROOT/Contents/Packages"
|
||||
fi
|
||||
# Create Distribution file.
|
||||
USRTITLE=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_usr/English.lproj/Description" IFPkgDescriptionTitle`
|
||||
CORETITLE=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_core/English.lproj/Description" IFPkgDescriptionTitle`
|
||||
ADMINTITLE=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_admin/English.lproj/Description" IFPkgDescriptionTitle`
|
||||
APPTITLE=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_app/English.lproj/Description" IFPkgDescriptionTitle`
|
||||
LIBTITLE=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_lib/English.lproj/Description" IFPkgDescriptionTitle`
|
||||
USRDESC=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_usr/English.lproj/Description" IFPkgDescriptionDescription`
|
||||
LAUNCHDTITLE=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_launchd/English.lproj/Description" IFPkgDescriptionTitle`
|
||||
COREDESC=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_core/English.lproj/Description" IFPkgDescriptionDescription`
|
||||
ADMINDESC=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_admin/English.lproj/Description" IFPkgDescriptionDescription`
|
||||
APPDESC=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_app/English.lproj/Description" IFPkgDescriptionDescription`
|
||||
LIBDESC=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_lib/English.lproj/Description" IFPkgDescriptionDescription`
|
||||
LAUNCHDDESC=`defaults read "$MUNKIROOT/code/pkgtemplate/Resources_launchd/English.lproj/Description" IFPkgDescriptionDescription`
|
||||
CONFOUTLINE=""
|
||||
CONFCHOICE=""
|
||||
CONFREF=""
|
||||
if [ ! -z "$CONFPKG" ]; then
|
||||
if [ $PKGTYPE == "flag" ]; then
|
||||
if [ $PKGTYPE == "flat" ]; then
|
||||
echo "Flat configuration package not implemented"
|
||||
exit 1
|
||||
else
|
||||
@@ -375,8 +423,8 @@ if [ ! -z "$CONFPKG" ]; then
|
||||
CONFVERSION=`defaults read "$CONFPKG/Contents/Info" CFBundleShortVersionString`
|
||||
CONFBASENAME=`basename "$CONFPKG"`
|
||||
fi
|
||||
CONFOUTLINE="<line choice=\"choice3\"/>"
|
||||
CONFCHOICE="<choice id=\"choice3\" title=\"$CONFTITLE\" description=\"$CONFDESC\">
|
||||
CONFOUTLINE="<line choice=\"choice4\"/>"
|
||||
CONFCHOICE="<choice id=\"choice4\" title=\"$CONFTITLE\" description=\"$CONFDESC\">
|
||||
<pkg-ref id=\"$CONFID\"/>
|
||||
</choice>"
|
||||
CONFREF="<pkg-ref id=\"$CONFID\" installKBytes=\"$CONFSIZE\" version=\"$CONFVERSION\" auth=\"Root\">${PKGPREFIX}$CONFBASENAME</pkg-ref>"
|
||||
@@ -391,21 +439,26 @@ cat > "$DISTFILE" <<EOF
|
||||
<line choice="choice0"/>
|
||||
<line choice="choice1"/>
|
||||
<line choice="choice2"/>
|
||||
<line choice="choice3"/>
|
||||
$CONFOUTLINE
|
||||
</choices-outline>
|
||||
<choice id="choice0" title="$USRTITLE" description="$USRDESC">
|
||||
<pkg-ref id="$PKGID.usr"/>
|
||||
<choice id="choice0" title="$CORETITLE" description="$COREDESC">
|
||||
<pkg-ref id="$PKGID.core"/>
|
||||
</choice>
|
||||
<choice id="choice1" title="$APPTITLE" description="$APPDESC">
|
||||
<choice id="choice1" title="$ADMINTITLE" description="$ADMINDESC">
|
||||
<pkg-ref id="$PKGID.admin"/>
|
||||
</choice>
|
||||
<choice id="choice2" title="$APPTITLE" description="$APPDESC">
|
||||
<pkg-ref id="$PKGID.app"/>
|
||||
</choice>
|
||||
<choice id="choice2" title="$LIBTITLE" description="$LIBDESC">
|
||||
<pkg-ref id="$PKGID.lib"/>
|
||||
<choice id="choice3" title="$LAUNCHDTITLE" description="$LAUNCHDDESC">
|
||||
<pkg-ref id="$PKGID.launchd"/>
|
||||
</choice>
|
||||
$CONFCHOICE
|
||||
<pkg-ref id="$PKGID.usr" installKBytes="$USRSIZE" version="$VERSION" auth="Root">${PKGPREFIX}munkitools_usr-$VERSION.pkg</pkg-ref>
|
||||
<pkg-ref id="$PKGID.core" installKBytes="$CORESIZE" version="$VERSION" auth="Root">${PKGPREFIX}munkitools_core-$VERSION.pkg</pkg-ref>
|
||||
<pkg-ref id="$PKGID.admin" installKBytes="$ADMINSIZE" version="$VERSION" auth="Root">${PKGPREFIX}munkitools_admin-$VERSION.pkg</pkg-ref>
|
||||
<pkg-ref id="$PKGID.app" installKBytes="$APPSIZE" version="$MSUVERSION" auth="Root">${PKGPREFIX}munkitools_app-$MSUVERSION.pkg</pkg-ref>
|
||||
<pkg-ref id="$PKGID.lib" installKBytes="$LIBSIZE" version="$VERSION" auth="Root" onConclusion="RequireRestart">${PKGPREFIX}munkitools_lib-$VERSION.pkg</pkg-ref>
|
||||
<pkg-ref id="$PKGID.launchd" installKBytes="$LAUNCHDSIZE" version="$VERSION" auth="Root" onConclusion="RequireRestart">${PKGPREFIX}munkitools_launchd-$VERSION.pkg</pkg-ref>
|
||||
$CONFREF
|
||||
</installer-script>
|
||||
EOF
|
||||
@@ -417,27 +470,40 @@ EOF
|
||||
|
||||
echo "Setting ownership to root..."
|
||||
|
||||
sudo chown root:admin "$USRROOT" "$APPROOT" "$LIBROOT"
|
||||
sudo chown -hR root:wheel "$USRROOT/usr"
|
||||
sudo chown root:admin "$COREROOT" "$ADMINROOT" "$APPROOT" "$LAUNCHDROOT"
|
||||
sudo chown -hR root:wheel "$COREROOT/usr"
|
||||
sudo chown -hR root:admin "$COREROOT/Library"
|
||||
|
||||
sudo chown -hR root:wheel "$ADMINROOT/usr"
|
||||
|
||||
sudo chown -hR root:admin "$APPROOT/Applications"
|
||||
sudo chown root:admin "$LIBROOT/Library"
|
||||
sudo chown -hR root:wheel "$LIBROOT/Library/LaunchDaemons"
|
||||
sudo chown -hR root:wheel "$LIBROOT/Library/LaunchAgents"
|
||||
sudo chown -hR root:admin "$LIBROOT/Library/Managed Installs"
|
||||
|
||||
sudo chown root:admin "$LAUNCHDROOT/Library"
|
||||
sudo chown -hR root:wheel "$LAUNCHDROOT/Library/LaunchDaemons"
|
||||
sudo chown -hR root:wheel "$LAUNCHDROOT/Library/LaunchAgents"
|
||||
|
||||
|
||||
|
||||
######################
|
||||
## Run PackageMaker ##
|
||||
######################
|
||||
|
||||
for pkg in usr app lib; do
|
||||
if [ "$pkg" == "app" ]; then
|
||||
ver="$MSUVERSION"
|
||||
else
|
||||
ver="$VERSION"
|
||||
fi
|
||||
CURRENTUSER=`whoami`
|
||||
for pkg in core admin app launchd; do
|
||||
case $pkg in
|
||||
"app")
|
||||
ver="$MSUVERSION"
|
||||
;;
|
||||
"launchd")
|
||||
ver="$LAUNCHDVERSION"
|
||||
;;
|
||||
*)
|
||||
ver="$VERSION"
|
||||
;;
|
||||
esac
|
||||
echo "Packaging munkitools_$pkg-$ver.pkg"
|
||||
/Developer/usr/bin/packagemaker \
|
||||
# use sudo here so packagemaker doesn't complain when it tries to
|
||||
# descend into munki_admin/Library/Managed Installs/*
|
||||
sudo /Developer/usr/bin/packagemaker \
|
||||
--root "$PKGTMP/munki_$pkg" \
|
||||
--info "$PKGTMP/info_$pkg" \
|
||||
--resources "$MUNKIROOT/code/pkgtemplate/Resources_$pkg" \
|
||||
@@ -448,6 +514,15 @@ for pkg in usr app lib; do
|
||||
--target $TARGET \
|
||||
--out "$PKGDEST/munkitools_$pkg-$ver.pkg" \
|
||||
#--verbose
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo "Error packaging munkitools_$pkg-$ver.pkg before rebuilding it."
|
||||
echo "Attempting to clean up temporary files..."
|
||||
sudo rm -rf "$PKGTMP"
|
||||
exit 2
|
||||
else
|
||||
# set ownership of package back to current user
|
||||
sudo chown -R "$CURRENTUSER" "$PKGDEST/munkitools_$pkg-$ver.pkg"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user