#!/bin/bash ##SlackBuild style build script CWD=`pwd` NAME=x11 VERSION=7.3 ARCH=i586 #x86_64 BUILD=1vl59 VL_PACKAGER=Uelsk8s ### #Load the build order reference list ### BUILD_ORDER=`cat $CWD/build_order` ### #Functions ### fix_permissions() { chown -R root:root . find . -perm 666 -exec chmod 644 {} \; find . -perm 664 -exec chmod 644 {} \; find . -perm 600 -exec chmod 644 {} \; find . -perm 444 -exec chmod 644 {} \; find . -perm 400 -exec chmod 644 {} \; find . -perm 440 -exec chmod 644 {} \; find . -perm 777 -exec chmod 755 {} \; find . -perm 775 -exec chmod 755 {} \; find . -perm 511 -exec chmod 755 {} \; find . -perm 711 -exec chmod 755 {} \; find . -perm 555 -exec chmod 755 {} \; } no_usr_share_docs() { if [ -d usr/share/doc ]; then mkdir usr/doc mv usr/share/doc/* usr/doc/ rmdir usr/share/doc fi } process_man_pages() { # Compress and if needed symlink the man pages: if [ -d usr/man ]; then ( cd usr/man for manpagedir in $(find . -type d -name "man*") ; do ( cd $manpagedir for eachpage in $( find . -type l -maxdepth 1) ; do ln -s $( readlink $eachpage ).gz $eachpage.gz rm $eachpage done gzip -9 *.* ) done ) fi } process_info_pages() { # Compress info pages and purge "dir" file from the package: if [ -d usr/info ]; then ( cd usr/info rm -f dir gzip -9 * ) fi } build_all_packages() { MAIN_BUILD_DIR=$TMP/$NAME-$VERSION rm -rf $MAIN_BUILD_DIR mkdir -p $MAIN_BUILD_DIR ( cd $CWD/src for xpackage in $BUILD_ORDER; do #See whether to use the "x11-" prefix on the package name if grep -wq "^$xpackage" $CWD/modularize ; then PKGNAME=$xpackage else PKGNAME="x11-$xpackage" fi PKGVER=`ls . | grep "^${xpackage}-" | rev | cut -f 3- -d . | cut -f 1 -d - | rev` if grep -wq "^$xpackage" $CWD/noarch ; then PKGARCH="noarch" else PKGARCH=$ARCH fi #Check if the package is blacklisted if grep -wq "^$xpackage" $CWD/package-blacklist ; then continue fi if [ -f "/var/log/packages/$PKGNAME-$PKGVER-$PKGARCH-$BUILD" ]; then echo "Skipping $PKGNAME-$PKGVER, it appears to be installed." continue fi #At this stage, if Mesa hasn't been built, tell the user to build it first if [ $xpackage = "mesa" ]; then source $CWD/mesa_vars if [ -f "/var/log/packages/mesa-$MESA_VERSION-$MESA_ARCH-$MESA_BUILD" ]; then continue else echo "You must compile Mesa before proceeding any further. Be sure to build it in $TMP and leave all the sources in one directory (Mesa-version). After Mesa is built and installed, ajust the configurations in $CWD/configure/xorg-server and re-run this script. The Xorg package building will continue from where it left off. Don't deleted the Mesa source directory in $TMP!" continue exit fi fi #OK, lets start building something! PKG=$MAIN_BUILD_DIR/package-$PKGNAME rm -rf $PKG mkdir -p $PKG mkdir $PKG/usr mkdir $PKG/install rm -rf $MAIN_BUILD_DIR/$xpackage-$PKGVER tar xvf $xpackage-$PKGVER.tar.* -C $MAIN_BUILD_DIR cd $MAIN_BUILD_DIR/$xpackage-$PKGVER if [ "$PKGARCH" = "i386" ]; then export CFLAGS="-O2 -march=i386 -mcpu=i686" elif [ "$PKGARCH" = "i486" ]; then export CFLAGS="-O2 -march=i486 -mtune=i686" elif [ "$PKGARCH" = "i586" ]; then export CFLAGS="-O2 -march=i586 -mtune=i686" elif [ "$PKGARCH" = "s390" ]; then export CFLAGS="-O2" elif [ "$PKGARCH" = "x86_64" ]; then export CFLAGS="-O2 -fpic" elif [ "$PKGARCH" = "noarch" ]; then export CFLAGS="" fi export CXXFLAGS="$CFLAGS" #export LDFLAGS="-Wl,--hash-style=gnu" fix_permissions if [ -r $CWD/patches/$xpackage.patch ]; then . $CWD/patches/$xpackage.patch fi if [ -r $CWD/configure/$xpackage ]; then . $CWD/configure/$xpackage else . $CWD/configure/configure fi make if ( ! make ); then echo "Make failed for $xpackage" exit fi make install DESTDIR=$PKG cat >> $PKG/install/slack-desc << EOF $PKGNAME: X11R$VERSION - $PKGNAME $PKGNAME: $PKGNAME: $PKGNAME is part of X11. $PKGNAME: For information about X.org (the $PKGNAME: maintainers of the open source X11 $PKGNAME: implementation), visit their website. $PKGNAME: $PKGNAME: Website: http://www.x.org/ $PKGNAME: Licenses: Various, see website. $PKGNAME: $PKGNAME: EOF if [ -r $CWD/doinst.sh/$xpackage ]; then cat $CWD/doinst.sh/$xpackage > $PKG/install/doinst.sh fi cd $PKG if [ -r $CWD/post-install/${PKGNAME}.post-install ]; then . $CWD/post-install/${PKGNAME}.post-install fi no_usr_share_docs process_man_pages process_info_pages 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 makepkg -p -l y -c n $PKGNAME-$PKGVER-$PKGARCH-$BUILD.tlz installpkg $PKGNAME-$PKGVER-$PKGARCH-$BUILD.tlz mv $PKGNAME-$PKGVER-$PKGARCH-$BUILD.tlz $TMP/finished-packages/$NAME-$VERSION cd $CWD/src done ) } build_single_package() { MAIN_BUILD_DIR=$TMP/$NAME-$VERSION rm -rf $MAIN_BUILD_DIR mkdir -p $MAIN_BUILD_DIR cd $CWD/src if grep -wq "^single_xpackage" $CWD/modularize ; then PKGNAME=$single_xpackage else PKGNAME="$single_xpackage" fi PKGVER=`ls . | grep "^${single_xpackage}-" | rev | cut -f 3- -d . | cut -f 1 -d - | rev` if grep -wq "^$single_xpackage" $CWD/noarch ; then PKGARCH="noarch" else PKGARCH=$ARCH fi if grep -wq "^$single_xpackage" $CWD/package-blacklist ; then echo "$single_xpackage is a blacklisted package." exit fi if [ -f "/var/log/packages/$PKGNAME-$PKGVER-$PKGARCH-$BUILD" ]; then echo "$PKGNAME-$PKGVER is installed, so it won't be built." exit fi if [ "$single_xpackage" = "mesa" ]; then echo "This script doesn't build Mesa, although its sources and build script were probably provided with Xorg in a separate directory and (check ../)." exit fi PKG=$MAIN_BUILD_DIR/package-$PKGNAME rm -rf $PKG mkdir -p $PKG mkdir $PKG/usr mkdir $PKG/install rm -rf $MAIN_BUILD_DIR/$single_xpackage-$PKGVER tar xvf $single_xpackage-$PKGVER.tar.* -C $MAIN_BUILD_DIR cd $MAIN_BUILD_DIR/$single_xpackage-$PKGVER if [ "$PKGARCH" = "i386" ]; then export CFLAGS="-O2 -march=i386 -mcpu=i686" elif [ "$PKGARCH" = "i486" ]; then export CFLAGS="-O2 -march=i486 -mtune=i686" elif [ "$PKGARCH" = "i586" ]; then export CFLAGS="-O2 -march=i586 -mtune=i686" elif [ "$PKGARCH" = "s390" ]; then export CFLAGS="-O2" elif [ "$PKGARCH" = "x86_64" ]; then export CFLAGS="-O2 -fpic" elif [ "$PKGARCH" = "noarch" ]; then export CFLAGS="" fi export CXXFLAGS="$CFLAGS" export LDFLAGS="-Wl,--hash-style=gnu" fix_permissions if [ -r $CWD/patches/$single_xpackage.patch ]; then . $CWD/patches/$single_xpackage.patch fi if [ -r $CWD/configure/$single_xpackage ]; then . $CWD/configure/$single_xpackage else . $CWD/configure/configure fi make if ( ! make ); then echo "Make failed for $single_xpackage" exit fi make install DESTDIR=$PKG cat >> $PKG/install/slack-desc << EOF $PKGNAME: X11R$VERSION - $PKGNAME $PKGNAME: $PKGNAME: $PKGNAME is part of X11. $PKGNAME: For information about X.org (the $PKGNAME: maintainers of the open source X11 $PKGNAME: implementation), visit their website. $PKGNAME: $PKGNAME: Website: http://www.x.org/ $PKGNAME: Licenses: Various, see website. $PKGNAME: $PKGNAME: EOF if [ -r $CWD/doinst.sh/$single_xpackage ]; then cat $CWD/doinst.sh/$single_xpackage > $PKG/install/doinst.sh fi cd $PKG if [ -r $CWD/post-install/${PKGNAME}.post-install ]; then . $CWD/post-install/${PKGNAME}.post-install fi no_usr_share_docs process_man_pages process_info_pages 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 makepkg -p -l y -c n $PKGNAME-$PKGVER-$PKGARCH-$BUILD.tlz installpkg $PKGNAME-$PKGVER-$PKGARCH-$BUILD.tlz mv $PKGNAME-$PKGVER-$PKGARCH-$BUILD.tlz $TMP/finished-packages/$NAME-$VERSION cd $CWD exit } ############################### #The actual script starts here# ############################### if [ $UID != 0 ]; then echo "You need to be root to run this script." exit fi if [ "$TMP" = "" ]; then TMP=/tmp fi if [ ! -d $TMP/finished-packages/$NAME-$VERSION ]; then mkdir -p $TMP/finished-packages/$NAME-$VERSION fi ### #Check if user passed any flags to the script and process them ### if [ $# = 0 ]; then echo "No arguments were used. Use the --help flag for a list of available options" exit elif [ $1 = "--build-all" ]; then echo "All the Xorg $VERSION packages will be built. Is this really what you want? (y/n)" read answer case $answer in y | yes | Y | YES | Yes ) build_all_packages;; n | no | N | No | NO ) exit;; * ) echo "Invalid answer: $answer." exit;; esac elif [ $1 = "--build-single" ]; then if [ -z $2 ]; then echo "No package name specified!" exit elif ! grep -wq ^$2 $CWD/build_order; then echo "No package \"$2\" found in the internal build order list." exit else export single_xpackage="$2" build_single_package fi elif [ $1 = "--show-build-order" ]; then echo $BUILD_ORDER exit elif [ $1 = "--help" ]; then echo "Available options: --help display this message --build-all build all the Xorg $VERSION packages --build-single package_name build only one package (replace package_name with the name of the Xorg package you wish to build - not the entire tarball name!) --show-build-order display all the package names available in the internal package build order" else echo "Unrecognized argument." exit fi