samtools-legacy.SlackBuild 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #!/bin/bash
  2. # Slackware build script for samtools-legacy
  3. # Copyright 2013-2021 Petar Petrov slackalaxy@gmail.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. # With help about the install paths from Arch Linux AUR:
  23. # https://aur.archlinux.org/packages/sa/samtools/PKGBUILD
  24. cd $(dirname $0) ; CWD=$(pwd)
  25. PRGNAM=samtools-legacy
  26. VERSION=${VERSION:-0.1.19}
  27. BUILD=${BUILD:-2}
  28. TAG=${TAG:-_SBo}
  29. PKGTYPE=${PKGTYPE:-tgz}
  30. SRCNAM=samtools
  31. SUFFIX=legacy
  32. if [ -z "$ARCH" ]; then
  33. case "$( uname -m )" in
  34. i?86) ARCH=i586 ;;
  35. arm*) ARCH=arm ;;
  36. *) ARCH=$( uname -m ) ;;
  37. esac
  38. fi
  39. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  40. # the name of the created package would be, and then exit. This information
  41. # could be useful to other scripts.
  42. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  43. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  44. exit 0
  45. fi
  46. TMP=${TMP:-/tmp/SBo}
  47. PKG=$TMP/package-$PRGNAM
  48. OUTPUT=${OUTPUT:-/tmp}
  49. if [ "$ARCH" = "i586" ]; then
  50. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  51. LIBDIRSUFFIX=""
  52. elif [ "$ARCH" = "i686" ]; then
  53. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  54. LIBDIRSUFFIX=""
  55. elif [ "$ARCH" = "x86_64" ]; then
  56. SLKCFLAGS="-O2 -fPIC"
  57. LIBDIRSUFFIX="64"
  58. else
  59. SLKCFLAGS="-O2"
  60. LIBDIRSUFFIX=""
  61. fi
  62. set -e
  63. rm -rf $PKG
  64. mkdir -p $TMP $PKG $OUTPUT
  65. cd $TMP
  66. rm -rf $SRCNAM-$VERSION
  67. tar xvf $CWD/$SRCNAM-$VERSION.tar.bz2
  68. cd $SRCNAM-$VERSION
  69. chown -R root:root .
  70. find -L . \
  71. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  72. -o -perm 511 \) -exec chmod 755 {} \; -o \
  73. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  74. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  75. # Use our CFLAGS/CXXFLAGS
  76. sed -i "/^C.*.*FLAGS/s/=/+=/" Makefile
  77. CFLAGS="$SLKCFLAGS" \
  78. make
  79. make razip
  80. # Install samtools, razip and bam library
  81. install -D -m755 samtools $PKG/usr/bin/samtools-$SUFFIX
  82. install -D -m755 razip $PKG/usr/bin/razip-$SUFFIX
  83. install -D -m644 libbam.a $PKG/usr/lib${LIBDIRSUFFIX}/libbam.a
  84. # Install bcftools its library and vsfutils
  85. cd bcftools
  86. install -D -m755 bcftools $PKG/usr/bin/bcftools-$SUFFIX
  87. install -D -m644 libbcf.a $PKG/usr/lib${LIBDIRSUFFIX}/libbcf.a
  88. install -D -m755 vcfutils.pl $PKG/usr/bin/vcfutils-$SUFFIX.pl
  89. # Include additional executables
  90. cd ../misc
  91. install -D -m755 ace2sam $PKG/usr/libexec/$PRGNAM/ace2sam
  92. install -D -m755 bamcheck $PKG/usr/libexec/$PRGNAM/bamcheck
  93. install -D -m755 maq2sam-long $PKG/usr/libexec/$PRGNAM/maq2sam-long
  94. install -D -m755 maq2sam-short $PKG/usr/libexec/$PRGNAM/maq2sam-short
  95. install -D -m755 md5fa $PKG/usr/libexec/$PRGNAM/md5fa
  96. install -D -m755 md5sum-lite $PKG/usr/libexec/$PRGNAM/md5sum-lite
  97. install -D -m755 wgsim $PKG/usr/libexec/$PRGNAM/wgsim
  98. # Include some scripts
  99. mkdir -p $PKG/usr/share/$PRGNAM
  100. cp -a \
  101. *.pl *.lua *.py plot-bamcheck \
  102. $PKG/usr/share/$PRGNAM
  103. # Include bam header files
  104. cd ..
  105. mkdir -p $PKG/usr/include/bam
  106. for f in *.h ; do
  107. install -m644 $f "$PKG/usr/include/bam"
  108. done
  109. # Install manpage
  110. install -D -m644 $SRCNAM.1 $PKG/usr/man/man1/$PRGNAM.1
  111. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  112. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  113. find $PKG/usr/man -type f -exec gzip -9 {} \;
  114. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  115. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  116. cp -a \
  117. AUTHORS COPYING INSTALL NEWS \
  118. $PKG/usr/doc/$PRGNAM-$VERSION
  119. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  120. cat $CWD/References > $PKG/usr/doc/$PRGNAM-$VERSION/References
  121. # Fix permissions in the package...
  122. find $PKG/usr/{doc,include,share} \
  123. -type d -exec chmod 755 {} \; -o \
  124. -type f -exec chmod 644 {} \;
  125. mkdir -p $PKG/install
  126. cat $CWD/slack-desc > $PKG/install/slack-desc
  127. cd $PKG
  128. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE