LinuxQuestions.org
Help answer threads with 0 replies.
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-09-2022, 01:09 AM   #1
slackuser222
Member
 
Registered: Jan 2022
Posts: 64

Rep: Reputation: Disabled
How to identify if a dependency is already installed?


Hi everybody! I know it is a silly question, but someone could tell me if there is any simple way to identify if one dependency is already installed in my slackware system? I'm struggling to install Qgis, and it has more than 60 dependencies, according to Slackbuilds site... And I am pretty sure that at least some of then is already installed.

Another problem intrigues me... in some cases, when I try to install some pack, it gives me a error message related to the lack of some dependence. Then I install the dependence and try to install the pack again, and it returns me the same error, related to the lack of the same dependence... Why do it happen? just installing the dependence seems not be enough... I have noticed that in some cases, when it happens, the slackbuild script creates in /tmp a file with the name_of_the_pack.txz. Then I run installpkg over this .txz file, and this sometimes solves the issue, and sometimes doesn't... Is this correct?

I guess that in some cases is necessary to add some reference in the PATH variable, but I'm not sure with cases are those.

Thanks in advance.
 
Old 01-09-2022, 01:16 AM   #2
imitis
Member
 
Registered: Oct 2007
Location: Latvia, Liepaja
Distribution: Slackware
Posts: 92

Rep: Reputation: 29
for packages that have a lot deps I tend to use sbotools: https://pink-mist.github.io/sbotools/ it does checking and all.
 
2 members found this post helpful.
Old 01-09-2022, 01:32 AM   #3
slackuser222
Member
 
Registered: Jan 2022
Posts: 64

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by imitis View Post
for packages that have a lot deps I tend to use sbotools: https://pink-mist.github.io/sbotools/ it does checking and all.
Thank you! I'm trying right now another one, SBOpkg. Do you think it is somehow similar to the sbotools?
 
Old 01-09-2022, 02:31 AM   #4
bormant
Member
 
Registered: Jan 2008
Posts: 426

Rep: Reputation: 240Reputation: 240Reputation: 240
sbopkg -k ...
With -k sbopkg skips (i.e., doesn't process) any package it finds to be already installed.
 
2 members found this post helpful.
Old 01-09-2022, 05:04 AM   #5
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,979

Rep: Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556
If I am not sure, I use "slackpkg search" or "slackpkg file-search". I sometimes just run with the build and see what is missing. That can be a bit time consuming, but once you have all the dependencies established the next set of build is a bit easier.
 
Old 01-09-2022, 06:01 AM   #6
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,657
Blog Entries: 19

Rep: Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480
If the dependencies are linked libraries, you can find them easily by running ldd on the executable. You'll get a list of all the libraries it has linked to and the ones it couldn't find. Other kinds of dependencies are more tricky. If you're lucky, running the app from the terminal will yield an informative error message when something isn't found. If you're less lucky, you get a stupid message like "Something is missing".

Last edited by hazel; 01-09-2022 at 06:15 AM.
 
4 members found this post helpful.
Old 01-09-2022, 06:13 AM   #7
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,221

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
Quote:
Originally Posted by slackuser222 View Post
I'm struggling to install Qgis, and it has more than 60 dependencies, according to Slackbuilds site...
With sbotools:
Code:
sboinstall qgis
With sbopkg you need to first generate a queue file with sqg, check out the docs with `man sqg`.
 
Old 01-09-2022, 08:24 AM   #8
Gordie
Member
 
Registered: Aug 2007
Location: Nolalu, Ontario, Canada
Distribution: Slackware64-Current
Posts: 871

Rep: Reputation: 364Reputation: 364Reputation: 364Reputation: 364
I use sboui. It makes easier work for me of such complicated builds.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2022-01-09_09-16-45.png
Views:	67
Size:	76.5 KB
ID:	38038  
 
4 members found this post helpful.
Old 01-09-2022, 09:14 AM   #9
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Quote:
Originally Posted by slackuser222 View Post
Hi everybody! I know it is a silly question, but someone could tell me if there is any simple way to identify if one dependency is already installed in my slackware system? I'm struggling to install Qgis, and it has more than 60 dependencies, according to Slackbuilds site... And I am pretty sure that at least some of then is already installed.
slackuser222 --

That's not really a Silly Q at all. If fact, it's essential to understand how Slackware Packages are Tracked to answer your Q.

There are lots of ways to tell if a package is installed on your Slackware System using the different Package Management Tools.

However, you can actially 'see for yourself' using /bin/ls, because for each installed package, there is a plain text file in /var/lib/pkgtools/packages/

For example, to see if postgis is installed, you could simply type from the command line:
Code:
$ ls -la /var/lib/pkgtools/packages/*postgis*

-rw-r--r-- 1 root root 6766 Jan  4 07:51 /var/lib/pkgtools/packages/postgis-3.1.2-x86_64-1_SBo
See below my sig ... I created a wrapper called ver which simplifies looking for packages as with wild-card names ( at least for me )

Note1: Speaking of dependencies ... /home/local/bin/ver depends on 2regex ( /home/local/bin/2regex )... below my sig ...

Now that I have /home/local/bin/ver , I can simply type ver some_package to see if I have it like so:
Code:
$ ver postgis

-rw-r--r-- 1 root root 6766 Jan  4 07:51 /var/log/packages/postgis-3.1.2-x86_64-1_SBo
So to see what's actually provided by the postgis package, you could look at the contents of the Package Manifest Text File:
Code:
$ cat /var/lib/pkgtools/packages/postgis-3.1.2-x86_64-1_SBo

PACKAGE NAME:     postgis-3.1.2-x86_64-1_SBo
COMPRESSED PACKAGE SIZE:     4.1M
UNCOMPRESSED PACKAGE SIZE:     31M
PACKAGE LOCATION: /tmp/postgis-3.1.2-x86_64-1_SBo.tgz
PACKAGE DESCRIPTION:
postgis: postgis (support for geographic objects in PostgreSQL)
postgis:
postgis: PostGIS adds support for geographic objects to the PostgreSQL
postgis: database. In effect, PostGIS "spatially enables" the PostgreSQL
postgis: server, allowing it to be used as a backend spatial database for
postgis: geographic information systems (GIS), much like ESRI's SDE or
postgis: Oracle's Spatial extension.
postgis:
postgis: http://postgis.org
postgis:
postgis:
FILE LIST:
./
install/
install/doinst.sh
install/slack-desc
<<snip>>
Note2: I am old and set in my ways ... until Slackware Current ( 15.0 ), Installed Package Manifest Files used to be in /var/log/packages/ which with Slackware 15.0, is now ( ? will be ? ) a SymLink pointing at /var/lib/pkgtools/packages/ and I've never bothered to change ver

Quote:
Another problem intrigues me... in some cases, when I try to install some pack, it gives me a error message related to the lack of some dependence. Then I install the dependence and try to install the pack again, and it returns me the same error, related to the lack of the same dependence... Why do it happen? just installing the dependence seems not be enough... I have noticed that in some cases, when it happens, the slackbuild script creates in /tmp a file with the name_of_the_pack.txz. Then I run installpkg over this .txz file, and this sometimes solves the issue, and sometimes doesn't... Is this correct?
I am afraid so ... and the tools depending on postgis have a few circular dependencies which requires that some of the packages be built and installed more than once !

Quote:
I guess that in some cases is necessary to add some reference in the PATH variable, but I'm not sure with cases are those.
I don't believe the PATH Variable will affect the dependency tree -- everything should land where it belongs.

One suggestion: after installing a REQUIRED Package, type: ldconfig

Quote:
Thanks in advance.
You're welcome and Hope this Helps more than it hurts

-- kjh

This /home/local/bin/ver

Code:
#!/bin/sh

PkgOnly=0
RetCode=0
NumErr=0

if [ "$1" = "-p" -o "$1" = "-b" ]
then
   PkgOnly=1
   shift
fi

for i in $(echo $@ |sed -e 's/,/ /g' -e 's/ and / /g')
do

   j="`2regex $i`"

   if [ "$PkgOnly" = "0" ]
   then
      ls -la /var/log/packages/*${j}* 2>/dev/null  ; RetCode=$?
   else
      for k in $(ls -1 /var/log/packages/*${j}* 2>/dev/null)
      do
         basename $k
      done
   fi

   [ "$RetCode" != "0" ] && NumErr=`expr $NumErr + 1`
   
done

[ "$NumErr" = "0" ] && exit 0

exit 1
This is /home/local/bin/2regex

Save it in your PATH and chmod 755 /path/to/2regex

Code:
#!/bin/sh
#
# 2regex command turns alpha to case-insensitive for ls
#
# B60318 - kjh added -lrspt options and help-text
#
PrgNam="`basename $0`"
DirNam="`dirname  $0`"

if [ "$DirNam" = "." ]
then
   if [ -f "$PrgNam" ]
   then
      DirNam="`pwd`"
   else
      DirNam="`whichone $PrgNam`"
      DirNam="`dirname $DirNam`"
   fi
elif [ "$DirNam" = ".." ]
then
   DirNam="`pwd`"
   DirNam="`dirname $DirNam`"
elif [ "`dirname $DirNam`" = ".." ]
then
   FooNam="`basename $DirNam`"
   DirNam="`pwd -P`"
   DirNam="`dirname $DirNam`/$FooNam"
elif [ "$DirNam" = "" ]               # should not happen ...
then                                  # see: man 3 dirname
   DirNam="`whichone $PrgNam`"
   DirNam="`dirname $DirNam`"
fi

AllArg="$@"
CwdDir="`pwd -P`"

AnchorLeft=0
AnchorRite=0
FixSpaces=0
AddPrefix=0
AddSuffix=0

WacExt ()
{
   echo "$@" |
   gawk '
   {
      if (( L = length( $0 )) < 1 )
      {
         print ""
         exit 0
      }
      for ( i = L ; i > 0 ; i -- )
      {
         if (( substr( $0, i,   1 ) == "." ) \
         &&  ( substr( $0, i-1, 1 ) != "/" ))
         {
            print substr( $0, 1, i-1 )
            exit 0
         }
      }
      print $0
      exit 0
   }'
   return $?
}
GetExt ()
{
   GetExtCase=""

   while [ "$1" = "-l" \
        -o "$1" = "-L" \
        -o "$1" = "-u" \
        -o "$1" = "-U" ]
   do
      if [ "$1" = "-l" -o "$1" = "-L" ]
      then
         GetExtCase="l"
         shift
      elif [ "$1" = "-u" -o "$1" = "-U" ]
      then
         GetExtCase="u"
         shift
      fi
   done

   echo "$@" |
   gawk '
   BEGIN {

      Case = "'"$GetExtCase"'" ""

   }
   function FixCase( DoCase, InStr )
   {
      if ( DoCase == "l" )
      {
         return( tolower( InStr ))
      }
      if ( DoCase == "u" )
      {
         return( toupper( InStr ))
      }
      return( InStr )
   }
   # main
   {
      if (( L = length( $0 )) < 1 )
      {
         print ""
         exit 0
      }
      for ( i = L ; i > 0 ; i -- )
      {
         if (( substr( $0, i,   1 ) == "." ) \
         &&  ( substr( $0, i-1, 1 ) != "/" ))
         {
            print FixCase( Case, substr( $0, i ))
            exit 0
         }
      }
      print ""
      exit 0
   }'
   return $?
}
Usage ()
{
   ErrNum=$1
   shift

   [ $# -gt 0 ] && echo -e "\n$*" >&2

   echo -e "\nusage:  $PrgNam [ -lrbps ] string" >&2
   cat  <<Usage_EOF >&2

Program $PrgNam converts a String to a Regular Expression suitable for ls
awk, grep or find.  Includes options to anchor the string left and right
and it can also convert each space to 'one-or-more-spaces'.
 
Options Include:

   -l - anchor left-side to Start of Line / Field

        example:  $PrgNam -l foo       -> '`$DirNam/$PrgNam -l foo`'

   -r - anchor right-side to End of Line / Field

        example:  $PrgNam -r bar       -> '`$DirNam/$PrgNam -r bar`'

   -b - translate each run of one-or-more spaces to '  *'

        example:  $PrgNam -b 'foo bar' -> '`$DirNam/$PrgNam -b 'foo bar'`'

   -p - Prefix string with a leading space REx

        example:  $PrgNam -p foo       -> '`$DirNam/$PrgNam -p baz`'

   -s - Append a space REx Suffix to string

        example:  $PrgNam -s bar       -> '`$DirNam/$PrgNam -s baz`'


Usage_EOF
 
   exit $ErrNum

}
while  getopts hspbrl junk 2>/dev/null
do
   case $junk in
      l)    AnchorLeft=1
            ;;
      r)    AnchorRite=1
            ;;
      b)    FixSpaces=1
            ;;
      p)    AddPrefix=1
            ;;
      s)    AddSuffix=1
            ;;
      h)    Usage 0
            ;;
      *)    Usage 1
            ;;
   esac
done

shift `expr $OPTIND - 1`

echo "$@" |
gawk '
BEGIN {

   AnchorLeft = "'"$AnchorLeft"'" +0
   AnchorRite = "'"$AnchorRite"'" +0
   FixSpaces  = "'"$FixSpaces"'"  +0
   AddPrefix  = "'"$AddPrefix"'"  +0
   AddSuffix  = "'"$AddSuffix"'"  +0
   # 
   # portable ... runs on nawk or gawk
   #
   Lower = "abcdefghijklmnopqrstuvwxyz"
   Upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

   for ( i = 1 ; i <= length( Lower ) ; i ++ )
   {
      L = substr( Lower, i, 1 )
      U = substr( Upper, i, 1 )

      LoAry[L] = i
      UpAry[U] = i
      REAry[i] = "[" U L "]"
   }
   c = p = ""
}
# main
{
   OutStr = ( AnchorLeft == 1 ) ? "^" : ""

   if ( AddPrefix == 1 )
   {
      OutStr = OutStr " *"
      p = " "
   }
   for ( i = 1 ; i <= length( $0 ) ; i ++ )
   {
      if (( c = substr( $0, i, 1 )) in LoAry )
      {
         OutStr = OutStr REAry[ LoAry[c] ] 
         p = c
         continue
      }
      if ( c in UpAry )
      {
         OutStr = OutStr REAry[ UpAry[c] ] 
         p = c
         continue
      }
      if (( FixSpaces == 1 ) && ( c == " " ))
      {
         if ( p == " " )
         {
            continue
         }
         OutStr = OutStr "  *"
         p = c
         continue
      }
      OutStr = OutStr c
      p = c
   }
   if (( AddSuffix == 1 ) && ( p != " " ))
   {
      OutStr = OutStr " *"
   }
   if ( AnchorRite == 1 )
   {
      OutStr = OutStr "$"
   }
   print OutStr
}'
 
5 members found this post helpful.
Old 01-09-2022, 11:46 AM   #10
slackuser222
Member
 
Registered: Jan 2022
Posts: 64

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by kjhambrick View Post
slackuser222 --

That's not really a Silly Q at all. If fact, it's essential to understand how Slackware Packages are Tracked to answer your Q.

There are lots of ways to tell if a package is installed on your Slackware System using the different Package Management Tools.

However, you can actially 'see for yourself' using /bin/ls, because for each installed package, there is a plain text file in /var/lib/pkgtools/packages/

For example, to see if postgis is installed, you could simply type from the command line:
Code:
$ ls -la /var/lib/pkgtools/packages/*postgis*

-rw-r--r-- 1 root root 6766 Jan  4 07:51 /var/lib/pkgtools/packages/postgis-3.1.2-x86_64-1_SBo
See below my sig ... I created a wrapper called ver which simplifies looking for packages as with wild-card names ( at least for me )

Note1: Speaking of dependencies ... /home/local/bin/ver depends on 2regex ( /home/local/bin/2regex )... below my sig ...

Now that I have /home/local/bin/ver , I can simply type ver some_package to see if I have it like so:
Code:
$ ver postgis

-rw-r--r-- 1 root root 6766 Jan  4 07:51 /var/log/packages/postgis-3.1.2-x86_64-1_SBo
So to see what's actually provided by the postgis package, you could look at the contents of the Package Manifest Text File:
Code:
$ cat /var/lib/pkgtools/packages/postgis-3.1.2-x86_64-1_SBo

PACKAGE NAME:     postgis-3.1.2-x86_64-1_SBo
COMPRESSED PACKAGE SIZE:     4.1M
UNCOMPRESSED PACKAGE SIZE:     31M
PACKAGE LOCATION: /tmp/postgis-3.1.2-x86_64-1_SBo.tgz
PACKAGE DESCRIPTION:
postgis: postgis (support for geographic objects in PostgreSQL)
postgis:
postgis: PostGIS adds support for geographic objects to the PostgreSQL
postgis: database. In effect, PostGIS "spatially enables" the PostgreSQL
postgis: server, allowing it to be used as a backend spatial database for
postgis: geographic information systems (GIS), much like ESRI's SDE or
postgis: Oracle's Spatial extension.
postgis:
postgis: http://postgis.org
postgis:
postgis:
FILE LIST:
./
install/
install/doinst.sh
install/slack-desc
<<snip>>
Note2: I am old and set in my ways ... until Slackware Current ( 15.0 ), Installed Package Manifest Files used to be in /var/log/packages/ which with Slackware 15.0, is now ( ? will be ? ) a SymLink pointing at /var/lib/pkgtools/packages/ and I've never bothered to change ver



I am afraid so ... and the tools depending on postgis have a few circular dependencies which requires that some of the packages be built and installed more than once !



I don't believe the PATH Variable will affect the dependency tree -- everything should land where it belongs.

One suggestion: after installing a REQUIRED Package, type: ldconfig



You're welcome and Hope this Helps more than it hurts

-- kjh

This /home/local/bin/ver

Code:
#!/bin/sh

PkgOnly=0
RetCode=0
NumErr=0

if [ "$1" = "-p" -o "$1" = "-b" ]
then
   PkgOnly=1
   shift
fi

for i in $(echo $@ |sed -e 's/,/ /g' -e 's/ and / /g')
do

   j="`2regex $i`"

   if [ "$PkgOnly" = "0" ]
   then
      ls -la /var/log/packages/*${j}* 2>/dev/null  ; RetCode=$?
   else
      for k in $(ls -1 /var/log/packages/*${j}* 2>/dev/null)
      do
         basename $k
      done
   fi

   [ "$RetCode" != "0" ] && NumErr=`expr $NumErr + 1`
   
done

[ "$NumErr" = "0" ] && exit 0

exit 1
This is /home/local/bin/2regex

Save it in your PATH and chmod 755 /path/to/2regex

Code:
#!/bin/sh
#
# 2regex command turns alpha to case-insensitive for ls
#
# B60318 - kjh added -lrspt options and help-text
#
PrgNam="`basename $0`"
DirNam="`dirname  $0`"

if [ "$DirNam" = "." ]
then
   if [ -f "$PrgNam" ]
   then
      DirNam="`pwd`"
   else
      DirNam="`whichone $PrgNam`"
      DirNam="`dirname $DirNam`"
   fi
elif [ "$DirNam" = ".." ]
then
   DirNam="`pwd`"
   DirNam="`dirname $DirNam`"
elif [ "`dirname $DirNam`" = ".." ]
then
   FooNam="`basename $DirNam`"
   DirNam="`pwd -P`"
   DirNam="`dirname $DirNam`/$FooNam"
elif [ "$DirNam" = "" ]               # should not happen ...
then                                  # see: man 3 dirname
   DirNam="`whichone $PrgNam`"
   DirNam="`dirname $DirNam`"
fi

AllArg="$@"
CwdDir="`pwd -P`"

AnchorLeft=0
AnchorRite=0
FixSpaces=0
AddPrefix=0
AddSuffix=0

WacExt ()
{
   echo "$@" |
   gawk '
   {
      if (( L = length( $0 )) < 1 )
      {
         print ""
         exit 0
      }
      for ( i = L ; i > 0 ; i -- )
      {
         if (( substr( $0, i,   1 ) == "." ) \
         &&  ( substr( $0, i-1, 1 ) != "/" ))
         {
            print substr( $0, 1, i-1 )
            exit 0
         }
      }
      print $0
      exit 0
   }'
   return $?
}
GetExt ()
{
   GetExtCase=""

   while [ "$1" = "-l" \
        -o "$1" = "-L" \
        -o "$1" = "-u" \
        -o "$1" = "-U" ]
   do
      if [ "$1" = "-l" -o "$1" = "-L" ]
      then
         GetExtCase="l"
         shift
      elif [ "$1" = "-u" -o "$1" = "-U" ]
      then
         GetExtCase="u"
         shift
      fi
   done

   echo "$@" |
   gawk '
   BEGIN {

      Case = "'"$GetExtCase"'" ""

   }
   function FixCase( DoCase, InStr )
   {
      if ( DoCase == "l" )
      {
         return( tolower( InStr ))
      }
      if ( DoCase == "u" )
      {
         return( toupper( InStr ))
      }
      return( InStr )
   }
   # main
   {
      if (( L = length( $0 )) < 1 )
      {
         print ""
         exit 0
      }
      for ( i = L ; i > 0 ; i -- )
      {
         if (( substr( $0, i,   1 ) == "." ) \
         &&  ( substr( $0, i-1, 1 ) != "/" ))
         {
            print FixCase( Case, substr( $0, i ))
            exit 0
         }
      }
      print ""
      exit 0
   }'
   return $?
}
Usage ()
{
   ErrNum=$1
   shift

   [ $# -gt 0 ] && echo -e "\n$*" >&2

   echo -e "\nusage:  $PrgNam [ -lrbps ] string" >&2
   cat  <<Usage_EOF >&2

Program $PrgNam converts a String to a Regular Expression suitable for ls
awk, grep or find.  Includes options to anchor the string left and right
and it can also convert each space to 'one-or-more-spaces'.
 
Options Include:

   -l - anchor left-side to Start of Line / Field

        example:  $PrgNam -l foo       -> '`$DirNam/$PrgNam -l foo`'

   -r - anchor right-side to End of Line / Field

        example:  $PrgNam -r bar       -> '`$DirNam/$PrgNam -r bar`'

   -b - translate each run of one-or-more spaces to '  *'

        example:  $PrgNam -b 'foo bar' -> '`$DirNam/$PrgNam -b 'foo bar'`'

   -p - Prefix string with a leading space REx

        example:  $PrgNam -p foo       -> '`$DirNam/$PrgNam -p baz`'

   -s - Append a space REx Suffix to string

        example:  $PrgNam -s bar       -> '`$DirNam/$PrgNam -s baz`'


Usage_EOF
 
   exit $ErrNum

}
while  getopts hspbrl junk 2>/dev/null
do
   case $junk in
      l)    AnchorLeft=1
            ;;
      r)    AnchorRite=1
            ;;
      b)    FixSpaces=1
            ;;
      p)    AddPrefix=1
            ;;
      s)    AddSuffix=1
            ;;
      h)    Usage 0
            ;;
      *)    Usage 1
            ;;
   esac
done

shift `expr $OPTIND - 1`

echo "$@" |
gawk '
BEGIN {

   AnchorLeft = "'"$AnchorLeft"'" +0
   AnchorRite = "'"$AnchorRite"'" +0
   FixSpaces  = "'"$FixSpaces"'"  +0
   AddPrefix  = "'"$AddPrefix"'"  +0
   AddSuffix  = "'"$AddSuffix"'"  +0
   # 
   # portable ... runs on nawk or gawk
   #
   Lower = "abcdefghijklmnopqrstuvwxyz"
   Upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

   for ( i = 1 ; i <= length( Lower ) ; i ++ )
   {
      L = substr( Lower, i, 1 )
      U = substr( Upper, i, 1 )

      LoAry[L] = i
      UpAry[U] = i
      REAry[i] = "[" U L "]"
   }
   c = p = ""
}
# main
{
   OutStr = ( AnchorLeft == 1 ) ? "^" : ""

   if ( AddPrefix == 1 )
   {
      OutStr = OutStr " *"
      p = " "
   }
   for ( i = 1 ; i <= length( $0 ) ; i ++ )
   {
      if (( c = substr( $0, i, 1 )) in LoAry )
      {
         OutStr = OutStr REAry[ LoAry[c] ] 
         p = c
         continue
      }
      if ( c in UpAry )
      {
         OutStr = OutStr REAry[ UpAry[c] ] 
         p = c
         continue
      }
      if (( FixSpaces == 1 ) && ( c == " " ))
      {
         if ( p == " " )
         {
            continue
         }
         OutStr = OutStr "  *"
         p = c
         continue
      }
      OutStr = OutStr c
      p = c
   }
   if (( AddSuffix == 1 ) && ( p != " " ))
   {
      OutStr = OutStr " *"
   }
   if ( AnchorRite == 1 )
   {
      OutStr = OutStr "$"
   }
   print OutStr
}'
I have no words to thank you for your answer, it was of an amazing help. The slackware community is the best one! Thank you very much!
 
2 members found this post helpful.
Old 01-09-2022, 12:45 PM   #11
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,221

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
@slackuser222, here's another way to search through your installed packages (multiple search terms with AND logic):
Code:
#!/bin/bash

## Search for installed Slackware packages

# set package dir
if [[ -d /var/lib/pkgtools/packages ]]; then
    # new Slackware package dir (15.0+)
    readonly lib=/var/lib/pkgtools/packages
else
    # old Slackware package dir
    readonly lib=/var/log/packages
fi

if [[ "$#" -eq 0 ]]; then
    # no search terms
    echo "Installed packages: $(find $lib -type f -maxdepth 1 -printf "%f\n" | wc -l)"
    exit 1
else
    # strip extra whitespace from arguments (xargs) and put into an array
    IFS=" " read -r -a array <<< "$(echo "$@" | xargs)"
    # prepend/append a backslash to each array element (for awk)
    array=( "${array[@]/#//}" )
    array=( "${array[@]/%//}" )
    # all terms to string
    search=${array[*]}
    # put ' && ' between each search term (for awk)
    search=$(echo "${search// / && }")
    # search (check case first)
    if [[ "$search" =~ [[:upper:]] ]]; then
	# case sensitive
	find "$lib" -type f -maxdepth 1 -printf "%f\n" | awk "$search"
    else
	# case insensitive
	find "$lib" -type f -maxdepth 1 -printf "%f\n" | awk "BEGIN{IGNORECASE=1} $search"
    fi
fi
 
4 members found this post helpful.
Old 01-09-2022, 01:51 PM   #12
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
drgibbon --

Thanks for the script !

I need to play with it !!

-- kjh
 
  


Reply



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
LXer: Identify PCI and USB Wired and Wireless Driver in Linux – Identify PCI Driver. Ubuntu, Debian, LXer Syndicated Linux News 0 08-20-2014 07:21 AM
Installing Squid on a cPanel Server - URI::URL Dependency Already Installed rustyz82 Linux - Server 1 01-14-2010 02:12 PM
How to check if i have a dependency already installed? With no.Mute Slackware 9 12-02-2009 07:25 AM
How to read "identify" button press event, or state of "identify" blue led with IPMI? iav Linux - Server 0 01-27-2009 01:13 PM
Required dependency already installed agtlewis Linux - General 6 10-06-2005 04:48 PM

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

All times are GMT -5. The time now is 03:31 AM.

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