slackpkg does not fully honor filter for duplicated packages
by zerouno from LinuxQuestions.org on (#5KV69)
consider that:
Code:# slackpkg -dialog=off search php-5
[ upgrade ] - php-7.4.20-x86_64-1 --> php-5.6.40-x86_64-1
# slackpkg -dialog=off upgrade php-5
php-7.4.21-x86_64-1.txzit grep php-5 in pkglist and find
Code:pasture php 5.6.40 x86_64 1 php-5.6.40-x86_64-1 ./pasture txznext run "givepriority php" and find php-7 that is in priority list
I expect that if I look for php-5 then I want php-5. If search tell me that I can upgrade to php-5 then I expect that upgrade allow me to upgrade to it.
If I look for php-6 slackpkg give me no results both in search and upgrade/install process
Code:# slackpkg -dialog=off search php-6
No package name matches the pattern.
# slackpkg -dialog=off upgrade php-6
No packages match the pattern for upgrade. Try:the same for 'kernel'
Code:# slackpkg -dialog=off upgrade kernel-generic-5.14
Looking for kernel-generic-5.14 in package list. Please wait... DONE
No packages match the pattern for upgrade. Try:
# slackpkg -dialog=off upgrade kernel-generic-5.13
Looking for kernel-generic-5.13 in package list. Please wait... DONE
kernel-generic-5.12.14-x86_64-1.txzsimilar with 'slackpkg download'. The difference is that slackpkg download allow to select more than one release if I use -dialog=on; that output a not clear output
Code:# slackpkg -dialog=off download kernel-generic-5.13
Looking for kernel-generic-5.13 in package list. Please wait... DONE
kernel-generic-5.12.14-x86_64-1.txz
kernel-generic-5.13.0-x86_64-1.txz
# slackpkg -dialog=off download pasture
Looking for pasture in package list. Please wait... DONE
apmd-3.2.2-x86_64-3.txz
php-5.6.40-x86_64-1.txz
php-7.4.21-x86_64-1.txzIf I look for pasture I want pasture only.
I made a simple patch to improve it
Code:--- core-functions.sh-15.0.5 2021-07-03 15:34:14.784596931 +0200
+++ core-functions.sh 2021-07-03 16:13:26.603413658 +0200
@@ -593,6 +593,7 @@
function givepriority {
local DIR
local ARGUMENT=$1
+ local FILTER="$2"
local PKGDATA
unset NAME
@@ -601,7 +602,7 @@
for DIR in ${PRIORITY[@]} ; do
[ "$PKGDATA" ] && break
- PKGDATA=( $(grep "^${DIR} ${ARGUMENT} " ${TMPDIR}/pkglist) )
+ PKGDATA=( $(grep "^${DIR} ${ARGUMENT} " ${TMPDIR}/pkglist |grep -w -- "$FILTER") )
if [ "$PKGDATA" ]; then
NAME=${PKGDATA[1]}
FULLNAME=$(echo "${PKGDATA[5]}.${PKGDATA[7]}")
@@ -693,7 +694,7 @@
download)
for ARGUMENT in $(echo $INPUTLIST); do
for i in $(grep -w -- "${ARGUMENT}" ${TMPDIR}/pkglist | cut -f2 -d\ | sort -u); do
- LIST="$LIST $(grep " ${i} " ${TMPDIR}/pkglist | cut -f6,8 -d\ --output-delimiter=.)"
+ LIST="$LIST $(grep " ${i} " ${TMPDIR}/pkglist|grep -w -- "${ARGUMENT}" | cut -f6,8 -d\ --output-delimiter=.)"
done
LIST="$(echo -e $LIST | sort -u)"
done
@@ -704,7 +705,7 @@
install|upgrade|reinstall)
for ARGUMENT in $(echo $INPUTLIST); do
for i in $(grep -w -- "${ARGUMENT}" ${TMPDIR}/pkglist | cut -f2 -d\ | sort -u); do
- givepriority $i
+ givepriority $i "${ARGUMENT}"
[ ! "$FULLNAME" ] && continue
case $CMD in
Code:# slackpkg -dialog=off upgrade pasture
Checking local integrity... DONE
Looking for pasture in package list. Please wait... DONE
php-5.6.40-x86_64-1.txz
# slackpkg -dialog=off download kernel-generic-5.13
Looking for kernel-generic-5.13 in package list. Please wait... DONE
kernel-generic-5.13.0-x86_64-1.txzThis patch also may help future slackpkg+ improvements, where duplicated packages are a normal thing.
Code:# slackpkg -dialog=off search php-5
[ upgrade ] - php-7.4.20-x86_64-1 --> php-5.6.40-x86_64-1
# slackpkg -dialog=off upgrade php-5
php-7.4.21-x86_64-1.txzit grep php-5 in pkglist and find
Code:pasture php 5.6.40 x86_64 1 php-5.6.40-x86_64-1 ./pasture txznext run "givepriority php" and find php-7 that is in priority list
I expect that if I look for php-5 then I want php-5. If search tell me that I can upgrade to php-5 then I expect that upgrade allow me to upgrade to it.
If I look for php-6 slackpkg give me no results both in search and upgrade/install process
Code:# slackpkg -dialog=off search php-6
No package name matches the pattern.
# slackpkg -dialog=off upgrade php-6
No packages match the pattern for upgrade. Try:the same for 'kernel'
Code:# slackpkg -dialog=off upgrade kernel-generic-5.14
Looking for kernel-generic-5.14 in package list. Please wait... DONE
No packages match the pattern for upgrade. Try:
# slackpkg -dialog=off upgrade kernel-generic-5.13
Looking for kernel-generic-5.13 in package list. Please wait... DONE
kernel-generic-5.12.14-x86_64-1.txzsimilar with 'slackpkg download'. The difference is that slackpkg download allow to select more than one release if I use -dialog=on; that output a not clear output
Code:# slackpkg -dialog=off download kernel-generic-5.13
Looking for kernel-generic-5.13 in package list. Please wait... DONE
kernel-generic-5.12.14-x86_64-1.txz
kernel-generic-5.13.0-x86_64-1.txz
# slackpkg -dialog=off download pasture
Looking for pasture in package list. Please wait... DONE
apmd-3.2.2-x86_64-3.txz
php-5.6.40-x86_64-1.txz
php-7.4.21-x86_64-1.txzIf I look for pasture I want pasture only.
I made a simple patch to improve it
Code:--- core-functions.sh-15.0.5 2021-07-03 15:34:14.784596931 +0200
+++ core-functions.sh 2021-07-03 16:13:26.603413658 +0200
@@ -593,6 +593,7 @@
function givepriority {
local DIR
local ARGUMENT=$1
+ local FILTER="$2"
local PKGDATA
unset NAME
@@ -601,7 +602,7 @@
for DIR in ${PRIORITY[@]} ; do
[ "$PKGDATA" ] && break
- PKGDATA=( $(grep "^${DIR} ${ARGUMENT} " ${TMPDIR}/pkglist) )
+ PKGDATA=( $(grep "^${DIR} ${ARGUMENT} " ${TMPDIR}/pkglist |grep -w -- "$FILTER") )
if [ "$PKGDATA" ]; then
NAME=${PKGDATA[1]}
FULLNAME=$(echo "${PKGDATA[5]}.${PKGDATA[7]}")
@@ -693,7 +694,7 @@
download)
for ARGUMENT in $(echo $INPUTLIST); do
for i in $(grep -w -- "${ARGUMENT}" ${TMPDIR}/pkglist | cut -f2 -d\ | sort -u); do
- LIST="$LIST $(grep " ${i} " ${TMPDIR}/pkglist | cut -f6,8 -d\ --output-delimiter=.)"
+ LIST="$LIST $(grep " ${i} " ${TMPDIR}/pkglist|grep -w -- "${ARGUMENT}" | cut -f6,8 -d\ --output-delimiter=.)"
done
LIST="$(echo -e $LIST | sort -u)"
done
@@ -704,7 +705,7 @@
install|upgrade|reinstall)
for ARGUMENT in $(echo $INPUTLIST); do
for i in $(grep -w -- "${ARGUMENT}" ${TMPDIR}/pkglist | cut -f2 -d\ | sort -u); do
- givepriority $i
+ givepriority $i "${ARGUMENT}"
[ ! "$FULLNAME" ] && continue
case $CMD in
Code:# slackpkg -dialog=off upgrade pasture
Checking local integrity... DONE
Looking for pasture in package list. Please wait... DONE
php-5.6.40-x86_64-1.txz
# slackpkg -dialog=off download kernel-generic-5.13
Looking for kernel-generic-5.13 in package list. Please wait... DONE
kernel-generic-5.13.0-x86_64-1.txzThis patch also may help future slackpkg+ improvements, where duplicated packages are a normal thing.