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()
{
if [ "$1" = '-a' ]; then
if [ "$1" = '-a' ] || [ "$1" = '-s' ]; then
shift
fi
while [ $# -gt 0 ]; do
@@ -492,23 +492,9 @@ function BuildListOfRequestedPackages()
function 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 $proceedWithInstallation ; then
echo "To be installed: ${packagesToInstall}"
if BuildFinalListOfPackagesToInstall ; then
for package in ${packagesToInstall} ; do
# 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()
{
# IsPackageNameValid <name>
@@ -709,11 +721,12 @@ Disclaimer:
http://dev.haiku-os.org/wiki/PackageFormat
Usage: ./installoptionalpackage [<pkg> [<pkg> ...]]
or ./installoptionalpackage [-a <pkg> [<pkg> ...]]
or ./installoptionalpackage [-a|-s <pkg> [<pkg> ...]]
or ./installoptionalpackage [-f|-h|-l]
Options:
-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
-h Print this help.
-l List installable packages
@@ -765,14 +778,15 @@ else
fi
# Support `installoptionalpackage <pkg> <pkg> ...`
if [ "$1" != '-f' ] && [ "$1" != '-l' ] && [ "$1" != '-h' ]; then
if [ "$1" != '-f' ] && [ "$1" != '-l' ] && [ "$1" != '-h' ] \
&& [ "$1" != '-s' ]; then
BuildListOfRequestedPackages $@
AddPackages
exit 0
fi
# Parse the arguments given to the script.
while getopts "a:fhl" opt; do
while getopts "as:fhl" opt; do
case $opt in
a)
BuildListOfRequestedPackages $@
@@ -792,6 +806,11 @@ while getopts "a:fhl" opt; do
ListPackages
exit 0
;;
s)
BuildListOfRequestedPackages $@
BuildFinalListOfPackagesToInstall
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1