New/updated make_munki_mpkg scripts that work with Git

This commit is contained in:
Greg Neagle
2011-08-24 09:39:51 -07:00
parent 0f2e8771e9
commit 68e6baf4c7
2 changed files with 45 additions and 10 deletions

View File

@@ -6,9 +6,12 @@
# Defaults.
PKGTYPE="bundle"
PKGID="com.googlecode.munki"
MUNKIROOT="/Users/Shared/munki/munki"
MUNKIROOT="."
OUTPUTDIR="/Users/Shared/pkgs"
CONFPKG=""
# add this number to Git revision index to get "build" number
# consistent with old SVN repo
MAGICNUMBER=482
usage() {
@@ -59,7 +62,7 @@ if [ $# -ne 0 ]; then
fi
if [ ! -d "$MUNKIROOT" ]; then
echo "Please set the munki root" 1>&2
echo "Please set the munki source root" 1>&2
exit 1
else
# Convert to absolute path.
@@ -74,7 +77,16 @@ fi
# Get the munki version.
MUNKIVERS=`defaults read "$MUNKIROOT/code/client/munkilib/version" CFBundleShortVersionString`
SVNREV=`svnversion $MUNKIROOT | cut -d: -f2 | tr -cd '[:digit:]'`
if [ "$?" != "0" ]; then
echo "$MUNKIROOT/code/client/munkilib/version is missing!" 1>&2
echo "Perhaps $MUNKIROOT does not contain the munki source?" 1>&2
exit 1
fi
# generate a psuedo-svn revision number from the list of Git revisions
GITREV=`git log -n1 --format="%H" -- code/client`
GITREVINDEX=`git rev-list --branches --reverse HEAD | grep -n $GITREV | cut -d: -f1`
SVNREV=$(($GITREVINDEX + $MAGICNUMBER))
VERSION=$MUNKIVERS.$SVNREV.0
# Get launchd version if different
@@ -270,6 +282,7 @@ cp -X "$MUNKIROOT/code/client/munkilib/"*.py "$COREROOT/usr/local/munki/munkilib
# Copy munki version.
cp -X "$MUNKIROOT/code/client/munkilib/version.plist" "$COREROOT/usr/local/munki/munkilib/"
echo $SVNREV > "$COREROOT/usr/local/munki/munkilib/svnversion"
echo $GITREV > "$COREROOT/usr/local/munki/munkilib/gitrevision"
# Set permissions.
chmod -R go-w "$COREROOT/usr/local/munki"
chmod +x "$COREROOT/usr/local/munki"

View File

@@ -1,6 +1,6 @@
#!/bin/bash
#
# Check out Munki from svn and build an mpkg distribution package.
# Check out Munki from git and build an mpkg distribution package.
# Defaults.
@@ -9,6 +9,7 @@ PKGID="com.googlecode.munki"
OUTPUTDIR=`pwd`
CONFPKG=""
CHECKOUTREV="HEAD"
BRANCH="master"
usage() {
@@ -25,7 +26,7 @@ EOF
}
while getopts "fi:r:o:c:h" option
while getopts "fi:r:o:b:c:h" option
do
case $option in
"f")
@@ -39,6 +40,9 @@ do
"o")
OUTPUTDIR="$OPTARG"
;;
"b")
BRANCH="$OPTARG"
;;
"c")
CONFPKG="$OPTARG"
;;
@@ -58,14 +62,29 @@ if [ $# -ne 0 ]; then
exit 1
fi
MUNKIDIR=`pwd`/"munki-git"
MUNKIDIR=`pwd`/"munki-SVN"
GIT=`which git`
WHICH_GIT_RESULT="$?"
if [ "$WHICH_GIT_RESULT" != "0" ]; then
echo "Could not find git in command path. Maybe it's not installed?" 1>&2
exit 1
fi
echo "Checking out munki from SVN..."
svn checkout -r "$CHECKOUTREV" http://munki.googlecode.com/svn/trunk/ "$MUNKIDIR"
echo "Cloning munki repo branch $BRANCH from code.google.com..."
git clone --branch "$BRANCH" --no-checkout -- https://code.google.com/p/munki/ "$MUNKIDIR"
CLONE_RESULT="$?"
if [ "$CLONE_RESULT" != "0" ]; then
echo "Error cloning munki repo: $CLONE_RESULT" 1>&2
exit 1
fi
echo "Checking out revision $CHECKOUTREV..."
cd "$MUNKIDIR"
git checkout "$CHECKOUTREV"
CHECKOUT_RESULT="$?"
if [ "$CHECKOUT_RESULT" != "0" ]; then
echo "Error checking out munki code from SVN: $CHECKOUT_RESULT"
echo "Error checking out $CHECKOUTREV: $CHECKOUT_RESULT" 1>&2
exit 1
fi
@@ -75,6 +94,9 @@ else
CONFPKGARG=""
fi
"$MUNKIDIR/code/tools/make_munki_mpkg.sh" -i "$PKGID" -r "$MUNKIDIR" -o "$OUTPUTDIR" $CONFPKGARG
# get the directory this script lives in so we can find make_munki_pkg.sh
TOOLSDIR=`dirname $0`
"$TOOLSDIR/make_munki_mpkg.sh" -i "$PKGID" -r "$MUNKIDIR" -o "$OUTPUTDIR" $CONFPKGARG
exit $?