Quote:
Originally Posted by Woodsman
See whether this script will help:
http://www.linuxquestions.org/questi...ckages-642787/
I've been using a slightly personalized version for several years. I always have a copy in /var/log of all non stock packages I installed. I run the script as part of my daily cron jobs.
|
All instances of ".tgz" would have to be changed to ".t[gx]z" or ".t.z" for those scripts to still work properly. If you use slackpkg then this script is nicer:
Code:
#!/bin/sh
(
cd /var/log/packages
THIRDPARTYPKGS=$(
for i in *
do
if ! grep "^PACKAGE NAME: ${i}.t[gx]z$" /var/lib/slackpkg/PACKAGES.TXT >/dev/null 2>&1; then
echo "$i"
fi
done
)
echo "$THIRDPARTYPKGS"
)
To list all first-party packages instead of third-party packages (which seems to be what the OP wants), the slackpkg-dependent script should be
Code:
#!/bin/sh
(
cd /var/log/packages
FIRSTPARTYPKGS=$(
for i in *
do
if grep "^PACKAGE NAME: ${i}.t[gx]z$" /var/lib/slackpkg/PACKAGES.TXT >/dev/null 2>&1; then
echo "$i"
fi
done
)
echo "$FIRSTPARTYPKGS"
)
By slackpkg-dependent I mean it depends on having run `slackpkg update` at least once. If you don't use slackpkg then you may adjust one of the scripts Woodsman linked to (the script in reply #9 has an option to list first-party packages, but since I no longer use the script I can't guarantee it still works -- though it should if you replace .tgz with .t[xg]z).
I just rigged up a quick script that produces tagfiles from the installed packages (using official packages only). This is also slackpkg-dependent.
Code:
#!/bin/bash
PACKAGES=/var/lib/slackpkg/PACKAGES.TXT
OUTPUTDIR=${OUTPUTDIR:-`pwd`}
(
cd /var/log/packages
PKGLIST=$(paste -d/ <(grep "^PACKAGE LOCATION:" $PACKAGES | sed 's/^PACKAGE LOCATION: //') <(grep "^PACKAGE NAME:" $PACKAGES | sed 's/^PACKAGE NAME: //'))
while read line
do
if [ -e "$(basename $line)" ]; then
mkdir -p "$OUTPUTDIR/$(dirname $line)"
echo "$(echo "$(basename $line)" | rev | cut -d- -f4- | rev):ADD" >> "$OUTPUTDIR/$(dirname $line)/tagfile"
else
mkdir -p "$OUTPUTDIR/$(dirname $line)"
echo "$(echo "$(basename $line)" | rev | cut -d- -f4- | rev):SKP" >> "$OUTPUTDIR/$(dirname $line)/tagfile"
fi
done < <(echo "$PKGLIST" | sed 's/[.]t[gx]z$//')
)
This will create a few directories in the path specified by OUTPUTDIR (by default the current directory). It should create extra/, patches/, slackware/ (or slackware64/) and testing/ directories (some of which have their own sub-directories), but the only important one is slackware{,64}. It should be noted that this will not handle a patched Slackware installation properly -- any upgraded packages will be listed as "SKP" in the relevant tagfile instead of "ADD". Thus, after running the script you should look at patches/packages/tagfile and modify the appropriate tagfiles under slackware{,64}/ to change the upgraded packages to ADD instead of SKP. There isn't really an easy way to do this in the script since some packages may have ambiguous roots (xf86-video-nouveau, for example, could be the one from x/, testing/, or the blacklist package from extra/, and hypothetically, if a patch was released, the script would not be able to tell which package the patch represented...). I think it is best to leave this for manual work. The following script, which must be run from the directory specified as $OUTPUTDIR from the last script (after running it), will try to adjust for the patches problem automatically, but no guarantees:
Code:
#!/bin/bash
PATCHES=$(grep ":ADD$" patches/packages/tagfile | cut -d: -f1)
while read line
do
PKG=$(grep -R "^${line}:SKP$" slackware{,64}/ 2>/dev/null | cut -d: -f1)
sed -i "s/^${line}:SKP$/${line}:ADD/" $PKG
done < <(echo "$PATCHES")
For a simpler script see
here, which uses a CD image/mirror (but will not omit official packages that you have replaced with unofficial packages -- it just checks to see if any package of the given name is installed regardless of whether or not it is official).
To use the tagfiles generated by my script, you would pass the name of the slackware{,64} directory to the installer and not $OUTPUTDIR (I believe the installer looks for tagfiles in a/, ap/, etc. directories under the mount point).