@@ -160,8 +160,15 @@ package_latest_version() { #returns the latest available versions of the specifi
160160 local package=" $1 "
161161 [ -z " $package " ] && error " package_latest_version(): no package specified!"
162162
163+ # support repo selection as '-t bookworm-backports' for $2 and $3
164+ local additional_flags
165+ additional_flags=()
166+ if [ " $2 " == ' -t' ]; then
167+ additional_flags=(-t " $3 " )
168+ fi
169+
163170 # use slower but more accurate apt list command to get package version for current architecture
164- apt-cache policy " $package " 2> /dev/null | grep " Candidate: " | awk ' {print $2}'
171+ apt-cache policy " ${additional_flags[@]} " " $ package" 2> /dev/null | grep " Candidate: " | awk ' {print $2}'
165172 # grep -rx "Package: $package" /var/lib/apt/lists --exclude="lock" --exclude-dir="partial" --after 4 | grep -o 'Version: .*' | awk '{print $2}' | sort -rV | head -n1
166173}
167174
@@ -476,8 +483,11 @@ install_packages() { #Make some packages dependencies of the $app app. Package-n
476483
477484 # convert input array to newline-separated string
478485 local IFS=' '
486+ local repo_selection=' ' # store selected repo to install from, eg. bookworm-backports
479487 while [ $# -gt 0 ]; do
480- if [ " $1 " == ' -t' ]; then # pass through -t args to apt: for "-t bookworm-backports"
488+ # pass through -t args to apt: for "-t bookworm-backports"
489+ if [ " $1 " == ' -t' ]; then
490+ repo_selection=" $2 "
481491 apt_flags+=(' -t' " $2 " )
482492 shift
483493 shift
@@ -575,7 +585,7 @@ install_packages() { #Make some packages dependencies of the $app app. Package-n
575585 using_local_packages=1 # remember that the pi-apps-local-packages repository is being used
576586
577587 # replace package url with name of package
578- packages=" $( echo " $packages " | sed " s|$ package |$packagename (>= $packageversion )|" ) "
588+ packages=" $( echo " $packages " | sed " s|^ ${ package} $ |$packagename (>= $packageversion )|" ) "
579589
580590 # expand regex (package-name contains *)
581591 elif echo " $package " | grep -q ' *' ; then
@@ -586,6 +596,12 @@ install_packages() { #Make some packages dependencies of the $app app. Package-n
586596
587597 # replace package with expanded list
588598 packages=" $( echo " $packages " | grep -vF " $package " ) " $' \n ' " $list "
599+
600+ # request package version if backports repo was specified
601+ elif [ ! -z " $repo_selection " ]; then
602+ local packageversion=" $( package_latest_version " $package " -t " $repo_selection " | sed ' s/+.*//g' ) "
603+ # add version specification to package
604+ packages=" $( echo " $packages " | sed " s|^${package} $|$package (>= $packageversion )|" ) "
589605 fi
590606 done
591607 # now package list shouldn't contain any '*' characters, urls, local filepaths
0 commit comments