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.

171 lines
6.3 KiB

  1. #!/bin/sh
  2. # Slackware build script for <appname>
  3. # Copyright <year> <you> <where you live>
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. # |-----------------------------------------------------------------| #
  23. # REMOVE THIS ENTIRE BLOCK OF TEXT #
  24. #
  25. # A license is required, and we strongly suggest you use the above
  26. # BSD/MIT style license. We DO NOT accept "Public Domain" scripts.
  27. # Public domain is not valid in some countries, and no license is
  28. # worse than a "bad" license in those countries.
  29. #
  30. # This template is not meant to be a 'cut and paste' script to
  31. # enable any random user to make a working package. While
  32. # we're certainly not discouraging use of this template, if
  33. # you haven't manually gone through each step of the process
  34. # without the build script (typically as a normal user, as this
  35. # will reveal problems that you won't see as root), then there's
  36. # a good chance that something important is missing from your
  37. # submission.
  38. # When using this template script, please remove as many of
  39. # these unnecessary comments as possible. Commented code is
  40. # a good thing, but if it's obvious, there's no need to comment it.
  41. #
  42. # AGAIN, REMOVE THE COMMENTS IF THEY ARE NOT NEEDED - DON'T JUST
  43. # DELETE THIS BLOCK OF TEXT WITHOUT BOTHERING TO READ WHAT'S IN IT.
  44. #
  45. # |-----------------------------------------------------------------| #
  46. PRGNAM=appname # replace with name of program
  47. VERSION=${VERSION:-1.4.1} # replace with version of program
  48. BUILD=${BUILD:-1}
  49. TAG=${TAG:-_SBo} # the "_SBo" is required
  50. # Automatically determine the architecture we're building on:
  51. if [ -z "$ARCH" ]; then
  52. case "$( uname -m )" in
  53. i?86) ARCH=i586 ;;
  54. arm*) ARCH=arm ;;
  55. # Unless $ARCH is already set, use uname -m for all other archs:
  56. *) ARCH=$( uname -m ) ;;
  57. esac
  58. fi
  59. CWD=$(pwd)
  60. TMP=${TMP:-/tmp/SBo} # For consistency's sake, use this
  61. PKG=$TMP/package-$PRGNAM
  62. OUTPUT=${OUTPUT:-/tmp} # Drop the package in /tmp
  63. if [ "$ARCH" = "i586" ]; then
  64. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  65. LIBDIRSUFFIX=""
  66. elif [ "$ARCH" = "i686" ]; then
  67. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  68. LIBDIRSUFFIX=""
  69. elif [ "$ARCH" = "x86_64" ]; then
  70. SLKCFLAGS="-O2 -fPIC"
  71. LIBDIRSUFFIX="64"
  72. else
  73. SLKCFLAGS="-O2"
  74. LIBDIRSUFFIX=""
  75. fi
  76. set -e # Exit on most errors
  77. # If you prefer to do selective error checking with
  78. # command || exit 1
  79. # then that's also acceptable.
  80. rm -rf $PKG
  81. mkdir -p $TMP $PKG $OUTPUT
  82. cd $TMP
  83. rm -rf $PRGNAM-$VERSION
  84. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  85. cd $PRGNAM-$VERSION
  86. chown -R root:root .
  87. find -L . \
  88. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  89. -o -perm 511 \) -exec chmod 755 {} \; -o \
  90. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  91. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  92. # Your application will probably need different configure flags;
  93. # these are provided as an example only.
  94. # Be sure to build only shared libraries unless there's some need for
  95. # static.
  96. CFLAGS="$SLKCFLAGS" \
  97. CXXFLAGS="$SLKCFLAGS" \
  98. ./configure \
  99. --prefix=/usr \
  100. --libdir=/usr/lib${LIBDIRSUFFIX} \
  101. --sysconfdir=/etc \
  102. --localstatedir=/var \
  103. --mandir=/usr/man \
  104. --docdir=/usr/doc/$PRGNAM-$VERSION \
  105. --disable-static \
  106. --build=$ARCH-slackware-linux
  107. # Compile the application and install it into the $PKG directory
  108. make
  109. make install DESTDIR=$PKG
  110. # Strip binaries and libraries - this can be done with 'make install-strip'
  111. # in many source trees, and that's usually acceptable if so, but if not,
  112. # use this:
  113. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  114. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  115. # Compress man pages
  116. # If the man pages are installed to /usr/share/man instead, you'll need to either
  117. # add the --mandir=/usr/man flag to configure or move them manually after the
  118. # make install process is run.
  119. find $PKG/usr/man -type f -exec gzip -9 {} \;
  120. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  121. # Compress info pages and remove the package's dir file
  122. # If no info pages are installed by the software, don't leave this in the script
  123. rm -f $PKG/usr/info/dir
  124. gzip -9 $PKG/usr/info/*.info*
  125. # Remove perllocal.pod and other special files that don't need to be installed,
  126. # as they will overwrite what's already on the system. If this is not needed,
  127. # remove it from the script.
  128. # Remove 'special' files
  129. find $PKG -name perllocal.pod \
  130. -o -name ".packlist" \
  131. -o -name "*.bs" \
  132. | xargs rm -f
  133. # Copy program documentation into the package
  134. # The included documentation varies from one application to another, so be sure
  135. # to adjust your script as needed
  136. # Also, include the SlackBuild script in the documentation directory
  137. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  138. cp -a \
  139. <documentation> \
  140. $PKG/usr/doc/$PRGNAM-$VERSION
  141. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  142. # Copy the slack-desc (and a custom doinst.sh if necessary) into ./install
  143. mkdir -p $PKG/install
  144. cat $CWD/slack-desc > $PKG/install/slack-desc
  145. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  146. # Make the package; be sure to leave it in $OUTPUT
  147. # If package symlinks need to be created during install *before*
  148. # your custom contents of doinst.sh runs, then add the -p switch to
  149. # the makepkg command below -- see makepkg(8) for details
  150. cd $PKG
  151. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}