Some SlackBuild scripts for Slackware.
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.

138 lines
3.5 KiB

  1. #!/bin/bash
  2. # Build script for Slackware
  3. # Copyright (C) 2019,2020 Damien Goutte-Gattat
  4. #
  5. # Redistribution and use of this script, with or without modifications,
  6. # is permitted provided that the following conditions are met:
  7. #
  8. # 1. Redistributions of this script must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. #
  11. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS'' AND ANY EXPRESS OR
  12. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  14. # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  15. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  17. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  18. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  19. # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  20. # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  21. # POSSIBILITY OF SUCH DAMAGE.
  22. #
  23. # Contact: Damien Goutte-Gattat <dgouttegattat@incenp.org>
  24. #
  25. # Latest tpm2-abrmd sourcecode is available at:
  26. # <https://github.com/tpm2-software/tpm2-abrmd>.
  27. #
  28. # Depends: l/tpm2-tss
  29. # Source package infos
  30. NAMESRC=${NAMESRC:-tpm2-abrmd}
  31. VERSION=${VERSION:-2.3.2}
  32. ARCHIVE=${ARCHIVE:-$NAMESRC-$VERSION.tar.gz}
  33. WGET=${WGET:-https://github.com/tpm2-software/tpm2-abrmd/releases/download/$VERSION/$ARCHIVE}
  34. # Build infos
  35. NAMEPKG=${NAMEPKG:-tpm2-abrmd}
  36. BUILD=${BUILD:-1GGD}
  37. ARCH=${ARCH:-$(uname -m | sed 's/^i.86$/i486/;s/^arm.*/arm/')}
  38. JOBS=${JOBS:-1}
  39. EXT=${EXT:-txz}
  40. # Directories
  41. TMP=${TMP:-/tmp}
  42. OUT=${OUT:-$TMP/build}
  43. PKG=${PKG:-$OUT/$NAMEPKG}
  44. CWD=$(pwd)
  45. set -e # Quit if a command returns non-zero
  46. # Sanity checks
  47. if [ $UID -eq 0 ]; then
  48. echo "You should NOT run this script as ROOT!"
  49. exit 1
  50. fi
  51. if [ ! -d $TMP ]; then
  52. echo "$TMP does not exists or is not a directory!"
  53. exit 1
  54. fi
  55. # Compilation flags
  56. LIBDIRSUFFIX=""
  57. case "$ARCH" in
  58. i?86)
  59. CPUOPT="-O2 -march=$ARCH -mtune=i686"
  60. ;;
  61. x86_64)
  62. CPUOPT="-O2 -fPIC"
  63. LIBDIRSUFFIX="64"
  64. ;;
  65. *)
  66. CPUOPT="-O2"
  67. ;;
  68. esac
  69. # Get and verify the source archive
  70. if [ ! -r $ARCHIVE ]; then
  71. wget -c -O $ARCHIVE.part "$WGET"
  72. mv $ARCHIVE.part $ARCHIVE
  73. fi
  74. sha256sum -c $ARCHIVE.sha256
  75. NAME=$(tar ft $ARCHIVE | head -n 1 | cut -d / -f 1)
  76. # Compile
  77. cd $TMP
  78. echo "Building $ARCHIVE..."
  79. tar xf $CWD/$ARCHIVE
  80. cd $NAME
  81. CFLAGS=$CPUOPT \
  82. CXXFLAGS=$CPUOPT \
  83. ./configure \
  84. --prefix=/usr \
  85. --libdir=/usr/lib$LIBDIRSUFFIX \
  86. --sysconfdir=/etc \
  87. --localstatedir=/var \
  88. --mandir=/usr/man \
  89. --with-systemdsystemunitdir=/usr/lib/systemd/system \
  90. --with-systemdpresetdir=/usr/lib/system/system-preset \
  91. --disable-static \
  92. --disable-dependency-tracking \
  93. --build=$ARCH-slackware-linux
  94. make -j $JOBS
  95. make install-strip DESTDIR=$PKG
  96. # Compress man pages
  97. find $PKG/usr/man -type f -exec gzip -9 {} \;
  98. # Install rc script
  99. install -D -m 644 $CWD/rc.tabrmd $PKG/etc/rc.d/rc.tabrmd
  100. # Install the documentation
  101. mkdir -p $PKG/usr/doc/$NAME
  102. install -m 644 AUTHORS CHANGELOG.md CONTRIBUTING.md LICENSE README.md \
  103. $PKG/usr/doc/$NAME
  104. # Copy slack-desc files
  105. install -D -m 644 $CWD/slack-desc $PKG/install/slack-desc
  106. # Add dependency infos
  107. cat <<EOF > $PKG/install/slack-required
  108. tpm2-tss
  109. EOF
  110. # Package the tree
  111. cd $PKG
  112. mkdir -p $OUT
  113. PACKAGING="
  114. chown root:root . -R
  115. /sbin/makepkg -l y -c n $OUT/$NAMEPKG-$VERSION-$ARCH-$BUILD.$EXT
  116. rm -rf $PKG
  117. rm -rf $TMP/$NAME
  118. "
  119. if type -p fakeroot ; then
  120. echo "$PACKAGING" | fakeroot
  121. else
  122. su -c "$PACKAGING"
  123. fi