Hi,
I have a helper script trim_server_base.sh that does two things:
- Install needed packages
- Remove unneeded packages
The script reads package names from two different text files and then proceeds to remove unwanted packages and to add needed packages. Here's a part of it:
Code:
CWD=$(pwd)
CRUFT=$(egrep -v '(^\#)|(^\s+$)' $CWD/pkglists/server-base-remove)
INSTALL=$(egrep -v '(^\#)|(^\s+$)' $CWD/pkglists/server-base-add)
for PACKAGE in $CRUFT; do
if [ -r /var/log/packages/${PACKAGE}-[0-9]* ] ; then
/sbin/removepkg ${PACKAGE}
fi
done
unset PACKAGES
for PACKAGE in $INSTALL; do
if [ ! -r /var/log/packages/${PACKAGE}-[0-9]* ] ; then
PACKAGES="$PACKAGES $PACKAGE"
fi
done
if [ -z $PACKAGES ]; then
continue
else
/usr/sbin/slackpkg install $PACKAGES
fi
Once slackpkg is configured correctly, the script works as expected... except for those Slackware packages with weird alphanumeric package version strings. Here's some examples from Slackware 14.0
- cdparanoia-III_10.2-i486-1
- libjpeg-v8a-i486-1
- iputils-s20101006-i482-2
- netdate-bsd4-i486-1
How can I "expand" my Bash syntax to fit these special cases?
Cheers,
Niki