#!/bin/bash # /usr/local/bin/diffpkg # original script written by T3slider at # https://www.linuxquestions.org/questions/slackware-14/listing-non-stock-slackware-packages-642787/ source /etc/functions-colors # Get the Slackware file list # wget http://slackware.osuosl.org/slackware-$VERSION/STOCKLIST.TXT VERSION="`cat /etc/slackware-version | awk '{print $2}' | sed -e 's/.0//'`" ROOTPATH="/home/public/slackware/$VERSION" STOCKLIST="$ROOTPATH/FILELIST.TXT" if [ ! -e "$ROOTPATH" ]; then if [ -n "$PS1" ] ; then # This shell is interactive echo -e "${BOLDRED}The directory ${BOLDWHITE}$ROOTPATH${BOLDRED} does not exist. Exiting.${COLOR_RESET}" else # This shell is not interactive echo "The directory $ROOTPATH does not exist. Exiting." fi exit 1 fi PATCHESLIST="$ROOTPATH/patches/FILE_LIST" EXTRALIST="$ROOTPATH/extra/FILE_LIST" STOCKPGKS="$HOME/tmp/stockpackages.txt" PATCHESPGKS="$HOME/tmp/patchpackages.txt" EXTRAPGKS="$HOME/tmp/extrapackages.txt" ALLPKGS="$HOME/tmp/allpackages.txt" DIFFSTOCKPKGS="$HOME/tmp/diffstockpkgs.txt" DIFFALLPKGS="$HOME/tmp/diffallpkgs.txt" DIFFALLPKGS2="/home/public/tmp" # alternate storage location # 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. echo "Checking stock packages..." for i in $(cat $STOCKLIST | grep .tgz$ | grep \/slackware\/ | \ awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \ sort > $STOCKPGKS # Make a list of the installed packages and sort them just as the above # file ls -A /var/log/packages/ | sort > $ALLPKGS # Show only the packages ADDED by you, INCLUDING the official Slackware # patches diff -U 0 $STOCKPGKS $ALLPKGS | grep -v \@\@$ | grep ^\+ | \ grep -v \+\+\+ | sed 's/^+//g' | sort > $DIFFSTOCKPKGS # Get the patches file list # wget http://slackware.osuosl.org/slackware-$VERSION/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. if [ -e "$PATCHESLIST" ]; then echo "Checking patches..." for i in $(cat $PATCHESLIST | grep .tgz$ | grep \/packages\/ | \ awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \ sort > $PATCHESPGKS # Show only diff -U 0 $PATCHESPGKS $DIFFSTOCKPKGS | grep -v \@\@$ | grep ^\+ | \ grep -v \+\+\+ | sed 's/^+//g' | sort > $DIFFALLPKGS else cp $DIFFSTOCKPKGS $DIFFALLPKGS fi # Get the extra file list # wget http://slackware.osuosl.org/slackware-$VERSION/extra/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. # if [ -e "$EXTRALIST" ]; then # echo "Checking extra..." # for i in $(cat $EXTRALIST | grep .tgz$ | grep \/packages\/ | \ # awk '{ print $8 }'); do basename $i; done | sed 's/.tgz$//g' | \ # sort > $EXTRAPGKS # # Show only # diff -U 0 $EXTRAPGKS $DIFFSTOCKPKGS | grep -v \@\@$ | grep ^\+ | \ # grep -v \+\+\+ | sed 's/^+//g' | sort > $DIFFALLPKGS # else # cp $DIFFSTOCKPKGS $DIFFALLPKGS # fi # the end rm -f $DIFFSTOCKPKGS 2> /dev/null rm -f $ALLPKGS 2> /dev/null rm -f $PATCHESPGKS 2> /dev/null rm -f $STOCKPGKS 2> /dev/null rm -f $EXTRAPGKS 2> /dev/null cp $DIFFALLPKGS $DIFFALLPKGS2 if [ -n "$PS1" ] ; then # This shell is interactive echo "A list of non-stock Slackware packages is available in:" echo -e "${BOLDGREEN}$DIFFALLPKGS${COLOR_RESET}" echo "and" echo -e "${BOLDGREEN}$DIFFALLPKGS2${COLOR_RESET}" else # This shell is not interactive echo "A list of non-stock Slackware packages is available in:" echo "$DIFFALLPKGS" echo "and" echo "$DIFFALLPKGS2" fi