google-go-lang.SlackBuild 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/bin/bash
  2. # Slackware build script for google-go-lang
  3. # Written by Eric Schultz eric at schultzter.ca
  4. # Taken over by Vincent Batts vbatts@hashbangbash.com
  5. # Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018 Vincent Batts
  6. # Copyright (c) 2012 Eric Schultz
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining a copy of
  9. # this software and associated documentation files (the "Software"), to deal in
  10. # the Software without restriction, including without limitation the rights to
  11. # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  12. # the Software, and to permit persons to whom the Software is furnished to do so,
  13. # subject to the following conditions:
  14. #
  15. # The above copyright notice and this permission notice shall be included in all
  16. # copies or substantial portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. # SOFTWARE.
  25. cd $(dirname $0) ; CWD=$(pwd)
  26. PRGNAM=google-go-lang
  27. VERSION=${VERSION:-1.19.7}
  28. BUILD=${BUILD:-1}
  29. TAG=${TAG:-_SBo}
  30. PKGTYPE=${PKGTYPE:-tgz}
  31. RELEASE=${RELEASE:-linux}
  32. RUN_TEST=${RUN_TEST:-false}
  33. if [ -z "$ARCH" ]; then
  34. case "$( uname -m )" in
  35. i?86) ARCH=i586 ;;
  36. arm*) ARCH=arm ;;
  37. *) ARCH=$( uname -m ) ;;
  38. esac
  39. fi
  40. if [ "$ARCH" = "i586" ]; then
  41. LIBDIRSUFFIX=""
  42. GOARCH="386"
  43. elif [ "$ARCH" = "x86_64" ]; then
  44. LIBDIRSUFFIX="64"
  45. GOARCH="amd64"
  46. elif [ "$ARCH" = "arm" ]; then
  47. LIBDIRSUFFIX=""
  48. GOARCH="arm"
  49. export GOARM="7" # can be '5' as well, to use soft float instead of hardware
  50. elif [ "$ARCH" = "aarch64" ]; then
  51. LIBDIRSUFFIX="64"
  52. GOARCH="arm64"
  53. else
  54. LIBDIRSUFFIX=""
  55. GOARCH=386
  56. fi
  57. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  58. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  59. exit 0
  60. fi
  61. TMP=${TMP:-/tmp/SBo}
  62. PKG=$TMP/package-$PRGNAM
  63. OUTPUT=${OUTPUT:-/tmp}
  64. set -e
  65. rm -rf $PKG
  66. mkdir -p $TMP $PKG/usr/lib${LIBDIRSUFFIX}/go${VERSION} $OUTPUT
  67. cd $PKG/usr/lib${LIBDIRSUFFIX}/go${VERSION}
  68. tar xvf $CWD/go${VERSION}.src.tar.gz
  69. cd go
  70. chown -R root:root .
  71. find -L . \
  72. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  73. -o -perm 511 \) -exec chmod 755 {} \; -o \
  74. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  75. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  76. # as of >= go1.5, the cross-compiler does not need to be bootstrap, so the
  77. # compiler need only be compiled for the host OS, which it detects
  78. unset GOBIN GOPATH GOOS GOARCH
  79. # Not sure why, but this causes run.bash to fail --rworkman
  80. unset BASH_ENV
  81. # gcc 5+ is go1.4 API, so we'll bootstrap with it
  82. export GOROOT_BOOTSTRAP="/usr"
  83. # Default GOROOT is the parent directory of all.bash,
  84. # which is the current directory we're in.
  85. # Defining it here means we can use it below when building
  86. # shared libraries
  87. export GOROOT="$(pwd)"
  88. # The value of GOROOT once the package is installed
  89. export GOROOT_FINAL="/usr/lib${LIBDIRSUFFIX}/go${VERSION}/go"
  90. case "$ARCH" in
  91. arm|i?86) export GOMAXPROCS=1 ;;
  92. esac
  93. cd src
  94. if [ "x${RUN_TEST}" = "xtrue" ] ; then
  95. LC_ALL=C \
  96. ./all.bash
  97. else
  98. LC_ALL=C \
  99. ./make.bash
  100. fi
  101. # As of go1.5, golang supports shared libraries, so generate them for use.
  102. $GOROOT/bin/go install -buildmode=shared std
  103. cd ..
  104. # remove Go build cache
  105. rm -rf pkg/obj/go-build/*
  106. # remove the doc Makefile
  107. rm -f doc/Makefile
  108. mkdir -p $PKG$GOROOT_FINAL
  109. # Put the profile scripts for setting PATH and env variables
  110. mkdir -p $PKG/etc/profile.d
  111. cat > $PKG/etc/profile.d/go.csh << EOF
  112. #!/bin/csh
  113. setenv GOROOT ${GOROOT_FINAL}
  114. setenv PATH \${GOROOT}/bin:\${PATH}
  115. EOF
  116. cat > $PKG/etc/profile.d/go.sh << EOF
  117. #!/bin/sh
  118. export GOROOT="${GOROOT_FINAL}"
  119. export PATH="\${GOROOT}/bin:\${PATH}"
  120. EOF
  121. chmod 0755 $PKG/etc/profile.d/go.csh
  122. chmod 0755 $PKG/etc/profile.d/go.sh
  123. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  124. cp -a \
  125. CONTRIBUTING.md LICENSE PATENTS README.md SECURITY.md VERSION \
  126. $PKG/usr/doc/$PRGNAM-$VERSION
  127. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  128. mkdir -p $PKG/install
  129. cat $CWD/slack-desc > $PKG/install/slack-desc
  130. cd $PKG
  131. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE