#!/bin/sh # # ----------------------------------------------------------------------------- # # Slackware SlackBuild script # =========================== # By: Eric Hameleers # For: pwc # URL: http://www.saillard.org/linux/pwc/ # Needs: # Changelog: # 10.0.7a-1: 01/Aug/2005 by Eric Hameleers # * Initial build. # # Run 'sh SlackBuild --cleanup' to build a Slackware package. # The package (.tgz) plus descriptive .txt file are created in /tmp . # Install using 'installpkg'. # # ----------------------------------------------------------------------------- # Control what to do and what not: DOWNLOADS=${DOWNLOADS:-1} # set to '0' if you don't want missing sources # to be downloaded before the build. # --- INIT --- # Set initial variables: CWD=`pwd` if [ "$TMP" = "" ]; then TMP=/tmp fi PRGNAM=pwc VERSION=10.0.7a ARCH=${ARCH:-i486} BUILD=1 KVER=${KVER:-`uname -r`} KSRC=${KSRC:-/usr/src/linux-${KVER}} if [ "$ARCH" = "i386" ]; then SLKCFLAGS="-O2 -march=i386 -mcpu=i686" elif [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mcpu=i686" elif [ "$ARCH" = "s390" ]; then SLKCFLAGS="-O2" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2" elif [ "$ARCH" = "athlon-xp" ]; then SLKCFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" fi PKG=$TMP/package-$PRGNAM if [ ! -d $TMP/tmp-$PRGNAM ]; then mkdir -p $TMP/tmp-$PRGNAM # location to build the source fi if [ ! -d $PKG ]; then mkdir -p $PKG # place for the package to be built fi # --- SOURCE FILE AVAILABILITY --- SOURCE[0]="${PRGNAM}-${VERSION}.tar.bz2" SOURCE[1]="ChangeLog" SRCURL[0]="http://www.saillard.org/linux/pwc/files/${PRGNAM}-${VERSION}.tar.bz2" SRCURL[1]="http://www.saillard.org/linux/pwc/ChangeLog" if [ $DOWNLOADS -eq 1 ]; then for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do if ! [ -f ${CWD}/${SOURCE[$i]} ]; then echo "Source '${SOURCE[$i]}' not available yet... will download now:" wget -nv -O ${CWD}/${SOURCE[$i]} "${SRCURL[$i]}" if [ $? -ne 0 ]; then echo "Downloading '${SOURCE[$i]}' failed... aborting the build." exit 1 fi fi done fi # --- PACKAGE BUILDING --- echo "++" echo "|| $PRGNAM-$VERSION" echo "++" rm -rf $PKG/* cd $PKG # Explode the package framework: if [ -f $CWD/_$PRGNAM.tar.gz ]; then explodepkg $CWD/_$PRGNAM.tar.gz fi cd $TMP/tmp-$PRGNAM # --- TARBALL EXTRACTION,PATCH,MODIFY --- echo "Extracting the program tarball for $PRGNAM..." tar -xjvf $CWD/${PRGNAM}-${VERSION}.tar.bz2 cd ${PRGNAM}-${VERSION} chown -R root.root * find . -perm 777 -exec chmod 755 {} \; # --- BUILDING --- echo Building ... CFLAGS="$SLKCFLAGS" KVER=${KVER} \ make 2>&1 | tee $CWD/make-${PRGNAM}.log # # Install all the needed stuff to the package dir # mkdir -p $PKG/lib/modules/${KVER}/kernel/drivers/usb/media cp -a pwc.ko $PKG/lib/modules/${KVER}/kernel/drivers/usb/media/ chmod 644 $PKG/lib/modules/${KVER}/kernel/drivers/usb/media/pwc.ko # And now write the module install stuff into doinst.sh : mkdir -p $PKG/install cat <<-EEOOTT > $PKG/install/doinst.sh # Check if we can depmod and modprobe the new module; # The running kernel must match with our kernel module: MYMODVER=$KVER MYKERNEL=\`uname -r\` # Check if the filesystem we're installing to, # is the root filesystem for our running kernel: TARI=\`/bin/ls -i etc/slackware-version | /bin/cut -f 1 -d ' '\` SRCI=\`/bin/ls -i /etc/slackware-version | /bin/cut -f 1 -d ' '\` if [ "\$MYKERNEL" = "\$MYMODVER" -a "\$SRCI" = "\$TARI" ]; then # Try to remove pwc plus possibly the obsolete pwcx module: sbin/modprobe -r pwcx pwc 1> /dev/null 2> /dev/null sbin/depmod -a \$MYKERNEL 1> /dev/null 2> /dev/null sbin/modprobe pwc 1> /dev/null 2> /dev/null fi # Make sure the module gets loaded on boot: if ! grep -q "pwc" etc/rc.d/rc.modules ; then echo "# Load the PWC kernel module" >> etc/rc.d/rc.modules echo "/sbin/modprobe pwc" >> etc/rc.d/rc.modules fi EEOOTT # --- DOCUMENTATION --- DOCS="$CWD/ChangeLog philips.txt" mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a $DOCS \ $PKG/usr/doc/$PRGNAM-$VERSION chmod -R a-w $PKG/usr/doc/$PRGNAM-$VERSION/* # --- PACKAGE DESCRIPTION --- mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc if [ -f $CWD/doinst.sh ]; then cat $CWD/doinst.sh > $PKG/install/doinst.sh fi # --- BUILDING --- # Build the package: cd $PKG makepkg --linkadd y --chown n $TMP/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz \ 2>&1 | tee $CWD/makepkg-${PRGNAM}.log (cd $TMP && md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz.md5) cat $CWD/slack-desc | grep "^${PRGNAM}" > $TMP/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.txt # --- CLEANUP --- # Clean up the extra stuff: if [ "$1" = "--cleanup" ]; then rm -rf $TMP/tmp-$PRGNAM rm -rf $PKG fi