LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Listing Non Stock Slackware Packages (https://www.linuxquestions.org/questions/slackware-14/listing-non-stock-slackware-packages-642787/)

Woodsman 05-16-2008 09:19 PM

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.

T3slider 05-16-2008 10:08 PM

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.)

Bruce Hill 05-17-2008 10:17 AM

Do you build your own, or install pkgs built by others?

Speek 05-17-2008 10:53 AM

Code:

cd /var/log/packages
ls *[aA-zZ]


bgeddy 05-17-2008 11:53 AM

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..

Woodsman 05-17-2008 01:22 PM

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. :scratch: 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!

T3slider 05-17-2008 05:49 PM

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


Woodsman 05-17-2008 09:45 PM

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!

T3slider 05-18-2008 12:46 AM

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]

shadowsnipes 05-18-2008 01:53 AM

Great thread with some interesting discussion and scripts.

Quote:

Originally Posted by Woodsman (Post 3156351)
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.

Bruce Hill 05-18-2008 01:58 AM

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.

shadowsnipes 05-18-2008 02:10 AM

Quote:

Originally Posted by Bruce Hill (Post 3156751)
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.

gnashley 05-18-2008 03:43 AM

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


bonecrusher 05-26-2008 11:15 AM

Quote:

Originally Posted by shadowsnipes (Post 3156760)
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.

T3slider 05-26-2008 12:20 PM

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.

Woodsman 05-26-2008 12:44 PM

Quote:

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).
Not strange. :)

One task, one tool. Your script fits the bill.

I'm still using your original script along with my minor modifications. I run the script hourly through cron and save the diff file to two different physical locations --- on my primary drive and my secondary drive. Both diff files get backed up daily and weekly. Should I ever have to rebuild bare metal (gulp!) I should have access to a list of non stock packages --- somewhere. :)

Eric's rsync scripts, which I modified slightly to my needs, also satisfies the idea of one task, one tool. I run the scripts daily through cron and maintain my patches and current trees. Simple and straightforward.

We live in a big world where there is almost always more than one way to solve a problem. Simple one-task scripts work for some, more complicated scripts like slackpkg work for others. To me that is one of the advantages of free/libre software and Slackware --- very little is shoved down our throats. We each get to choose our path and comfort zone. :)

Thanks again for your efforts on this thread.

harryhaller 09-17-2008 06:08 AM

Good thread!

It seems to me that the best thing is to install all non-stock packages in /usr/local.

Apparently installpkg and removepkg allow this if you add -root /usr/local to the command line - I haven't yet tried it though.

Alien Bob 09-17-2008 06:29 AM

Quote:

Originally Posted by harryhaller (Post 3282979)
Good thread!

It seems to me that the best thing is to install all non-stock packages in /usr/local.

Apparently installpkg and removepkg allow this if you add -root /usr/local to the command line - I haven't yet tried it though.

No, that is not what the -root option is for! The directory "-root" is pointing to must always be the root of a Slackware filesystem. Either your own system's root (/) or that of another that you have mounted for maintenance, or to work in using chroot, or if you are the Slackware installer (which uses "-root /mnt" to install your system).

If a package was compiled to use /usr instead of /usr/local then there is no way you can install it to /usr/local and expect it to work. The only option is to recompile it using a prefix of /usr/local instead of /usr .

Eric

harryhaller 09-17-2008 06:49 AM

Quote:

No, that is not what the -root option is for! The directory "-root" is pointing to must always be the root of a Slackware filesystem.
Well - a good job I posted that, because I clearly misunderstood the man page. Thanks Bob.

If I compile a SlackBuild package I cannot change the configure options since they relate to the location of where the package is to be created - by default /tmp.

Either installpkg or SlackBuild etc. should provide an option to specify a different target directory area.

I've started only recently using SB and the other packages - before I would always compile myself - to /usr/local of course. That's messy because it's difficult keeping track of the programs and their related components.

Now, I am now regretting having installed packages to the stock core system - especially because of the problems when installing a new system or updating the old system - as this thread has revealed.

If a package is not part of the distro - it should be installed to /usr/local.

I suppose I'll have to hack my own version of SlackBuild.

Alien Bob 09-17-2008 07:56 AM

Quote:

Originally Posted by harryhaller (Post 3283014)
If I compile a SlackBuild package I cannot change the configure options since they relate to the location of where the package is to be created - by default /tmp.

Either installpkg or SlackBuild etc. should provide an option to specify a different target directory area.

Nothing forces you to use /tmp as the output location (where the packages are created). If you look at any SlackBuild on the SBo site, they have a line
Code:

OUTPUT=${OUTPUT:-/tmp}        # Drop the package in /tmp
Which means you can change that to any other directory.
And: this location has nothing to do with the software's "configure" command parameters. The "configure --prefix=/usr" just means that the resulting software (not the Slackware package) is going to use /usr and the directories below that (bin, share, man, ...). Please do not confuse the two.

Quote:

Now, I am now regretting having installed packages to the stock core system - especially because of the problems when installing a new system or updating the old system - as this thread has revealed.

If a package is not part of the distro - it should be installed to /usr/local.

I suppose I'll have to hack my own version of SlackBuild.
If you install software as a Slackware package it does not matter (with respect to manageability) whether it is compiled for using /usr or /usr/local - you can easily remove any package from your system using the removepkg command.
And exactly for that reason, I would advise to create only packages that install themselves into "prefix=/usr". It does make the compilation of other software that depends on it, easier afterwards.

And any software that you manually compile and install (./configure && make && make install) will by default install itself with a "prefix=/usr/local" which is good because it enables you to quickly wipe anything you ever compiled - by going onto /usr/local and deleting the stuff you find there. You will be certain that there is no proper Slackware package (official or 3rd party) that installed itself to /usr/local . You keep packages and locally-compiled software nicely apart this way.

Eric

harryhaller 09-17-2008 08:13 AM

I just ran installpkg -root $HOME/local as a non-root user.

It couldn't update /var/log etc. nor could it run ldconfig, of course, because of the permissons, but it did install correctly to my home directory.

Running it as root, it installed the package, but still had problems writing to /var - this time without complaining - because there is not record of the installation there.

Hence removepkg failed since there was no record of the installation.

This is just for info, to see what happens if one uses the "root" option as I though it could be used.

Bruce Hill 09-17-2008 08:18 AM

I would like to add that Eric (Alien Bob) has created Alien's SlackBuild Toolkit,
an online SlackBuild script generator that you can use as a template for making
your own Slackpacks. It is serving me very well.

Thanks, Eric!

harryhaller 09-17-2008 08:36 AM

Quote:

The "configure --prefix=/usr" just means that the resulting software (not the Slackware package) is going to use /usr and the directories below that (bin, share, man, ...). Please do not confuse the two.
Sorry, I am clearly getting confused. That is good news then. I will edit the SB script in future to go to /usr/local.

Quote:

If you install software as a Slackware package it does not matter (with respect to manageability) whether it is compiled for using /usr or /usr/local - you can easily remove any package from your system using the removepkg command.
This is true of updates, but not of clean installs.

Up until now all software I had installed myself (/usr/local) would simply be remounted after a clean install. In /usr, I would have to re-install all the packages again.

Even if I changed the configure options within the SB script - the install log would be in /var - not in /usr/local/var - and hence be missing in a clean install.

I would like install/removepkg to respect the /usr/local prefix and open a separate /var/log under /usr/local thus providing a clean separation between the stock system and the local additions, since the local subdirectories persist after a clean installation.

The two parts should be kept separate since their origins and fate are separate.

So at the moment, by changing the SB script I could install to /usr/local - but would lose all records of it and the ability to use removepkg after a clean install.

Thanks again for clearing up the misunderstandings that crept into my head, Eric - I was working late last night - I must have been more tired than I realised :)

harryhaller 09-17-2008 08:48 AM

Quote:

I would like to add that Eric (Alien Bob) has created Alien's SlackBuild Toolkit,
Thanks Eric and Bruce - that's neat!

piete 09-17-2008 09:19 AM

Quote:

I would like install/removepkg to respect the /usr/local prefix
It doesn't understand the /usr/local prefix to respect it. If you do a clean install of SuSE or Debian or Ubuntu or Redhat do you expect, having installed 3rd party packages previously, to be able to now remove those 3rd party packages?

No. Because they're registered to the package manager which you've since wiped along with the rest of the "core" install.

If you register something with the package manager you're saying "This package? It's now core to me. Look after it for me." If you don't want it managed that way then do it the old fashioned way:

./configure --prefix=/usr/local && make && make install

You cannot have a core system with tools and expect those tools to exist anywhere outside of that system (slackware + pkgtool). It doesn't matter how you slice it, a clean install will (as far as the package manager is concerned) remove records of anything the system considers core, and since you've told the system these new packages are also core ... poof.

What you can do is look at it another way: the only thing that is required for the pkgtool to understand about a package is the log in /var/log/packages/<packagename>. So if you can ensure a package that you build does not encroach on territory outside of /usr/local (/etc for example), you can mirror your 3rd party (non-core/unmanaged/etc) install logs elsewhere. On a clean install, copy the log back and magically pkgtool remembers how to remove that package and is therefore managing it again!

What you may wish to look into are things called tagfiles, with which you can build your own installable catergories, so reinstalling previously built packages doesn't become a burden. This is a much better solution than the above, imo. 30 seconds on google brought me this:

http://www.bilbos-stekkie.com/tagger/tagfiles.html

I daresay you'll discover a whole stack more information with a bit of patience and the right key words.

Finally, here are some ideas for you to chew on that should help future posts. Crucially, the only difference between a "slackbuild package" and an "installpkg package" is that slackbuild is a 3rd party site so the available packages there are not part of core slack release, unlike the latter.

slackbuild: script that generates a (Slackware) package from given source code and associated patches
package: gzipped tar containing (usually) binary files and an install script
pkgtools: collection of (Slackware) package management tools including:
- installpkg
- removepkg
- makepkg

Best regards,
- Piete.

harryhaller 09-17-2008 10:33 AM

Quote:

if you can ensure a package that you build does not encroach on territory outside of /usr/local (/etc for example), you can mirror your 3rd party (non-core/unmanaged/etc) install logs elsewhere.
That is precisely the aim. I.e. in /usr/local. But why "mirrored"?

Quote:

On a clean install, copy the log back and magically pkgtool remembers how to remove that package and is therefore managing it again!
Or have the package respect/look in /usr/local as well.

This is why I was quite excited by the "root" option of install/removepkg since I thought that with that option, it would understand that it was relocating itself from the root directory to the /usr/local with /usr/local being the prefix for all locations that it used (except ld.conf etc.).

By clean install, I mean, of course, a clean of install of the same distro (as opposed to an update) - hence I can expect the package tools to "re-appear" in the new installation. A migration to another distro is another matter.

But your suggestions regarding the tag files are a possible alternative - nevertheless, the idea of /usr/local being self sufficient regarding the components included in the package together with the installation logs is, imho, the best and cleanest way.

Clearly, it's best to stick to updates. Unfortunately if you skip a release or two - as I and others did going from 10.1 to 12.1 - one is forced to do a clean install.

keefaz 09-17-2008 10:43 AM

Quote:

Originally Posted by harryhaller (Post 3283237)
Clearly, it's best to stick to updates. Unfortunately if you skip a release or two - as I and others did going from 10.1 to 12.1 - one is forced to do a clean install.

I upgraded my Slackware system from 10.1 to 12.1 with a clean install
But I have a separate /home partition and a /home/build directory where I put kernel sources and all extra softwares sources with the corresponding packages and slackbuild scripts. This way I can always do a clean install and reinstall the extra softwares I added to Slackware system, either with the tgz packages or I rebuild them with the slackbuild scripts

GazL 09-17-2008 12:09 PM

Quote:

Originally Posted by keefaz (Post 3283252)
I upgraded my Slackware system from 10.1 to 12.1 with a clean install
But I have a separate /home partition and a /home/build directory where I put kernel sources and all extra softwares sources with the corresponding packages and slackbuild scripts. This way I can always do a clean install and reinstall the extra softwares I added to Slackware system, either with the tgz packages or I rebuild them with the slackbuild scripts

That's good advice. I do exactly the same. ;)

Woodsman 09-17-2008 01:33 PM

Quote:

It seems to me that the best thing is to install all non-stock packages in /usr/local.
That might be an idea for people who zealously control their own box. For third-party packagers, such as the great people at slackbuilds.org, I think the best presumption is install in /usr. Many end-users do not maintain /usr/local in a separate partition, therefore compiling a package for that location provides no benefit over installing into /usr. Third-party packagers cannot and should not presume a separate /usr/local file system. Besides, the /usr/local file system is supposed to be reserved for end-users only.

People who regularly get their hands dirty with their system easily can modify the build scripts to /usr/local. For myself, I prefer to maintain my separate /usr/local partition and file system. I consider third-party packages from slackbuilds.org and slacky.eu to be system (core) software rather than personal software. Therefore I prefer to have those packages installed in /usr.

Quote:

If I compile a SlackBuild package I cannot change the configure options since they relate to the location of where the package is to be created - by default /tmp.
I change the location in every build script I download because I have /tmp mounted non-executable. I also maintain a separate build area for all of my software and I use a separate tmp location within that area.

Bruce Hill 09-17-2008 04:18 PM

Quote:

Originally Posted by Alien Bob (Post 3283079)
If you install software as a Slackware package it does not matter (with respect to manageability) whether it is compiled for using /usr or /usr/local - you can easily remove any package from your system using the removepkg command.
And exactly for that reason, I would advise to create only packages that install themselves into "prefix=/usr". It does make the compilation of other software that depends on it, easier afterwards.

Eric

I haven't finished my first cup of coffee this morning, so maybe I'm not
reading some posts after this one correctly. But this is very important,
IMO, and should be considered. Unless you don't plan on compiling any
other packages -- such as Woodsman's 64 non-stock packages.

harryhaller 09-18-2008 06:09 AM

If you put something in the core system and it doesn't function, then you are facing greater problems than if you had put it into /usr/local.

/usr/local, as a separate partition, can be simply dismounted.

As for compiling - well I have /usr/local prioritised both in my paths as well as in ld.conf.

Hence if you have the old standard program in the core sytem and the new program in /usr/local, when you run the program the newer version will run. Problems? Unmount /usr/local, try again and if it works, you know where the problem is - and, more importantly, you can carry on working.

The other aspect is creep - at what point do you have a slackware distribution and at what point do you have a system based in Slackware?

Ad absurdum - one would end up having an lfs system since you have given up the idea of keeping the core system strictly separate from any changes/additions you make.

If yours were a business - a bank say - an IT auditor would have grave considerations about tampering with the core system. S/he would want all changes/additions to be kept separately so that they could be given special consideration.

Surely the same would apply to us when debugging a problem? We could focus on where changes had been made much easier if they were kept separately.

Anyway that's my attitude.

If I were to continue putting changes/addtions into the core system, I would really consider moving onto LFS - after all, I would be be half way there.

Slackware would then be a useful source of packages for when I was to lazy to compile myself and a reference system.

I wouldn't have /usr/local because the whole system was "local".

keefaz 09-18-2008 06:54 AM

And /opt directory has not been discussed yet :)

harryhaller 09-18-2008 07:40 AM

/opt seems to be just for packages - as opposed to individual programs.

Quote:

1.13. /opt

This directory is reserved for all the software and add-on packages that are not part of the default installation. For example, StarOffice, Kylix, Netscape Communicator and WordPerfect packages are normally found here.

Quote:

1.17. /usr

(..)

/usr/local

The original idea behind '/usr/local' was to have a separate ('local') '/usr' directory on every machine besides '/usr', which might be just mounted read-only from somewhere else. It copies the structure of '/usr'. These days, '/usr/local' is widely regarded as a good place in which to keep self-compiled or third-party programs. The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr. Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.
So I stand corrected about what I wrote about keeping the original program in /usr, but otherwise my point of view agrees with the standards that additions should be placed in /usr/local.

gnashley 09-18-2008 11:11 AM

YOu have to take into account common practices -which means that most users/admins will install any *packaged* software with, usuallly, a prefix of /usr. /usr/local is most often used for software that is installed without packaging it and for a place to put single-file installations -that is short scripts which don't have any ancillary files.
/opt was originally designed to be used for any software which doesn't conform to normal pratices of spreading files out in different places. that is, some programs look for all their files under a single directory. /opt provides a place for htese programs -anything in /opt can follow whatever conevntion they want. usually progs there are installed into a single directory.

The one rule about /usr/local that most distros do folow is that it should be emptied as the distro is delivered.
In summary, if you want to do like everyone else is doing, only put stuff in /usr/local which is installed manually or by using 'make install, or an install.sh script. If you create packages for installation , they should nearly lawys be in prefix /usr, although there are exceptions. Some exceptions are really 'illegal', -products which create their own subdirectory in /usr. These should usually be installed, instead in a subdirectory under /usr/lib (no capitals in the name). Then links or wrappers to the binaries are placed in the normal path /usr/bin.

While true that pkgtool will manage packages installed under /usr/local and that some third-party packages may thus overwrite files from the official packages, this is still the most common practice across almost all distros. The biggest 'violators' have historically been several large open-source cross-platform programs, like X11, KDE, Mozilla and others.

If you create a package using prefix /usr/local, installing it with installpkg will still keep the database info under /var/log/packages. If you had a separate partition mounted on /usr/local you could use root=/usr/local installpkg pkgname to install the program there, but that is not correct -pkgtool rightly will ignore the database files which get installed to /usr/local/var/log/packages.
The 'root' option to installpkg is used when you are creating a complete installation under a certain subdirectory, which will be mounted as the main / partition afterwards(or if you want to copy the whole thing to some device).

As soon as you finish installing Slackware, it becomes yours -very few installations are left exactly like the installer created. It doesn't mean you should just go ahead and use LFS, just because you change the hostname or add a package or two(hundred) which are not part of the official release. Slackware users rarely rely 100% on official packages.

If you find anyone else distributing binary packages for Slackware which are installed under /usr/local, you should consider that a bug -no reputable packages is going to do that, and if someone does that, it screams that they don't know what they are doing -even though it may be 'legal', it is just simply not the accepted practice.


All times are GMT -5. The time now is 10:56 AM.