LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-10-2016, 01:47 PM   #406
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,058

Rep: Reputation: Disabled

Well,maybe we could try ash[1].

But you are right, first let's see how many bash extensions slackpkg itself uses.

I'll check that running it with a command like:
bash --posix slackpkg ...
just out of curiosity.

PS This reminds me this old thread POSIX-compatible rc.init scripts for Slack (13.0+).

[1]dash is available from slackbuilds.org but not shipped in Slackware.

PS Slow typer, I didn't see your new answer before I press the [save] button.

But, I digress. Sorry.

Last edited by Didier Spaier; 01-10-2016 at 02:01 PM.
 
Old 01-10-2016, 01:54 PM   #407
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 983

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
slackpkg does not work with ash

# ash /usr/sbin/slackpkg
/etc/slackpkg/slackpkg.conf: 97: Syntax error: word unexpected (expecting ")")

row 97:
PRIORITY=( patches PKGMAIN extra pasture testing )

array declaration inline, another advanced bash structure.

slackpkg+ works fine with bash --posix
bashism works with --posix


edit:
slackware
Code:
# ash
$ echo $(echo hello)
hello
solaris:
Code:
$ /bin/sh
$ echo $(echo hello)
syntax error: `(' unexpected

Last edited by zerouno; 01-10-2016 at 01:57 PM.
 
Old 01-10-2016, 03:27 PM   #408
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Slackware implicitly expects that the root user has bash configured as the login shell.
 
Old 01-11-2016, 10:00 AM   #409
phenixia2003
Senior Member
 
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
Hello,

Quote:
Originally Posted by zerouno View Post
I want to try to replace some if echo ..|grep ... with the operator =~ since bash supports it to try to increase performance.

Code:
$ time [[ slackware =~ "^(slackware)|(slackware64)|(extra)|(pasture)|(patches)|(testing)$" ]]

real    0m0.000s
user    0m0.000s
sys     0m0.000s

$ time echo slackware | grep -qwE "(slackware)|(slackware64)|(extra)|(pasture)|(patches)|(testing)"

real    0m0.002s
user    0m0.000s                                                                                                                                        
sys     0m0.002s
what do you think?

there are many other optimization possible
Code:
$ xxx="repo:pkg"
$ time echo "$xxx" | cut -f1 -d":"
repo

real    0m0.002s
user    0m0.000s
sys     0m0.001s
$ time echo ${xxx/:*/}
repo

real    0m0.000s
user    0m0.000s
sys     0m0.000s
By curiosity, I tried that on givepriority() (which can be called, more or less, a bottleneck) and the resulting optimization is really noticeable.

1. upgrade-all before optimization
Code:
$ time slackpkg -dialog=off -batch=on -default_answer=no upgrade-all
Checking local integrity... DONE
Looking for packages to upgrade. Please wait... 
DONE


Total package(s): 280

Do you wish to upgrade selected packages (Y/n)? n

real    0m26.737s
user    0m18.182s
sys     0m3.424s
2. upgrade-all after optimization
Code:
time slackpkg -dialog=off -batch=on -default_answer=no upgrade-all

Checking local integrity... DONE
Looking for packages to upgrade. Please wait...
DONE

Total package(s): 280

Do you wish to upgrade selected packages (Y/n)? n


real    0m11.785s
user    0m10.787s
sys     0m2.593s
3. upgrade-all after optimization (and use grep 2>/dev/null -w "${PAT}")
Code:
$ time slackpkg -dialog=off -batch=on -default_answer=no upgrade-all

Checking local integrity... DONE
Looking for packages to upgrade. Please wait... 
DONE

Total package(s): 280

Do you wish to upgrade selected packages (Y/n)? n


real    0m9.225s
user    0m10.678s
sys     0m2.310s

Here is the changes done (slackpkg+ 1.6.1/7mt) :
Code:
--- slackpkgplus.sh.orig	2016-01-09 16:13:29.440109874 +0100
+++ slackpkgplus.sh	2016-01-11 16:56:55.278481507 +0100
@@ -8,7 +8,7 @@
 
   # regular expression used to distinguish the 3rd party repositories from the standard slackware directories.
   #
-SLACKDIR_REGEXP="(slackware)|(slackware64)|(extra)|(pasture)|(patches)|(testing)"
+SLACKDIR_REGEXP="^((slackware)|(slackware64)|(extra)|(pasture)|(patches)|(testing))$"
 
 if [ -e $CONF/slackpkgplus.conf ];then
   # You can override GREYLIST WGETOPTS SLACKPKGPLUS VERBOSE USEBL ALLOW32BIT SENSITIVE_SEARCH from command-line
@@ -363,6 +363,7 @@
     fi
   } # END checkmd5()
 
+
   # Found packages in repository.
   # This function selects the package from the higher priority
   # repository directories.
@@ -408,8 +409,10 @@
 					      )| grep -f - -n -m 1 ${TMPDIR}/pkglist
 		)
       if [ ! -z "$PKGINFOS" ] ; then
-	LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
-	PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
+	LINEIDX=${$PKGINFOS/:*/}
+	PKGDATA=( ${PKGINFOS/*:/} )
+	#LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
+	#PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
 	sed -i --expression "${LINEIDX}d" --expression "${PRIORITYIDX}i${PKGDATA[*]}" ${TMPDIR}/pkglist
 	(( PRIORITYIDX++ ))
 	if [ "$PKGDATA" ]; then
@@ -422,9 +425,15 @@
     for CPRIORITY in ${PRIORITY[@]} ; do
       [ "$PKGDATA" ] && break
 
-      DIR=$(echo "$CPRIORITY" | cut -f1 -d":")
-      PAT=$(echo "$CPRIORITY" | cut -s -f2- -d":")
-      REPOSITORY=$(echo "${DIR}" | sed "s/SLACKPKGPLUS_//")
+      #DIR=$(echo "$CPRIORITY" | cut -f1 -d":")
+      #PAT=$(echo "$CPRIORITY" | cut -s -f2- -d":")
+      #REPOSITORY=$(echo "${DIR}" | sed "s/SLACKPKGPLUS_//")
+
+      DIR=${CPRIORITY/:*/}
+      REPOSITORY=${DIR/SLACKPKGPLUS_/}
+      PAT=""
+      [[ "$CPRIORITY" =~ .*:.* ]] && PAT=${CPRIORITY/*:/}
+
 
 	# pass to the next iteration when there are priority filters and the
 	# current repository is not accepted by the defined filter rules ...
@@ -433,7 +442,9 @@
 	continue
       fi
 
-      if echo "$CPRIORITY " | grep -q "[a-zA-Z0-9]\+[:]" ; then
+      #if echo "$CPRIORITY " | grep -q "[a-zA-Z0-9]\+[:]" ; then
+
+      if [[ "$CPRIORITY" =~ ^[-_[:alnum:]]+[:] ]] ; then
 
 	  # [Reminder] ARGUMENT is always a basename, but PAT can be :
 	  #    1. a basename (ie. gcc, glibc-solibs)
@@ -442,12 +453,15 @@
 	  #
 	PKGDATA=""
 	LINEIDX=""
-        grep -n "^${DIR} " ${TMPDIR}/pkglist | grep -w "${PAT}" > ${TMPDIR}/packages.matches
-        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} ")
+        #grep -n "^${DIR} " ${TMPDIR}/pkglist | grep -w "${PAT}" > ${TMPDIR}/packages.matches
+        #PKGINFOS=$(grep -m 1 "^[[:digit:]]\+:${DIR} ${ARGUMENT} " ${TMPDIR}/packages.matches)
 
         if [ ! -z "$PKGINFOS" ] ; then
-	  LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
-	  PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
+	  LINEIDX=${PKGINFOS/:*/}
+	  PKGDATA=( ${PKGINFOS/*:/} )
+	  #LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
+	  #PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
         fi
       else
 	  # $CPRIORITY is of kind "repository" (ie. slackware, extra, patches,...)
Nota: I left the old code in comment to ease verifications.

--
SeB
Attached Files
File Type: txt slackpkg+-optimized-givepriority.diff.txt (3.2 KB, 8 views)
 
Old 01-11-2016, 12:26 PM   #410
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 983

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
My intent was to increase performance, not to triplicate it

1.7.a3
Code:
real    0m16.407s
user    0m4.569s
sys     0m7.959s
new (pushed on devel branch)
Code:
real    0m5.002s
user    0m2.650s
sys     0m1.664s
I tried, just for experiment, some other extreme bashism. But it increase performance only in very-ripetitive functions (as givepriority() ) where 0.01 seconds multiplicated for hundreds packages can make the difference.
For example,
basename $1 ==> ${1/*\//}
we have similar code near repository parsing or before a wget command, where 0.01 seconds are not a visible thing.



Yesterday I saw another issue on that patch, so I not included it in that commit. But I must to retry.
 
1 members found this post helpful.
Old 01-11-2016, 12:30 PM   #411
phenixia2003
Senior Member
 
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
Hello,

Quote:
Originally Posted by zerouno View Post
Yesterday I saw another issue on that patch, so I not included it in that commit. But I must to retry.
Can you give more info about that issue.

--
SeB
 
Old 01-11-2016, 12:33 PM   #412
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 983

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
Quote:
Originally Posted by phenixia2003 View Post
Can you give more info about that issue.
yes, but I must re-apply it before , becouse I don't remember very well.
 
Old 01-11-2016, 12:59 PM   #413
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 983

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
No, was not a patch problem... (that however needs to be bashished)


I run
slackpkg search rar
to find the rar package
and it return too many packages, so I thought was an issue.

Really is not a code problem.
grep --color rar /var/lib/pkglist
match all repository that contains a /library/ directory.


I think that
Code:
        grep ${GREPOPTS} "^${DIR}.*${SEARCHSTR}" "${TMPDIR}/pkglist" > $PKGINFOS
may be improved with
Code:
        grep ${GREPOPTS} "^${DIR}.*\(/${SEARCHSTR}[/ ]\)\|\( [^/ ]*${SEARCHSTR}[^/ ]* \)" "${TMPDIR}/pkglist" > $PKGINFOS
'rar' match packages containing the 'rar' pattern (for example unrar or a package called library) or a path including the directory 'rar', such as
./SLACKPKGPLUS_slackonly_141/system/rar
 
Old 01-11-2016, 01:11 PM   #414
phenixia2003
Senior Member
 
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
Hello,

I was checking if search could be optimized, and I found a bug.

The context: slackware64 with multilib, PKG_PRIORITY set as below :

Code:
$ grep ^PKGS_PRIORITY /etc/slackpkg/slackpkgplus.conf
PKGS_PRIORITY=( multilib alienbob32 restricted ktown )
With the current code, searching for gcc returns the following :

Code:
$ slackpkg search gcc

DONE

The list below shows all packages with name matching "gcc".

[ Status           ] [ Repository               ] [ Package                                  ]
  upgrade                                           gcc-4.8.2_multilib-x86_64-1alien --> gcc-4.8.2-x86_64-1  
  upgrade                                           gcc-g++-4.8.2_multilib-x86_64-1alien --> gcc-g++-4.8.2-x86_64-1  
  upgrade                                           gcc-gfortran-4.8.2_multilib-x86_64-1alien --> gcc-gfortran-4.8.2-x86_64-1  
  upgrade                                           gcc-gnat-4.8.2_multilib-x86_64-1alien --> gcc-gnat-4.8.2-x86_64-1  
  upgrade                                           gcc-go-4.8.2_multilib-x86_64-1alien --> gcc-go-4.8.2-x86_64-1  
  upgrade                                           gcc-java-4.8.2_multilib-x86_64-1alien --> gcc-java-4.8.2-x86_64-1  
  upgrade                                           gcc-objc-4.8.2_multilib-x86_64-1alien --> gcc-objc-4.8.2-x86_64-1  
   installed                                        gccmakedep-1.0.2-noarch-2                 
   installed           multilib                     gcc-4.8.2_multilib-x86_64-1alien          
   installed           multilib                     gcc-g++-4.8.2_multilib-x86_64-1alien      
   installed           multilib                     gcc-gfortran-4.8.2_multilib-x86_64-1alien  
   installed           multilib                     gcc-gnat-4.8.2_multilib-x86_64-1alien     
   installed           multilib                     gcc-go-4.8.2_multilib-x86_64-1alien       
   installed           multilib                     gcc-java-4.8.2_multilib-x86_64-1alien     
   installed           multilib                     gcc-objc-4.8.2_multilib-x86_64-1alien     

You can search specific files using "slackpkg file-search file".
the multilib repository has precedence over slackware64 (and patches) repositories. Therefore, the gcc upgrade proposals are inappropriates, and are caused by a bug in searchPackages :
Code:
    if echo "$DIR" | grep -q "[a-zA-Z0-9]\+[:]" ; then
          DIR=$(echo "$i" | cut -f2- -d":") # <= bug, the cut is bad, should be -f1 instead
      fi
The patch for 1.6.1/7mt :
Code:
--- slackpkgplus.sh.orig        2016-01-09 16:13:29.440109874 +0100
+++ slackpkgplus.sh     2016-01-11 20:18:40.471107912 +0100
@@ -528,7 +528,7 @@
     for i in ${PRIORITY[@]}; do
       DIR="$i"
       if echo "$DIR" | grep -q "[a-zA-Z0-9]\+[:]" ; then
-              DIR=$(echo "$i" | cut -f2- -d":")
+          DIR=$(echo "$i" | cut -f1 -d":")
       fi
 
       if [ "$CMD" == "file-search" ] ; then
With that, the search works as it should :
Code:
slackpkg search gcc


NOTICE: remember to re-run 'slackpkg update' after modifying slackpkgplus.conf

DONE

The list below shows all packages with name matching "gcc".

[ Status           ] [ Repository               ] [ Package                                  ]
   installed           multilib                     gcc-4.8.2_multilib-x86_64-1alien          
   installed           multilib                     gcc-g++-4.8.2_multilib-x86_64-1alien      
   installed           multilib                     gcc-gfortran-4.8.2_multilib-x86_64-1alien  
   installed           multilib                     gcc-gnat-4.8.2_multilib-x86_64-1alien     
   installed           multilib                     gcc-go-4.8.2_multilib-x86_64-1alien       
   installed           multilib                     gcc-java-4.8.2_multilib-x86_64-1alien     
   installed           multilib                     gcc-objc-4.8.2_multilib-x86_64-1alien     
   installed                                        gccmakedep-1.0.2-noarch-2                 

You can search specific files using "slackpkg file-search file".
--
SeB
 
Old 01-11-2016, 01:31 PM   #415
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 983

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
mmm, this should have a larger impact.

it is present from commit afddae5749e618bbb3b00e3c2122f60042e1f867 that is 0.9rc2 - 30/Apr/2013

I will fix in devel branch.

it just impacts the search command. Do you think that we should plan to backport it in 1.6.1 tree? (may be the first backport in slackpkg+ history and the begin of stabilizing it)
 
Old 01-11-2016, 01:46 PM   #416
phenixia2003
Senior Member
 
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
Hello,

Quote:
Originally Posted by zerouno View Post
mmm, this should have a larger impact.

it is present from commit afddae5749e618bbb3b00e3c2122f60042e1f867 that is 0.9rc2 - 30/Apr/2013

I will fix in devel branch.

it just impacts the search command. Do you think that we should plan to backport it in 1.6.1 tree? (may be the first backport in slackpkg+ history and the begin of stabilizing it)
Yes, it would be better.

I also did some modification to optimize searchPackage, and here is the results so far :

1. current code :
Code:
$ time slackpkg search slackware

DONE

The list below shows all packages with name matching "slackware".
...
You can search specific files using "slackpkg file-search file".

real    0m46.167s
user    0m31.300s
sys     0m5.233s
2. with optimization:
Code:
time slackpkg search slackware

DONE

The list below shows all packages with name matching "slackware".
...
You can search specific files using "slackpkg file-search file".

real    0m32.716s
user    0m24.116s
sys     0m4.578s
Note: the times includes the time required to print results.

--
SeB
 
1 members found this post helpful.
Old 01-11-2016, 02:27 PM   #417
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 983

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
Good.
But now I have to regroup all things and apply all pending patch, before I lost something, so to consolidate it.
 
Old 01-11-2016, 03:23 PM   #418
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 983

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
The bashism introduce some regression.

I'm in devel branch

bashism is in that commit:
Code:
commit 6553f7d8c4b3ff077814dd192862dee3897f3bb1
Author: Matteo Rossini <zerouno@slacky.it>
Date:   Mon Jan 11 18:44:06 2016 +0100

    Improved givepriority() performance by using bashism.

commit fac0996698cdab713b876c4d20a53307ccd14085
I'm running the same cases that we are testing before applying that patch.


so, before bashism:
Code:
# git checkout fac0996698cdab713b876c4d20a53307ccd14085
# slackpkg -dialog=off -batch=on -default_answer=no install alienbob_current:libiptcdata-1.0.4

Looking for libiptcdata-1.0.4 in package list. Please wait... DONE

[ Repository               ] [ Package                                  ]
  alienbob_current             libiptcdata-1.0.4-i486-2alien.tgz         

Total package(s): 1

Do you wish to install selected packages (Y/n)? n
after bashism:
Code:
# git checkout 6553f7d8c4b3ff077814dd192862dee3897f3bb1
# slackpkg -dialog=off -batch=on -default_answer=no install alienbob_current:libiptcdata-1.0.4

Looking for libiptcdata-1.0.4 in package list. Please wait... DONE

No packages match the pattern for install. Try:

        /usr/sbin/slackpkg reinstall|upgrade
the diff (you can see small differences from your patch, but should not impact):
Code:
# git diff fac0996698cdab713b876c4d20a53307ccd14085 6553f7d8c4b3ff077814dd192862dee3897f3bb1|cat
diff --git a/src/slackpkgplus.sh b/src/slackpkgplus.sh
index e1605d0..bff35e7 100755
--- a/src/slackpkgplus.sh
+++ b/src/slackpkgplus.sh
@@ -10,7 +10,7 @@ CONF=${CONF:-/etc/slackpkg} # needed if you're running slackpkg 2.28.0-12
 
   # regular expression used to distinguish the 3rd party repositories from the standard slackware directories.
   #
-SLACKDIR_REGEXP="(slackware)|(slackware64)|(extra)|(pasture)|(patches)|(testing)"
+SLACKDIR_REGEXP="^((slackware)|(slackware64)|(extra)|(pasture)|(patches)|(testing))$"
 
 if [ -e $CONF/slackpkgplus.conf ];then
   # You can override GREYLIST WGETOPTS SLACKPKGPLUS VERBOSE USEBL ALLOW32BIT SENSITIVE_SEARCH from command-line
@@ -755,8 +755,8 @@ if [ "$SLACKPKGPLUS" = "on" ];then
                                               )| grep -f - -n -m 1 ${TMPDIR}/pkglist
                 )
       if [ ! -z "$PKGINFOS" ] ; then
-        LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
-        PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
+        LINEIDX=${$PKGINFOS/:*/}      #LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
+        PKGDATA=( ${PKGINFOS/*:/} )   #PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
         sed -i --expression "${LINEIDX}d" --expression "${PRIORITYIDX}i${PKGDATA[*]}" ${TMPDIR}/pkglist
         (( PRIORITYIDX++ ))
         if [ "$PKGDATA" ]; then
@@ -769,9 +769,9 @@ if [ "$SLACKPKGPLUS" = "on" ];then
     for CPRIORITY in ${PRIORITY[@]} ; do
       [ "$PKGDATA" ] && break
 
-      DIR=$(echo "$CPRIORITY" | cut -f1 -d":")
-      PAT=$(echo "$CPRIORITY" | cut -s -f2- -d":")
-      REPOSITORY=$(echo "${DIR}" | sed "s/SLACKPKGPLUS_//")
+      DIR=${CPRIORITY/:*/}                                                #DIR=$(echo "$CPRIORITY" | cut -f1 -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
         # current repository is not accepted by the defined filter rules ...
@@ -780,7 +780,8 @@ if [ "$SLACKPKGPLUS" = "on" ];then
         continue
       fi
 
-      if echo "$CPRIORITY " | grep -q "[a-zA-Z0-9]\+[:]" ; then
+      #if echo "$CPRIORITY " | grep -q "[a-zA-Z0-9]\+[:]" ; then
+      if [[ "$CPRIORITY" =~ "^[-_[:alnum:]]+[:]" ]] ; then
 
           # [Reminder] ARGUMENT is always a basename, but PAT can be :
           #    1. a basename (ie. gcc, glibc-solibs)
@@ -789,12 +790,13 @@ if [ "$SLACKPKGPLUS" = "on" ];then
           #
         PKGDATA=""
         LINEIDX=""
-        grep -n "^${DIR} " ${TMPDIR}/pkglist | grep -w "${PAT}" > ${TMPDIR}/packages.matches
-        PKGINFOS=$(grep -m 1 "^[[:digit:]]\+:${DIR} ${ARGUMENT} " ${TMPDIR}/packages.matches)
+        #grep -n "^${DIR} " ${TMPDIR}/pkglist | grep -w "${PAT}" > ${TMPDIR}/packages.matches
+        #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=$(echo "$PKGINFOS" | cut -f1 -d":")
-          PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
+          LINEIDX=${PKGINFOS/:*/}       #LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
+          PKGDATA=( ${PKGINFOS/*:/} )   #PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
         fi
       else
           # $CPRIORITY is of kind "repository" (ie. slackware, extra, patches,...)

Code:
# grep libiptcdata /var/lib/slackpkg/pkglist
SLACKPKGPLUS_alienbob_current libiptcdata 1.0.4 i486 2alien libiptcdata-1.0.4-i486-2alien ./SLACKPKGPLUS_alienbob_current/libiptcdata tgz
SLACKPKGPLUS_alienbob_141 libiptcdata 1.0.4 i486 2alien libiptcdata-1.0.4-i486-2alien ./SLACKPKGPLUS_alienbob_141/libiptcdata tgz
SLACKPKGPLUS_slackonly_current libiptcdata 1.0.4 i586 2_slack libiptcdata-1.0.4-i586-2_slack ./SLACKPKGPLUS_slackonly_current/libraries/libiptcdata txz
SLACKPKGPLUS_slackonly_141 libiptcdata 1.0.4 i486 2_slack libiptcdata-1.0.4-i486-2_slack ./SLACKPKGPLUS_slackonly_141/libraries/libiptcdata txz
I not tested bashism on 1.6.1 version.
 
Old 01-12-2016, 03:09 AM   #419
phenixia2003
Senior Member
 
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
Hello,

Quote:
Originally Posted by zerouno View Post
The bashism introduce some regression.

I'm in devel branch

bashism is in that commit:
Code:
commit 6553f7d8c4b3ff077814dd192862dee3897f3bb1
Author: Matteo Rossini <zerouno@slacky.it>
Date:   Mon Jan 11 18:44:06 2016 +0100

    Improved givepriority() performance by using bashism.

commit fac0996698cdab713b876c4d20a53307ccd14085
I'm running the same cases that we are testing before applying that patch.


so, before bashism:
Code:
# git checkout fac0996698cdab713b876c4d20a53307ccd14085
# slackpkg -dialog=off -batch=on -default_answer=no install alienbob_current:libiptcdata-1.0.4

Looking for libiptcdata-1.0.4 in package list. Please wait... DONE

[ Repository               ] [ Package                                  ]
  alienbob_current             libiptcdata-1.0.4-i486-2alien.tgz         

Total package(s): 1

Do you wish to install selected packages (Y/n)? n
after bashism:
Code:
# git checkout 6553f7d8c4b3ff077814dd192862dee3897f3bb1
# slackpkg -dialog=off -batch=on -default_answer=no install alienbob_current:libiptcdata-1.0.4

Looking for libiptcdata-1.0.4 in package list. Please wait... DONE

No packages match the pattern for install. Try:

        /usr/sbin/slackpkg reinstall|upgrade
the diff (you can see small differences from your patch, but should not impact):
Code:
# git diff fac0996698cdab713b876c4d20a53307ccd14085 6553f7d8c4b3ff077814dd192862dee3897f3bb1|cat
diff --git a/src/slackpkgplus.sh b/src/slackpkgplus.sh
index e1605d0..bff35e7 100755
--- a/src/slackpkgplus.sh
+++ b/src/slackpkgplus.sh
@@ -10,7 +10,7 @@ CONF=${CONF:-/etc/slackpkg} # needed if you're running slackpkg 2.28.0-12
 
   # regular expression used to distinguish the 3rd party repositories from the standard slackware directories.
   #
-SLACKDIR_REGEXP="(slackware)|(slackware64)|(extra)|(pasture)|(patches)|(testing)"
+SLACKDIR_REGEXP="^((slackware)|(slackware64)|(extra)|(pasture)|(patches)|(testing))$"
 
 if [ -e $CONF/slackpkgplus.conf ];then
   # You can override GREYLIST WGETOPTS SLACKPKGPLUS VERBOSE USEBL ALLOW32BIT SENSITIVE_SEARCH from command-line
@@ -755,8 +755,8 @@ if [ "$SLACKPKGPLUS" = "on" ];then
                                               )| grep -f - -n -m 1 ${TMPDIR}/pkglist
                 )
       if [ ! -z "$PKGINFOS" ] ; then
-        LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
-        PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
+        LINEIDX=${$PKGINFOS/:*/}      #LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
+        PKGDATA=( ${PKGINFOS/*:/} )   #PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
         sed -i --expression "${LINEIDX}d" --expression "${PRIORITYIDX}i${PKGDATA[*]}" ${TMPDIR}/pkglist
         (( PRIORITYIDX++ ))
         if [ "$PKGDATA" ]; then
@@ -769,9 +769,9 @@ if [ "$SLACKPKGPLUS" = "on" ];then
     for CPRIORITY in ${PRIORITY[@]} ; do
       [ "$PKGDATA" ] && break
 
-      DIR=$(echo "$CPRIORITY" | cut -f1 -d":")
-      PAT=$(echo "$CPRIORITY" | cut -s -f2- -d":")
-      REPOSITORY=$(echo "${DIR}" | sed "s/SLACKPKGPLUS_//")
+      DIR=${CPRIORITY/:*/}                                                #DIR=$(echo "$CPRIORITY" | cut -f1 -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
         # current repository is not accepted by the defined filter rules ...
@@ -780,7 +780,8 @@ if [ "$SLACKPKGPLUS" = "on" ];then
         continue
       fi
 
-      if echo "$CPRIORITY " | grep -q "[a-zA-Z0-9]\+[:]" ; then
+      #if echo "$CPRIORITY " | grep -q "[a-zA-Z0-9]\+[:]" ; then
+      if [[ "$CPRIORITY" =~ "^[-_[:alnum:]]+[:]" ]] ; then
 
           # [Reminder] ARGUMENT is always a basename, but PAT can be :
           #    1. a basename (ie. gcc, glibc-solibs)
@@ -789,12 +790,13 @@ if [ "$SLACKPKGPLUS" = "on" ];then
           #
         PKGDATA=""
         LINEIDX=""
-        grep -n "^${DIR} " ${TMPDIR}/pkglist | grep -w "${PAT}" > ${TMPDIR}/packages.matches
-        PKGINFOS=$(grep -m 1 "^[[:digit:]]\+:${DIR} ${ARGUMENT} " ${TMPDIR}/packages.matches)
+        #grep -n "^${DIR} " ${TMPDIR}/pkglist | grep -w "${PAT}" > ${TMPDIR}/packages.matches
+        #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=$(echo "$PKGINFOS" | cut -f1 -d":")
-          PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
+          LINEIDX=${PKGINFOS/:*/}       #LINEIDX=$(echo "$PKGINFOS" | cut -f1 -d":")
+          PKGDATA=( ${PKGINFOS/*:/} )   #PKGDATA=( $(echo "$PKGINFOS" | cut -f2- -d":") )
         fi
       else
           # $CPRIORITY is of kind "repository" (ie. slackware, extra, patches,...)

Code:
# grep libiptcdata /var/lib/slackpkg/pkglist
SLACKPKGPLUS_alienbob_current libiptcdata 1.0.4 i486 2alien libiptcdata-1.0.4-i486-2alien ./SLACKPKGPLUS_alienbob_current/libiptcdata tgz
SLACKPKGPLUS_alienbob_141 libiptcdata 1.0.4 i486 2alien libiptcdata-1.0.4-i486-2alien ./SLACKPKGPLUS_alienbob_141/libiptcdata tgz
SLACKPKGPLUS_slackonly_current libiptcdata 1.0.4 i586 2_slack libiptcdata-1.0.4-i586-2_slack ./SLACKPKGPLUS_slackonly_current/libraries/libiptcdata txz
SLACKPKGPLUS_slackonly_141 libiptcdata 1.0.4 i486 2_slack libiptcdata-1.0.4-i486-2_slack ./SLACKPKGPLUS_slackonly_141/libraries/libiptcdata txz
I not tested bashism on 1.6.1 version.
In the patch to optimize givepriority (ie. in this post), there's the statement below :
Code:
+      if [[ "$CPRIORITY" =~ ^[-_[:alnum:]]+[:] ]] ; then
However, in the commit you pointed out, this statement is as below :
Code:
 if [[ "$CPRIORITY" =~ "^[-_[:alnum:]]+[:]" ]] ; then
Which is wrong. The regexp after =~ must not be placed in quotes since bash 3.2 :
Code:
f.  Quoting the string argument to the [[ command's  =~ operator now forces
    string matching, as with the other pattern-matching operators.
To verify this :

Code:
$ CPRIORITY="repository:pattern"

$ [[ "$CPRIORITY" =~ ^[-_[:alnum:]]+[:] ]] && echo "OK" || echo "KO"
OK

[[ "$CPRIORITY" =~ "^[-_[:alnum:]]+[:]" ]] && echo "OK" || echo "KO"
KO

$ CPRIORITY="^[-_[:alnum:]]+[:]"
$ [[ "$CPRIORITY" =~ "^[-_[:alnum:]]+[:]" ]] && echo "OK" || echo "KO"
OK
Note that in slackpkgplus.sh from git, there are two statements like that :
Code:
grep "=~" slackpkgplus.sh.git
773:       [[ "$CPRIORITY" =~ ".*:.*" ]] && PAT=${CPRIORITY/*:/} || PAT=""     #PAT=$(echo "$CPRIORITY" | cut -s -f2- -d":")
784:      if [[ "$CPRIORITY" =~ "^[-_[:alnum:]]+[:]" ]] ; then
When these statements are corrected, slackpkg install alienbob_current::libiptcdata-1.0.4 works as expected :

Code:
slackpkg -dialog=off -batch=on -default_answer=no install alienbob_current:libiptcdata-1.0.4

Looking for libiptcdata-1.0.4 in package list. Please wait... install -> 0 s ellapsed
DONE

[ Repository               ] [ Package                                  ]
  alienbob_current             libiptcdata-1.0.4-i486-2alien.tgz         

Total package(s): 1

Do you wish to install selected packages (Y/n)? n
Cheers.


--
SeB
 
Old 01-12-2016, 03:16 AM   #420
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 983

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
ok, english is not the best for me, so I not undestood well the "quoting" paragraph. I added it to clarify, without think that it may broke the working.
Thankyou.
Today I will have less time to work for slackpkg+
 
  


Reply

Tags
slackpkg



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Holding a package update from slackpkg gazj Slackware 2 01-25-2011 04:58 PM
Where can I find a 3rd Party Repository for RHEL 5? tightlikethat Linux - Newbie 3 02-27-2010 08:46 PM
Best 3rd Party RPM Repository for FC9 kromberg Fedora 11 11-13-2008 08:04 PM
Package Kit Error-- "Cannot retrieve repository metadata (repomd.xml) for repository" mbvpixies78 Linux - Newbie 11 08-22-2008 07:20 PM
3rd party package managers? crontab Slackware 3 10-06-2007 10:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration