#!/bin/sh # # SlackBuild for unixdos-tools # http:// # By SukkoPera # 03/10/2005 # # Thanks a lot to CAT for his Slackware package cration # guide (http://www.slacky.it/misto/tutorial/spunleashed.txt) # # Check out # - http://www.sukkopera.tk # - http://www.slacky.it # - http://www.nyft.org # # Notes: # - x # Get the current and temporary directories CWD=`pwd` if [ "$TMP" = "" ]; then TMP=/tmp/pkg fi # Set up working directories if [ ! -d $TMP ] then mkdir -p $TMP fi # Some useful variables about the package NAME=`basename $0 .SlackBuild` PKG=$TMP/package-$NAME VERSION=1.0 #VERSION=`date +%Y%m%d` ARCH=i486 BUILD=1suk_12.0 SOURCEARCH1=dos2unix-3.1 SOURCEARCH2=unix2dos-2.2 # Set compilation flags according to the architecture case $ARCH in "i686") SLCKFLAGS="-O2 -march=i686" ;; "celeron") SLCKFLAGS="-Os -march=pentium3" ;; "pentium3") SLCKFLAGS="-O2 -march=pentium3" ;; "pentium4") SLCKFLAGS="-O2 -march=pentium4" ;; "duron"|"sempron") SLCKFLAGS="-Os -march=athlon-xp -m3dnow" ;; "athlonxp") SLCKFLAGS="-O2 -march=athlon-xp -m3dnow" ;; "x86_64") SLCKFLAGS="-O2 -march=athlon64" ;; "sparc") SLCKFLAGS="-O2" ;; "supersparc") SLCKFLAGS="-O2 -mcpu=supersparc" ;; *|"i486") SLCKFLAGS="-O2 -march=i486 -mcpu=i686" ;; esac # Add flags common to all architectures SLCKFLAGS="-pipe -fomit-frame-pointer $SLCKFLAGS" # Print a welcome screen echo "+-----------------------------------------------------------------------" echo "| $NAME-$VERSION" echo "+-----------------------------------------------------------------------" if [ -d $PKG ] then if [ "$1" == "--clean" ] then # Clean up a previous build and go on rm -rf $PKG $TMP/$NAME-$VERSION else # Warn the user and stop echo "Previous package build directory found, please remove it and" echo "restart the SlackBuild script: $PKG" exit 1 fi fi mkdir -p $PKG for i in usr/bin usr/man/man1 do echo "--- Creating directory $PKG/$i" mkdir -p $PKG/$i done cd $TMP mkdir $NAME-$VERSION ########################################## ### dos2unix ########################################## # Decompress echo "------------------------- Uncompressing source -------------------------" tar jxvf $CWD/$SOURCEARCH1.tar.bz2 #mv $SOURCEARCH $NAME-$VERSION cd $SOURCEARCH1 echo "------------------------------- Patching -------------------------------" patch -p1 < $CWD/dos2unix-3.1.patch patch -p1 < $CWD/dos2unix-3.1-segfault.patch make clean # Build #echo "------------------------------ Configuring -----------------------------" echo "------------------------------ Compiling -------------------------------" make CFLAGS="$SLCKFLAGS" res=$? if [ $res -ne 0 ] then # make failed, we cannot continue exit $res fi echo "------------------------------ Installing ------------------------------" #make install DESTDIR=$PKG #res=$? #if [ $res -ne 0 ] #then # make install failed, we cannot continue # exit 1 #fi cp dos2unix $PKG/usr/bin ln -s dos2unix $PKG/usr/bin/mac2unix cp dos2unix.1 $PKG/usr/man/man1 # Doc echo "----------------- Copying documentation and other files ----------------" DOCSDIR=$PKG/usr/doc/$NAME-$VERSION/$SOURCEARCH1 mkdir -p $DOCSDIR for i in COPYRIGHT INSTALL do # cat $i | gzip > $DOCSDIR/$i.gz cp -a $i $DOCSDIR done cd .. ########################################## ### unix2dos ########################################## # Decompress echo "------------------------- Uncompressing source -------------------------" tar zxvf $CWD/$SOURCEARCH2.src.tar.gz #mv $SOURCEARCH $NAME-$VERSION echo "------------------------------- Patching -------------------------------" patch -p1 < $CWD/unix2dos-mkstemp.patch patch -p1 < $CWD/unix2dos-2.2-segfault.patch patch -p1 < $CWD/unix2dos-2.2-manpage.patch # Build #echo "------------------------------ Configuring -----------------------------" echo "------------------------------ Compiling -------------------------------" gcc $SLCKFLAGS -o unix2dos unix2dos.c res=$? if [ $res -ne 0 ] then # make failed, we cannot continue exit $res fi echo "------------------------------ Installing ------------------------------" #make install DESTDIR=$PKG #res=$? #if [ $res -ne 0 ] #then # make install failed, we cannot continue # exit 1 #fi cp unix2dos $PKG/usr/bin cp unix2dos.1 $PKG/usr/man/man1 # Doc echo "----------------- Copying documentation and other files ----------------" DOCSDIR=$PKG/usr/doc/$NAME-$VERSION/$SOURCEARCH2 mkdir -p $DOCSDIR for i in COPYRIGHT do # cat $i | gzip > $DOCSDIR/$i.gz cp -a $i $DOCSDIR done # Gzip man pages find $PKG/usr/man -name "*.[123456789]" -exec gzip -9 {} \; # SlackBuild stuff mkdir -p $PKG/usr/doc/$NAME-$VERSION/slackbuild cp $CWD/{$0,slack-desc} $PKG/usr/doc/$NAME-$VERSION/slackbuild # Strip binaries echo "--------------------------- Stripping binaries -------------------------" find $PKG -type f | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded # Set permissions echo "--------------------------- Setting permissions ------------------------" chown -R root.bin $PKG/usr/bin # $PKG/usr/sbin chown -R root.root $PKG/usr/doc chmod -R 755 $PKG/usr/doc/* find $PKG/usr/doc -type f -exec chmod 644 {} \; if [ -d $PKG/usr/share ] then chown -R root.root $PKG/usr/share chmod -R 755 $PKG/usr/share/* find $PKG/usr/share -type f -exec chmod 644 {} \; fi # Copy Slackware package files echo "--------------------- Copying Slackware package files ------------------" mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc #cp $CWD/doinst.sh $PKG/install #chmod 755 $PKG/install/doinst.sh #cat $CWD/slack-required > $PKG/install/slack-required # Create package echo "---------------------------- Creating package --------------------------" echo "Creating package" cd $PKG makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz # Clean up if [ "$1" = "--cleanup" ]; then echo "---------------------- Cleaning up working directory -------------------" rm -rf $TMP/$NAME-$VERSION rm -rf $PKG fi # Package created echo "Package creation finished!"