Index: branches/iFabio/Chameleon/package/builddmg =================================================================== --- branches/iFabio/Chameleon/package/builddmg (revision 0) +++ branches/iFabio/Chameleon/package/builddmg (revision 297) @@ -0,0 +1,470 @@ +#!/bin/bash + +# $1 Path to store built package + +packagesidentity="org.chameleon" + +packagename="Chameleon" + +pkgroot="${0%/*}" + +COL_BLACK="\x1b[30;01m" +COL_RED="\x1b[31;01m" +COL_GREEN="\x1b[32;01m" #COL_GREEN="\x1b[32;01m" +COL_YELLOW="\x1b[33;01m" +COL_MAGENTA="\x1b[35;01m" +COL_CYAN="\x1b[36;01m" +COL_WHITE="\x1b[37;01m" +COL_BLUE="\x1b[34;01m" +COL_RESET="\x1b[39;49;00m" + +#version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' ) +version=$( cat version ) +stage=${version##*-} +revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' ) +builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' ) +timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" ) + +distributioncount=0 +xmlindent=0 + +indent[0]="\t" +indent[1]="\t\t" +indent[2]="\t\t\t" +indent[3]="\t\t\t\t" + +main () +{ + +# clean up the destination path + +rm -R -f "${1}" +echo "" +echo -e $COL_BLACK" ----------------------------------"$COL_RESET +echo -e $COL_BLACK" Building $packagename Install Package"$COL_RESET +echo -e $COL_BLACK" ----------------------------------"$COL_RESET +echo "" + +outline[$((outlinecount++))]="${indent[$xmlindent]}" + +# build core package + echo "================= Core =================" + ((xmlindent++)) + packagesidentity="org.chameleon" + mkdir -p ${1}/Core/Root/usr/sbin + mkdir -p ${1}/Core/Root/usr/local/bin + mkdir -p ${1}/Core/Root/usr/standalone/i386 + mkdir -p ${1}/Core/Root/usr/standalone/i386/modules + cp -R ${1%/*}/i386/modules ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386 + # cp -f ${1%/*}/i386/boot0hfs ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386 + fixperms "${1}/Core/Root/" + cp -f ${pkgroot}/fdisk440 ${1}/Core/Root/usr/sbin +# cp -f ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/sbin + local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} ) + echo " [BUILD] i386 " + buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1 + +# build Chameleon package + echo "================= Chameleon =================" + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + choices[$((choicescount++))]="\n\n" + + # build standard package + mkdir -p ${1}/Standard/Root + mkdir -p ${1}/Standard/Scripts/Tools + cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts + # ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile + echo " [BUILD] Standard " + buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EFI']) && exclusive(choices['noboot'])\"" >/dev/null 2>&1 + # End build standard package + + # build efi package + mkdir -p ${1}/EFI/Root + mkdir -p ${1}/EFI/Scripts/Tools + cp -f ${pkgroot}/Scripts/EFI/* ${1}/EFI/Scripts + # ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Tools/SetFile + echo " [BUILD] EFI " + buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['noboot'])\"" >/dev/null 2>&1 + # End build efi package + + # build reset choice package + mkdir -p ${1}/noboot/Root + echo " [BUILD] Reset choice " + buildpackage "${1}/noboot" "/tmpcham" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['EFI'])\"" >/dev/null 2>&1 + # End build reset choice package + + # build Modules package + echo "================= Modules =================" + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + choices[$((choicescount++))]="\n\n" + ((xmlindent++)) + packagesidentity="org.chameleon.module" + modules=($( find "${pkgroot}/Scripts/Modules" -type d -depth 1 -not -name '.svn' )) + for (( i = 0 ; i < ${#modules[@]} ; i++ )) + do + mkdir -p "${1}/${modules[$i]##*/}/Root" + mkdir -p "${1}/${modules[$i]##*/}/Scripts" + ditto --noextattr --noqtn "${modules[$i]}/postinstall" "${1}/${modules[$i]##*/}/Scripts/postinstall" + echo " [BUILD] ${modules[$i]##*/} " + buildpackage "${1}/${modules[$i]##*/}" "/" "" "start_selected=\"false\"" >/dev/null 2>&1 + rm -R -f "${1}/${i##*/}" + done + ((xmlindent--)) + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + # End build Modules packages + + # build bdmesg package +# mkdir -p ${1}/Bdmesg/Root +# cp -f ${1%/*}/i386/bdmesg ${1}/Bdmesg/Root +# fixperms "${1}/Bdmesg/Root/" + # echo " [BUILD] bdmesg " +# buildpackage "${1}/Bdmesg" "/usr/sbin/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1 + # End build bdmesg package + + ((xmlindent--)) + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" +# End build Chameleon package + +# build Extras package + echo "================= Extras =================" + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + choices[$((choicescount++))]="\n\n" + ((xmlindent++)) + packagesidentity="org.chameleon.extras.com" + + # build utility package + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + choices[$((choicescount++))]="\n\n" + ((xmlindent++)) + packagesidentity="org.chameleon.utility.com" + + # build package for Chameleon PrefPanel + mkdir -p "${1}/PrefPanel/Root" + ditto --noextattr --noqtn "${pkgroot}/Configuration/PrefPanel/Chameleon.prefPane" "${1}/PrefPanel/Root" + echo " [BUILD] Chameleon Preference Panel " + buildpackage "${1}/PrefPanel" "/Library/PreferencePanes/Chameleon.prefPane" "" "start_selected=\"false\"" >/dev/null 2>&1 + # End build package for Chameleon PrefPanel + + # build package for SMBIOSDefault + mkdir -p "${1}/SMBIOSDefault/Root" + ditto --noextattr --noqtn "${pkgroot}/Configuration/SMBIOSDefault/smbios.plist" "${1}/SMBIOSDefault/Root" + echo " [BUILD] SMBIOSDefault " + buildpackage "${1}/SMBIOSDefault" "/Extra/Example" "" "start_selected=\"false\"" >/dev/null 2>&1 + # End build package for SMBIOSDefault + + # build package for EFIMounter + mkdir -p "${1}/EFIMounter/Root" + ditto --noextattr --noqtn "${pkgroot}/Configuration/EFIMounter/EFI Mounter.app" "${1}/EFIMounter/Root" + echo " [BUILD] EFIMounter " + buildpackage "${1}/EFIMounter" "/Applications/EFI Mounter.app" "" "start_selected=\"false\"" >/dev/null 2>&1 + # End build package for EFIMounter + + # build package for Documentation + mkdir -p "${1}/Documentation/Root" + cp -f ${pkgroot}/doc/BootHelp.txt ${1}/Documentation/Root + cp -f ${pkgroot}/doc/README ${1}/Documentation/Root + cp -f ${pkgroot}/doc/Users_Guide0.5.pdf ${1}/Documentation/Root + echo " [BUILD] Documentation " + buildpackage "${1}/Documentation" "/Library/Documentation/Chameleon2RC5" "" "start_selected=\"false\"" >/dev/null 2>&1 + # End build package for Documentation + + ((xmlindent--)) + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + # End utility package + + # build options packages + echo "================= Options =================" + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + choices[$((choicescount++))]="\n\n" + ((xmlindent++)) + + # build base options packages + packagesidentity="org.chameleon.options.com" + + options=($( find "${pkgroot}/Scripts/BaseOptions" -type d -depth 1 -not -name '.svn' )) + for (( i = 0 ; i < ${#options[@]} ; i++ )) + do + mkdir -p "${1}/${options[$i]##*/}/Root" + mkdir -p "${1}/${options[$i]##*/}/Scripts" + ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall" + echo " [BUILD] ${options[$i]##*/} " + buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\"" >/dev/null 2>&1 + done + # End build base options packages + + # build resolution packages + echo "================= Res. Options =================" + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + choices[$((choicescount++))]="\n\n" + ((xmlindent++)) + packagesidentity="org.chameleon.resolution" + resolutions=($( find "${pkgroot}/Scripts/Resolutions" -type d -depth 1 -not -name '.svn' )) + for (( i = 0 ; i < ${#resolutions[@]} ; i++ )) + do + mkdir -p "${1}/${resolutions[$i]##*/}/Root/" + mkdir -p "${1}/${resolutions[$i]##*/}/Scripts/" + ditto --noextattr --noqtn "${resolutions[$i]}/postinstall" "${1}/${resolutions[$i]##*/}/Scripts/postinstall" + echo " [BUILD] ${resolutions[$i]##*/} " + buildpackage "${1}/${resolutions[$i]##*/}" "/tmpcham" "" "start_selected=\"false\"" >/dev/null 2>&1 + done + + ((xmlindent--)) + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + # End build resolution packages + + # build Advanced packages + echo "================= Adv. Options =================" + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + choices[$((choicescount++))]="\n\n" + ((xmlindent++)) + + packagesidentity="org.chameleon.advanced.options.pkg" + optionsadv=($( find "${pkgroot}/Scripts/Advanced" -type d -depth 1 -not -name '.svn' )) + for (( i = 0 ; i < ${#optionsadv[@]} ; i++ )) + do + mkdir -p "${1}/${optionsadv[$i]##*/}/Root" + mkdir -p "${1}/${optionsadv[$i]##*/}/Scripts" + ditto --noextattr --noqtn "${optionsadv[$i]}/postinstall" "${1}/${optionsadv[$i]##*/}/Scripts/postinstall" + echo " [BUILD] ${optionsadv[$i]##*/} " + buildpackage "${1}/${optionsadv[$i]##*/}" "/" "" "start_selected=\"false\"" >/dev/null 2>&1 + done + + ((xmlindent--)) + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + # End build Advanced packages + + ((xmlindent--)) + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + + # End build options packages + + # build theme packages + echo "================= Themes =================" + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + choices[$((choicescount++))]="\n\n" + ((xmlindent++)) + packagesidentity="org.chameleon.theme.pkg" + artwork="${1%/*}" + themes=($( find "${artwork%/*}/artwork/themes" -type d -depth 1 -not -name '.svn' )) + for (( i = 0 ; i < ${#themes[@]} ; i++ )) + do + theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' ) + mkdir -p "${1}/${theme}/Root/" + ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}" + find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+ + find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+ + echo " [BUILD] ${themes[$i]##*/} " + buildpackage "${1}/${theme}" "/Extra/Themes" "" "start_selected=\"false\"" >/dev/null 2>&1 + rm -R -f "${1}/${i##*/}" + done + + ((xmlindent--)) + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + # End build theme packages + + # build kext packages + echo "================= Kexts =================" + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + choices[$((choicescount++))]="\n\n" + ((xmlindent++)) + packagesidentity="org.chameleon.kext.pkg" + kexts=($( find "${pkgroot}/Kexts" -type d -name '*.kext' -depth 1 )) + for (( i = 0 ; i < ${#kexts[@]} ; i++ )) + do + filename="${kexts[$i]##*/}" + mkdir -p "${1}/${filename%.kext}/Root" + ditto --noextattr --noqtn --arch i386 "${kexts[$i]}" "${1}/${filename%.kext}/Root/${filename}" + find "${1}/${filename%.kext}" -name '.DS_Store' -or -name '.svn' -exec rm -R -f {} \; 2>/dev/null + fixperms "${1}/${filename%.kext}/Root" + chown 501:20 "${1}/${filename%.kext}/Root" + echo " [BUILD] ${filename%.kext} " + buildpackage "${1}/${filename%.kext}" "/Extra/Extensions" "" "start_selected=\"false\"" >/dev/null 2>&1 + rm -R -f "${1}/${filename%.kext}" + done + ((xmlindent--)) + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + # End build kext packages + + ((xmlindent--)) + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" +# End build Extras package + +# build post install package + echo "================= Post =================" + mkdir -p ${1}/Post/Root + mkdir -p ${1}/Post/Scripts + cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts + echo " [BUILD] Post " + buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1 + outline[$((outlinecount++))]="${indent[$xmlindent]}" + +# build meta package + makedistribution "${1}" "${2}" "${3}" "${4}" "${5}" + +# clean up + rm -R -f "${1}" + +} + +fixperms () +{ + # $1 path + find "${1}" -type f -exec chmod 644 {} \; + find "${1}" -type d -exec chmod 755 {} \; + chown -R 0:0 "${1}" +} + +buildpackage () +{ +# $1 Path to package to build containing Root and or Scripts +# $2 Install Location +# $3 Size +# $4 Options + +if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then + + local packagename="${1##*/}" + local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] ) + find "${1}" -name '.DS_Store' -delete + local filecount=$( find "${1}/Root" | wc -l ) + if [ "${3}" ]; then + local installedsize="${3}" + else + local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} ) + fi + local header="\n\n" + header+="\t\n" + rm -R -f "${1}/Temp" + + [ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp" + [ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom" + + if [ -d "${1}/Scripts" ]; then + header+="\t\n" + for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) ) + do + header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n" + done + header+="\t\n" + chown -R 0:0 "${1}/Scripts" + pushd "${1}/Scripts" >/dev/null + find . -print | cpio -o -z -H cpio > "../Temp/Scripts" + popd >/dev/null + fi + + header+="" + echo -e "${header}" > "${1}/Temp/PackageInfo" + pushd "${1}/Root" >/dev/null + find . -print | cpio -o -z -H cpio > "../Temp/Payload" + popd >/dev/null + pushd "${1}/Temp" >/dev/null + + xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none . + + popd >/dev/null + + outline[$((outlinecount++))]="${indent[$xmlindent]}\t" + + if [ "${4}" ]; then + local choiceoptions="${indent[$xmlindent]}${4}\n" + fi + choices[$((choicescount++))]="\n\t#${packagename// /}.pkg\n\n" + + rm -R -f "${1}" +fi +} + +makedistribution () +{ + rm -f "${1%/*}/${packagename// /}"*.pkg + + find "${1}" -type f -name '*.pkg' -depth 1 | while read component + do + mkdir -p "${1}/${packagename}/${component##*/}" + pushd "${1}/${packagename}/${component##*/}" >/dev/null + xar -x -f "${1%}/${component##*/}" + popd >/dev/null + done + + ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution" + ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources" + + find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null + + for (( i=0; i < ${#outline[*]} ; i++)); + do + echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution" + done + + for (( i=0; i < ${#choices[*]} ; i++)); + do + echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution" + done + + echo "" >> "${1}/${packagename}/Distribution" + + perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f` + perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f` + +# Adding Package type test (not translated) +# perl -i -p -e "s/%PKGTYPE%/TEST/g" `find "${1}/${packagename}/Resources" -type f` +# + + stage=${stage/RC/Release Candidate } + stage=${stage/FINAL/2.0 Final} + perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f` + + find "${1}/${packagename}" -name '.DS_Store' -delete + pushd "${1}/${packagename}" >/dev/null + xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none . + popd >/dev/null + +# Here is the place for assign a Icon to the pkg +# command use to generate the file: +# ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip +ditto -xk "${pkgroot}/Icon.zip" "${pkgroot}/" +DeRez -only icns "${pkgroot}/Icon/Icon.icns" > tempicns.rsrc +Rez -append tempicns.rsrc -o "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" +SetFile -a C "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" +rm -f tempicns.rsrc +rm -rf "${pkgroot}/Icon" +# End + + md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" | awk {'print $4'} ) + echo "MD5 (${packagename// /}-${version}-r${revision}.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}.pkg.md5" + echo "" + + echo -e $COL_BLACK" --------------------------"$COL_RESET + echo -e $COL_BLACK" Building process complete!"$COL_RESET + echo -e $COL_BLACK" --------------------------"$COL_RESET + echo "" + echo -e $COL_BLACK" Build info." + echo -e $COL_BLACK" ===========" + echo -e $COL_BLUE" Package name: "$COL_BLACK"$packagename-${version}-r$revision.pkg"$COL_RESET + echo -e $COL_BLUE" MD5: "$COL_BLACK"$md5"$COL_RESET + echo -e $COL_BLUE" Version: "$COL_BLACK"$version"$COL_RESET + echo -e $COL_BLUE" Stage: "$COL_BLACK"$stage"$COL_RESET + echo -e $COL_BLUE" Date/Time: "$COL_BLACK"$builddate"$COL_RESET + echo "" + +} + +main "${1}" "${2}" "${3}" "${4}" "${5}" + Property changes on: branches/iFabio/Chameleon/package/builddmg ___________________________________________________________________ Added: svn:executable + * Index: branches/iFabio/Chameleon/Make.rules =================================================================== --- branches/iFabio/Chameleon/Make.rules (revision 296) +++ branches/iFabio/Chameleon/Make.rules (revision 297) @@ -123,3 +123,5 @@ $(SRCROOT)/autoconf.h \ $(SRCROOT)/autoconf.inc + +.DEFAULT_GOAL := all Index: branches/iFabio/Chameleon/Makefile =================================================================== --- branches/iFabio/Chameleon/Makefile (revision 296) +++ branches/iFabio/Chameleon/Makefile (revision 297) @@ -30,7 +30,7 @@ # # Currently builds for i386 # -clean config rebuild_config: +config rebuild_config: @if [ -e ".svn" ]; then svnversion -n | tr -d [:alpha:] > revision; fi @echo ================= make config for i386 =================; @( OBJROOT=$(OBJROOT)/i386; \ @@ -90,11 +90,15 @@ done -pkg installer: all +pkg: all @if [ -e "$(SYMROOT)" ]; then \ sudo `pwd`/package/buildpkg `pwd`/sym/package; \ fi; +dmg: all + @if [ -e "$(SYMROOT)" ]; then \ + sudo `pwd`/package/builddmg `pwd`/sym/package; \ + fi; + .PHONY: config .PHONY: clean -.DEFAULT_GOAL := all