Added '-s', which shows the final list of packages that would be installed.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36399 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matt Madia
2010-04-21 15:51:17 +00:00
parent c333e7dff6
commit 0e3ac47627
+38 -19
View File
@@ -479,7 +479,7 @@ function IsPackageAndDepsOkToInstall()
function BuildListOfRequestedPackages() function BuildListOfRequestedPackages()
{ {
if [ "$1" = '-a' ]; then if [ "$1" = '-a' ] || [ "$1" = '-s' ]; then
shift shift
fi fi
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
@@ -492,23 +492,9 @@ function BuildListOfRequestedPackages()
function AddPackages() function AddPackages()
{ {
# AddPackages # AddPackages
packagesToInstall=""
proceedWithInstallation=false
for desiredPackage in ${wantsToInstall}; do
if IsPackageNameValid $desiredPackage ; then
for item in ${availablePackages[${desiredPackage}]} ; do
if ! ContainsSubstring "${packagesToInstall}" "${item}" ; then
packagesToInstall="${packagesToInstall} ${item}"
fi
done
proceedWithInstallation=true
fi
done
# If one or more packages can be installed, do it. # If one or more packages can be installed, do it.
if $proceedWithInstallation ; then if BuildFinalListOfPackagesToInstall ; then
echo "To be installed: ${packagesToInstall}"
for package in ${packagesToInstall} ; do for package in ${packagesToInstall} ; do
# output the "if [ IsOptionalHaikuImagePackageAdded..." code block # output the "if [ IsOptionalHaikuImagePackageAdded..." code block
@@ -526,6 +512,32 @@ function AddPackages()
} }
function BuildFinalListOfPackagesToInstall()
{
# BuildFinalListOfPackagesToInstall
packagesToInstall=""
proceedWithInstallation=false
for desiredPackage in ${wantsToInstall}; do
if IsPackageNameValid $desiredPackage ; then
for item in ${availablePackages[${desiredPackage}]} ; do
if ! ContainsSubstring "${packagesToInstall}" "${item}" ; then
packagesToInstall="${packagesToInstall} ${item}"
fi
done
proceedWithInstallation=true
fi
done
if [ $proceedWithInstallation ] ; then
echo "To be installed: ${packagesToInstall}"
return 0
else
return 1
fi
}
function IsPackageNameValid() function IsPackageNameValid()
{ {
# IsPackageNameValid <name> # IsPackageNameValid <name>
@@ -709,11 +721,12 @@ Disclaimer:
http://dev.haiku-os.org/wiki/PackageFormat http://dev.haiku-os.org/wiki/PackageFormat
Usage: ./installoptionalpackage [<pkg> [<pkg> ...]] Usage: ./installoptionalpackage [<pkg> [<pkg> ...]]
or ./installoptionalpackage [-a <pkg> [<pkg> ...]] or ./installoptionalpackage [-a|-s <pkg> [<pkg> ...]]
or ./installoptionalpackage [-f|-h|-l] or ./installoptionalpackage [-f|-h|-l]
Options: Options:
-a Add one or more packages and all dependencies -a Add one or more packages and all dependencies
-s Show the final list of packages that would be installed
-f Remove cached data and list installable packages -f Remove cached data and list installable packages
-h Print this help. -h Print this help.
-l List installable packages -l List installable packages
@@ -765,14 +778,15 @@ else
fi fi
# Support `installoptionalpackage <pkg> <pkg> ...` # Support `installoptionalpackage <pkg> <pkg> ...`
if [ "$1" != '-f' ] && [ "$1" != '-l' ] && [ "$1" != '-h' ]; then if [ "$1" != '-f' ] && [ "$1" != '-l' ] && [ "$1" != '-h' ] \
&& [ "$1" != '-s' ]; then
BuildListOfRequestedPackages $@ BuildListOfRequestedPackages $@
AddPackages AddPackages
exit 0 exit 0
fi fi
# Parse the arguments given to the script. # Parse the arguments given to the script.
while getopts "a:fhl" opt; do while getopts "as:fhl" opt; do
case $opt in case $opt in
a) a)
BuildListOfRequestedPackages $@ BuildListOfRequestedPackages $@
@@ -792,6 +806,11 @@ while getopts "a:fhl" opt; do
ListPackages ListPackages
exit 0 exit 0
;; ;;
s)
BuildListOfRequestedPackages $@
BuildFinalListOfPackagesToInstall
exit 0
;;
\?) \?)
echo "Invalid option: -$OPTARG" >&2 echo "Invalid option: -$OPTARG" >&2
exit 1 exit 1