SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've recently switched over to slamd64 on my new box, as it's capable of 64-bit computing, and I tried to use the slackupdate script as I usually do: http://darklinux.net/slackupdate/
But, it didn't work, first it wanted a '/etc/slackware-version', then after some modification it kept complaining about GPG, then after some modification, it still failed. So I quit modifying it, deleted it and made my own. I actually made my own update script earlier, but deleted it because it was crap. However after about many hours of careful scripting I think I made a better one, and not only that, but one that works with both slackware and slamd64 and any slack* that has a CHECKSUMS.md5 and a packages directory with packages to be updated in it. So here it is, it is released under GPL v2 (if that's possible):
Code:
#!/bin/sh
# universal slack updater
# USER CONFIG SECTION START
# point this to the slack version directory of your favorite slack server
server="http://anorien.warwick.ac.uk/mirrors/slamd64/slamd64-12.1"
#server="http://slackware.mirrors.tds.net/pub/slackware/slackware-12.1"
# patches directory and main packages directory
patches="$server/patches"
slack="$server/slackware"
# config directory
config=~/.usu
# temporary directory
temp=/tmp/usu
# USER CONFIG SECTION END, it's recommended you do NOT edit below this line
#______________________________________________________________________________
# function that chops up package names in given directory
chopnames()
{
# filter the list for names, version, arch, release
cut -d - -f 1 "$1/revpacknames" | rev >> "$1/release"
cut -d - -f 2 "$1/revpacknames" | rev >> "$1/arch"
cut -d - -f 3 "$1/revpacknames" | rev >> "$1/version"
cut -d - -f 1-3 --complement "$1/revpacknames" | rev >> "$1/names"
}
# insure sanity of config directory
# if config is a directory
if test -d "$config"
then
# if blacklist is not a file
if test ! -f "$config/blacklist"
then
rm -rf "$config/blacklist"
echo > "$config/blacklist"
fi
# if update is not a directory
if test ! -d "$config/update"
then
rm -f "$config/update"
mkdir "$config/update"
fi
# if original is not a directory
if test ! -d "$config/original"
then
rm -f "$config/original"
mkdir "$config/original"
fi
# if config is not a directory
else
rm -f "$config"
mkdir "$config"
mkdir "$config/update"
mkdir "$config/original"
echo > "$config/blacklist"
fi
# clear and ready the temporary directory
if test -e "$temp"
then
rm -rf "$temp"
fi
mkdir "$temp"
mkdir "$temp/packages"
mkdir "$temp/installed"
mkdir "$temp/update"
mkdir "$temp/original"
cd "$temp"
# get list of packages to be updated if newer
if ! wget -N -P "$config/update" "$patches/CHECKSUMS.md5"
then
echo
echo "Error downloading $patches/CHECKSUMS.md5 from server !"
echo
# fail
exit 1
fi
# get list of original packages if newer
if ! wget -N -P "$config/original" "$slack/CHECKSUMS.md5"
then
echo
echo "Error downloading $slack/CHECKSUMS.md5 from server !"
echo
# fail
exit 1
fi
# filter these lists for tgz only
cat "$config/update/CHECKSUMS.md5" | grep './packages/.*.tgz$' > update/filtered.md5
cat "$config/original/CHECKSUMS.md5" | grep './*/.*.tgz$' > original/filtered.md5
# generate list of update package names and its reverse
cat update/filtered.md5 | sed 's|/| |g' | awk '{ print $4 }' | sed 's|.tgz||g' | sort > update/packnames
rev update/packnames > update/revpacknames
# generate list of original package names and its reverse
cat original/filtered.md5 | sed 's|/| |g' | awk '{ print $4 }' | sed 's|.tgz||g' | sort > original/packnames
rev original/packnames > original/revpacknames
# generate installed packages list and its reverse
ls -1 /var/log/packages > installed/packnames
rev installed/packnames > installed/revpacknames
# run chopnames in the three directories
chopnames update
chopnames installed
chopnames original
# for every name in update see if there is a match in installed
comm -12 installed/names update/names > preaddnamematch
# add new packages if they are not installed
comm -23 update/names original/names > newname
comm -23 newname installed/names >> preaddnamematch
# sort
sort preaddnamematch > preblacknamematch
# remove blacklisted items if blacklist is not empty
if test $(cat $config/blacklist | wc -w) == 0
then
cat preblacknamematch > namematch
else
comm -3 preblacknamematch $config/blacklist > namematch
fi
# restore spaces for update
comm namematch update/names | sed 's|\t|#|' | awk '{ print $2 }' > updatenamematch
# restore spaces for installed
comm namematch installed/names | sed 's|\t|#|' | awk '{ print $2 }' > installednamematch
# generate update table
paste updatenamematch update/version update/arch update/release | sed '/^\t/ d' > updatetable
# generate installed table
paste installednamematch installed/version installed/arch installed/release | sed '/^\t/ d' > installedtable
# generate main table
paste updatetable installedtable > table
# parse main table
awk '{
# arch
if ( $3 == $7 )
{
# version
if ( $2 == $6 )
{
# release
if ( $4 != $8 )
{
printf("%s-%s-%s-%s.tgz\n", $1, $2, $3, $4);
}
}
else
{
printf("%s-%s-%s-%s.tgz\n", $1, $2, $3, $4);
}
}
}' table > install
# if install is empty, system is up-to-date, else get packages and generate md5sums file
if test $(cat install | wc -w) == 0
then
echo
echo "Your system is up-to-date !"
echo
# success
exit 0
else
# get packages
if ! wget -P packages -i install -B "$patches/packages/"
then
echo
echo "Warning downloading a package from server has falied !"
echo
fi
# generate md5sum
while read line
do
grep "$line" update/filtered.md5 >> md5sum.md5
done < install
# check md5sums
if md5sum -c md5sum.md5
then
echo
echo "Packages have been downloaded to $temp/packages"
echo "So, to install them run this as root:"
echo
echo "upgradepkg $temp/packages/*"
echo
# success
exit 0
else
echo
echo "md5sums do NOT match !"
echo
# failure
exit 1
fi
fi
The script has been completely rethought, rewritten, revised, etc. It should now work a lot better. It is still experimental ... not tested too much. So tell me via e-mail or PM if you use it and find bugs.
Features include the ability to check for updates to installed packages, completely new packages (scripts often omit this), and is specifically designed not to cause conflicts (avoid use of grep) as can sometimes happen when you have 32-bit compatibility apps installed (slackupdate cannot handle this properly and is too complicated for me to fix).
Last edited by H_TeXMeX_H; 04-16-2009 at 05:31 AM.
Reason: revised script
I wrote my own script in perl. You just point it to the site locations where you want to pull packages, and keep a list of packages you want. Then you run upgradepkg on the ones you want.
I made a new completely revised version of the script ... with new features.
I deleted the old script and made a new one. This one should be a lot better. I could not have made this one earlier because I just didn't know enough scripting ... really more a lack of experience. Either way I learned more from making this script that from any other script I have even written. Please report bugs if you decide to use it.
It's also way faster than the older one and probably significantly faster than slackupdate.
Last edited by H_TeXMeX_H; 04-03-2009 at 12:03 PM.
Which new (i.e. not available in slackpkg) features would I get with your script?
Not many, slackpkg is available for slamd64 now in 12.2, so there's not really any benefit for using this script over slackpkg. You can use either. Probably slackpkg has more features.
I guess I could try installing slackpkg from 12.2.
Either way I wrote this script for two reasons:
1) To learn how to script better.
2) Because I was unhappy with other update scripts I've tried. True, I haven't tried slackpkg, but will soon, probably when I upgrade.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.