hare.SlackBuild 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/bash
  2. # Slackware build script for hare
  3. # Copyright 2023 Dave Gauer, http://ratfactor.com
  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. cd $(dirname $0) ; CWD=$(pwd)
  23. # Note that hare doesn't yet have a released version.
  24. # This script is set to the same commit currently (at the time of this
  25. # writing) used by the Alpine community package:
  26. #
  27. # https://git.alpinelinux.org/aports/tree/community/hare/APKBUILD
  28. #
  29. PRGNAM=hare
  30. VERSION=${VERSION:-20230225}
  31. BUILD=${BUILD:-1}
  32. TAG=${TAG:-_SBo}
  33. PKGTYPE=${PKGTYPE:-tgz}
  34. COMMITVERSION=${COMMITVERSION:-1cbc3d0453055fa75b15797e937f4abafe53bcbc}
  35. if [ -z "$ARCH" ]; then
  36. case "$( uname -m )" in
  37. i?86) ARCH=i586 ;;
  38. arm*) ARCH=arm ;;
  39. *) ARCH=$( uname -m ) ;;
  40. esac
  41. fi
  42. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  43. # the name of the created package would be, and then exit. This information
  44. # could be useful to other scripts.
  45. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  46. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  47. exit 0
  48. fi
  49. TMP=${TMP:-/tmp/SBo}
  50. PKG=$TMP/package-$PRGNAM
  51. OUTPUT=${OUTPUT:-/tmp}
  52. if [ "$ARCH" = "i586" ]; then
  53. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  54. LIBDIRSUFFIX=""
  55. elif [ "$ARCH" = "i686" ]; then
  56. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  57. LIBDIRSUFFIX=""
  58. elif [ "$ARCH" = "x86_64" ]; then
  59. SLKCFLAGS="-O2 -fPIC"
  60. LIBDIRSUFFIX="64"
  61. else
  62. SLKCFLAGS="-O2"
  63. LIBDIRSUFFIX=""
  64. fi
  65. set -e
  66. rm -rf $PKG
  67. mkdir -p $TMP $PKG $OUTPUT
  68. cd $TMP
  69. rm -rf $PRGNAM-$VERSION
  70. if [ -e $CWD/$PRGNAM-$COMMITVERSION.tar.gz ]
  71. then
  72. # browser download
  73. tar xvf $CWD/$PRGNAM-$COMMITVERSION.tar.gz
  74. else
  75. # wget download
  76. tar xvf $CWD/$COMMITVERSION.tar.gz
  77. fi
  78. cd $PRGNAM-$COMMITVERSION
  79. chown -R root:root .
  80. find -L . \
  81. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  82. -o -perm 511 \) -exec chmod 755 {} \; -o \
  83. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  84. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  85. # Copy example config and change prefix dir and mandirs.
  86. # Interestingly, this changes them to what is shown at
  87. # https://harelang.org/distributions/
  88. # /usr/local --> /usr
  89. # /usr/share/man --> /usr/man
  90. cp config.example.mk config.mk
  91. sed -i 's|/usr/local|/usr|' config.mk
  92. sed -i 's|/share/man|/man|' config.mk
  93. # Making this build script idempotent to make it easier to test
  94. make clean
  95. CFLAGS="$SLKCFLAGS" \
  96. CXXFLAGS="$SLKCFLAGS" \
  97. PREFIX=/usr \
  98. make
  99. # Shouldn't need this (install also performs it), but I had some
  100. # trouble (zero length hare.1) and this *seemed* to do the trick.
  101. make docs
  102. make install DESTDIR=$PKG PREFIX=/usr
  103. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  104. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  105. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  106. cp -a \
  107. COPYING \
  108. README \
  109. README.md \
  110. $PKG/usr/doc/$PRGNAM-$VERSION
  111. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  112. # man pages need to be compressed
  113. gzip -9 $PKG/usr/man/man1/hare.1
  114. gzip -9 $PKG/usr/man/man1/haredoc.1
  115. mkdir -p $PKG/install
  116. cat $CWD/slack-desc > $PKG/install/slack-desc
  117. cd $PKG
  118. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE