LinuxQuestions.org
Help answer threads with 0 replies.
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 04-20-2010, 02:18 PM   #1
Lufbery
Senior Member
 
Registered: Aug 2006
Location: Harrisburg, PA
Distribution: Slackware 64 14.2
Posts: 1,180
Blog Entries: 29

Rep: Reputation: 135Reputation: 135
A new snag with my update_slackware.sh script ... and a solution!


Hi all

The script that I wrote (with a lot of help from the LQ crew) has worked exceptionally well. It is fast (download speed being the limiting factor), secure (it checks md5sums and GPG signatures), and fails in a sane way if something goes wrong.

It requires the user to be logged in as root, and works best when the user:
  1. Has a full installation of Slackware.
  2. Is running the -stable branch of Slackware.
  3. Has a directory set up on the hard drive for a persistent local mirror.
  4. Has a proper GPG personal key and has imported and signed the Slackware Security GPG key.
  5. Has not replaced packages from the default installation of Slackware with ones not maintained by the Slackware team.

The above list describes my installation pretty well. In the three and a half years that I've been running Slackware, starting with Slackware 11 in late 2006, I've only ever run a full installation of the stock -stable branch. I've added packages to Slackware that aren't included, but I've never replaced any until I decided to use the updated KDE 4.3.1 packages from Vincent Batts instead of the stock KDE 4.2.4 that comes with Slackware 13.

This last point is important for me because the Slackware developers released a a new patch for the kdebase-workspace-4.2.4 package today. So if I just run my script, I'll end up (most likely) breaking KDE! That's not a good thing.

The simple solution is to modify the lftp command in the script to exclude KDE patches, like so:

Code:
lftp -c "open slackware.mirrors.tds.net/pub/slackware/slackware64-13.0/patches/ ; mirror -e -n -X kde* packages"
One caveat: I need to test that command to make sure it does what I want it to do,

The larger issue, though, is the fact that so much of this script is hard-coded. The mirror location is hard coded, and with it, the Slackware version. Now I'm going to hard-code the blacklist. When I upgrade to the next version of Slackware, I'll need to update the script with new values.

Personally, I'm not bothered by this state of affairs. This is, after all, a script and not a true application (like slackpkg ). To make this script more generally useful, I would need to set up variables for the mirror, Slackware version, and blacklist -- all passed to the lftp line of the script. The variables would probably need to be stored in an update_slackware.conf file that I would update from time to time, when needed.

Right now, there's two things stopping me from making the script more general:
  1. I'm not sure how to pass variables to a command with Bash scripting.
  2. Editing the script is as easy as editing a configuration file.

The first point is interesting because one of the major points of this exercise was to learn more about using Bash scripting to simplify the computer stuff that I do. So I'm probably going to continue hacking on this script as time permits and see if I can learn how to create and pass variables to it.

Mostly, though, my main future goals on this script are to improve the comments add a copyright, give credit to those who helped me and contributed code, better document the use assumptions, and add some disclaimers about causing problems with one's installation if one isn't careful.

I also want to refine the error-checking and provide more useful messages when something fails.
 
Old 04-20-2010, 04:09 PM   #2
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by Lufbery View Post
The simple solution is to modify the lftp command in the script to exclude KDE patches, like so:

Code:
lftp -c "open slackware.mirrors.tds.net/pub/slackware/slackware64-13.0/patches/ ; mirror -e -n -X kde* packages"
One caveat: I need to test that command to make sure it does what I want it to do,
What if you upgrade a single package? Best to maintain a direct package blacklist I think. I know I have upgraded a few random packages here and there that are official. It would be nice to be informed of updates to these as well, in case you recompiled to add a feature, but then a new version is officially released (probably for security purposes) and your recompiled version is now vulnerable (and thus you should recompile the new version to include the compile-time feature you want). For example, I used to recompile Amarok to support MySQL. If you were not made aware of this (or if you don't study the ChangeLog like a hawk) you might be running an insecure program without knowing it.

Quote:
Originally Posted by Lufbery View Post
This is, after all, a script and not a true application (like slackpkg ).
Code:
$ file /usr/sbin/slackpkg
/usr/sbin/slackpkg: POSIX shell script text executable
slackpkg may be a more complex script but it is just that, a script.

Quote:
Originally Posted by Lufbery View Post
Right now, there's two things stopping me from making the script more general:
  1. I'm not sure how to pass variables to a command with Bash scripting.
Depends on what you mean by passing variables. You can pass variables to your script itself, or just pass variables to a command within your script. Variables are set with
Code:
VARIABLE="value"
and read with
Code:
$VARIABLE
So if you just want to pass options to a script, for example, the mirror location, you could use
Code:
MIRROR="slackware.mirrors.tds.net/pub/slackware/slackware64-13.0/patches/"
lftp -c "open $MIRROR ; mirror -e -n -X kde* packages"
Note that I believe that should work without fail in that instance with double quotes, but always be aware of quoting...single quotes would pass the literal $MIRROR.

Quote:
Originally Posted by Lufbery View Post
2. Editing the script is as easy as editing a configuration file.
Just have to source a configuration file that includes your variable settings for that.
Code:
. settings.cfg
or
Code:
source settings.cfg
would load all of the variables declared in settings.cfg.

Best to just go through a bash tutorial or browse other bash scripts and see what they're doing.
 
Old 04-21-2010, 07:49 AM   #3
Lufbery
Senior Member
 
Registered: Aug 2006
Location: Harrisburg, PA
Distribution: Slackware 64 14.2
Posts: 1,180

Original Poster
Blog Entries: 29

Rep: Reputation: 135Reputation: 135
T3slider,

Thanks for the response! I definitely need to spend more time with a Bash tutorial or two. I get the concepts, but not the syntax.

I'm thinking that what would be really cool is for the script to list the updated packages and offer me a choice of installing all or just some of them. Year (and years) ago, I made pretty sophisticated batch files in DOS that had menus. Right now, though, with both a four-year-old son and a four-month-old son, my computer time is rather limited.

Regards,
 
Old 04-21-2010, 12:01 PM   #4
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
I agree that a blacklist is essential, so I would recommend adding one (non-hard-coded). Take a look at my script (on the previous thread or on my site) for an easy way to add blacklist support.
 
Old 04-21-2010, 08:33 PM   #5
Lufbery
Senior Member
 
Registered: Aug 2006
Location: Harrisburg, PA
Distribution: Slackware 64 14.2
Posts: 1,180

Original Poster
Blog Entries: 29

Rep: Reputation: 135Reputation: 135
H_TeXMeX_H,

I've definitely got a lot to learn. Your blacklist is an excellent idea and it's implemented elegantly.

I need to do something like that now because the MD5sum checking fails if the KDE package isn't there; thereby aborting the script. I really need to parse what you've done, but it looks like you use grep and cut to modify the CHECKSUMS.md5 file to remove the lines with the blacklisted packages.

Regards,
 
  


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
Solution to inject script to multiple servers?? cdestiny Linux - Server 3 07-23-2008 01:14 PM
Script/Solution to problem?!?! PLEASE HELP xberetta21 Linux - Newbie 9 01-28-2008 09:56 AM
LXer: Sometimes a CGI script is the most elegant solution LXer Syndicated Linux News 0 03-02-2007 12:31 PM
Need a Document.all solution which transform any ma js script. nadavvin Linux - Software 1 11-10-2006 11:55 AM
Script as a backup Solution shawnbishop Linux - Software 3 04-14-2006 08:39 PM

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

All times are GMT -5. The time now is 04:30 AM.

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