You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.7 KiB

  1. #!/bin/bash
  2. # Slackware build script for hug
  3. # Written by Steve Pledger <spledger91@yahoo.com>
  4. cd $(dirname $0) ; CWD=$(pwd)
  5. PRGNAM=hug
  6. VERSION=${VERSION:-0.100}
  7. BUILD=${BUILD:-1}
  8. TAG=${TAG:-_SBo}
  9. PKGTYPE=${PKGTYPE:-tgz}
  10. if [ -z "$ARCH" ]; then
  11. case "$( uname -m )" in
  12. i?86) ARCH=i486 ;;
  13. arm*) ARCH=arm ;;
  14. *) ARCH=$( uname -m ) ;;
  15. esac
  16. fi
  17. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  18. # the name of the created package would be, and then exit. This information
  19. # could be useful to other scripts.
  20. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  21. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  22. exit 0
  23. fi
  24. TMP=${TMP:-/tmp/SBo}
  25. PKG=$TMP/package-$PRGNAM
  26. OUTPUT=${OUTPUT:-/tmp}
  27. # Version number may change, so figure out the real version
  28. SRCVER=$(grep 'REM Version' $CWD/hug.bac | tail -n1 | cut -d' ' -f3)
  29. if [ "$VERSION" != "$SRCVER" ]; then
  30. cat <<EOF
  31. WARNING: The source version ($SRCVER) does not match the VERSION variable ($VERSION).
  32. To build anyway, run the SlackBuild like this:
  33. VERSION=$SRCVER ./$PRGNAM.SlackBuild
  34. exiting...
  35. EOF
  36. exit 1
  37. fi
  38. if [ "$ARCH" = "i486" ]; then
  39. SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  40. LIBDIRSUFFIX=""
  41. elif [ "$ARCH" = "i686" ]; then
  42. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  43. LIBDIRSUFFIX=""
  44. elif [ "$ARCH" = "x86_64" ]; then
  45. SLKCFLAGS="-O2 -fPIC"
  46. LIBDIRSUFFIX="64"
  47. else
  48. SLKCFLAGS="-O2"
  49. LIBDIRSUFFIX=""
  50. fi
  51. set -e
  52. rm -rf $PKG
  53. mkdir -p $TMP $PKG $OUTPUT
  54. cd $TMP
  55. rm -rf $PRGNAM-$VERSION
  56. mkdir $PRGNAM-$VERSION
  57. cd $PRGNAM-$VERSION
  58. # Bacon creates a binary in the same location as the source, so copy the source file here.
  59. cat $CWD/hug.bac > hug.bac
  60. chown -R root:root .
  61. find -L . \
  62. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  63. -o -perm 511 \) -exec chmod 755 {} \; -o \
  64. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  65. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  66. # Build shared object "hug.so"
  67. bacon -p -o $(echo $SLKCFLAGS | sed -e 's: : -o :g') -f hug.bac
  68. mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
  69. install -m 0755 hug.so $PKG/usr/lib${LIBDIRSUFFIX}
  70. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  71. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  72. mkdir -p $PKG/usr/include
  73. sed -e 's:./hug.so:hug.so:' $CWD/hug_imports.bac > $PKG/usr/include/hug_imports.bac
  74. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  75. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  76. cat $CWD/README.SLACKWARE > $PKG/usr/doc/$PRGNAM-$VERSION/README.SLACKWARE
  77. mkdir -p $PKG/install
  78. cat $CWD/slack-desc > $PKG/install/slack-desc
  79. cd $PKG
  80. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE