diff --git a/data/bin/installoptionalpackage b/data/bin/installoptionalpackage index 1682e48861..b397040989 100755 --- a/data/bin/installoptionalpackage +++ b/data/bin/installoptionalpackage @@ -27,6 +27,7 @@ declare -A availablePackages declare availablePackagesKeys="" +declare wantsToInstall="" # Some Packages cannot be installed, # as they require either the source code or compiled binaries declare packageIgnoreList='Bluetooth Development DevelopmentMin \ @@ -476,13 +477,26 @@ function IsPackageAndDepsOkToInstall() } -function AddPackage() +function BuildListOfRequestedPackages() { - # AddPackage + if [ "$1" = '-a' ]; then + shift + fi + while [ $# -gt 0 ]; do + wantsToInstall="${wantsToInstall} $1" + shift + done + echo "wantsToInstall: ${wantsToInstall}" +} + + +function AddPackages() +{ + # AddPackages packagesToInstall="" proceedWithInstallation=false - for desiredPackage in ${1}; do + for desiredPackage in ${wantsToInstall}; do if IsPackageNameValid $desiredPackage ; then for item in ${availablePackages[${desiredPackage}]} ; do if ! ContainsSubstring "${packagesToInstall}" "${item}" ; then @@ -695,11 +709,15 @@ Disclaimer: http://dev.haiku-os.org/wiki/PackageManagerIdeas http://dev.haiku-os.org/wiki/PackageFormat -Usage: ./installoptionalpackage [-f] [-h] [-l] [-a " [ ...]"] --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 +Usage: ./installoptionalpackage [ [ ...]] + or ./installoptionalpackage [-a [ ...]] + or ./installoptionalpackage [-f|-h|-l] + +Options: +-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 EOF } @@ -747,11 +765,19 @@ else Init fi +# Support `installoptionalpackage ...` +if [ "$1" != '-f' ] && [ "$1" != '-l' ] && [ "$1" != '-h' ]; then + BuildListOfRequestedPackages $@ + AddPackages + exit 0 +fi + # Parse the arguments given to the script. while getopts "a:fhl" opt; do case $opt in a) - AddPackage "$OPTARG" + BuildListOfRequestedPackages $@ + AddPackages exit 0 ;; f)