Author: mmadia Date: 2010-04-21 16:07:19 +0200 (Wed, 21 Apr 2010) New Revision: 36395 Changeset: http://dev.haiku-os.org/changeset/36395/haiku Modified: haiku/trunk/data/bin/installoptionalpackage Log: Added support for '-f' in installoptionalpackage, which removes cached data before displaying the available optional packages that can be installed. Modified: haiku/trunk/data/bin/installoptionalpackage =================================================================== --- haiku/trunk/data/bin/installoptionalpackage 2010-04-21 11:20:07 UTC (rev 36394) +++ haiku/trunk/data/bin/installoptionalpackage 2010-04-21 14:07:19 UTC (rev 36395) @@ -309,7 +309,7 @@ function Init() { - + # Set up some directory paths baseDir=`finddir B_COMMON_DATA_DIRECTORY`/optional-packages tmpDir=`finddir B_COMMON_TEMP_DIRECTORY` @@ -322,16 +322,23 @@ if ! [ -d ${baseDir} ] ; then mkdir -p ${baseDir} fi - + + DetectSystemConfiguration + DownloadAllBuildFiles + ReadPackageNamesIntoMemory +} + + +function DownloadAllBuildFiles() +{ + # DownloadAllBuildFiles # Retreive the necessary jam files from svn. local buildFiles="OptionalPackages OptionalPackageDependencies \ OptionalBuildFeatures" for file in ${buildFiles} ; do GetBuildFile ${file} done - - DetectSystemConfiguration - ReadPackageNamesIntoMemory + } @@ -688,14 +695,33 @@ http://dev.haiku-os.org/wiki/PackageManagerIdeas http://dev.haiku-os.org/wiki/PackageFormat -Usage: ./installoptionalpackage [-l] [-a "<pkg> [<pkg> ...]"] +Usage: ./installoptionalpackage [-f] [-h] [-l] [-a "<pkg> [<pkg> ...]"] +-a Add one or more packages and all dependencies +-f Remove cached data and list installable packages +-h Print this help. -l List installable packages --a Add one or more packages and all dependencies EOF } +function RemoveCachedFiles() +{ + # RemoveCachedFiles + echo "Removing cached files ..." + if [ -d ${baseDir} ]; then + rm -rf ${baseDir} + fi + + # Unset variables, which prevents duplicate entries. + declare -A availablePackages + declare availablePackagesKeys="" + + # Reinitialize + Init +} + + function ListPackages() { # ListPackages @@ -722,12 +748,17 @@ fi # Parse the arguments given to the script. -while getopts "a:lh" opt; do +while getopts "a:fhl" opt; do case $opt in a) AddPackage "$OPTARG" exit 0 ;; + f) + RemoveCachedFiles + ListPackages + exit 0 + ;; h) DisplayUsage exit 0