LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-18-2008, 03:31 PM   #1
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
my slack* update script


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
You can also download it here:
http://draconishinobi.50webs.com/slackware/scripts.html

EDIT:

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
 
Old 07-19-2008, 08:23 AM   #2
the3dfxdude
Member
 
Registered: May 2007
Posts: 730

Rep: Reputation: 358Reputation: 358Reputation: 358Reputation: 358
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.
 
Old 04-03-2009, 12:01 PM   #3
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928

Original Poster
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
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.
 
Old 04-03-2009, 12:15 PM   #4
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Hi,

I use slackpkg to get updates for Slackare-current as well as Slackware-stable (12.2 at time of writing).

Which new (i.e. not available in slackpkg) features would I get with your script?

I can't easily check myself, as unfortunately I am not so good yet at bash scripting

Last edited by Didier Spaier; 04-03-2009 at 12:16 PM.
 
Old 04-03-2009, 01:18 PM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928

Original Poster
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Quote:
Originally Posted by Didier Spaier View Post
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.
 
Old 04-03-2009, 02:00 PM   #6
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Should I understand that you didn't upgrade to 12.2 yet ? IMHO it's worthwhile, as is slackpkg.

Anyhow, learn how to script better is definitely something I should do

Take care,

EDIT while you are at it, if you are a http://slackbuilds.org user, give a try to sbopk @ http://sbopkg.org/. Still in testing stage it's already very useful.

Last edited by Didier Spaier; 04-03-2009 at 02:07 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Update from Slack 10 to 12 failed oddo Slackware 6 01-21-2008 01:56 PM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 10:48 PM
update slack ahmed gamal Slackware 5 08-13-2006 01:52 AM
Update to Slack 10.2 linuxhippy Slackware 9 11-18-2005 06:44 PM
How to Update Slack Patches? Lucinda Slackware 6 05-15-2005 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration