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.
Here are two scripts for Slackware that I have written that can help with some of the packager's out there. I was inspired to write these scripts after I found thegeekster had posted some of his scripts. For anyone who missed that thread here is the link.
buildpkg
Buildpkg is a script that will recreate a Slackware package what was installed on your system, if you have lost the original. It could also be useful for some dial-up people, who do not want to go and redownload the original package.
Code:
#!/bin/bash
#
# The purpose of this script is to recreate a Slackware package
# from your disk. Basicly the opposite of installpkg, where
# installpkg will install software on your system. This script
# will recreate the Slackware package that was installed, if you
# misplaced the original package, but still have it installed.
#
# This software is released and licensed under the GPL v2, for
# further documentation look at http://www.gnu.org/copyleft/gpl.html
#
# Author: James Caffrey <jamescaffrey@gmail>
# Version: 1.3.1
#
#
# Some variables
VER=1.3.1
CWD=`pwd`
PKGDB="/var/log/packages"
PKGDBS="/var/log/scripts"
# Exit Status
# 0 Clean
# 1 Did not pass sanity checks
# 2 Errors
# 3 Package not found
# Sanity checks
if [ "`whoami`" != "root" ]; then
echo
echo "ERROR: You must be root!"
echo
exit 1
fi
if [ ! -e "/sbin/makepkg" ]; then
echo
echo "ERROR: You seem to be missing /sbin/makepkg you"
echo " should get it from a Slackware mirror."
echo
exit 1
fi
if [ ! -d "$PKGDB" -o -d "PKGDBS" ]; then
echo
echo "ERROR: You are missing one or both of the following"
echo " directories: /var/log/packages /var/log/scripts"
echo " Please install pkgtools from a Slackware mirror"
echo
exit 1
fi
# Functions
usage() {
cat << EOF
`basename $0` $VER
A tool to rebuild a Slackware package from hard disk. This can
be used to rebuild the package, when you have lost it, but it is
still installed on your system.
Options:
-n|--no-cleanup Will not cleanup the tmp directory when done
-t|--tmp Sets tmp directory. Default:/var/tmp/buildpkg
-h|--help Shows this help message
-v|--version Displays version information
Usage:
`basename $0` [options] <package_name>
EOF
}
count_args() {
args=$#
}
show_list() {
while true
do
echo
echo "More than one package was found with the name $PKGNAME"
echo "so here is a list of packages that match your description"
echo "Please choose one:"
#give a list
find $PKGDB -type f -name "*$PKGNAME*" -exec basename {} \; | sort
echo
echo -n "Enter package name here: "
read PKGNAME
#make sure we have the full package
#name so we can break it down later
count_args `find $PKGDB -type f -name "*$PKGNAME*" -exec basename {} \;`
if [ "$args" = "1" ]; then
#we got it
PKGNAME=`find $PKGDB -type f -name "*$PKGNAME*" -exec basename {} \;`
return
fi
if [ "$args" = "0" ]; then
echo
echo "Your package name $PKGNAME could not be found"
echo
exit 2
fi
done
}
# Just one more sanity check :)
if [ $# = 0 ]; then
usage
exit 0
fi
# Parse args
CLEANUP=1
while [ $1 ]
do
case $1 in
-h|--help) usage; exit 0 ;;
-v|--version) echo "`basename $0` $VER"; exit 0;;
-n|--no-cleanup) CLEANUP=0;;
-t|--tmp) TMP=$OPTARG;;
*) PKGNAME="`basename $1 .tgz`";;
esac
done
# Setup a tmp directory
TMP=${TMP:-/var/tmp/buildpkg}
if [ ! -d $TMP ]; then
mkdir -p $TMP
fi
# Get full package name
count_args `find $PKGDB -type f -name "*$PKGNAME*" -exec basename {} \;`
#count_args sets the args variable
case $args in
0)
echo
echo "Your package $PKGNAME could not be found"
echo
exit 3;;
1)
PKGNAME=`find $PKGDB -type f -name "*$PKGNAME*" -exec basename {} \;`
;; #we should be good
*)
show_list
;;
esac
# Break down package name
i=1
while [ ! "`echo $PKGNAME | cut -f $i -d -`" = "" ]
do
i=`expr $i + 1`
done
i=`expr $i - 1` #exclude null value
NAME=`expr $i - 3`
NAME="`echo $PKGNAME | cut -f 1-$NAME -d -`"
VERSION=`expr $i - 2`
VERSION="`echo $PKGNAME | cut -f $VERSION -d -`"
ARCH=`expr $i - 1`
ARCH="`echo $PKGNAME | cut -f $ARCH -d -`"
BUILD="`echo $PKGNAME | cut -f $i -d -`"
# Setup work space, and hierarchy
PKGDIR="$TMP/package-$NAME"
if [ ! -d "$PKGDIR" ]; then
mkdir -p $PKGDIR
fi
mkdir -p $PKGDIR/install
# Copy files
for files in `cat $PKGDB/$PKGNAME | grep -v "$NAME:" | grep -v "PACKAGE" | grep -v "FILE LIST:"`
do
if [ "$files" = "install/slack-desc" ]; then
cat $PKGDB/$PKGNAME | grep "$NAME:" > $PKGDIR/install/slack-desc
elif [ "$files" = "install/doinst.sh" ]; then
#some packages have the "upgraded" status in
#their file name, so we have to account for that
if [ -e "$PKGDBS/$PKGNAME" ]; then
cat $PKGDBS/$PKGNAME > $PKGDIR/install/doinst.sh
else
#when packages do have the "upgraded" status, their
#file name is usually not equal to PKGNAME most of
#the time the revision is different. Not perfect I
#know, but it hasn't failed yet. :)
find $PKGDBS -name "*$NAME-$VERSION*" -exec cat {} > $PKGDIR/install/doinst.sh \;
fi
elif [ -f "/$files" ]; then
#maybe the .new file still remains
cp -p "/$files" "$PKGDIR/`dirname $files`"
elif [ -f "/`dirname $files`/`basename $files .new`" ]; then
#we have to replace the .new
cp -p "/`dirname $files`/`basename /$files .new`" "$PKGDIR/`dirname $files`"
DIR=`pwd`
cd "$PKGDIR/`dirname $files`"
OLD=`basename $files .new`
mv $OLD "$OLD.new"
cd $DIR
elif [ -d "/$files" ]; then
#its a directory
mkdir -p $PKGDIR/$files
elif [ "$files" = "install/" ]; then
#there is no /install directory
#true
continue
else
echo
echo "ERROR: $files could not be found"
echo " still continuing"
echo
fi
done
# Correct permissions
for dir in /bin /usr/bin /sbin /usr/sbin /usr/X11R6/bin ; do
if [ -d "$PKGDIR/$dir" ]; then
chown -R root.bin $PKGDIR/$dir
fi
done
# Make the package
cd $PKGDIR
/sbin/makepkg -l y -c n $NAME-$VERSION-$ARCH-$BUILD.tgz
# Housekeeping stuff
cp $NAME-$VERSION-$ARCH-$BUILD.tgz $CWD
cd $CWD
if [ "$CLEANUP" -eq "1" ]; then
rm -rf $PKGDIR
fi
exit 0
#########################ChangeLog###############################
# #
# 20050424 1.3.1 #
# *Modified exit status #
# *Code cleanup with parsing arguments #
# *Minor code clean, using parameter expansion #
# instead of if statement #
# #
# 20050401 1.3 #
# *Optimized package searching by using -name #
# with the find command as opposed to piping #
# all data through grep #
# #
# 20050326 1.2 #
# *Cleanup the Copying Files loop to be more #
# friendly with .new files. #
# #
# *Allowed package searching for input with #
# less than full name ie: foo #
# #
# 20050309 1.1 #
# *Packages with a dash in the "name" now work #
# #
# 20050308 1.0 #
# *Initial release #
# #
#################################################################
# End of buildpkg
viewpkg
Viewpkg is a tool for examining Slackware packages. It is similar to explodepkg, but without writing to the hard disk, it just displays the contents of the package through a pager.
Code:
#!/bin/bash
#
# The purpose of this software/script is to allow the user
# to view the contents of a Slackware package with out having
# to install, or untar (explode) the package.
#
# This software is released and licensed under the GPL v2, for
# further documentation look at http://www.gnu.org/copyleft/gpl.html
# Some minor parts of this script were taken from the /sbin/installpkg
# on a Slackware 10.1 system. Those parts are protected by the copyright
# and disclaimer below.
#
# Copyright 1994, 1998, 2000 Patrick Volkerding, Concord, CA, USA
# Copyright 2001, 2003 Slackware Linux, Inc., Concord, CA, USA
# All rights reserved.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Author: James Caffrey <jamescaffrey@gmail.com>
# Version: 1.4.1
#
# Version of viewpkg
VER=1.4.1
CWD=`pwd`
PAGER=${PAGER:-/usr/bin/less}
usage() {
#displays how to use viewpkg
cat << EOF
viewpkg $VER
A tool to view the contents of a Slackware package. Similar
to explodepkg but without writing the whole package to your
hard disk. Viewpkg is used for examining and debugging.
Options:
-h|--help Displays this help message
-v|--version Displays version information
Usage:
`basename $0` [options] package_name
EOF
}
crunch() {
# This function, and the implementation that
# it serves was borrowed from /sbin/installpkg.
# Thanks Pat. :)
while read foo
do
echo $foo
done
}
#if no args, bomb out
if [ $# = 0 ]; then
usage
exit 1
fi
# Parse the args
while [ "$1" ]
do
case $1 in
-h|--help)
usage
exit 1
;;
-v|--version)
echo "viewpkg $VER"
exit 1
;;
*)
#we use basename, so if user passes a
#package name that is not in pwd
PKGDIR="`dirname $1`"
PKGNAME="`basename $1`"
if [ ! -e $1 ]; then
echo
echo "ERROR: package does not exist"
echo
exit 1
fi
shift
;;
esac
done
# Check to see if is a package, not
# just a tar gzip'd archive
cd $PKGDIR
if [ "`echo $PKGNAME | rev | cut -f 1 -d . | rev`" != "tgz" ]; then
echo
echo "ERROR: package name given, is not a package"
echo " it do not have a .tgz extension"
echo
exit 2
fi
# Some temp files
TMPPERM="/tmp/`basename $0`-$$-1"
TMPFILE="/tmp/`basename $0`-$$-2"
# Breakdown the package name
i=1
while [ ! "`echo $PKGNAME | cut -f $i -d -`" = "" ]
do
i=`expr $i + 1`
done
i=`expr $i - 1` #exclude null value
NAME=`expr $i - 3`
NAME="`echo $PKGNAME | cut -f 1-$NAME -d -`"
#currently not using these, but maybe for future use
#VERSION=`expr $i - 2`
#VERSION="`echo $PKGNAME | cut -f $VERSION -d -`"
#ARCH=`expr $i - 1`
#ARCH="`echo $PKGNAME | cut -f $ARCH -d -`"
#BUILD="`echo $PKGNAME | cut -f $i -d -`"
(
# Give a nice header
echo "Package Name: `basename $PKGNAME .tgz`"
COMPRESSED=`gzip -l $PKGNAME | grep -v ratio | crunch | cut -f 1 -d ' '`
echo "Compressed Package Size: `expr $COMPRESSED / 1024` K"
UNCOMPRESSED=`gzip -l $PKGNAME | grep -v ratio | crunch | cut -f 2 -d ' '`
echo "Uncompressed Package Size: `expr $UNCOMPRESSED / 1024` K"
echo "Package Location: $PKGDIR/$PKGNAME"
echo "Package Description:"
# Find and print out slack-desc
cd $PKGDIR
tar -ztvf $PKGNAME | grep "slack-desc" > /dev/null
if [ $? = 0 ]; then
tar -zxOf $PKGNAME install/slack-desc | grep $NAME
else
echo
echo "No slack-desc file found in package. I guess"
echo "that is problem one with this package. :)"
echo
fi
# Print out all files in archive
echo
echo "File List:"
#this gets permissions and ownerships
tar -ztvf $PKGNAME | cut -b 1-23 > $TMPPERM
#this gets directories and files
tar -ztvf $PKGNAME | cut -f 3 -d : | cut -c 4- > $TMPFILE
#lets put them together
paste $TMPPERM $TMPFILE
#this worked most of the time, execpt with
#files that were large you would see part
#of the file size listed
#tar -ztvf $PKGNAME | cut -b 1-24,52-
# Find and print out doinst.sh
echo
echo "Installation Script:"
tar -ztvf $PKGNAME | grep "doinst.sh" > /dev/null
if [ $? = 0 ]; then
tar -zxOf $PKGNAME install/doinst.sh
fi
) | $PAGER
# Cleanup
rm -f $TMPPERM
rm -f $TMPFILE
cd $CWD
#########################ChangeLog###############################
# #
# 20050424 1.4.1 #
# *Simplify the implementation of checking #
# for if file is a Slackware package. #
# *Minor code clean up; elminated an if #
# statement by using parameter expansion #
# #
# 20050405 1.4 #
# *Added showing of compressed and #
# uncompressed package size, mostly #
# borrowed from /sbin/installpkg, #
# thanks Pat. :) #
# #
# 20050326 1.3 #
# *Added checking it see if file given #
# is a Slackware package. Other wise #
# any gzip'd tar file would work but #
# but give errors #
# #
# 20050318 1.2 #
# *Updated engine which displays #
# file list #
# #
# 20050315 1.1 #
# *Bug fixes, improper detection #
# of slack-desc and doinst.sh files #
# #
# 20050310 1.0 #
# *Initial release #
# #
#################################################################
Is there anywhere we could put up all the various SlackBuild / other Slackware scripts? Otherwise they're likely to keep disappearing into the mists of time...
I am glad that you like them. I will post any other that I come up with. It would be nice to have a central location for all the scripts/SlackBuilds that the community contributes.
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Rep:
I'm interested in using this slackbuid script. Here's my situation-Slack 10 is on my 4 GB laptop harddrive (no second drive and I only have a 128 MB usb stick). I am networked to a Fedora Core Linux pc with 26 GB. My current drive is almost full with only 600 MB free. If I use the build script it'll probably need around 3 GB-can I save this info onto my networked pc drives?
For the heck of it, Ill post a few of my own slackware scripts. These are for speeding up package installation. Some of the comments and variables are in finnish, sorry bout that, but its pretty simple anyways. 'purkinavaaja' means Can Opener in english, thus the name.. (; Theyre still a work in progress, and need a tad of modifying to suit your likings (I save all hand installed .tgz's, most people dont)
purkinavaaja.sh
Code:
#!/bin/bash
#debug
#echo $(date) - $1 >> purkki-dump
asennatgz() {
sudo /usr/sbin/beep -r 2
aterm -e tgzswitch $kohde
exit 0
}
# main handling code
mv $1 ~/
kohde=~/$(echo $1 | cut -d "/" -f 3)
#echo $kohde > purkki-dump
# extracting..
# type?
data=$(file $kohde)
# tgz
if echo $kohde | grep ".tgz" ; then
asennatgz
fi
# tar.gz
if echo $data | grep gzip ; then
purin='tar xzf '
fi
# tar.bz2
if echo $data | grep bzip2 ; then
purin='tar xjf '
fi
# zip
if echo $data | grep Zip ; then
purin='unzip'
fi
puraiso() {
mount -t iso9660 $1 /mnt/iso -o loop
}
# iso, experimental
if echo $data | grep ISO ; then
purin='puraiso'
fi
mkdir -p ~/extract-tmp
cd ~/extract-tmp/ && $purin $kohde
# all done, notify user
sudo /usr/sbin/beep -r 2
exit 0
Now, that was pretty basic stuff, but its a nifty script to use as an interceptor for firefox. Just check toe remember checkmark, and everytime you download a package, it gets sent to the "can opener" automagickly.. Imporeves my productivity alot. When its all set, you get a nice beep notify. (requires beep to be installed, and a passwordless sudo done for your user. Now, I use aterm for the terminal app, but that is modifiable ofcourse.)
Then the serious speedup. The "can opener" activates this script when intercepting a tgz, triggering an easy install / upgrade, which tries to figure if we have similar packages installed allready, and shows you the pkg description even before installing.
tgzswitch
Code:
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: $0 package.tgz"
exit 1
fi
if [ ! $(whoami) == "root" ]; then
echo "you must be root"
if ! su -c "tgzswitch $*" ; then tgzswitch $* ; fi
exit $?
fi
package=$(basename $1)
pkgname=$(echo $package | cut -d "-" -f 1)
tar xzOf - install/slack-desc < $package | grep $pkgname
echo
echo "What will it be, install or upgrade?"
if ls /var/log/packages/*$pkgname* >/dev/null 2>&1 ; then
echo "We scavenged this from /var/log/packages/:"
ls /var/log/packages/*$pkgname*
fi
echo -n "[install/upgrade]: "
read toiminto
clear
$toiminto\pkg $package
logname=$(basename $package .tgz)
if grep "bin/*" /var/log/packages/$logname* >/dev/null 2>&1 ; then
echo "Installed binaries:"
grep "bin/*" /var/log/packages/$logname* | grep -iv "bin/ "
fi
echo -n "Archiving package... "
mv $package /share/packages/tgz/
echo "done"
echo -n "Ready to exit? "
read valmis
Ill be englishifying them some more when manage to snatch the time for it, and ofcourse add nifty new features.. (;
Hope someone else benefits from my scripts, ive made em mostly to counter my own frustration with slapt-get and swaret, so to couter that, now I can do fast and easy installs by downloading the packages I want with firefox.. Just associate tar.gz, tar, tgz and the likes of that with the "can opener"
Is there anywhere we could put up all the various SlackBuild / other Slackware scripts? Otherwise they're likely to keep disappearing into the mists of time...
Here's a site I came across. Maybe everyone should try sending in their Slackbuilds.
pkgtools must include these 2 scripts buildpkg and viewpkg for better Package Management and improved productivity.
Here's a scenario:
1. you have created a package and installed on your system
2. your friend needs that package and you put your CD/DVD somewhere
3. Buildpkg can re-create the package and allows you to get it back
4. you are happy and your friend is happy
There is minimal difference between the commands that you specified,
and buildpkg, except it is done with a single command. Know I tried your
commands, and they worked great, but there is one minor defect. It
does not replace any of the .new files. Allow me to elaborate. Take any
package that has a config file that Pat has renamed with .new and has
added the config() fucntion to the ./install/doinst.sh of the package, when
using your commands, if the .new does not exsit, then it will be omitted
when removepkg copies the files to the preserved_packages directory.
I hope that was explained correctly, and throughly enough.
Tank is it possible to get these two scripts in text format or as a gzipped file?
Pasting from the browser doesn't seem to work too well.
Perhaps you'd mail them to me at amigo@ibiblio.org ?
Thanks!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.