LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-23-2012, 01:03 AM   #1
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
14.0RC2 vs. 13.37: strange Bash script failure


Hi,

I'm using a "master" build script to build my extra packages, so once Slackware is installed, I can pretty much launch the script, and it will fetch stuff and build it in the right order. Here's what the script looks like:

Code:
#!/bin/sh
# Copyright (c) 2012 Niki Kovacs <info@microlinux.fr>
# -----------------------------------------------------------------------------
#
# This script builds Slackware packages listed in the 'packages'
# file. It puts them in the Slackware directory. If the package already exists
# in slackware/ *and* if it's already installed, the script skips to the next
# package, otherwise it builds and installs the package, until all packages
# listed in the package file are built.

CWD=`pwd`
SOURCEDIR=${CWD}/source
case $(uname -m) in
  x86_64) OUTPUT=$CWD/slackware/x86_64 ;;
  *     ) OUTPUT=$CWD/slackware/i486 ;;
esac
export OUTPUT

# Set the number of parallel make jobs
if [ -z "$NUMJOBS" ]; then
  case $(uname -m) in
    x86_64) NUMJOBS="-j4" ;;
    *     ) NUMJOBS="-j2" ;;
  esac
  export NUMJOBS="$NUMJOBS"
fi

PACKAGES=$(egrep -v '(^\#)|(^\s+$)' $CWD/packages)

for PACKAGE in ${PACKAGES} ; do
  if [ -r ${OUTPUT}/${PACKAGE}-[0-9]*.tgz ] ; then
    if [ -r /var/log/packages/${PACKAGE}-[0-9]* ] ; then
      continue
    fi
  fi
  echo
  echo "+=============================================================================="
  echo "| Building package ${PACKAGE}..."
  echo "+=============================================================================="
  echo 
  sleep 3

  (
    cd ${SOURCEDIR}/${PACKAGE} || exit 1
    ./${PACKAGE}.SlackBuild || exit 1
  )
  upgradepkg --reinstall --install-new ${OUTPUT}/${PACKAGE}-[0-9]*.tgz || exit 1
done

echo 
echo "+=============================================================================="
echo "| Successfully built and installed all packages !"
echo "+=============================================================================="
echo
Rough description of what the script does:

1) it reads the names of packages to build in an external 'packages' file, which is basically a list, one package per line, with a few comments.

2) It checks if the package has already been built before AND if it's installed.

3) If not, it builds the package, puts it into the OUTPUT directory and installs it.

Now strangely enough, the script works perfectly with 13.37 (as it has always worked with previous versions of Slackware since around 10.2).

But under 14.0RC2, it fails. I get a "binary operator expected" message at the if... then statements that do the testing if the package is installed and present in the OUTPUT directory.

What happens is if a package is installed AND it's in the OUTPUT directory, the script fails and builds it anyway, instead of skipping to the next package that's not yet built/installed.

Any idea what's wrong here?

Last edited by kikinovak; 08-23-2012 at 01:06 AM.
 
Old 08-23-2012, 02:08 AM   #2
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Original Poster
Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
OK, I guess I got the culprit. I took a peek in /var/log/packages, and it seems like 'upgradepkg' has got a new behaviour. When I use it with --reinstall --install-new on an already installed package, I get a second entry in /var/log/packages, the second one having a timestamp added to the tag.

Considering that, it's normal my test fails, since if [ -r FILE ] expects a single file as an argument and fails when there are more than one.

Phew.
 
Old 08-23-2012, 02:19 AM   #3
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Why would you ever use --reinstall and --install-new together? I think they are supposed to be mutually exclusive. I mean, just look at what the options are called. If it is new, it isn't a reinstall and if it is a reinstall it isn't new.
 
Old 08-23-2012, 02:23 AM   #4
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Just take out --reinstall. The packages that are already installed with the same version number will be skipped by upgradepkg anyway and new packages will be installed.
 
Old 08-23-2012, 03:09 AM   #5
phenixia2003
Senior Member
 
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
Quote:
Originally Posted by kikinovak View Post
OK, I guess I got the culprit. I took a peek in /var/log/packages, and it seems like 'upgradepkg' has got a new behaviour. When I use it with --reinstall --install-new on an already installed package, I get a second entry in /var/log/packages, the second one having a timestamp added to the tag.

Considering that, it's normal my test fails, since if [ -r FILE ] expects a single file as an argument and fails when there are more than one.

Phew.
Hello,

I guess your issue is elsewhere since nothing (except pkgtool's version number) has been changed in upgradepkg since 13.37 :
Code:
$ diff -Nausr 13.37/ 14.0/

Files 13.37//install/slack-desc and 14.0//install/slack-desc are identical
Files 13.37//sbin/explodepkg and 14.0//sbin/explodepkg are identical
Files 13.37//sbin/installpkg and 14.0//sbin/installpkg are identical
Files 13.37//sbin/makebootdisk and 14.0//sbin/makebootdisk are identical
Files 13.37//sbin/makepkg and 14.0//sbin/makepkg are identical
diff -Nausr 13.37//sbin/pkgtool 14.0//sbin/pkgtool
--- 13.37//sbin/pkgtool 2011-03-07 19:14:54.000000000 +0100
+++ 14.0//sbin/pkgtool  2012-08-09 20:38:10.000000000 +0200
@@ -212,7 +212,7 @@
  CMD_START="true"
  rm -f $TMP/SeT*
  while [ 0 ]; do
-  dialog --title "Slackware Package Tool (pkgtool version 13.37)" \
+  dialog --title "Slackware Package Tool (pkgtool version 14.0)" \
 --menu "\nWelcome to the Slackware package tool.\n\
 \nWhich option would you like?\n" 17 75 7 \
 "Current" "Install packages from the current directory" \
Files 13.37//sbin/removepkg and 14.0//sbin/removepkg are identical
Files 13.37//sbin/upgradepkg and 14.0//sbin/upgradepkg are identical
Files 13.37//usr/man/man8/explodepkg.8 and 14.0//usr/man/man8/explodepkg.8 are identical
Files 13.37//usr/man/man8/installpkg.8 and 14.0//usr/man/man8/installpkg.8 are identical
Files 13.37//usr/man/man8/makepkg.8 and 14.0//usr/man/man8/makepkg.8 are identical
Files 13.37//usr/man/man8/pkgtool.8 and 14.0//usr/man/man8/pkgtool.8 are identical
Files 13.37//usr/man/man8/removepkg.8 and 14.0//usr/man/man8/removepkg.8 are identical
Files 13.37//usr/man/man8/upgradepkg.8 and 14.0//usr/man/man8/upgradepkg.8 are identical
Files 13.37//var/log/setup/setup.70.install-kernel and 14.0//var/log/setup/setup.70.install-kernel are identical
Files 13.37//var/log/setup/setup.80.make-bootdisk and 14.0//var/log/setup/setup.80.make-bootdisk are identical
Files 13.37//var/log/setup/setup.htmlview and 14.0//var/log/setup/setup.htmlview are identical
Files 13.37//var/log/setup/setup.services and 14.0//var/log/setup/setup.services are identical

After looking at upgradepkg's code, the "TIMESTAMP" are used to mark packages to remove (starting at line #286) :

Code:
# Showtime.  Let's do the upgrade.  First, we will rename all the
# installed packages with this basename to make them easy to remove later:

TIMESTAMP=$(date +%Y-%m-%d,%T)
...
for installed_package in $ROOT/var/log/packages/$SHORT* ; do
  if [ "$(package_name $installed_package)" = "$SHORT" ]; then
    mv $installed_package ${installed_package}-upgraded-$TIMESTAMP
  fi
done
And, starting at line #348 :
Code:
    for rempkg in *-$TIMESTAMP ; do
      if [ "$VERBOSE" = "verbose" ]; then
        ROOT=$ROOT /sbin/removepkg $rempkg

--
SeB

Last edited by phenixia2003; 08-23-2012 at 03:11 AM.
 
  


Reply

Tags
bash, error, script



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
[SOLVED] Strange characters in bash script.... cryingthug Programming 16 05-20-2012 02:34 PM
[SOLVED] bash script failure in Mint 9 Isadora seannachie Linux - Newbie 5 10-30-2011 11:43 AM
Strange behavior when killing bash through a script alirezan1 Linux - Newbie 3 03-12-2009 07:29 PM
Strange if statement behaviour when using bash/bash script freeindy Programming 7 08-04-2008 06:00 AM
A strange bash script kingsyl Linux - Newbie 2 07-13-2004 11:07 PM

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

All times are GMT -5. The time now is 03:14 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