# slackbuildrc is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or any later version. # # slackbuildrc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 59 Temple # Place - Suite 330, Boston, MA 02111-1307, USA # PVERSION=`echo $VERSION | tr '-' '_'` ARCH=${ARCH:-$(arch)} TMP=${TMP:-/tmp} TAG=${TAG:-_mb} CWD="`pwd`" RTOOL="wget --no-check-certificate --connect-timeout=30" PKG=${TMP}/package-${PACKAGE} DOCS=$PKG/usr/doc/$PACKAGE-$VERSION if [ -x /usr/bin/kde-config ]; then KDEPREF=$(kde-config --prefix) fi NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "} # Ignore that which should be ignored to avoid long build times and # massive warning spew: IGNORE_GNU_EXTENSIONS=${IGNORE_GNU_EXTENSIONS:--Wno-unknown-warning-option -Wno-gnu-line-marker -Wno-gnu-anonymous-struct -Wno-gnu-include-next} # Exit the script on errors: rm -f $TMP/error-${PACKAGE}.log set -e trap 'echo "$0 FAILED at line $LINENO!" | tee $TMP/error-${PACKAGE}.log' ERR # Catch unitialized variables: set -u P1=${1:-1} # Slackware 11 and up need other option (gcc > 3.3.x) if [ `gcc -dumpversion | tr -d '.' |cut -c 1-2` -gt 33 ]; then MOPT=tune else MOPT=cpu fi LIBDIR=/usr/lib LIBDIRSUFFIX= SLKLDFLAGS= if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686 $IGNORE_GNU_EXTENSIONS" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=pentium4 -mtune=generic $IGNORE_GNU_EXTENSIONS" elif [ "$ARCH" = "s390" ]; then SLKCFLAGS="-O2 $IGNORE_GNU_EXTENSIONS" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -march=x86-64 -mtune=generic -fPIC $IGNORE_GNU_EXTENSIONS" LIBDIR=/usr/lib64 LIBDIRSUFFIX=64 SLKLDFLAGS="-L/usr/lib64 -fPIC" elif [ "$ARCH" = "hppa" ]; then SLKCFLAGS="-O2 $IGNORE_GNU_EXTENSIONS" elif [ "$ARCH" = "hppa1.1" ]; then SLKCFLAGS="-O2 -march=1.1 -mschedule=7100LC $IGNORE_GNU_EXTENSIONS" elif [ "$ARCH" == "armv7l" ] || [ "$ARCH" == "armv6l" ]; then ARCH="arm" SLKCFLAGS="-O2 $IGNORE_GNU_EXTENSIONS" else SLKCFLAGS="-O2 $IGNORE_GNU_EXTENSIONS" fi rm -rf $PKG mkdir -p $TMP mkdir -p $PKG # From upgradepkg # Return a package name that has been stripped of the dirname portion # and any of the valid extensions (only): pkgbase() { PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev) case $PKGEXT in 'tgz' ) PKGRETURN=$(basename $1 .tgz) ;; 'tbz' ) PKGRETURN=$(basename $1 .tbz) ;; 'tlz' ) PKGRETURN=$(basename $1 .tlz) ;; 'txz' ) PKGRETURN=$(basename $1 .txz) ;; *) PKGRETURN=$(basename $1) ;; esac echo $PKGRETURN } package_name() { STRING=$(pkgbase $1) # Check for old style package name with one segment: if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then echo $STRING else # has more than one dash delimited segment # Count number of segments: INDEX=1 while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do INDEX=$(expr $INDEX + 1) done INDEX=$(expr $INDEX - 1) # don't include the null value # If we don't have four segments, return the old-style (or out of spec) package name: if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then echo $STRING else # we have four or more segments, so we'll consider this a new-style name: NAME=$(expr $INDEX - 3) NAME="$(echo $STRING | cut -f 1-$NAME -d -)" echo $NAME # cruft for later ;) #VER=$(expr $INDEX - 2) #VER="$(echo $STRING | cut -f $VER -d -)" #ARCH=$(expr $INDEX - 1) #ARCH="$(echo $STRING | cut -f $ARCH -d -)" #BUILD="$(echo $STRING | cut -f $INDEX -d -)" fi fi } # end from upgradepkg # Check packages required to build. check_required() { missing=0 if [ -s "$CWD/slack-required" ]; then while read line; do found=0 SHORT="$(package_name $line)" if [ ! -r /var/log/packages/$line ]; then for installed_package in /var/log/packages/$SHORT* ; do if [ "$(package_name $installed_package)" = "$SHORT" ]; then # found one found=1 break fi done fi # Report missing packages if [ $found == 0 ]; then if [ $missing == 0 ]; then echo Recomended and required packages for building $PACKAGE are: missing=1 fi echo -e "\t$line" fi done < $CWD/slack-required # If packages are missing, a final message and abort. if [ $missing == 1 ]; then echo Install these packages first, then run this Slackbuild again. exit 1 fi fi } # # get_source($CWD, $SRC, $URL) # get_source() { src="$1" url="$2" if [ ! -f $CWD/$src ]; then ( cd $CWD $RTOOL $url -O $src ) fi if [ ! -f $CWD/$src ]; then echo "Source $src not found, aborting." exit 1 fi } unpack_source() { src="$1" wrk="$2" mkdir -p $TMP cd $TMP rm -rf $wrk if [ "$PACKAGE_EXT" == "zip" ]; then unzip $CWD/$src elif [ "$PACKAGE_EXT" == "bz2" ]; then tar xfvj $CWD/$src elif [ "$PACKAGE_EXT" == "xz" ]; then tar xfvJ $CWD/$src elif [ "$PACKAGE_EXT" == "lzma" ]; then tar xfvJ $CWD/$src else tar xfvz $CWD/$src fi if [ ! -d $wrk ]; then echo "Directory $TMP/$wrk doesn't exist, aborting." exit 1 fi cd $wrk chown -R root:root . chmod -R u+w,go+r-w,a-s . } fixup_package() { pkg="$1" cd $pkg set +e 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 find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs strip -g 2> /dev/null set -e if [ -d $pkg/usr/man ]; then ( cd $pkg/usr/man find . -type f -exec gzip -9 {} \; for i in $(find . -type l) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done ) fi mkdir -p $pkg/install if [ -f $CWD/$PACKAGE.doinst.sh.gz ]; then zcat $CWD/$PACKAGE.doinst.sh.gz > $pkg/install/doinst.sh elif [ -f $CWD/$PACKAGE.doinst.sh ]; then cat $CWD/$PACKAGE.doinst.sh > $pkg/install/doinst.sh elif [ -f $CWD/doinst.sh.gz ]; then zcat $CWD/doinst.sh.gz > $pkg/install/doinst.sh elif [ -f $CWD/doinst.sh ]; then cat $CWD/doinst.sh > $pkg/install/doinst.sh else if [ -d $pkg/usr/lib${LIBDIRSUFFIX} ]; then echo "/sbin/ldconfig" >> $pkg/install/doinst.sh fi fi SLDESC=slack-desc if [ ! -f $pkg/install/slack-desc ]; then # There is no generated slack-desc if [ -f $CWD/$PACKAGE.slack-desc ]; then SLDESC=$PACKAGE.slack-desc fi cat $CWD/$SLDESC > $pkg/install/slack-desc fi if [ -f $CWD/$PACKAGE.slack-required ]; then SLREQ=$CWD/$PACKAGE.slack-required else SLREQ=$CWD/slack-required fi if [ -f $SLREQ ]; then cat $SLREQ > $pkg/install/slack-required fi # Compress info pages and remove the package's dir file: if [ -d $PKG/usr/info ]; then rm -rf $PKG/usr/info/dir gzip -9f $PKG/usr/info/*.info* fi # Don't ship .la files: rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la makepkg -p -l y -c n $TMP/$PACKAGE-$PVERSION-$ARCH-$BUILD$TAG.txz tail -n 11 $pkg/install/slack-desc > $TMP/$PACKAGE-$PVERSION-$ARCH-$BUILD$TAG.txt md5sum $TMP/$PACKAGE-$PVERSION-$ARCH-$BUILD$TAG.txz > $TMP/$PACKAGE-$PVERSION-$ARCH-$BUILD$TAG.txz.md5 }