#!/bin/sh # Copyright 2007, 2008, 2009 Patrick Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 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. # To build only a single package group, specify it as $1, like: # ./x11.SlackBuild lib # To build only a single package, specify both the source directory # and the name of the package, like: # ./x11.SlackBuild lib libX11 # Set initial variables: CWD=$(pwd) TMP=${TMP:-/tmp} # A lot of this stuff just controls the package names this time: VERSION=${VERSION:-7.3} ARCH=${ARCH:-x86_64} TARGET=i486 NUMJOBS=${NUMJOBS:-" -j7 "} BUILD=${BUILD:-1_slamd64} PKGARCH=$ARCH export CC="gcc -m32" LIBDIRSUFFIX="" SLKCFLAGS="-O2" # Set up a few useful functions: fix_perms() { chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; } SLACK_X_BUILD_DIR=$TMP/x11-compat32-build mkdir -p $SLACK_X_BUILD_DIR # Better have some binaries installed first, as this may not be # in the "magic order". I built mine by hand through trial-and-error # before getting this script to work. It wasn't that hard... I think. ;-) ( cd src for x_source_dir in xcb lib; do # See if $1 is a source directory like "lib": if [ ! -z "$1" ]; then if [ ! "$1" = "${x_source_dir}" ]; then continue fi fi PKG=${SLACK_X_BUILD_DIR}/package-${x_source_dir}-compat32 rm -rf $PKG mkdir -p $PKG ( cd $x_source_dir for x_pkg in *.tar.bz2 ; do # Reset $PKGARCH to its initial value: PKGARCH=$ARCH PKGNAME=$(echo $x_pkg | rev | cut -f 2- -d - | rev) # Perhaps $PKGARCH should be something different: if grep -wq "^$PKGNAME" ${CWD}/noarch ; then PKGARCH=noarch fi if grep -wq "^$PKGNAME" ${CWD}/package-blacklist ; then continue fi cd $SLACK_X_BUILD_DIR # If $2 is set, we only want to build one package: if [ ! -z "$2" ]; then if [ "$2" = "$PKGNAME" ]; then # Set $PKG to a private dir for the modular package build: PKG=$SLACK_X_BUILD_DIR/package-$PKGNAME-compat32 rm -rf $PKG mkdir -p $PKG else continue fi fi if grep -wq "^$PKGNAME" ${CWD}/modularize ; then # Set $PKG to a private dir for the modular package build: PKG=$SLACK_X_BUILD_DIR/package-$PKGNAME-compat32 rm -rf $PKG mkdir -p $PKG fi # Let's figure out the version number on the modular package: MODULAR_PACKAGE_VERSION=$(echo $x_pkg | rev | cut -f 3- -d . | cut -f 1 -d - | rev) rm -rf $(basename $x_pkg .tar.bz2) tar xf $CWD/src/${x_source_dir}/${x_pkg} || exit 1 cd $(basename $x_pkg .tar.bz2) || exit 1 fix_perms # If any patches are needed, call this script to apply them: if [ -r $CWD/patch/${PKGNAME}.patch ]; then . $CWD/patch/${PKGNAME}.patch fi # I heard somewhere that -O2 breaks some chipset or another. If you encounter # problems, please contact volkerdi@slackware.com. Thanks! :-) # ./configure, using custom configure script if needed: if [ -r $CWD/configure/${PKGNAME} ]; then ARCH=$TARGET . $CWD/configure/${PKGNAME} else # This is the default configure script: ARCH=$TARGET . $CWD/configure/configure fi if ! make $NUMJOBS ; then touch ${SLACK_X_BUILD_DIR}/${PKGNAME}.failed continue fi make install DESTDIR=$PKG # Strip binaries: ( 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 find . | xargs file | grep "current ar archive" | grep ELF | cut -f 1 -d : | xargs strip -g 2> /dev/null ) # If there's any special post-install things to do, do them: if [ -r $CWD/post-install/${PKGNAME}.post-install ]; then RUNSCRIPT=$(mktemp -p $TMP) || exit 1 cat $CWD/post-install/${PKGNAME}.post-install \ | sed -e "s#usr/lib#usr/lib${LIBDIRSUFFIX}#g" > $RUNSCRIPT . $RUNSCRIPT rm -f $RUNSCRIPT fi # If this package requires some doinst.sh material, add it here: if [ -r $CWD/doinst.sh/${PKGNAME} ]; then mkdir -p $PKG/install cat $CWD/doinst.sh/${PKGNAME} \ | sed -e "s#usr/lib#usr/lib${LIBDIRSUFFIX}#g" \ >> $PKG/install/doinst.sh fi # If this is a modular package, build it here: if [ -d $SLACK_X_BUILD_DIR/package-$PKGNAME-compat32 ]; then cd $PKG mkdir -p $PKG/install if [ -r $CWD/slack-desc/${PKGNAME} ]; then cat $CWD/slack-desc/${PKGNAME} > $PKG/install/slack-desc else touch $PKG/install/slack-desc-missing fi if [ -r $CWD/build/${PKGNAME} ]; then MODBUILD=$(cat $CWD/build/${PKGNAME}) else MODBUILD=$BUILD fi rm -rf usr/{bin,share,info,man,include} ( if [ -e usr/doc/* ]; then cd usr/doc/* find | grep -v COPYING | xargs rm -rf fi ) if [ -r $CWD/makepkg/${PKGNAME} ]; then BUILD=$MODBUILD . $CWD/makepkg/${PKGNAME} else /sbin/makepkg -l y -c n ${SLACK_X_BUILD_DIR}/${PKGNAME}-compat32-${MODULAR_PACKAGE_VERSION}-${PKGARCH}-${MODBUILD}.txz fi fi # Reset $PKG to assume we're building the whole source dir: PKG=${SLACK_X_BUILD_DIR}/package-${x_source_dir}-compat32 done # Nothing here? Must have been fully modular. :-) if [ ! -d ${SLACK_X_BUILD_DIR}/package-${x_source_dir}-compat32/etc -a \ ! -d ${SLACK_X_BUILD_DIR}/package-${x_source_dir}-compat32/usr ]; then continue fi ) done ) exit 0 # I don't think I'll be using the following stuff, since I went for the latest in # "individual", rather than a release. That was mostly because version 7.1 depends # on a version of Mesa that won't build against kernel headers this new (&etc.). # If environment variable "REFRESH" is exported, start by refreshing the source tree: # export REFRESH yes if [ ! -z "$REFRESH" ]; then # Only works once, unless you uncomment above. unset REFRESH ( cd patches lftp -c \ "lftp ftp://ftp.x.org:/pub/X11R7.1/patches mirror --delete --dereference . exit" chmod 644 * ) ( cd src mkdir -p update everything for dir in app data deprecated doc driver extras font lib proto util xserver ; do # We won't really download "update", as problems ensue. Plus, --dereference is # bringing us updated files when needed, so it's redundant (like "everything"). if [ ! -d $dir ]; then mkdir $dir fi ( cd $dir lftp -c \ "lftp ftp://ftp.x.org:/pub/X11R7.1/src/$dir mirror -c --delete --dereference --include-glob "*.tar.bz2" . exit" chmod 644 * ) done ) fi