From eff79b9ccfb8be16bdf5016af5fa9b60e99ae01f Mon Sep 17 00:00:00 2001 From: Matteo Rossini Date: Tue, 12 Jan 2016 19:04:29 +0100 Subject: [PATCH] Fixed a bug with the bashism. In install/upgrade Fixed an issue when search for a package that have more than a version in the same repository. --- src/slackpkgplus.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/slackpkgplus.sh b/src/slackpkgplus.sh index 6144a6a..3a9925a 100755 --- a/src/slackpkgplus.sh +++ b/src/slackpkgplus.sh @@ -770,7 +770,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then [ "$PKGDATA" ] && break DIR=${CPRIORITY/:*/} #DIR=$(echo "$CPRIORITY" | cut -f1 -d":") - [[ "$CPRIORITY" =~ ".*:.*" ]] && PAT=${CPRIORITY/*:/} || PAT="" #PAT=$(echo "$CPRIORITY" | cut -s -f2- -d":") + [[ "$CPRIORITY" =~ .*:.* ]] && PAT=${CPRIORITY/*:/} || PAT="" #PAT=$(echo "$CPRIORITY" | cut -s -f2- -d":") REPOSITORY=${DIR/SLACKPKGPLUS_/} #REPOSITORY=$(echo "${DIR}" | sed "s/SLACKPKGPLUS_//") # pass to the next iteration when there are priority filters and the @@ -781,7 +781,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then fi #if echo "$CPRIORITY " | grep -q "[a-zA-Z0-9]\+[:]" ; then - if [[ "$CPRIORITY" =~ "^[-_[:alnum:]]+[:]" ]] ; then + if [[ "$CPRIORITY" =~ ^[-_[:alnum:]]+[:] ]] ; then # [Reminder] ARGUMENT is always a basename, but PAT can be : # 1. a basename (ie. gcc, glibc-solibs) @@ -794,6 +794,15 @@ if [ "$SLACKPKGPLUS" = "on" ];then #PKGINFOS=$(grep -m 1 "^[[:digit:]]\+:${DIR} ${ARGUMENT} " ${TMPDIR}/packages.matches) PKGINFOS=$(grep -n "^${DIR} " ${TMPDIR}/pkglist | grep 2>/dev/null -w "${PAT}" | grep -m 1 "^[[:digit:]]\+:${DIR} ${ARGUMENT} ") + if [ ! -z "$PKGINFOS" ] ; then + LINEIDX=${PKGINFOS/:*/} #LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":") + PKGDATA=( ${PKGINFOS/*:/} ) #PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") ) + fi + elif [[ "$CPRIORITY" =~ ^[.][*][:] ]] ; then + PKGDATA="" + LINEIDX="" + PKGINFOS=$(grep 2>/dev/null -n -w "${PAT}" ${TMPDIR}/pkglist | grep -m 1 " ${ARGUMENT} ") + if [ ! -z "$PKGINFOS" ] ; then LINEIDX=${PKGINFOS/:*/} #LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":") PKGDATA=( ${PKGINFOS/*:/} ) #PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") ) @@ -832,7 +841,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then fi if [ ! -z "$LINEIDX" ] ; then - # CPRIORITY is of kind reponame:pattern. The selected package is at line #LINEIDX. To + # CPRIORITY is of kind reponame:pattern or .*:pattern. The selected package is at line #LINEIDX. To # ensure that slackpkg (ie. core code) will install|upgrade this (exact) package, the # line which describes it (ie. in TMPDIR/pkglist) must be moved at line #PRIORITYIDX. # @@ -1499,6 +1508,10 @@ if [ "$SLACKPKGPLUS" = "on" ];then package=$pref AUTOPRIORITY=" $AUTOPRIORITY -e $package " + + if [ "$CMD" == "install" ] || [ "$CMD" == "upgrade" ] ; then + PRIORITYLIST=( ${PRIORITYLIST[*]} ".*:${package}" ) + fi fi if [ "$CMD" == "remove" ];then