LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 12-26-2006, 07:20 PM   #31
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 490
Blog Entries: 1

Rep: Reputation: 55

jong357:
Quote:
As of 1.15, we should stop calling tar with a j or z switch.
I didn't know that. I learn something new here every day. Thanks.
Regards,
Bill
 
Old 12-26-2006, 08:20 PM   #32
cdale77
Member
 
Registered: Oct 2006
Location: Berekeley
Distribution: Slackware 11; 2.6.21.1
Posts: 48

Rep: Reputation: 15
Shilo,

Great stuff, and perfect timing. I'm a newb, and I just discovered how great compiling programs is, and I usually use checkinstall. But there's a few key packages I want to build that I can't get to work (flightgear, anyone?). I would love to try this.

Are you going to take the feedback from others that I can't understand and post a revised version? That would be very, very helpful for the community.
 
Old 12-27-2006, 12:52 AM   #33
MannyNix
Member
 
Registered: Dec 2005
Location: ~
Distribution: Slackware -current, OpenBSD
Posts: 449

Rep: Reputation: 41
Quote:
Originally Posted by cdale77
(flightgear, anyone?). I would love to try this.
Yup, do you mean this one?
The .tgz is there. the slackbuild inside the src dir. Just edit to your needs and take a look at slack-requiered.

Quote:
Originally Posted by cdale77
Shilo,
Are you going to**** and post a revised version? That would be very, very helpful for the community.
I agree. Shilo is
 
Old 12-27-2006, 04:32 AM   #34
shilo
Senior Member
 
Registered: Nov 2002
Location: Stockton, CA
Distribution: Slackware 11 - kernel 2.6.19.1 - Dropline Gnome 2.16.2
Posts: 1,132

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by mannyslack
I agree. Shilo is
I disagree. I don't even make the top five list when you look at some of the other posters in this thread.

I have tried to incorporate several of the suggestions in this thread, along with some other stuff. It's a real work in progress. Comments are appreciated. Look out for any mistakes I may have made. I'm still not all that good at scripting and haven't tested this out very well. Also, If I didn't mention your contributions in the comments, I apologize.

If the general consensus is that this is an improvement, I will point the first post here.

Here we go:

Code:
#!/bin/sh

########################
# NOTES:
#
########################
#
# Add in thegeeksters stuff? (Mostly need to read it better so I understand it.)
#
# consider adding "update-desktop-database" to doinst.sh when .desktop files are present:
#   if [ -x usr/bin/update-desktop-database -a -x usr/bin/chroot ]; then
#     usr/bin/chroot /$ROOT /usr/bin/update-desktop-database &> /dev/null
#   fi
#
# When do I need the same for update-mime-database?
#   if [ -x usr/bin/update-mime-database -a -x usr/bin/chroot ]; then
#     usr/bin/chroot /$ROOT /usr/bin/update-mime-database /usr/share/mime &> /dev/null
#   fi
#
########################

########################
# Set initial variables:
# (If we're lucky, this is all that needs to be done manually.)
########################

NAME=			# Program name
PNAME=$NAME		# Package name (Useful for changing case, etc.)
VERSION=		# Program version
PVERSION=$VERSION	# Package version (Useful for removing "-"s, CVS/SVN builds, etc.)
ARCH=${ARCH:-i686}	# Package architecture
BUILD=${BUILD:-1}	# Build number
TAG=${TAG:-seb}	# Packager initials (use your own)

CWD=`pwd`
TMP=${TMP:-/tmp}	# Location to compile the source
PKG=$TMP/package-$NAME	# Location to build the package (use "package-$NAME" to avoid poss. conflicts)
OUTPUT=${OUTPUT:-/tmp}	# Location to save final package.

# List the package documentation.  Adjust accordingly.
PDOCS="AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README TODO TROUBLESHOOTING"

########################

# Define compiler flags based on intended architecture:
# Can easily expand this for alternate compilations

if [ "$ARCH" = "i386" ]; then
  SLKCFLAGS="-O2 -march=i386 -mtune=i686"
elif [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
fi

# Let's make sure that root is building the package
if [ "$(id -u)" != "0" ]; then
    echo "This script must be run as root!"
    exit 1
fi

set -e #Stop the script on errors.  Also, followed some examples (from robw810?) and sprinkled in some "|| exit 1" throughout.  Is this all correct/good idea?

if [ ! -d $TMP ]; then
  mkdir -p $TMP		# location to build the source
fi

rm -rf $PKG		# Get rid of any leftovers
mkdir -p $PKG		# Make sure $PKG and $TMP (-p switch) exist

if [ ! -d $OUTPUT ]; then
  mkdir -p $OUTPUT	# Make sure $OUTPUT exists
fi

cd $TMP || exit 1
rm -rf $NAME-$VERSION
tar xvf $CWD/$NAME-$VERSION.tar.*  || exit 1 # Should handle most cases. (Thanks jong357)
cd $NAME-$VERSION || exit 1

# Correct general permissions/ownership:

chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 711 -exec chmod 755 {} \;
find . -perm 666 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -perm 600 -exec chmod 644 {} \;
find . -perm 555 -exec chmod 755 {} \;
find . -perm 511 -exec chmod 755 {} \;
find . -perm 444 -exec chmod 644 {} \;
find . -perm 440 -exec chmod 644 {} \;
find . -perm 400 -exec chmod 644 {} \;

# Classic "./configure && make && make install":
#
# Added "--program-prefix="" \".  (Thanks Alien Bob).  Think that should be OK.
# As for the "$ARCH-slackware-linux", I believe that is incorrect.  For example,
# even if building an i686 package, it should still be "i486-slackware-linux".
# Maybe the correct info can be gleaned from "gcc -v"?
# Also, some packages will prefer using "--build=", so this section is still
# open for discussion.
# Also, should "--enable-shared" be added to this generic script?
# As a whole, which other flags should be used in a generic case? --disable-debug, --disable static
# Should "CXXFLAGS="$SLKCFLAGS" \" be added?
#
# This section could use a lot of work :)

CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --sysconfdir=/etc \
  --localstatedir=/var/lib \
  --program-prefix="" \
  $ARCH-slackware-linux \
  || exit 1
  
make || exit 1 #-j3 #Seem to recall some debate on the usefulness of -j3. Open for discussion.
make install DESTDIR=$PKG || exit 1

########################
#
# With newer versions of Slackware, ownership of binaries stays root.root.
# If you want the older behavior (root.bin), uncomment this section.
# Also, added a section to check for KDE binaries (Thanks Alien Bob).
#
########################
#
## Correct binaries ownership:
#
#if ls $PKG/bin &> /dev/null; then
#  chown -R root.bin $PKG/bin
#fi
#
#if ls $PKG/usr/bin &> /dev/null; then
#  chown -R root.bin $PKG/usr/bin
#fi
#
#if ls $PKG/sbin &> /dev/null; then
#  chown -R root.bin $PKG/sbin
#fi
#
#if ls $PKG/usr/sbin &> /dev/null; then
#  chown -R root.bin $PKG/usr/sbin
#fi
#
#if ls $PKG/usr/X11R6/bin &> /dev/null; then
#  chown -R root.bin $PKG/usr/X11R6/bin
#fi
#
#if ls $PKG/opt/kde/bin &> /dev/null; then
#  chown -R root.bin $PKG/opt/kde/bin
#fi
########################

# Strip binaries and libs:

( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)

# Compress man pages: (Thanks danieldk, Alien Bob, et al.)
if [ -d $PKG/usr/man ]; then
  ( cd $PKG/usr/man
    # gzip the man pages:
    find . -name "*.?" -type f 2> /dev/null | xargs gzip -9 2> /dev/null
    # re-do the symlinks:
    for i in `find . -type l` ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  )
fi

if [ -d $PKG/usr/X11R6/man ]; then
  ( cd $PKG/usr/X11R6/man
    # gzip the man pages:
    find . -name "*.?" -type f 2> /dev/null | xargs gzip -9 2> /dev/null
    # re-do the symlinks:
    for i in `find . -type l` ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  )
fi

if [ -d $PKG/opt/kde/share/man ]; then
  ( cd $PKG/opt/kde/share/man
    # gzip the man pages:
    find . -name "*.?" -type f 2> /dev/null | xargs gzip -9 2> /dev/null
    # re-do the symlinks:
    for i in `find . -type l` ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  )
fi

# Compress info pages if they exist (and remove the dir file)
# Taken from http://www.slackwiki.org/Writing_A_SlackBuild_Script
# Probably needs cleanup like man pages.
if [ -d $PKG/usr/info ]; then
  gzip -9 $PKG/usr/info/*.info
  rm -f $PKG/usr/info/dir
fi

# Create package docs:

mkdir -p $PKG/usr/doc/$PNAME-$PVERSION
cp -a $PDOCS $PKG/usr/doc/$PNAME-$PVERSION
# Include a copy of the SlackBuild in the Docs.  Would /usr/src/SlackBuilds be better?
cat $CWD/$PNAME.SlackBuild > $PKG/usr/doc/$PNAME-$PVERSION/$PNAME.SlackBuild
chmod 644 $PKG/usr/doc/$PNAME-$PVERSION/*

# Add package description:
# Helpful hint: When writing a slack-desc file, search the source for a .spec
# file.  This usually has a good description to copy.

if [ -e $CWD/slack-desc ]; then
  mkdir -p $PKG/install
  cat $CWD/slack-desc > $PKG/install/slack-desc
fi

# Add install script:

if [ -e $CWD/doinst.sh ]; then
  cat $CWD/doinst.sh > $PKG/install/doinst.sh
fi

# Add desktop file:

if [ -e $CWD/$PNAME.desktop ]; then
  mkdir -p $PKG/usr/share/applications
  cat $CWD/$PNAME.desktop > $PKG/usr/share/applications/$PNAME.desktop
fi

# Build the package:

cd $PKG
makepkg -l y -c n $OUTPUT/$PNAME-$PVERSION-$ARCH-$BUILD$TAG.tgz

# Calculate md5sum.  Thanks truthfatal.

md5sum $OUTPUT/$PNAME-$PVERSION-$ARCH-$BUILD$TAG.tgz > $OUTPUT/$PNAME-$PVERSION-$ARCH-$BUILD$TAG.tgz.md5

# Clean up the extra stuff:

if [ "$1" = "--cleanup" ]; then
  rm -rf $PKG
fi
Also, I now tend to use the dropline-build-system to build packages. I believe it is similar to gnashley's method.

Last edited by shilo; 01-03-2007 at 02:32 PM.
 
Old 12-27-2006, 09:04 AM   #35
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 490
Blog Entries: 1

Rep: Reputation: 55
SlackBuilds

Shilo, Thanks for doing this. I've incorporated a large number of the suggestions here into my own script.
I have one more (minor) tweak. Alien Bob, in his recent scripts, has a mod to the method of cd'ing into the untarred source directory. As so:
Code:
if [ -d ${PRGNAM}-${VERSION} ]; then
  cd ${PRGNAM}-${VERSION} # directory created by tarball extraction
else
  cd  ${PRGNAM}*  # a little less specific
fi
I have had to use this trick a few times, when the source packager did not adhere to the normal directory name. This will eliminate most of those problems, but not all, so beware.
I also don't understand the difference between the "set -e" command and putting " || exit 1" throughout the script. Can someone clarify?
Regards,
Bill
 
Old 12-27-2006, 10:10 AM   #36
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,257

Rep: Reputation: Disabled
The "set -e" will abort the script on any error, while the " || exit 1" will only abort the script on that specific error encountered.
The "set -e" will often catch scripting errors for you that you did not realize you made.

Eric
 
Old 12-28-2006, 01:17 AM   #37
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,755

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
Since I got mentioned here I'll chime in. My latest work on PkgBuild brings improvements to the 'src2pkg' program which will generate a script for you which uses the PkgBuild API. It also includes a replacement for checkinstall and a simple utiltity called 'tracklist' which does nothing but run a command while tracking it with installwatch. It then parses the ouput file to produce a list of files and directories created -completely unintrusive.
src2pkg takes the tarball name as it's only required argument, so it does some extar parsing to extrapolate the $NAME, $VERSION and other needed variables. It even works with debian-type tarballs which are named like:
prgname_0.0.1.orig.tar.gz. You may find some interesting code in these new utilities.

BTW, I'm working on a routine to generate slack-desc files, but I'm not sure who uses them or how they should look. Can anyone help me with that? An example would be the most informative. Are these used by swaret? Any other programs which actually use them? I may use them differently in the end(in conjunction with slackdeptrack??), but it would be helpful to know more about them.

The latest release of PkgBuild/src2pkg/trackinstall/tracklist is here:
http://distro.ibiblio.org/pub/linux/...9.7-i486-1.tgz

Last edited by gnashley; 12-28-2006 at 03:59 AM.
 
Old 12-28-2006, 06:54 AM   #38
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 490
Blog Entries: 1

Rep: Reputation: 55
Quote:
Originally Posted by Alien Bob
The "set -e" will abort the script on any error, while the " || exit 1" will only abort the script on that specific error encountered.
The "set -e" will often catch scripting errors for you that you did not realize you made.

Eric
Thanks, Eric. Now one (last, I hope) question: Would it be better to leave the "set -e" at the first of the script, depend on the "exit" statements (once the syntax is ok) or both?
OT: Today I become eligible for Social Security, so you now know why I have such a hard time understanding even the simplest things!
Regards,
Bill
 
Old 12-29-2006, 03:03 AM   #39
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,755

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
'set -e' should go near the beginning of your script.
Using exit allows you to have more specific control over errors and do something useful when they occur. This is why I don't use 'set -e' in my system as I try to handle errors on na case-by-case basis. Also, some configure scripts and Makefiles don't return a 'clean' standard error signal -like when they print out a message at the end of configuration. This sometimes causes 'false' signals.
If using 'set -e' causes problems you can always insert 'exit' at the trouble spots.
 
Old 12-31-2006, 01:16 AM   #40
truthfatal
Member
 
Registered: Mar 2005
Location: Winnipeg, MB
Distribution: Raspbian, Debian, Slackware, OS X
Posts: 443
Blog Entries: 9

Rep: Reputation: 32
Nice script! I'm going to play with it for a few installs I want to do
All I wanted to add was
Code:
# Calculate md5sum
cd $OUTPUT
md5sum ./$PNAME-$PVERSION-$ARCH-$BUILD$TAG.tgz > $PNAME-$PVERSION-$ARCH-$BUILD$TAG.tgz.md5
 
Old 12-31-2006, 06:25 AM   #41
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,257

Rep: Reputation: Disabled
Quote:
########################
#
# Why use this? Already covered above, right?
#
########################
#
#if [ ! -d $TMP ]; then
# mkdir -p $TMP # location to build the source
#fi
#
########################
Explicit creation of $TMP directory should be part of the script.
Example of why this is necessary - suppose your directories are as follows:

Code:
TMP=/scratch
PKG=/home/alien/slackbuilds
OUTPUT=/home/ftp/pub/slackbuilds
The mkdir line could be a oneliner:
Code:
mkdir -p $TMP $PKG $OUTPUT
Eric
 
Old 12-31-2006, 10:43 PM   #42
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 490
Blog Entries: 1

Rep: Reputation: 55
Eric,
I agree with your selected example. But, in the presented script, $TMP is part of the path to $PKG &, in this case, the user cannot change it, so running "mkdir -p $PKG" will ensure that $TMP is present. If the user is provided the opportunity to instantiate $PKG, so that $TMP was not part of the path, your approach would be necessary. As I've noted before, in the scripts I write, $TMP is "/tmp/tmp-$NAME", so $PKG is "/tmp/tmp-$NAME/package-$NAME" & all cleanup has to do is "rm -rf $TMP".
Regards,
Bill
 
Old 01-01-2007, 06:05 AM   #43
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,257

Rep: Reputation: Disabled
Never underestimate what an end user may or may not do - someone can edit the values of those three values in the script.

Eric
 
Old 01-01-2007, 12:08 PM   #44
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 490
Blog Entries: 1

Rep: Reputation: 55
Quote:
Originally Posted by Alien Bob
Never underestimate what an end user may or may not do - someone can edit the values of those three values in the script.

Eric
Indeed! I've managed to edit many a script into unusability! However, anyone who can edit a script, SHOULD know enough to be sure it doesn't break elsewhere, but as you say, one never knows.
Regards,
Bill
 
Old 01-03-2007, 01:47 PM   #45
shilo
Senior Member
 
Registered: Nov 2002
Location: Stockton, CA
Distribution: Slackware 11 - kernel 2.6.19.1 - Dropline Gnome 2.16.2
Posts: 1,132

Original Poster
Rep: Reputation: 49
Alien Bob-

I'm slow, but it makes sense now. I'll get the script edited in the next couple of days.

Thanks.

##EDIT###
Made changes. Does this look OK?

Last edited by shilo; 01-03-2007 at 02:09 PM.
 
  


Reply

Tags
slackbuild


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
The perfect gtkpod.SlackBuild shilo Slackware 3 08-04-2005 06:31 PM
GNOME.SlackBuild jmdlcar Slackware 1 06-03-2005 04:52 PM
KDE.SlackBuild spaceballs Slackware 8 04-01-2005 08:42 AM
GSB [Gnome Slackbuild] Xian Slackware 27 03-12-2005 07:53 PM
SlackBuild system thegeekster Slackware 7 06-01-2004 06:59 PM


All times are GMT -5. The time now is 09:23 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration