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 05-16-2008, 09:19 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Listing Non Stock Slackware Packages


I seem to recall reading this somewhere. I want to create a list of all non stock Slackware packages I have compiled and installed.

I don't use slackpkg or anything like that. I'm guessing these tools do what I am asking, but I prefer to stay away from those tools. I'm just looking for a simple script or two.

Thanks to anybody who can point me to some links for some simple scripts, if they exist.
 
Old 05-16-2008, 10:08 PM   #2
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
slackpkg will do what you want, but I understand not wanting to install it just for that (I don't use slackpkg either). I don't know of any existing scripts, but I was interested enough to write a simple script myself. You should be aware that my scripting skills suck (and the form definitely isn't perfect), but it seems to work for me. If anyone notices glaring errors, feel free to correct them. I browsed the output of the script on my box and it looked like everything was there, and nothing was extra -- but again, my scripting skills suck.

[EDIT]Note that version 2 of my script is in post number 7, and I think it's a big improvement. If you want simplicity in design, choose this (V1) of the script. If you want simplicity in use (it now has command-line parameters), and better filtering (it now includes extra/ in addition to patches/), choose V2 of the script. This one's fine, it's just not as feature-complete. Do what you want though. [/EDIT]

[EDIT2]OK, version 3 (probably the last version) is in post number 9. It fixes a parsing dilemma from version 2 when trying to list all official Slackware packages that are NOT installed, EXCLUDING any upgrades by the packages in the patches/ directory. I would recommend either using version 1 or version 3 -- version 2 can safely be left by the wayside. Version 1 is still a nice SIMPLE script that does what it was designed to do and nothing more -- it detects non-Slackware packages on your system (but it doesn't distinguish extra/ packages from actual non-Slackware packages). Version 3 does a little more, as you can see by reading post number 9.[/EDIT2]
Code:
#!/bin/sh

# Get the Slackware 12.0 file list
wget http://slackware.osuosl.org/slackware-12.0/FILELIST.TXT

# Parse the file list, isolating only the .tgz packages (and in this case
# only the core slackware packages, excluding extra/, pasture/, testing/ etc.
# The filenames are also isolated and parsed.
for i in $(cat FILELIST.TXT | grep .tgz$ | grep \/slackware\/ | \
awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \
sort > slackpackages.txt

# Make a list of the installed packages and sort them just as the above
# file
ls -A /var/log/packages/ | sort > mypackages.txt

# Show only the packages ADDED by you, INCLUDING the official Slackware
# patches
diff -U 0 slackpackages.txt mypackages.txt | grep -v \@\@$ | grep ^\+ | \
grep -v \+\+\+ | sed 's/^+//g' | sort > differences.txt

# Get the patches file list
wget http://slackware.osuosl.org/slackware-12.0/patches/FILE_LIST

# Parse the file list, isolating only the .tgz packages (and in this case
# only the packages, excluding the source
# The filenames are also isolated and parsed.
for i in $(cat FILE_LIST | grep .tgz$ | grep \/packages\/ | \
awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \
sort > slackpatches.txt

# Show only
diff -U 0 slackpatches.txt differences.txt | grep -v \@\@$ | grep ^\+ | \
grep -v \+\+\+ | sed 's/^+//g' | sort > finaldifferences.txt
Note that this little script is for Slackware 12.0, but to update it for 12.1 you just need to update the location of FILELIST.TXT and FILE_LIST (just change 12.0 to 12.1 in the URLs). Make a new directory for the script, make a new file (like newpackages.sh) in that directory, paste the above, make the script executable, and run it. It'll output several text files -- differences.txt contains all of the new files added by you, including official patches. finaldifferences.txt (creative naming, I know) contains ONLY the files added by you, EXCLUDING the patches (that's the file you want to look at). Note that I didn't take /extra into account (it would be very easy to add, but I figure most people don't install everything in there anyway and would probably recognize anything they did install there. But feel free to add it in if you want.)

Last edited by T3slider; 05-18-2008 at 12:50 AM.
 
Old 05-17-2008, 10:17 AM   #3
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
Do you build your own, or install pkgs built by others?
 
Old 05-17-2008, 10:53 AM   #4
Speek
Member
 
Registered: Sep 2003
Location: The Netherlands
Distribution: Slackware
Posts: 124

Rep: Reputation: 41
Code:
cd /var/log/packages
ls *[aA-zZ]
 
Old 05-17-2008, 11:53 AM   #5
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
Quote:
cd /var/log/packages
ls *[aA-zZ]
So this catches all the packages ending with alphabetic characters as in *_SBo, *lsl etc ? Clever...

Shame I chose package_name-version-arch-revision as my naming scheme for my home built packages where revision==numeric. Bummer !!

Should have researched this more before deciding on a naming scheme...

Nice simple little regex though. Thanks..
 
Old 05-17-2008, 01:22 PM   #6
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
T3slider, I used your basic script, revised to my taste, and the script works great. Tip of the hat to you!

I maintain the recent version and current trees on my hard drive, therefore I did not need to use wget. I added the following to the script:

VERSION="`cat /etc/slackware-version | awk '{print $2}' | sed -e 's/.0//'`"

I then added a quick error check:

ROOTPATH="/home/public/slackware/$VERSION"
if [ ! -e "$ROOTPATH" ]; then
echo "The directory $ROOTPATH does not exist. Exiting."
exit 1
fi


I converted all the various txt file names to variables.

From long ago I obtained three pkg information scripts from here at LQ. To help me remember the name of this new script and maintain consistency with the names of those excellent scripts, I named this new script diffpkg.

I then added the following at the beginning of the script:
# original script written by T3slider at
# https://www.linuxquestions.org/quest...ckages-642787/


Good job!

Quote:
slackpkg will do what you want, but I understand not wanting to install it just for that (I don't use slackpkg either).
My slightly modified version of Eric's rsync scripts satisfy my needs for packages. The scripts maintain my patches and current tree, and I manually decide what and when to update. Package management tools are a great idea, but I never have been fond of blind updating. I like the ability to revert to a previous version of a package if a new version hiccups. (I modified Eric's patches rsync script to not delete previous packages.) I have needed to revert a handful of times. I recall samba being one of those times (last summer I think).

Quote:
Do you build your own, or install pkgs built by others?
Both. In the beginning I only downloaded packages. Gradually I grew uneasy with the fact that many people do not include their build scripts with their packages. Seems I should have been able to study their scripts and later build my own packages. Similar to the vendor lock-in problem with proprietary software. And not including the build script provides fodder for speculation and possible distrust.

These days I search fervently for a build script and roll my own package. I am in the process of gradually replacing downloaded packages with my own. Hence, this thread, which I now hopes helps others too.

Quote:
cd /var/log/packages
ls *[aA-zZ]
Now that is a slick approach --- except that I don't attach any suffixes to the packages I build. Otherwise very clever!

Thanks again everybody!
 
1 members found this post helpful.
Old 05-17-2008, 05:49 PM   #7
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Looks like my commenting was messed up (or I got lazy and forgot to add the comment for the last `diff` command -- also, the commenting for parsing the FILE_LIST file is messy and incomplete). I've decided to update my script (it's now more complex but easier to use. In addition, it no longer requires downloading the FILE_LIST file since the FILELIST.TXT file also includes the patches directory).
Quote:
Originally Posted by Speek
cd /var/log/packages
ls *[aA-zZ]
That is absolute genius. It almost always works with standard packaging techniques. I'm impressed. Unfortunately there are a few (and I stress the word FEW -- 2, actually, so a couple I guess) packages on my system that don't conform to that standard, so it's not 100% -- but if I were more stringent in the first place it would have been a great idea.

Woodsman, good to hear it works. Using variables etc. is a way better idea (and I know how to use variables too, I was just lazy). It's probably also a good idea to set the filename variables to an absolute location (so you won't get messy files all over the place if you run the script from a different folder). My new script takes care of this as long as you set the FILEDIR variable properly.
Quote:
Originally Posted by Woodsman
From long ago I obtained three pkg information scripts from here at LQ.
And to think I've been manually `ls`ing or `grep`ing /var/log/packages all this time.
Quote:
Originally Posted by Woodsman
I then added the following at the beginning of the script:
# original script written by T3slider at
# https://www.linuxquestions.org/quest...ckages-642787/
So kind.

Here is my version 2.0 of the script. It now contains variables for just about everything you would want to change (and a few of them, like ROOTPATH and FILEDIR, can be passed on the command-line. This is important -- if FILEDIR and ROOTPATH are not set to an absolute location, files will be downloaded and/or created in your current directory. You can override this by either adding absolute locations to ROOTHPATH and FILEDIR [which point to the same place by default] or by specifying a directory on the command-line when you execute the script). In addition, I've added parameters that allow nice, easy output to the screen. The parameters are shown if you run the script with the --help option, but basically you can see what patches you have installed, what patches you do NOT have installed/are out of date, the packages in extra/ you have/don't have installed, the core slackware packages you have/don't have installed*, and the non-Slackware packages you have installed.

*Make sure to read the help for this -- an interesting parsing problem is preventing me from excluding patched packages from the not-installed-Slackware-packages list without too much effort. That is a design-flaw in my script, so as of right now you'd have to compare your -sN output with your -p output to see which not-installed Slackware packages are ACTUALLY not installed instead of just upgraded.

If no one uses/wants this script, it's really OK -- this is helpful for keeping track of my system (and the script should work for much time to come). Without further ado, here it is.
Code:
#!/bin/sh

# This script was created by T3slider at linuxquestions.org. The WTFPL
# license basically applies -- do whatever you want with it.

# The version of Slackware being used. Note that I parse the output of
# /etc/slackware-version. To specify a version manually, comment 
# the following line and uncomment the next line. The parsing line was
# lovingly stolen from Woodsman on LQ (and subsequently modified). :)
# The modification was used to ensure that only the LAST .0 is removed.

VERSION=`cat /etc/slackware-version | awk '{print $2}' | sed 's/.0$//'`
# VERSION=${VERSION:-12.0}

# The idea for a root path was also lovingly (and shamelessly) stolen from
# Woodsman at LQ. If you use a local sync of -current or another branch,
# you can use the existing FILELIST.TXT instead of downloading a new one.
# This may be necessary if you are syncing with -current and you are not 
# fully up to date, and the FILELIST.TXT file is different than the one
# on your system (ie your installed packages are different than the ones
# contained in the new FILELIST.TXT file). Note that
# $ROOTHPATH/FILELIST.TXT should exist. You should comment out the `wget`
# line below if you are using a ROOTPATH, or else your FILELIST.TXT will
# be overwritten!

ROOTPATH=${ROOTPATH:-`pwd`}

# The directory to store the files that will be generated

FILEDIR=${FILEDIR:-`pwd`}

# The filenames for each file created.
# SLACKPKGS is the parsed FILELIST.TXT containing ONLY slackware/
# SLACKPTCHS is the parsed FILELIST.TXT containing patches/
# SLACKEXTRA is the parsed FILELIST.TXT containing extra/
# MYPKGS is the list of packages installed on YOUR system
# DIFFPKGSEP is the list of packages installed on your system that are NOT 
# 	in the slackware/ directory
# DIFFPKGSE is the list of packages installed on your system that are NOT
#       in the slackware/ directory OR the patches/ directory
# DIFFPKGS is the list of packages installed on your system that are NOT 
#	in the slackware/, extra/ or patches/ directory. You have 
# 	obviously installed these yourself.

SLACKPKGS=slackpkgs.txt
SLACKPTCHS=slackptchs.txt
SLACKEXTRA=slackextra.txt
MYPKGS=mypkgs.txt
DIFFPKGSEP=diffpkgsEP.txt
DIFFPKGSE=diffpkgsE.txt
DIFFPKGS=diffpkgs.txt

if [ ! -z $1 ]; then
  case $1 in
  --help)
    echo "Usage: $0 [options]"
    echo ""
    echo "This script will identify any non-Slackware packages you have"
    echo "installed on your system, as well as any official Slackware"
    echo "packages installed from extra/ and patches/. The script must"
    echo "be run WITHOUT parameters before it can be run WITH parameters."
    echo ""
    echo "Parameters:"
    echo "  --help      This help"
    echo "  -p          Show the installed patches"
    echo "  -pN         Show patches that are NOT installed (or are not"
    echo "                up-to-date)"
    echo "  -e          Show extra/ packages installed"
    echo "  -eN         Show extra/ packages NOT installed (or not"
    echo "                up-to-date)"
    echo "  -s          Show slackware/ packages installed (note that"
    echo "                packages upgraded with packages in patches/"
    echo "                will not be shown -- to see ALL official"
    echo "                Slackware packages installed, you should also"
    echo "                run this script with the -p parameter)"
    echo "  -sN         Show slackware/ packages NOT installed (note that"
    echo "                packages upgraded with packages in patches/"
    echo "                will be shown because parsing is difficult)"
    echo "  -m          Show non-Slackware packages that are installed"
    ;;
  -p)
    diff -U 0 $DIFFPKGSEP $DIFFPKGSE | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g'
    ;;
  -pN)
    diff -U 0 $SLACKPTCHS $DIFFPKGSEP | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g'
    ;;
  -e)
    diff -U 0 $DIFFPKGSE $DIFFPKGS | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g'
    ;;
  -eN)
    diff -U 0 $SLACKEXTRA $DIFFPKGSEP | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g'
    ;;
  -s)
      comm -1 -2 $SLACKPKGS $MYPKGS
    ;;
  -sN)
    diff -U 0 $SLACKPKGS $MYPKGS | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g'
    ;;
  -m)
    cat $DIFFPKGS
    ;;
  esac
exit 0
fi

if [ ! -e "$ROOTPATH" ]; then
echo "The directory $ROOTPATH does not exist. Exiting."
exit 1
fi
cd $ROOTPATH

# Get the Slackware $VERSION file list. If you are using a local
# FILELIST.TXT (ie you are using a ROOTPATH) comment out the next line.
wget http://slackware.osuosl.org/slackware-$VERSION/FILELIST.TXT || exit 1

if [ ! -e "$FILEDIR" ]; then
echo "The directory $FILEDIR does not exist. Exiting."
exit 1
fi
cd $FILEDIR

if [ ! -e "$ROOTPATH/FILELIST.TXT" ]; then
echo "The file $ROOTPATH/FILELIST.TXT does not exist. Exiting."
exit 1
fi

# Parse the file list, isolating only the .tgz packages (and in this case
# only the core slackware packages, excluding extra/, pasture/, testing/
# patches/ etc. and also excluding the source directory)
# The filenames are also isolated and parsed.
for i in $(cat $ROOTPATH/FILELIST.TXT | grep .tgz$ | grep \/slackware\/ | \
awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \
sort > $SLACKPKGS

# Parse the file list, isolating only the .tgz packages (and in this case
# only the packages in patches/)
# The filenames are also isolated and parsed.
for i in $(cat $ROOTPATH/FILELIST.TXT | grep .tgz$ | \
grep \/patches\/packages\/ | \
awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \
sort > $SLACKPTCHS

# Parse the file list, isolating only the .tgz packages (and in this case
# only the packages in extra/)
# The filenames are also isolated and parsed.
for i in $(cat $ROOTPATH/FILELIST.TXT | grep .tgz$ | \
grep \/extra\/ | grep -v \/extra\/source\/ | \
awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \
sort > $SLACKEXTRA

# Make a list of the installed packages and sort them just as the above
# file
ls -A1 /var/log/packages/ | sort > $MYPKGS

# Show only the packages ADDED by you, INCLUDING the official Slackware
# patches and the extra/ directory
diff -U 0 $SLACKPKGS $MYPKGS | grep -v \@\@$ | grep ^\+ | \
grep -v \+\+\+ | sed 's/^+//g' | sort > $DIFFPKGSEP

# Show only the packages ADDED by you, INCLUDING extra/ but EXCLUDING
# patches/.
diff -U 0 $SLACKPTCHS $DIFFPKGSEP | grep -v \@\@$ | grep ^\+ | \
grep -v \+\+\+ | sed 's/^+//g' | sort > $DIFFPKGSE

# Show only the packages ADDED by you, EXCLUDING extra/ and patches/.
# These are non-Slackware packages that you have added by yourself.
diff -U 0 $SLACKEXTRA $DIFFPKGSE | grep -v \@\@$ | grep ^\+ | \
grep -v \+\+\+ | sed 's/^+//g' | sort > $DIFFPKGS
 
Old 05-17-2008, 09:45 PM   #8
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Quote:
And to think I've been manually `ls`ing or `grep`ing /var/log/packages all this time.
I really like whichpkg. Quite useful!

Quote:
Make sure to read the help for this -- an interesting parsing problem is preventing me from excluding patched packages from the not-installed-Slackware-packages list without too much effort.
I ran into the same problem. The difference between the patches and extra branch is that extra contains additional subdirectories whereas patches contains only the packages subdirectory. I use only two packages from extra and therefore did not pursue the problem further. Your original basic script works just fine for me. I have 64 non stock packages installed. Not bad!

And the great reg ex example above will help me know which packages were long ago installed but not built by me locally.

All in all, a great thread everybody. Thanks!

My reason for wanting to know all the non stock packages installed is I am slowly building a bare metal recovery punch list. I have a decent backup plan (a how-to eventually will appear at my web site), but I wanted to know which packages I would need to rebuild and install too. Every little piece of information helps.

There ought to be a place (web site) for storing useful Slackware scripts like these!
 
Old 05-18-2008, 12:46 AM   #9
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
OK, I fixed the parsing problem, so I am releasing version 3 (my final version unless I feel like adding features or unless one of my loyal zero users request a feature). The ONLY things you will have to change are the variables at the start of the script -- no more commenting of the wget line is required if you use a ROOTPATH (it tests for it). I also added an option to delete the files that were created when running the script (in case you have other .txt files in there and forget which ones were created by the script, I guess). Now, the -sN option outputs only the official Slackware packages (in the slackware/ directory) that are NOT installed. Any packages that were UPGRADED by the packages from the patches/ directory will NOT be listed, as it should be -- ONLY the packages that are truly not installed on your system are listed. I "borrowed" part of upgradepkg's parsing code, so the license had to be included (and therefore the script is enlarged because of all of the commented code).

This little script has really grown to be a nice utility that can be used to see what's on your system. It can tell you if your system is not up-to-date (ie if there are packages in the patches/ directory that you don't have -- not important for -current users, obviously, but useful for people that stick to a stable version), can help you remember what you installed from the extra/ directory, and tell you what you did and didn't install from the slackware/ directory -- and, of course, which extra, non-Slackware packages you have added to your system. Every option outputs the desired package list to standard output, so you can redirect it into a file or something if you wish (although several files are created, only one of them contains actual useful output -- $DIFFPKGS). I can't really think of anything else that needs to be added to the script, so this'll probably be it. I'm sure it won't receive much use, but that's OK with me -- at least I have a nice utility that I can use. The script is posted below, along with the --help menu, in case anyone still doesn't know what the script does.
Code:
Usage: ./diffpkg.sh [options]

This script will identify any non-Slackware packages you have
installed on your system, as well as any official Slackware
packages installed from extra/ and patches/. The script must
be run WITHOUT parameters before it can be run WITH parameters.

Parameters:
  --help      This help
  -p          Show the installed patches
  -pN         Show patches that are NOT installed (or are not
                up-to-date)
  -e          Show extra/ packages installed
  -eN         Show extra/ packages NOT installed (or not
                up-to-date)
  -s          Show slackware/ packages installed (note that
                packages upgraded with packages in patches/
                will not be shown -- to see ALL official
                Slackware packages installed, you should also
                run this script with the -p parameter)
  -sN         Show slackware/ packages NOT installed (note that
                packages upgraded with packages in patches/
                will NOT be shown, and so only packages that
                you truly don't have are shown)
  -m          Show non-Slackware packages that are installed
  -c          Clean up (delete all of the files created by this
                script). Note that FILELIST.TXT will not be
                deleted in case you used an existing one, and
                therefore it will have to be removed manually
Code:
#!/bin/sh

# This script was created by T3slider at linuxquestions.org. The WTFPL
# license basically applies -- do whatever you want with it.

# The version of Slackware being used. Note that I parse the output of
# /etc/slackware-version. To specify a version manually, comment 
# the following line and uncomment the next line. The parsing line was
# lovingly stolen from Woodsman on LQ (and subsequently modified). :)
# The modification was used to ensure that only the LAST .0 is removed.
# It's kind of pointless, since 12.0.0 minus either .0 is still 12.0,
# but it bothered me (12.1.0 minus .0 = 12.1, for the curious). :) Note 
# that if you want to be able to pass VERSION as a command-line argument,
# you'll have to comment the first line and uncomment the second.

VERSION=`cat /etc/slackware-version | awk '{print $2}' | sed 's/.0$//'`
# VERSION=${VERSION:-12.0}

# The idea for a root path was also lovingly (and shamelessly) stolen from
# Woodsman at LQ. If you use a local sync of -current or another branch,
# you can use the existing FILELIST.TXT instead of downloading a new one.
# This may be necessary if you are syncing with -current and you are not 
# fully up to date, and the FILELIST.TXT file is different than the one
# on your system (ie your installed packages are different than the ones
# contained in the new FILELIST.TXT file). Note that
# $ROOTHPATH/FILELIST.TXT should exist. You should set WGETLIST to "No" 
# (or anything except "yes") below if you are using a ROOTPATH, or else
# your FILELIST.TXT will be overwritten!

ROOTPATH=${ROOTPATH:-`pwd`}
WGETLIST=${WGETLIST:-yes}

# The directory to store the files that will be generated

FILEDIR=${FILEDIR:-`pwd`}

# The filenames for each file created.
# SLACKPKGS is the parsed FILELIST.TXT containing ONLY slackware/
# SLACKPTCHS is the parsed FILELIST.TXT containing patches/
# SLACKEXTRA is the parsed FILELIST.TXT containing extra/
# MYPKGS is the list of packages installed on YOUR system
# SLACKNOTINSTALLED is the list of Slackware packages NOT installed on
# 	your system. It is ONLY generated when running with the -sN switch
# DIFFPKGSEP is the list of packages installed on your system that are NOT 
# 	in the slackware/ directory
# DIFFPKGSE is the list of packages installed on your system that are NOT
#       in the slackware/ directory OR the patches/ directory
# DIFFPKGS is the list of packages installed on your system that are NOT 
#	in the slackware/, extra/ or patches/ directory. You have 
# 	obviously installed these yourself.

SLACKPKGS=slackpkgs.txt
SLACKPTCHS=slackptchs.txt
SLACKEXTRA=slackextra.txt
MYPKGS=mypkgs.txt
SLACKNOTINSTALLED=slacknotinstalled.txt
DIFFPKGSEP=diffpkgsEP.txt
DIFFPKGSE=diffpkgsE.txt
DIFFPKGS=diffpkgs.txt

# END OF USER-CONFIGURABLE SECTION. Do not touch anything below this line
# unless you know what you are doing (or you feel like playing around).

if [ ! -e "$FILEDIR" ]; then
echo "The directory $FILEDIR does not exist. Exiting."
exit 1
fi
cd $FILEDIR

if [ ! -z $1 ]; then
  case $1 in
  --help)
    echo "Usage: $0 [options]"
    echo ""
    echo "This script will identify any non-Slackware packages you have"
    echo "installed on your system, as well as any official Slackware"
    echo "packages installed from extra/ and patches/. The script must"
    echo "be run WITHOUT parameters before it can be run WITH parameters."
    echo ""
    echo "Parameters:"
    echo "  --help      This help"
    echo "  -p          Show the installed patches"
    echo "  -pN         Show patches that are NOT installed (or are not"
    echo "                up-to-date)"
    echo "  -e          Show extra/ packages installed"
    echo "  -eN         Show extra/ packages NOT installed (or not"
    echo "                up-to-date)"
    echo "  -s          Show slackware/ packages installed (note that"
    echo "                packages upgraded with packages in patches/"
    echo "                will not be shown -- to see ALL official"
    echo "                Slackware packages installed, you should also"
    echo "                run this script with the -p parameter)"
    echo "  -sN         Show slackware/ packages NOT installed (note that"
    echo "                packages upgraded with packages in patches/"
    echo "                will NOT be shown, and so only packages that"
    echo "                you truly don't have are shown)"
    echo "  -m          Show non-Slackware packages that are installed"
    echo "  -c          Clean up (delete all of the files created by this"
    echo "                script). Note that FILELIST.TXT will not be"
    echo "                deleted in case you used an existing one, and"
    echo "                therefore it will have to be removed manually"
    ;;
  -p)
    diff -U 0 $DIFFPKGSEP $DIFFPKGSE | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g'
    ;;
  -pN)
    diff -U 0 $SLACKPTCHS $DIFFPKGSEP | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g'
    ;;
  -e)
    diff -U 0 $DIFFPKGSE $DIFFPKGS | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g'
    ;;
  -eN)
    diff -U 0 $SLACKEXTRA $DIFFPKGSEP | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g'
    ;;
  -s)
      comm -1 -2 $SLACKPKGS $MYPKGS
    ;;
  -sN)
# The following script, up until the "sed -i" line, was adapted from 
# upgradepkg, installed by default in Slackware. For the (little) amount of
# documentation on this (small) section, see the /sbin/upgradepkg script.
# Since I am not permitted to include this code without the upgradepkg
# license, it is included below. It basically just parses the filenames
# to compare the installed patches, without comparing the versions.
# Thanks Pat!

# Copyright 1999  Patrick Volkerding, Moorhead, Minnesota, USA
# Copyright 2001, 2002, 2003  Slackware Linux, Inc., Concord, California, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    diff -U 0 $SLACKPKGS $MYPKGS | grep -v \@\@$ | grep ^\- | \
      grep -v ^\-\-\- | sed 's/^\-//g' > $SLACKNOTINSTALLED
    for i in `cat $SLACKPTCHS`; do
    INDEX=1
    if [ ! "`echo $i | cut -f $INDEX -d -`" = $i ]; then
    while [ ! "`echo $i | cut -f $INDEX -d -`" = "" ]; do
      INDEX=`expr $INDEX + 1`
    done
    INDEX=`expr $INDEX - 1` # don't include the null value
    if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then
      NAME=$i
    else
      NAME=`expr $INDEX - 3`
      NAME="`echo $i | cut -f 1-$NAME -d -`"
    fi
    else
      NAME=$i
    fi

    sed -i "/$NAME-[0-9]/d" $SLACKNOTINSTALLED
    done
    cat $SLACKNOTINSTALLED
    ;;
  -m)
    cat $DIFFPKGS
    ;;
  -c)
    rm -rf $SLACKPKGS $SLACKPTCHS $SLACKEXTRA $SLACKNOTINSTALLED \
      $MYPKGS $DIFFPKGSEP $DIFFPKGSE $DIFFPKGS
    ;;
  esac
exit 0
fi

if [ ! -e "$ROOTPATH" ]; then
echo "The directory $ROOTPATH does not exist. Exiting."
exit 1
fi
cd $ROOTPATH

# Get the Slackware $VERSION file list. If you are using a local
# FILELIST.TXT (ie you are using a ROOTPATH), set WGETLIST to "No" above.
if [ $WGETLIST == "yes" ]; then
  rm -rf FILELIST.TXT
  wget http://slackware.osuosl.org/slackware-$VERSION/FILELIST.TXT || exit 1
else
  if [ ! -e "$ROOTPATH/FILELIST.TXT" ]; then
    echo "The directory $ROOTPATH/FILELIST.TXT does not exist. Exiting."
    exit 1
  fi
fi

if [ ! -e "$FILEDIR" ]; then
echo "The directory $FILEDIR does not exist. Exiting."
exit 1
fi
cd $FILEDIR

# Parse the file list, isolating only the .tgz packages (and in this case
# only the core slackware packages, excluding extra/, pasture/, testing/
# patches/ etc. and also excluding the source directory)
# The filenames are also isolated and parsed.
for i in $(cat $ROOTPATH/FILELIST.TXT | grep .tgz$ | grep \/slackware\/ | \
awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \
sort > $SLACKPKGS

# Parse the file list, isolating only the .tgz packages (and in this case
# only the packages in patches/)
# The filenames are also isolated and parsed.
for i in $(cat $ROOTPATH/FILELIST.TXT | grep .tgz$ | \
grep \/patches\/packages\/ | \
awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \
sort > $SLACKPTCHS

# Parse the file list, isolating only the .tgz packages (and in this case
# only the packages in extra/)
# The filenames are also isolated and parsed.
for i in $(cat $ROOTPATH/FILELIST.TXT | grep .tgz$ | \
grep \/extra\/ | grep -v \/extra\/source\/ | \
awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \
sort > $SLACKEXTRA

# Make a list of the installed packages and sort them just as the above
# file
ls -A1 /var/log/packages/ | sort > $MYPKGS

# Show only the packages ADDED by you, INCLUDING the official Slackware
# patches and the extra/ directory
diff -U 0 $SLACKPKGS $MYPKGS | grep -v \@\@$ | grep ^\+ | \
grep -v \+\+\+ | sed 's/^+//g' | sort > $DIFFPKGSEP

# Show only the packages ADDED by you, INCLUDING extra/ but EXCLUDING
# patches/.
diff -U 0 $SLACKPTCHS $DIFFPKGSEP | grep -v \@\@$ | grep ^\+ | \
grep -v \+\+\+ | sed 's/^+//g' | sort > $DIFFPKGSE

# Show only the packages ADDED by you, EXCLUDING extra/ and patches/.
# These are non-Slackware packages that you have added by yourself.
diff -U 0 $SLACKEXTRA $DIFFPKGSE | grep -v \@\@$ | grep ^\+ | \
grep -v \+\+\+ | sed 's/^+//g' | sort > $DIFFPKGS
[edit]Fixed a typo in the script (it only affects improperly-named packaged or VERY, VERY old packages [pre-8.0!], but would likely cause the script to crash). $1 was changed to $i in the modified upgradepkg code. The script now also deletes the existing FILELIST.TXT if it exists before `wget`ing the new one (but if WGETLIST is set to No, of course, it will not be touched). This is because wget renames the NEW file if an existing file by the same name exists -- and therefore running the script with parameters will reflect the OLD FILELIST.TXT. If you aren't paying attention (ie you don't check to see if FILELIST.TXT.1 is created), you could continue thinking your system is up-to-date when in actual fact it is not. Sorry about that -- I apologize to my loyal zero users. [/edit]
[edit2]After testing the -sN option with an improper name format in $SLACKPTCHS (which shouldn't happen since Pat controls that -- but it creates a potentially infinite loop if the package name is in the wrong format), I fixed the parsing formula (I added a small check to ensure there is at least one '-' in the package name). Without the modification, a package name like "aaabase" or something, without any '-' characters (which was used a LONG time ago) would cause an infinite loop, rendering the -sN option useless as long as that filename is in $SLACKPTCHS. I think everything's fixed now, so I probably won't be adding/modifying the script further (unless of course my loyal zero users request a feature or I feel like expanding the script). On a side note, I really like the `whichpkg` script that gnashley posted (it's better than using the Slackware package browser) and the `pkginfo` script. I modified the `lspkg` script to utter simplicity since the wild-cards were actually making it less useful in my opinion (`lspkg *fusion*` wouldn't find compiz-fusion-blahblahblah, for example), but the modified version (6 lines including error-checking) is very helpful. [/edit2]

Last edited by T3slider; 05-18-2008 at 08:09 PM.
 
Old 05-18-2008, 01:53 AM   #10
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
Great thread with some interesting discussion and scripts.

Quote:
Originally Posted by Woodsman View Post
My slightly modified version of Eric's rsync scripts satisfy my needs for packages. The scripts maintain my patches and current tree, and I manually decide what and when to update. Package management tools are a great idea, but I never have been fond of blind updating. I like the ability to revert to a previous version of a package if a new version hiccups. (I modified Eric's patches rsync script to not delete previous packages.) I have needed to revert a handful of times. I recall samba being one of those times (last summer I think).
If you use slackpkg correctly you won't simply be blindly updating. I actually thought of writing my own version of the script that this thread was about, but slackpkg handles it very nicely and it can sync with a local mirror on your hard drive. slackpkg can be used in batch mode with default_answer to "no" to generate some quick lists and you can use the dialog (default) to always select which packages to include in your current action. It doesn't do anything without you telling it to, and I find it a nice supplement to the native pkgtools. If you want to use an older version of a package or not include it, then you can either uncheck its box on the dialogs when you perform actions or simply blacklist the package all together.

See my HowTo: Upgrade Slackware 12.0 to 12.1 for some examples of using slackpkg.
 
Old 05-18-2008, 01:58 AM   #11
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
Slackpkg can also be used quickly and easily to list the non-Slackware
packages in your system, without using it to update or install anything.
 
Old 05-18-2008, 02:10 AM   #12
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
Quote:
Originally Posted by Bruce Hill View Post
Slackpkg can also be used quickly and easily to list the non-Slackware
packages in your system, without using it to update or install anything.
Yes, that's one of the things I showed how to do in my HowTo linked above.
 
Old 05-18-2008, 03:43 AM   #13
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Since th geekster's 'whichpkg' got mentined here, I'll throw in another. In 2001, Cameron Kerr wrote a script called 'whichpkg' which searches through a MANIFEST file for your search string. I updated the script to work with MANIFEST.bz2 files. I find this program more useful than the geekster's. Usually, when I need to find out what package a file belongs to, it is because the file is 'missing'. Using this script then tells me whether the file is available in an official Slackware package, by searching all the packages available listed in the MANIFEST.

Code:
#!/bin/sh

# This is a script to answer the question "In which Slackware package(s) does
# the file <query_filename> belong to?". Typically the user would have to
# manually consult the MANIFEST.gz file on the Slackware CD-ROM to find out
# this information. This file can be helpful for the testldddeps script, made
# by me also.
#
# Cameron R Kerr
# Last revised: 27 August 2001
# cameron.kerr@paradise.net.nz
# http://homepages.paradise.net.nz/~cameronk/
#
# Please send any improvements back to me to share with the world.

#
# Modified by Gilbert Ashley
# 3 July 2005
# Added support for bzip2 Manifests

function usage()
{
  echo -n "USAGE: `basename $0` " >&2
  echo "[-h|--help] | [-e|--exact] [-s|--show] <MANIFEST[.gz|.bz2]> <query>" >&2
  echo "Version: 19 August 2001 Author: cameron.kerr@paradise.net.nz" >&2
  exit 1
}

# Deal with program arguments

TEMP=`getopt -n \`basename $0\` --longoptions="help,exact,show" "hes" "$@"`

eval set -- "${TEMP}"

EXACT=0
SHOW=0
while true
do
  case "$1" in

    -h|--help) usage;;

    -e|--exact) EXACT=1; shift;;

    -s|--show) SHOW=1; shift;;

    --) shift; break;;

    *) echo "Internal error!"; exit 1;;

  esac  
done

MANIFEST="$1"; shift
QUERY="$1"; shift

# Lets support reading gzip'd versions of MANIFEST, since it is by default.

FILETYPE=`file "${MANIFEST}"`

if [ "`echo ${FILETYPE} | grep 'gzip compressed data'`" ]; then
  CATTER=zcat
elif [ "`echo ${FILETYPE} | grep 'bzip2 compressed data'`" ]; then
  CATTER=bzcat
elif [ "`echo ${FILETYPE} | grep 'ASCII text'`" ]; then
  CATTER=cat
else
  echo "  Sorry! invalid file format for ${MANIFEST} ." >&2
  echo "  Give the path to a valid Slackware MANIFEST" >&2
  echo "  file. Either MANIFEST.bz2, MANIFEST.gz or the" >&2
  echo "  decompressed MANIFEST file." >&2
  exit 2
fi  

# Handle the case where /usr/bin/... is given, as it is stored as usr/bin/...
# in the MANIFEST
QUERY_INTERNAL="`echo \"${QUERY}\" | sed -e 's/^\///'`"

# If the user has asked for exact matching, append a space at the end.
if [ $EXACT == 1 ]; then
  QUERY_INTERNAL="${QUERY_INTERNAL} "
fi

# If the user has asked for fully qualifed matching, prepend a space

echo "Please wait while searching..."

${CATTER} ${MANIFEST} | awk '
BEGIN {
  starting = 1
}

/^\|\|   Package:  / {
  if( starting == 1 )
    starting = 0
  else
    printf( "\n" )
  printf( "%s ", $3 )
}  

/^[-bcdlps][-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT][[:space:]]/ {
  printf( "%s ", $6 )
}  

END {
  printf( "\n" )
}  
' | fgrep "${QUERY_INTERNAL}" | cut -d' ' -f1

exit 0
 
Old 05-26-2008, 11:15 AM   #14
bonecrusher
Member
 
Registered: Mar 2004
Location: St. Louis, MO
Distribution: Ubuntu, Debian, Slack, RH, Gentoo
Posts: 207

Rep: Reputation: 30
Quote:
Originally Posted by shadowsnipes View Post
Yes, that's one of the things I showed how to do in my HowTo linked above.
Code:
#!/bin/sh
echo "Working! Please be patient."
echo
slackpkg update
slackpkg -dialog=off -batch=on -default_answer=no clean-system > NonStandardPKGS.txt
echo
echo
echo "Cat of File:"
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
cat  NonStandardPKGS.txt
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo
echo "Created \"./NonStandardPKGS.txt\""
echo "Done!"
All "non-standard" pkgs > "NonStandardPKGS.txt"

@ShadowSnipes:
Figured I may as well put "my" fancy script here. (thanks)

@all
This is one good reason to install slackpkg if for no other reason then to quickly list non-standard packs.

Last edited by bonecrusher; 05-26-2008 at 11:24 AM. Reason: spel'n suxs
 
Old 05-26-2008, 12:20 PM   #15
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by bonecrusher
This is one good reason to install slackpkg if for no other reason then to quickly list non-standard packs.
I guess I'm strange -- I don't feel the need (or want) to install an app that does way more than what I need just to do something a simple script does just as well (and takes up less room). I don't really want or need to use slackpkg for anything else, and I think it's kind of overkill just to list non-Slackware packages. If I wanted to use slackpkg for other things as well, then I would absolutely use it -- but at this point in time I'll stick with my script, which does just fine.
 
  


Reply

Tags
packages, slackpkg, slackware



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
Listing of packages installed on system borgibo Linux - Newbie 4 06-16-2008 03:42 PM
listing the installed Packages nmansour Linux - Newbie 4 10-28-2007 02:16 PM
Make slackpkg prefer /extra over /slackware when listing packages to update rignes Slackware 1 06-02-2007 06:00 PM
Listing of packages installed on system kushalkoolwal Debian 12 06-22-2006 02:59 AM
Listing installed packages in Gentoo ? Builder Linux - Distributions 1 07-08-2004 05:09 PM

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

All times are GMT -5. The time now is 01:11 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