diff options
-rwxr-xr-x | libgphoto2/build/libgphoto2.SlackBuild | 238 |
1 files changed, 150 insertions, 88 deletions
diff --git a/libgphoto2/build/libgphoto2.SlackBuild b/libgphoto2/build/libgphoto2.SlackBuild index b6edc64b..1cf1cc30 100755 --- a/libgphoto2/build/libgphoto2.SlackBuild +++ b/libgphoto2/build/libgphoto2.SlackBuild @@ -1,5 +1,6 @@ #!/bin/sh # $Id$ +# Copyright (c) 2006 Eric Hameleers <alien@slackware.com> # ----------------------------------------------------------------------------- # # Slackware SlackBuild script @@ -16,6 +17,9 @@ # The compilation needs installed header files to make it run # errorfree. So, I installed the package and re-ran the build. # I love circular cependencies. +# 2.2.1-1: 08/oct/2006 by Eric Hameleers <alien@slackware.com> +# * Update. +# Rewrote the SlackBuild for Slackware 10.x/11.x compatibility. # # Run 'sh SlackBuild --cleanup' to build a Slackware package. # The package (.tgz) plus descriptive .txt file are created in /tmp . @@ -25,105 +29,124 @@ # --- INIT --- # Set initial variables: -CWD=`pwd` -if [ "$TMP" = "" ]; then - TMP=/tmp -fi PRGNAM=libgphoto2 -VERSION=2.2.0 +VERSION=2.2.1 ARCH=${ARCH:-i486} BUILD=1 DOCS="ABOUT-NLS AUTHORS CHANGES COPYING ChangeLog HACKING INSTALL \ MAINTAINERS NEWS README TESTERS" -# If you have more source files, list them here as SOURCE[1], SOURCE[2], etc. -# If you know the URL for a source file, you can put that into the SRCURL[] -# variable, and the SlackBuild script will try to download it for you. +SOURCE="${PRGNAM}-${VERSION}.tar.gz" +SRCURL="http://dl.sourceforge.net/sourceforge/gphoto/${PRGNAM}-${VERSION}.tar.gz" -SOURCE[0]="${PRGNAM}-${VERSION}.tar.gz" -SRCURL[0]="http://surfnet.dl.sourceforge.net/sourceforge/gphoto/${PRGNAM}-${VERSION}.tar.gz" +# Place to build (TMP) package (PKG) and output (OUTPUT) the program: +TMP=${TMP:-/tmp/build} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} ## ## --- with a little luck, you won't have to edit below this point --- ## ## -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" +# Where do we look for sources? +CWD=`pwd` +SRCDIR=`dirname $0` +[ "${SRCDIR:0:1}" == "." ] && SRCDIR=${CWD}/${SRCDIR} + +# Exit the script on errors: +set -e +trap 'echo "$0 FAILED!" | tee $OUTPUT/error-${PRGNAM}.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 -PKG=$TMP/package-$PRGNAM +case "$ARCH" in + i386) SLKCFLAGS="-O2 -march=i386 -m${MOPT}=i686" + SLKLDFLAGS=""; LIBDIRSUFFIX="" + ;; + i486) SLKCFLAGS="-O2 -march=i486 -m${MOPT}=i686" + SLKLDFLAGS=""; LIBDIRSUFFIX="" + ;; + s390) SLKCFLAGS="-O2" + SLKLDFLAGS=""; LIBDIRSUFFIX="" + ;; + powerpc) SLKCFLAGS="-O2" + SLKLDFLAGS=""; LIBDIRSUFFIX="" + ;; + x86_64) SLKCFLAGS="-O2 -fPIC" + SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64" + ;; + athlon-xp) SLKCFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" + SLKLDFLAGS=""; LIBDIRSUFFIX="" + ;; +esac if [ ! -d $TMP/tmp-$PRGNAM ]; then mkdir -p $TMP/tmp-$PRGNAM # location to build the source -elif [ "$1" != "--oldbuild" ]; then +elif [ "$P1" != "--oldbuild" ]; then # If the "--oldbuild" parameter is present, we keep # the old build files and continue; # By default we remove the remnants of previous build and continue: rm -rf $TMP/tmp-$PRGNAM/* fi -if [ ! -d $PKG ]; then - mkdir -p $PKG # place for the package to be built +if [ "$PKG" = "" -o "$PKG" = "/" ] ; then + echo "Please provide a sane value for the variable 'PKG'." + exit 1 +elif [ ! -d $PKG ]; then + mkdir -p $PKG # place for the package to be built +else + rm -rf $PKG/* # We always erase old package's contents: +fi + +if [ ! -d $OUTPUT ]; then + mkdir -p $OUTPUT # place for the package to be saved fi # --- SOURCE FILE AVAILABILITY --- -for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do - if ! [ -f ${CWD}/${SOURCE[$i]} ]; then - if ! [ "${SRCURL[$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." - mv "${CWD}/${SOURCE[$i]}" "${CWD}/${SOURCE[$i]}.FAIL" - exit 1 - fi - else - echo "File '${SOURCE[$i]}' not available... aborting the build." +if ! [ -f ${SRCDIR}/${SOURCE} ]; then + if ! [ "x${SRCURL}" == "x" ]; then + echo "Source '${SOURCE}' not available yet... will download now:" + wget -nv -O "${SRCDIR}/${SOURCE}" "${SRCURL}" || true + if [ $? -ne 0 ]; then + echo "Downloading '${SOURCE}' failed... aborting the build." + mv -f "${SRCDIR}/${SOURCE}" "${SRCDIR}/${SOURCE}".FAIL exit 1 fi + else + echo "File '${SOURCE}' not available... aborting the build." + exit 1 fi -done +fi -if [ "$1" == "--download" ]; then +if [ "$P1" == "--download" ]; then echo "Download complete." exit 0 fi + # --- PACKAGE BUILDING --- echo "++" echo "|| $PRGNAM-$VERSION" echo "++" -# Safety net 8-) -if [ "$PKG" = "" -o "$PKG" = "/" ] ; then - cat <<-EOT - Your script sucks!!! - You were about to delete the contents of your computer's hard disk! - Please provide a value for the variable 'PKG'. - EOT - exit 1 -fi -# We always erase old package's contents: -rm -rf $PKG/* - cd $PKG # Explode the package framework: -if [ -f $CWD/_$PRGNAM.tar.gz ]; then - explodepkg $CWD/_$PRGNAM.tar.gz +if [ -f $SRCDIR/_$PRGNAM.tar.gz ]; then + explodepkg $SRCDIR/_$PRGNAM.tar.gz fi cd $TMP/tmp-$PRGNAM @@ -131,16 +154,20 @@ cd $TMP/tmp-$PRGNAM # --- TARBALL EXTRACTION,PATCH,MODIFY --- -echo "Extracting the program tarball(s) for $PRGNAM..." -for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do - if `file $CWD/${SOURCE[$i]} | grep -q ": bzip2"`; then - tar -xjvf $CWD/${SOURCE[$i]} - elif `file $CWD/${SOURCE[$i]} | grep -qi ": zip"`; then - unzip $CWD/${SOURCE[$i]} - else - tar -xzvf $CWD/${SOURCE[$i]} - fi -done +echo "Extracting the source archive(s) for $PRGNAM..." +if `file $SRCDIR/${SOURCE} | grep -q ": bzip2"`; then + tar -xjvf $SRCDIR/${SOURCE} || true +elif `file $SRCDIR/${SOURCE} | grep -qi ": zip"`; then + unzip $SRCDIR/${SOURCE} || true +elif `file $SRCDIR/${SOURCE} | grep -qi ": 7-zip"`; then + 7za -x $SRCDIR/${SOURCE} || true +else + tar -xzvf $SRCDIR/${SOURCE} || true +fi +if [ $? -ne 0 ]; then + echo "Error in unpacking '${SOURCE}!' Aborting..." + exit $? +fi cd ${PRGNAM}-${VERSION} chown -R root.root * @@ -151,18 +178,25 @@ find . -perm 777 -exec chmod 755 {} \; echo Building ... +if [ ! -d /usr/include/gphoto2 ]; then + mkdir -p /usr/include/gphoto2 + find libgphoto2 -type f -name "*.h" -exec cp {} /usr/include/gphoto2/ \; + find libgphoto2_port/libgphoto2_port -type f -name "*.h" -exec cp {} /usr/include/gphoto2/ \; + CLEANUP_INCL="yes" +else + CLEANUP_INCL="no" +fi + +LDFLAGS="$SLKLDFLAGS" \ CFLAGS="$SLKCFLAGS" \ ./configure --prefix=/usr \ + --libdir=/usr/lib${LIBDIRSUFFIX} \ --localstatedir=/var \ --sysconfdir=/etc \ + --with-drivers=all \ --with-doc-dir=/usr/doc/${PRGNAM}-${VERSION} \ - 2>&1 | tee $CWD/configure-${PRGNAM}.log -make 2>&1 | tee $CWD/make-${PRGNAM}.log -RES=$? -if [ $RES -ne 0 ]; then - echo "Our make failed with error code '$RES'. Aborting the SlackBuild..." - exit $RES -fi + 2>&1 | tee $OUTPUT/configure-${PRGNAM}.log +make 2>&1 | tee $OUTPUT/make-${PRGNAM}.log # # Install all the needed stuff to the package dir @@ -170,28 +204,57 @@ fi # Use installwatch if available: which installwatch > /dev/null 2>&1 if [ $? == 0 ]; then - installwatch -o $CWD/install-${PRGNAM}.log make DESTDIR=$PKG install + installwatch -o $OUTPUT/install-${PRGNAM}.log make DESTDIR=$PKG install else - make DESTDIR=$PKG install 2>&1 |tee $CWD/install-${PRGNAM}.log + make DESTDIR=$PKG install 2>&1 |tee $OUTPUT/install-${PRGNAM}.log fi -# Create a link to print-usb-usermap +# Create a link to print-usb-usermap and print-camera-list mkdir -p $PKG/usr/bin (cd $PKG/usr/bin ln -sf ../lib/libgphoto2/print-usb-usermap + ln -sf ../lib/libgphoto2/print-camera-list ) +[ "$CLEANUP_INCL" == "yes" ] && rm -rf /usr/include/gphoto2 + + +# --- DOINST.SH --- + +mkdir -p $PKG/install +cat <<-EOT > $PKG/install/doinst.sh + # Install usbcam script for hotplug and udev + if [ ! -f etc/hotplug/usb/usbcam ]; then + mkdir -p etc/hotplug/usb + cat usr/doc/$PRGNAM-$VERSION/linux-hotplug/usbcam.group | sed -e "s/^GROUP=.*$/GROUP=video/" > etc/hotplug/usb/usbcam + chmod 755 etc/hotplug/usb/usbcam + fi + # Write hotplug usermap file + if [ ! -s etc/hotplug/usb/usbcam.usermap ]; then + ./usr/bin/print-camera-list usb-usermap > etc/hotplug/usb/usbcam.usermap + fi + # Write udev rules for gphoto2 + VUDEV=$( /usr/bin/udevinfo -V | sed -e 's/.* \([^ ]*\)/\1/' ) + if ! \`ls etc/udev/rules.d/ | grep -q libgphoto2\`; then + if [ \$VUDEV -lt 98 ]; then + ./usr/bin/print-camera-list udev-rules /etc/hotplug/usb/usbcam > etc/udev/rules.d/libgphoto2.rules + else + ./usr/bin/print-camera-list udev-rules-0.98 /etc/hotplug/usb/usbcam > etc/udev/rules.d/libgphoto2.rules + fi + fi + EOT + + # --- DOCUMENTATION --- mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION -cp -a $DOCS \ - $PKG/usr/doc/$PRGNAM-$VERSION -# Remove cruft -rm -r $PKG/usr/doc/$PRGNAM-$VERSION/apidocs.html +cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true +# Remove cruft directory +rm -rf $PKG/usr/doc/$PRGNAM-$VERSION/apidocs.html chmod -R a-w $PKG/usr/doc/$PRGNAM-$VERSION/* # Move incorrectly installed man pages -mv $PKG/usr/share/man $PKG/usr/ && rmdir $PKG/usr/share +mv $PKG/usr/share/man $PKG/usr/ && rmdir $PKG/usr/share || true # Compress the man page(s) find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \; @@ -210,12 +273,12 @@ chmod -R o-w $PKG # --- 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 +cat $SRCDIR/slack-desc > $PKG/install/slack-desc +if [ -f $SRCDIR/doinst.sh ]; then + cat $SRCDIR/doinst.sh >> $PKG/install/doinst.sh fi -if [ -f $CWD/slack-required ]; then - cat $CWD/slack-required > $PKG/install/slack-required +if [ -f $SRCDIR/slack-required ]; then + cat $SRCDIR/slack-required > $PKG/install/slack-required fi @@ -223,19 +286,18 @@ fi # 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 $PKG/install/slack-desc | grep "^${PRGNAM}" > $TMP/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.txt +makepkg --linkadd y --chown n --prepend $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log +(cd $OUTPUT && md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz.md5) +cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.txt if [ -f $PKG/install/slack-required ]; then - cat $PKG/install/slack-required > $TMP/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.dep + cat $PKG/install/slack-required > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.dep fi # --- CLEANUP --- # Clean up the extra stuff: -if [ "$1" = "--cleanup" ]; then +if [ "$P1" = "--cleanup" ]; then rm -rf $TMP/tmp-$PRGNAM rm -rf $PKG fi |