Index: trunk/package/Distribution =================================================================== --- trunk/package/Distribution (revision 1765) +++ trunk/package/Distribution (revision 1766) @@ -39,8 +39,51 @@ return false; } + function get_chameleon_boot_plist() { + if (my.target) { + var chameleon_boot_plist = my.target.mountpoint + '/Extra/org.chameleon.Boot.plist' + return system.files.plistAtPath(chameleon_boot_plist); + } + return null; + } + function chameleon_boot_plist_exists() { - return system.files.fileExistsAtPath(my.target.mountpoint + '/Extra/org.chameleon.Boot.plist'); + if (get_chameleon_boot_plist() != null) + return true; + return false; } + function check_chameleon_kernel_option(kernelFlags, value) { + var flags = kernelFlags.split(" "); + for ( var i = 0; i < flags.length; i++ ) { + if (flags[i] == value) + return true; + } + return false; + } + + function check_chameleon_option(key, value) { + var bootPlist = get_chameleon_boot_plist(); + if (bootPlist) { + if (key == "KFflag") + key = "Kernel Flags"; + + if (bootPlist[ key ]) { + if ( key == "Kernel Flags" ) + return check_chameleon_kernel_option( bootPlist[ key ], value ); + + // Check if value is a boolean + var pattern=/^(Y(es)?|No?)$/i; + var result = value.match(pattern); // Check if the value is a boolean + if ( result && bootPlist[ key ].charAt(0).toLowerCase() == value.charAt(0).toLowerCase() ) + return true; + else + return bootPlist[ key ] == value; // check if the strings are equal + } + else + return false; + } + return false; + } + Index: trunk/package/Scripts/Main/postinstall =================================================================== --- trunk/package/Scripts/Main/postinstall (revision 1765) +++ trunk/package/Scripts/Main/postinstall (revision 1766) @@ -1,5 +1,24 @@ #!/bin/bash +mergeString () { + local src="${1}" + local new="${2}" + local result="$src" + + 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 "*********************************" @@ -180,7 +199,7 @@ if [[ -n "$currentFlags" ]];then # Combine new kernel flags with old ones. - kernelFlagString="${kernelFlagString} $currentFlags" + kernelFlagString=$( mergeString "$currentFlags" "${kernelFlagString}" ) fi elif [ -e "$chamTemp/install_type_new" ]; then Index: trunk/package/buildpkg.sh =================================================================== --- trunk/package/buildpkg.sh (revision 1765) +++ trunk/package/buildpkg.sh (revision 1766) @@ -531,7 +531,9 @@ packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}") buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/$chamTemp/options" - addChoice --group="${builtOptionsList}" --start-selected="false" --pkg-refs="$packageRefId" "${optionName}" + addChoice --group="${builtOptionsList}" \ + --start-selected="check_chameleon_option('$key','$value')" \ + --pkg-refs="$packageRefId" "${optionName}" done done @@ -548,6 +550,7 @@ keylayoutPackageRefId=$(getPackageRefId "${modules_packages_identity}" "Keylayout") fi + chameleon_keylayout_key="KeyLayout" # ------------------------------------------------------ # Available Keylayout boot options are discovered by # reading contents of /Keymaps folder after compilation @@ -556,18 +559,19 @@ # Adjust array contents to match expected format # for boot options which is: name:key=value for (( i = 0 ; i < ${#availableOptions[@]} ; i++ )); do - # availableOptions[i]=${availableOptions[i]}":KeyLayout="${availableOptions[i]} # Start build of a keymap package module choiceId="${availableOptions[i]}" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root # create dummy file with name of key/value - echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/KeyLayout=${availableOptions[i]}" + echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/${chameleon_keylayout_key}=${availableOptions[i]}" packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/options" # Add the Keylayout package because the Keylayout module is needed - addChoice --group="KeyLayout" --start-selected="false" --pkg-refs="$packageRefId $keylayoutPackageRefId" "${choiceId}" + addChoice --group="KeyLayout" \ + --start-selected="check_chameleon_option('${chameleon_keylayout_key}','${choiceId}')" \ + --pkg-refs="$packageRefId $keylayoutPackageRefId" "${choiceId}" done # End build KeyLayout options packages