Index: trunk/package/Scripts.templates/AddOption/postinstall =================================================================== --- trunk/package/Scripts.templates/AddOption/postinstall (revision 0) +++ trunk/package/Scripts.templates/AddOption/postinstall (revision 1801) @@ -0,0 +1,57 @@ +#!/bin/bash + +set -u + +targetVolume="$3" + +key="@optionKey@" +value="@optionValue@" +type="@optionType@" +logName="@LOG_FILENAME@" +logFile="${targetVolume}/$logName" + +# Check if target volume exists +if [[ ! -d "$targetVolume" ]]; then + echo "$targetVolume volume does not exist!" >&2 + exit 1 +fi + +exec >>"${logFile}" 2>&1 + +echo "Added boot option: ${key}=${value}" + +key="${key// /\\ }" # Escape spaces +value="${value// /\\ }" # Escape spaces + +bootPListFile="${targetVolume}/Extra/org.chameleon.Boot.plist" + +case "$type" in + bool|text) + /usr/libexec/plistbuddy -c "Add :${key} string ${value}" "$bootPListFile" + ;; + list) + current_values=$( /usr/libexec/plistbuddy -c "Print :${key}" \ + "$bootPListFile" 2>/dev/null ) + result=$? + current_values="${current_values// /\\ }" # Escape spaces + current_values="${current_values//\"/\\\"}" # Escape double quotes + + if [[ $result -eq 0 ]]; then + # Append our new values + if [[ "$current_values" = "" ]]; then + new_values="${value}" + else + new_values="${current_values}\ ${value}" + fi + /usr/libexec/plistbuddy -c "Set :${key} ${new_values}" \ + "$bootPListFile" + else + # Create a new option + new_values="${value}" + /usr/libexec/plistbuddy -c "Add :${key} string ${new_values}" \ + "$bootPListFile" + fi + ;; +esac + +exit 0 Property changes on: trunk/package/Scripts.templates/AddOption/postinstall ___________________________________________________________________ Added: svn:executable + * Index: trunk/package/Scripts.templates/Post/postinstall =================================================================== --- trunk/package/Scripts.templates/Post/postinstall (revision 1800) +++ trunk/package/Scripts.templates/Post/postinstall (revision 1801) @@ -1,245 +1,40 @@ #!/bin/bash -mergeString () { - local src="${1}" - local new="${2}" - local result="$src" +# $1 = Full path to the installation package the installer app is processing +# $2 = Full path to the installation destination +# $3 = Installation volume (mountpoint) to receive the payload +# $4 = Root directory for the system - for newItem in $new ;do - local found=0 - for srcItem in $src ;do - if [[ $newItem == $srcItem ]];then - found=1 - break - fi - done - [[ $found -eq 0 ]] && result="$result $newItem" - done - - echo "$result" -} - -echo "===============================================" -echo "Post Post-Install Script" -echo "*********************************" - -#echo "DEBUG: $ 1 = Full path to the installation package the installer app is processing: " $1 -#echo "DEBUG: $ 2 = Full path to the installation destination: " $2 -#echo "DEBUG: $ 3 = Installation volume (mountpoint) to receive the payload: " $3 -#echo "DEBUG: $ 4 = Root directory for the system: " $4 - # Check target exists -if [ ! -e "$3" ] -then - echo "$3 volume does not exist!" +if [ ! -d "$3" ]; then + echo "$3 volume does not exist !" >&2 exit 1 fi # If target volume root of current system then replace # / with volume name. -if [ "$3" == "/" ] -then +if [ "$3" == "/" ]; then dest_vol="/Volumes/"$( ls -1F /Volumes | sed -n 's:@$::p' ) else dest_vol="$3" fi +logName="@LOG_FILENAME@" +logFile="${dest_vol}/$logName" + +exec >>"${logFile}" 2>&1 + # Find script location so to find the Install Log script. MYLOCATION="${PWD}/${BASH_ARGV[0]}" export MYLOCATION="${MYLOCATION%/*}" scriptDir=$MYLOCATION # Write some information to the Install Log -"$scriptDir"InstallLog.sh "${dest_vol}" "Running Post postinstall script" -"$scriptDir"InstallLog.sh "${dest_vol}" "Target volume = ${dest_vol}" +echo "======================================================" +echo "Running Post postinstall script" +echo "Target volume = ${dest_vol}" -# set temporary directory -chamTemp="$dest_vol/usr/local/chamTemp" - - # --------------------------------------------- -# Build org.chameleon.Boot.plist -# --------------------------------------------- -# All options selected are now dummy files with -# the filename of the option and value residing -# in /usr/local/chamTemp/options/ -# for example. Boot Banner=Yes - -# Are there any options to build? -if [ "$(ls -A ${chamTemp}/options )" ]; then - - # Check for temporary directory/Extra folder. - if [ ! -d "$chamTemp"/Extra ]; then - mkdir "$chamTemp"/Extra - fi - - # Create template for org.chameleon.Boot.plist" - tempOCBP="$chamTemp"/Extra/org.chameleon.Boot.plist - cp "$4"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist "$tempOCBP" - - # Read list of all boot options the user added. - while IFS= read -r -d '' FILE; do - option="${FILE##*/}" - key="${option%%=*}" - value="${option#*=}" - - # Check for 'Kernel Flags' key indicate that should be a kernel flag - if [[ "$key" = "Kernel Flags" ]];then - # plistbuddy only add's if the key doesn't already exist. - # So let's store any kernelflags and add them all at the - # same time once when we reach the end of the options list. - kernelflag[${#kernelflag[*]}]="$value" - "$scriptDir"InstallLog.sh "${dest_vol}" "Added kernel flag: $value" - else - # escape any spaces - keyToUse=$( echo "$key" | sed 's/ /\\ /g' ) - sudo /usr/libexec/plistbuddy -c "Add :${keyToUse} string ${value}" "$tempOCBP" - returnValue=$? - if [ ${returnValue} -ne 1 ]; then - "$scriptDir"InstallLog.sh "${dest_vol}" "Added boot option: ${key}=${value}" - else - "$scriptDir"InstallLog.sh "${dest_vol}" "Can't add ${key}=${value} as an option already exists for: ${key}" - fi - fi - done < <( find "${chamTemp}/options" -type f -print0 ) - - # Add any kernel flags together in to one string. - kernelFlagString="${kernelflag[@]}" - # We add the final string in the next section. -fi - -# --------------------------------------------- -# Add any installed modules to the Install Log -# --------------------------------------------- -if [ -e "${chamTemp}"/Extra/modules ]; then - ls "${chamTemp}"/Extra/modules | while read FILE - do - "$scriptDir"InstallLog.sh "${dest_vol}" "Added module: $FILE" - if [ "$FILE" == "Keylayout.dylib" ]; then - "$scriptDir"InstallLog.sh "${dest_vol}" "Also adding required Keymaps." - fi - done -fi - -# --------------------------------------------- -# Add any installed themes to the Install Log -# --------------------------------------------- -if [ -e "${chamTemp}"/Extra/Themes ]; then - ls "${chamTemp}"/Extra/Themes | while read FILE - do - "$scriptDir"InstallLog.sh "${dest_vol}" "Added Theme: $FILE" - done -fi - -# Does a temporary /Extra folder exist? -if [ -d "$chamTemp"/Extra ]; then - - # --------------------------------------------- - # Merge /Extra folders? - # --------------------------------------------- - # Does the user want to upgrade an existing /Extra folder? - # If so, then merge their existing one in to the temp one. - if [ -e "$chamTemp/install_type_upgrade" ]; then - "$scriptDir"InstallLog.sh "${dest_vol}" "User selected to do an upgrade install." - - # first move the new org.chameleon.Boot.plist out of tmp - # Extra folder so we can merge that separately. - mv "$tempOCBP" "$chamTemp/holding.plist" - - # Check for an existing /Extra folder - # and merge existing /Extra with temp one. - if [ -e "$dest_vol"/.ChameleonEFI ]; then - if [ -e "/Volumes/EFI/Extra" ]; then - "$scriptDir"InstallLog.sh "${dest_vol}" "Merging existing /Volumes/EFI/Extra folder." - ditto --noextattr --noqtn /Volumes/EFI/Extra "$chamTemp"/Extra - fi - else - if [ -e "$dest_vol/Extra" ]; then - "$scriptDir"InstallLog.sh "${dest_vol}" "Merging existing ${dest_vol}/Extra folder." - ditto --noextattr --noqtn "${dest_vol}"/Extra "$chamTemp"/Extra - fi - fi - - # Check existing plist name for old naming convention - # and change to new convention. - if [ -e "$chamTemp"/Extra/com.apple.Boot.plist ]; then - "$scriptDir"InstallLog.sh "${dest_vol}" "Renaming existing com.apple.Boot.plist to org.chameleon.Boot.plist." - mv "$chamTemp"/Extra/com.apple.Boot.plist "$tempOCBP" - fi - - # Before merging org.chameleon.Boot.plist, copy any - # existing kernel flags, then delete the entry. - currentFlags=$( sudo /usr/libexec/plistbuddy -c "Print :Kernel\ Flags" "$tempOCBP" ) - sudo /usr/libexec/plistbuddy -c "Delete :Kernel\ Flags" "$tempOCBP" - - # Merge new org.chameleon.Boot.plist (holding.plist) - # with their currently existing one. - "$scriptDir"InstallLog.sh "${dest_vol}" "------ -Merging new options into org.chameleon.Boot.plist. -NOTE: Please check the new merged org.chameleon.Boot.plist as -NOTE: any existing keys will NOT have been updated. -NOTE: For example: If you already had Wait=No as a boot option -NOTE: and chose Wait=Yes from the list, this will NOT be changed. -------" - sudo /usr/libexec/plistbuddy -c "Merge $chamTemp/holding.plist" "$tempOCBP" - - if [[ -n "$currentFlags" ]];then - # Combine new kernel flags with old ones. - kernelFlagString=$( mergeString "$currentFlags" "${kernelFlagString}" ) - fi - - elif [ -e "$chamTemp/install_type_new" ]; then - "$scriptDir"InstallLog.sh "${dest_vol}" "User selected to make a new install." - fi - - # Write kernel flags option - kernelFlagString=$(echo ${kernelFlagString}) # Remove leading and trailing spaces - if [[ -n "$kernelFlagString" ]];then - sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP" - returnValue=$? - if [ ${returnValue} -ne 0 ]; then # key already exists. - sudo /usr/libexec/plistbuddy -c "Delete :Kernel\ Flags" "$tempOCBP" - sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP" - fi - fi - - # --------------------------------------------- - # Copy temp Extra folder to target destination - # --------------------------------------------- - # Check for an existing /Extra folder. If found, back it up - # before copying the temporary Extra folder to destination. - # Extra folder now resides in /usr/local/chamTemp/ - # Copy /usr/local/chamTemp/Extra to correct location. - - if [ ! -f "$dest_vol"/.ChameleonEFI ]; then - # The Standard install option chosen - rm -rf "$dest_vol/Extra" # Remove old Extra directory - - "$scriptDir"InstallLog.sh "${dest_vol}" "Writing new Extra folder to: $dest_vol/" - echo "Copying $chamTemp/Extra TO $dest_vol" - cp -R "$chamTemp"/Extra "$dest_vol" - else - # The EFI system partition install option was chosen - rm -rf "/Volumes/EFI/Extra" # Remove old Extra directory - - "$scriptDir"InstallLog.sh "${dest_vol}" "Writing new Extra folder to: /Volumes/EFI/" - cp -R "$chamTemp"/Extra "/Volumes/EFI" - fi -else - if [ ! -f "$dest_vol"/.ChameleonEFI ]; then - if [ -e "$dest_vol"/Extra ]; then - "$scriptDir"InstallLog.sh "${dest_vol}" "No elements selected for adding to an Extra folder, -so leaving existing $dest_vol/Extra folder untouched." - fi - else - if [ -e "/Volumes/EFI/Extra" ]; then - "$scriptDir"InstallLog.sh "${dest_vol}" "No elements selected for adding to an Extra folder, -so leaving existing /Volumes/EFI/Extra folder untouched." - fi - fi -fi - -# --------------------------------------------- # Update Rights # --------------------------------------------- chmod 777 ${dest_vol}/Extra 2>/dev/null @@ -253,41 +48,10 @@ "$scriptDir"UnMountEFIvolumes.sh "${dest_vol}" "${scriptDir}" # remove any temporary boot sector files if they exist -if [ -d /tmp/newbs ]; then - cleanUp="${cleanUp},1a" - rm /tmp/newbs -fi -if [ -d /tmp/origbs ]; then - cleanUp="${cleanUp},1b" - rm /tmp/origbs -fi -if [ -d /tmp/newBootSector ]; then - cleanUp="${cleanUp},1c" - rm /tmp/newbs -fi -if [ -d /tmp/originalBootSector ]; then - cleanUp="${cleanUp},1d" - rm /tmp/origbs -fi +rm -f /tmp/newbs /tmp/origbs /tmp/originalBootSector /tmp/newBootSector -# delete the temporary Chameleon folder -if [ -e "$chamTemp" ]; then - cleanUp="${cleanUp},2" - rm -rf "$chamTemp" -fi - # Remove /.ChameleonEFI file -if [ -f "$dest_vol"/.ChameleonEFI ]; then - cleanUp="${cleanUp},3" - rm "$dest_vol"/.ChameleonEFI -fi +rm -f "${dest_vol}/.ChameleonEFI" -"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup: ${cleanUp}" -"$scriptDir"InstallLog.sh "${dest_vol}" "LineBreak" -"$scriptDir"InstallLog.sh "${dest_vol}" "Post script complete" - -echo "===============================================" -echo "END - Post Post-Install Script" -echo "*********************************" -echo "-----------------------------------------------" -echo "" +echo "======================================================" +echo "Post postinstall script complete" Index: trunk/package/Scripts.templates/Pre/clean_bootplist.pl =================================================================== --- trunk/package/Scripts.templates/Pre/clean_bootplist.pl (revision 0) +++ trunk/package/Scripts.templates/Pre/clean_bootplist.pl (revision 1801) @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +use strict; +use YAML::Syck; + +our $target_volume; +our $boot_plist_filepath; + +our $yaml_file="@YAML_FILE@"; + +if ($#ARGV < 0) { + print stderr "A target volume is needed\n"; +} else { + $target_volume=$ARGV[0]; +} + +$boot_plist_filepath = "${target_volume}/Extra/org.chameleon.Boot.plist"; +if ( -f "$boot_plist_filepath" ) { + main("$yaml_file"); +} + +sub _do_cmd { + my ($cmd, $key, $value) = @_; + my $out; + + $key =~ s/([\s])/\\$1/g; # Escape characters in key + $value =~ s/([\s"])/\\$1/g; # Escape characters in value (space & ") + my $plistbuddy_command="$cmd :$key $value"; + + open ( OUTPUT, "-|", '/usr/libexec/plistbuddy', "-c", "$plistbuddy_command", "$boot_plist_filepath" ); + my $exit_code = $?; + chomp($out = ); + close OUTPUT; + return $out; +} + +sub get_boot_plist_option { + my ($option) = @_; + return _do_cmd( "Print", "$option"); +} + +sub delete_boot_plist_option { + my ($option) = @_; + return _do_cmd( "Delete", "$option"); +} + +sub delete_boot_plist_text_option { + my ($option, $values) = @_; + my $current_value = get_boot_plist_option "$option"; + if ( $current_value ne "") { + foreach my $recognized_value (@{$values}) { + if ($recognized_value eq $current_value) { + return _do_cmd( "Delete", "$option"); + } + } + } + return ""; +} + +sub delete_boot_plist_list_option { + my ($option, $values) = @_; + my $current_value = get_boot_plist_option "$option"; + if ( $current_value ne "") { + my %count; + my @new_list; + foreach my $value (@{$values}) { + $count{$value} = 1; + } + foreach my $value (split(/\s+/,$current_value)) { + if ( not exists $count{$value} ) { + push @new_list, $value; + } + } + return _do_cmd( "Set", $option, join(' ',@new_list) ); + } + return ""; +} + +sub main() { + # Remove all options that installer can managed + my ($yaml_file) = @_; + my $hash_ref = LoadFile($yaml_file) or die "Can't open yaml file\n"; + foreach my $option ( keys %{$hash_ref} ) { + my $type = $hash_ref->{$option}->{type}; + if ( $type =~ /^bool$/i ) { + delete_boot_plist_option($option); + } elsif ( $type =~ /^text$/i ) { + delete_boot_plist_text_option( $option, + $hash_ref->{$option}->{values} ); + } elsif ( $type =~ /^list$/i ) { + delete_boot_plist_list_option( $option, + $hash_ref->{$option}->{values} ); + } + } +} Property changes on: trunk/package/Scripts.templates/Pre/clean_bootplist.pl ___________________________________________________________________ Added: svn:executable + * Index: trunk/package/Scripts.templates/Pre/preinstall =================================================================== --- trunk/package/Scripts.templates/Pre/preinstall (revision 1800) +++ trunk/package/Scripts.templates/Pre/preinstall (revision 1801) @@ -77,6 +77,19 @@ echo "======================================================" >>"${logFile}" +# Check existing plist name for old naming convention and change to new convention. +if [[ -f "${targetVolume}/Extra/com.apple.Boot.plist" ]]; then + echo "Renaming existing com.apple.Boot.plist to org.chameleon.Boot.plist" >>"${logFile}" + mv "${targetVolume}/Extra/com.apple.Boot.plist" "${targetVolume}/Extra/org.chameleon.Boot.plist" +fi + +# --------------------------------------------- +# Clearing options that Chameleon can managed +# --------------------------------------------- +echo "Clearing options..." >>"${logFile}" +"${PWD}/clean_bootplist.pl" "${targetVolume}" 2>&1 | grep -v 'Does Not Exist' >>"${logFile}" +echo "======================================================" >>"${logFile}" + echo "===============================================" echo "END - Pre-Install Script" echo "*********************************" Index: trunk/package/Scripts.templates/InstallTheme/postinstall =================================================================== --- trunk/package/Scripts.templates/InstallTheme/postinstall (revision 0) +++ trunk/package/Scripts.templates/InstallTheme/postinstall (revision 1801) @@ -0,0 +1,22 @@ +#!/bin/bash + +set -u + +targetVolume="$3" + +themeName="@themeName@" +themeDir="@themeDir@" +logName="@LOG_FILENAME@" +logFile="${targetVolume}/$logName" + +# Check if target volume exists +if [[ ! -d "$targetVolume" ]]; then + echo "$targetVolume volume does not exist!" >&2 + exit 1 +fi + +exec >>"${logFile}" 2>&1 + +[[ -d "${targetVolume}/Extra/Themes/$themeDir" ]] && echo "Theme $themeName installed" + +exit 0 Property changes on: trunk/package/Scripts.templates/InstallTheme/postinstall ___________________________________________________________________ Added: svn:executable + * Index: trunk/package/Scripts.templates/InstallModule/postinstall =================================================================== --- trunk/package/Scripts.templates/InstallModule/postinstall (revision 0) +++ trunk/package/Scripts.templates/InstallModule/postinstall (revision 1801) @@ -0,0 +1,22 @@ +#!/bin/bash + +set -u + +targetVolume="$3" + +moduleName="@moduleName@" +moduleFile="@moduleFile@" +logName="@LOG_FILENAME@" +logFile="${targetVolume}/$logName" + +# Check if target volume exists +if [[ ! -d "$targetVolume" ]]; then + echo "$targetVolume volume does not exist!" >&2 + exit 1 +fi + +exec >>"${logFile}" 2>&1 + +[[ -f "${targetVolume}/Extra/modules/$moduleFile" ]] && echo "Module $moduleName installed" + +exit 0 Property changes on: trunk/package/Scripts.templates/InstallModule/postinstall ___________________________________________________________________ Added: svn:executable + * Index: trunk/package/Scripts/Sub/UnMountEFIvolumes.sh =================================================================== --- trunk/package/Scripts/Sub/UnMountEFIvolumes.sh (revision 1800) +++ trunk/package/Scripts/Sub/UnMountEFIvolumes.sh (revision 1801) @@ -2,7 +2,6 @@ echo "===============================================" echo "Unmount all volumes named EFI" -echo "*****************************" # loop through and un-mount ALL mounted 'EFI' system partitions - Thanks kizwan @@ -12,10 +11,10 @@ if [ "$#" -eq 2 ]; then targetVolumeChosenByUser="$1" scriptDir="$2" - echo "DEBUG: passed argument for targetVolumeChosenByUser = $targetVolumeChosenByUser" - echo "DEBUG: passed argument for scriptDir = $scriptDir" + # echo "DEBUG: passed argument for targetVolumeChosenByUser = $targetVolumeChosenByUser" + # echo "DEBUG: passed argument for scriptDir = $scriptDir" else - echo "Error - wrong number of values passed" + echo "Error - wrong number of values passed" >&2 exit 9 fi @@ -34,6 +33,3 @@ fi exit 0 - - - Index: trunk/package/buildpkg.sh =================================================================== --- trunk/package/buildpkg.sh (revision 1800) +++ trunk/package/buildpkg.sh (revision 1801) @@ -67,6 +67,10 @@ # ====== GLOBAL VARIABLES ====== declare -r LOG_FILENAME="Chameleon_Installer_Log.txt" +declare -a chameleonOptionType +declare -a chameleonOptionKey +declare -a chameleonOptionValues + declare -a pkgrefs declare -a choice_key declare -a choice_options @@ -88,7 +92,6 @@ # Package identifiers declare -r chameleon_package_identity="org.chameleon" declare -r modules_packages_identity="${chameleon_package_identity}.modules" -declare -r chamTemp="usr/local/chamTemp" # ====== FUNCTIONS ====== @@ -97,21 +100,11 @@ echo "${result%"${result##*[![:space:]]}"}" # remove trailing whitespace characters } -argument () { - local opt="$1" - - if [[ $# -eq 0 ]];then - echo "$0: option requires an argument -- '$opt'" >&2; exit 1 - fi - echo "$opt" -} - function makeSubstitutions () { # Substition is like: Key=Value # # Optionnal arguments: # --subst= : add a new substitution - # --subst : add a new substitution # # Last argument(s) is/are file(s) where substitutions must be made @@ -134,7 +127,6 @@ while [[ $# -gt 0 ]];do local option="$1" case "$option" in - --subst) shift; addSubst "$(argument $@)"; shift ;; --subst=*) shift; addSubst "${option#*=}" ;; -*) echo "Unrecognized makeSubstitutions option '$option'" >&2 @@ -178,7 +170,6 @@ # # Optionnal arguments: # --subst= : add a new substitution - # --subst : add a new substitution # # Substition is like: Key=Value # @@ -192,7 +183,6 @@ local option="$1" case "$option" in --pkg-rootdir=*) shift; pkgRootDir="${option#*=}" ;; - --subst) shift; allSubst[${#allSubst[*]}]="$option"; allSubst[${#allSubst[*]}]="$1" ; shift ;; --subst=*) shift; allSubst[${#allSubst[*]}]="${option}" ;; -*) echo "Unrecognized addTemplateScripts option '$option'" >&2 @@ -381,6 +371,53 @@ echo "(my.choice.selected && $(exclusive_one_choice ${@}))" } +recordChameleonOption () { + local type="$1" + local key="$2" + local value="$3" + + # Search for an existing key + local found=0 + for (( idx=0 ; idx < ${#chameleonOptionKey[@]}; idx++ ));do + if [[ "$key" == "${chameleonOptionKey[$idx]}" ]];then + found=1 + break + fi + done + + # idx contain the index of a new key or an existing one + if [[ $found -eq 0 ]]; then + # Create a new one + chameleonOptionKey[$idx]="$key" + chameleonOptionType[$idx]="$type" + chameleonOptionValues[$idx]="" + fi + + case "$type" in + bool) ;; + text|list) chameleonOptionValues[$idx]="${chameleonOptionValues[$idx]} $value" ;; + *) echo "Error unknown type '$type' for '$key'" >&2 + exit 1 + ;; + esac +} + +generate_options_yaml_file () { + local yamlFile="$1" + echo "---" > $yamlFile + for (( idx=0; idx < ${#chameleonOptionKey[@]}; idx++ ));do + printf "%s:\n type: %s\n" "${chameleonOptionKey[$idx]}" "${chameleonOptionType[$idx]}" >> $yamlFile + case ${chameleonOptionType[$idx]} in + text|list) + printf " values:\n" >> $yamlFile + for value in ${chameleonOptionValues[$idx]};do + printf " - %s\n" "$value" >> $yamlFile + done + ;; + esac + done +} + main () { @@ -393,18 +430,17 @@ echo -e $COL_CYAN" ----------------------------------"$COL_RESET echo "" -# build pre install package +# Add pre install choice echo "================= Preinstall =================" packagesidentity="${chameleon_package_identity}" choiceId="Pre" - mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root - addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId} packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}" -# End build pre install package + # Package will be build at the end +# End pre install choice + # build core package echo "================= Core =================" packagesidentity="${chameleon_package_identity}" @@ -428,33 +464,6 @@ addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}" # End build core package -# build install type - echo "================= Chameleon =================" - addGroupChoices --exclusive_one_choice "InstallType" - packagesidentity="${chameleon_package_identity}.type" - - # build new install package - choiceId="New" - mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root - echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/install_type_new" - - packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp" - addChoice --group="InstallType" --start-selected="!choices['Upgrade'].selected" --pkg-refs="$packageRefId" "${choiceId}" - # End build new install package - - # build upgrade package - choiceId="Upgrade" - mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root - echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/install_type_upgrade" - - packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp" - addChoice --group="InstallType" --start-selected="chameleon_boot_plist_exists()" --pkg-refs="$packageRefId" "${choiceId}" - # End build upgrade package - -# End build install type - # build Chameleon package echo "================= Chameleon =================" addGroupChoices --exclusive_one_choice "Chameleon" @@ -474,6 +483,10 @@ # End build standard package # build efi package +if [[ 1 -eq 0 ]];then + # Only standard installation is currently supported + # We need to update the script to be able to install + # Chameleon on EFI partition choiceId="EFI" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources @@ -486,7 +499,7 @@ buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" addChoice --group="Chameleon" --start-visible="systemHasGPT()" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build efi package - +fi # build no bootloader choice package choiceId="noboot" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root @@ -518,11 +531,16 @@ { # Start build Resolution package module choiceId="AutoReso" + moduleFile="Resolution.dylib" mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root" - ditto --noextattr --noqtn "${SYMROOT}/i386/modules/Resolution.dylib" "${PKG_BUILD_DIR}/${choiceId}/Root" + ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root" + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \ + --subst="moduleName=$choiceId" \ + --subst="moduleFile=$moduleFile" \ + InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build Resolution package module } @@ -533,11 +551,16 @@ { # Start build klibc package module choiceId="klibc" + moduleFile="${choiceId}.dylib" mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root" - ditto --noextattr --noqtn "${SYMROOT}/i386/modules/${choiceId}.dylib" ${PKG_BUILD_DIR}/${choiceId}/Root + ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" ${PKG_BUILD_DIR}/${choiceId}/Root + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \ + --subst="moduleName=$choiceId" \ + --subst="moduleFile=$moduleFile" \ + InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build klibc package module } @@ -553,11 +576,16 @@ fi # Start build uClibc package module choiceId="uClibc" + moduleFile="uClibcxx.dylib" mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root" - ditto --noextattr --noqtn "${SYMROOT}/i386/modules/uClibcxx.dylib" "${PKG_BUILD_DIR}/${choiceId}/Root" + ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root" + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \ + --subst="moduleName=$choiceId" \ + --subst="moduleFile=$moduleFile" \ + InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" # Add the klibc package because the uClibc module is dependent of klibc module addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId $klibcPackageRefId" "${choiceId}" # End build uClibc package module @@ -570,6 +598,7 @@ { # Start build Keylayout package module choiceId="Keylayout" + moduleFile="${choiceId}.dylib" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/{modules,Keymaps} mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin layout_src_dir="${SRCROOT}/i386/modules/Keylayout/layouts/layouts-src" @@ -579,14 +608,19 @@ tar czf "${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps/layouts-src.tar.gz" README *.slt) fi # Adding module - ditto --noextattr --noqtn ${SYMROOT}/i386/modules/${choiceId}.dylib ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/modules + ditto --noextattr --noqtn ${SYMROOT}/i386/modules/$moduleFile ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/modules # Adding Keymaps ditto --noextattr --noqtn ${SRCROOT}/Keymaps ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps # Adding tools ditto --noextattr --noqtn ${SYMROOT}/i386/cham-mklayout ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin + # Adding scripts + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \ + --subst="moduleName=$choiceId" \ + --subst="moduleFile=$moduleFile" \ + InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" # Don't add a choice for Keylayout module # addChoice "${choiceId}" "Module" --start-selected="false" "$packageRefId" @@ -659,9 +693,6 @@ # create folders required for each boot option mkdir -p "${PKG_BUILD_DIR}/$optionName/Root/" - # create dummy file with name of key/value - echo "" > "${PKG_BUILD_DIR}/$optionName/Root/${keyValue}" - case "$type" in bool) startSelected="check_chameleon_bool_option('$key','$value')" ;; text) startSelected="check_chameleon_text_option('$key','$value')" ;; @@ -670,8 +701,14 @@ exit 1 ;; esac + recordChameleonOption "$type" "$key" "$value" + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/$optionName" \ + --subst="optionType=$type" \ + --subst="optionKey=$key" \ + --subst="optionValue=$value" \ + AddOption packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}") - buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/$chamTemp/options" + buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/" addChoice --group="${builtOptionsList}" \ --start-selected="$startSelected" \ --pkg-refs="$packageRefId" "${optionName}" @@ -704,11 +741,14 @@ choiceId="${availableOptions[i]}" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root - # create dummy file with name of key/value - echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/${chameleon_keylayout_key}=${availableOptions[i]}" - + recordChameleonOption "text" "$chameleon_keylayout_key" "$choiceId" + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \ + --subst="optionType=text" \ + --subst="optionKey=$chameleon_keylayout_key" \ + --subst="optionValue=$choiceId" \ + AddOption packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/options" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" # Add the Keylayout package because the Keylayout module is needed addChoice --group="Keymaps" \ --start-selected="check_chameleon_text_option('${chameleon_keylayout_key}','${choiceId}')" \ @@ -727,22 +767,42 @@ artwork="${SRCROOT}/artwork/themes" themes=($( find "${artwork}" -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 "${PKG_BUILD_DIR}/${theme}/Root/" - rsync -r --exclude=.svn --exclude="*~" "${themes[$i]}/" "${PKG_BUILD_DIR}/${theme}/Root/${theme}" + themeName=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' ) + themeDir="$themeName" + mkdir -p "${PKG_BUILD_DIR}/${themeName}/Root/" + rsync -r --exclude=.svn --exclude="*~" "${themes[$i]}/" "${PKG_BUILD_DIR}/${themeName}/Root/${themeName}" + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${themeName}" \ + --subst="themeName=$themeName" \ + --subst="themeDir=$themeDir" \ + InstallTheme - packageRefId=$(getPackageRefId "${packagesidentity}" "${theme}") - buildpackage "$packageRefId" "${theme}" "${PKG_BUILD_DIR}/${theme}" "/$chamTemp/Extra/Themes" - addChoice --group="Themes" --start-selected="false" --pkg-refs="$packageRefId" "${theme}" + packageRefId=$(getPackageRefId "${packagesidentity}" "${themeName}") + buildpackage "$packageRefId" "${themeName}" "${PKG_BUILD_DIR}/${themeName}" "/Extra/Themes" + addChoice --group="Themes" --start-selected="false" --pkg-refs="$packageRefId" "${themeName}" done # End build theme packages# End build Extras package +# build pre install package + echo "================= Pre =================" + packagesidentity="${chameleon_package_identity}" + choiceId="Pre" + + packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") + mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root + mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources + local yamlFile="Resources/chameleon_options.yaml" + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \ + --subst="YAML_FILE=${yamlFile}" ${choiceId} + generate_options_yaml_file "${PKG_BUILD_DIR}/${choiceId}/Scripts/$yamlFile" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" +# End build pre install package + # build post install package echo "================= Post =================" packagesidentity="${chameleon_package_identity}" choiceId="Post" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root - addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId} InstallerLog + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId} cp -f ${PKGROOT}/Scripts/Sub/UnMountEFIvolumes.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")