X-Git-Url: http://git.onelab.eu/?p=sface.git;a=blobdiff_plain;f=macos%2Fbuild-dmg.sh;h=323ab8f89f627d4217c3908e43bfb18920cc8f2b;hp=87fb1c755ddb7d8448c7ec935e3e09df3dab6023;hb=beab7d44ca4dd2a79bbb41befe64bdfb145fbb82;hpb=8a673bd7946c84ce42fac3491eb29cb3dbc6ecc9 diff --git a/macos/build-dmg.sh b/macos/build-dmg.sh index 87fb1c7..323ab8f 100755 --- a/macos/build-dmg.sh +++ b/macos/build-dmg.sh @@ -1,7 +1,8 @@ #!/bin/sh # PURPOSE -# package a combination of sfa+sface into a snow leopard dmg install disk +# package a combination of sfa+sface into a dmg install disk +# supports leopard and snow leopard # # REQUIREMENTS # sface-skel-snow-leopard.dmg is the skeleton that has Qt and all the other third-party software @@ -11,6 +12,9 @@ # the script expects the taglevels for both sfa and sface, # in order to retrieve the corresponding code and to label the resulting package properly # alternatively, a build-dir and tags file can be used instead +# Should have the following tools installed +# git: to retrieve code +# rpm: to retrieve the version numbers in specfiles # NOTES # we initially leveraged the first similar packaging initially made by Baris Metin @@ -45,35 +49,18 @@ COMMAND=$(basename $0) function git_url () { echo $1 | cut -d @ -f 1 ; } function git_tag () { echo $1 | cut -d @ -f 2 ; } -# go in $dest and retrieve $path part of codebase based on gitpath, e.g. -# git_retrieve \ -# git://git.onelab.eu/sface.git@sface-0.1-5 -# sface -# /Volumes/sface-skel-sn/sface.app/Contents/Resources/ -# or, with the -f (-file) option: -# git_retrieve -f \ -# git://git.onelab.eu/sface.git@sface-0.1-5 -# macos/appIcon.icns -# /Volumes/sface-skel-sn/sface.app/appIcon.icns +# go in $dest and retrieve module into provided path +# git_retrieve git://git.onelab.eu/sface.git@sface-0.1-5 /tmp/sfa-module function git_retrieve () { - filemode="" - case "$1" in -f|--file) filemode=true; shift;; esac - gitpath=$1; shift - path=$1; shift - dest=$1; shift + gitpath="$1"; shift + dest="$1"; shift giturl=$(git_url $gitpath) gittag=$(git_tag $gitpath) - if [ -z "$filemode" ] ; then - [ -d "$dest" ] || mkdir -p "$dest" - pushd "$dest" >& /dev/null - git archive --remote=${giturl} ${gittag} | tar -xf - ${path} - popd >& /dev/null - else - destdir=$(dirname "$dest") - [ -d "$destdir" ] || mkdir -p "$destdir" - git archive --remote=${giturl} ${gittag} | tar -xOf - ${path} > "${dest}" - fi + [ -d "$dest" ] || mkdir -p "$dest" + pushd "$dest" >& /dev/null + git archive --remote=${giturl} ${gittag} | tar -xf - + popd >& /dev/null } function die () { @@ -102,8 +89,16 @@ function package () { img_mnt="/Volumes/${img_mnt_name}" # check we're clear - [ -f $img_dmg ] && die "output dmg $img_dmg already exists" - [ -f $img_raw_dmg ] && die "please clean up tmp file $img_raw_dmg" + if [ -f $img_dmg ] ; then + [ -z "$FORCE_REWRITE" ] && die "output dmg $img_dmg already exists" + echo "Trashing (force_rewrite) former output $img_dmg" + rm -f $img_dmg + fi + if [ -f $img_raw_dmg ] ; then + [ -z "$FORCE_REWRITE" ] && die "please clean up tmp file $img_raw_dmg" + echo "Cleaning (force_rewrite) former tmp file $img_raw_dmg" + rm -f $img_raw_dmg + fi if [ -n "$FORCE_DOWNLOAD" ] ; then [ -d "$skel_mnt" ] && hdiutil unmount "$skel_mnt" @@ -153,28 +148,49 @@ Also make sure to trash the current one before retrying" resource_path=$app/Contents/Resources bin_path=$app/Contents/MacOS - # retrieve sfa/sfa and sface/sface in the image - rm -rf "$img_mnt"/$resource_path/{sfa,sface} - git_retrieve $sfa_GITPATH sfa "$img_mnt"/$resource_path/ - git_retrieve $sface_GITPATH sface "$img_mnt"/$resource_path/ + # retrieve sfa and sface full repos in a temp dir + temp=$(mktemp -d -t sface-dmg) + + git_retrieve $sfa_GITPATH $temp/sfa + git_retrieve $sface_GITPATH $temp/sface + + # retrieve version number, and run make version + sfa_spec=$temp/sfa/sfa.spec + # use newlines and keep only the first line, for multiple packages + sfa_version=$(rpm -q --specfile $sfa_spec --qf '%{version}\n' | head -1) + # cannot extract taglevel, issues lots of 'error: incorrect format: unknown tag' + # turns out release is the same in our case as we haven't computed header.spec + sfa_release=$(rpm -q --specfile $sfa_spec --qf '%{release}\n' | head -1 | cut -d. -f1) + sfa_tag=${sfa_version}-${sfa_release} + make -C $temp/sfa VERSIONTAG="${sfa_tag}" SCMURL="${sfa_GITPATH}" version + + sface_spec=$temp/sface/sface.spec + sface_version=$(rpm -q --specfile $sface_spec --qf '%{version}\n' | head -1) + sface_release=$(rpm -q --specfile $sface_spec --qf '%{release}\n' | head -1 | cut -d. -f1) + sface_tag=${sface_version}-${sface_release} + make -C $temp/sface VERSIONTAG="${sface_tag}" SCMURL="${sface_GITPATH}" version + + # copy sfa/ and sface/ subdirs in image + rm -rf "$img_mnt"/$resource_path/{sfa,clientbin,sface} + tar -C $temp/sfa -cf - sfa clientbin | tar -C "$img_mnt"/$resource_path/ -xf - + tar -C $temp/sface -cf - sface | tar -C "$img_mnt"/$resource_path/ -xf - + # copy binaries from sface to the bin dir for bin in sface.bin sface-run; do - # don't use the --file mode as this loses the executable bit - git_retrieve $sface_GITPATH $bin "$img_mnt"/$bin_path + cp $temp/sface/$bin "$img_mnt"/$bin_path done ### install background and app icons # clean up any 'background' dir if exists rm -rf "$img_mnt"/{,.}background - git_retrieve --file $sface_GITPATH macos/graphic-install-background.png "$img_mnt"/.background/background.png - git_retrieve --file $sface_GITPATH macos/graphic-sfa.icns "$img_mnt"/$resource_path/appIcon.icns + mkdir -p "$img_mnt"/.background "$img_mnt"/$resource_path/sface/images + cp $temp/sface/macos/graphic-install-background.png "$img_mnt"/.background/background.png + cp $temp/sface/macos/graphic-sfa.icns "$img_mnt"/$resource_path/appIcon.icns + cp $temp/sface/macos/graphic-sfa.png "$img_mnt"/$resource_path/sface/images + cp $temp/sface/macos/graphic-sfa64.png "$img_mnt"/$resource_path/sface/images # the volume icons won't work - who cares -# git_retrieve --file $sface_GITPATH macos/graphic-vol-sface.icns "$img_mnt"/.background/volumeIcon.icns -# git_retrieve --file $sface_GITPATH macos/graphic-vol-sface.png "$img_mnt"/.background/volumeIcon.png - - # instantiate version - sed -e "s,@VERSIONTAG@,$sfa_release,g" -e "s,@SCMURL@,${sfa_GITPATH},g" \ - "$img_mnt"/$resource_path/sfa/util/version.py.in > "$img_mnt"/$resource_path/sfa/util/version.py +# cp $temp/sface/macos/graphic-vol-sface.icns "$img_mnt"/.background/volumeIcon.icns +# cp $temp/sface/macos/graphic-vol-sface.png "$img_mnt"/.background/volumeIcon.png # clean up just in case find "$img_mnt" -name '*pyc' | xargs rm -f @@ -185,6 +201,8 @@ Also make sure to trash the current one before retrying" read _ fi + rm -rf $temp + hdiutil detach "$img_mnt" rm -f $img_dmg echo "Compressing..." @@ -211,6 +229,7 @@ function usage () { echo "Common options" echo " -i : interactive : let you align icons properly in the image before it gets wrapped" echo " -f : force download of the skeleton package" + echo " -F : force overwrite if output already exists" echo " -a leopard|snow-leopard" echo " -A : run on all known archs" echo " -n : dry-run" @@ -222,7 +241,7 @@ DEFAULT_BUILD_DIR=$HOME/git/build DEFAULT_TAGS_FILE=onelab-k32-tags.mk function main () { - while getopts "b:t:c:s:ifa:Anvh" opt ; do + while getopts "b:t:c:s:ifFa:Anvh" opt ; do case $opt in b) BUILD_DIR=$OPTARG;; t) TAGS_FILE=$OPTARG;; @@ -230,6 +249,7 @@ function main () { s) sfa_GITPATH=$OPTARG;; i) INTERACTIVE=true;; f) FORCE_DOWNLOAD=true;; + F) FORCE_REWRITE=true ;; a) ARCHS="$ARCHS $OPTARG";; A) ARCHS="leopard snow-leopard";; n) dry_run=true;;