google-go-lang.SlackBuild 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.17.9}
  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="6" # can be '5' as well, to use soft float instead of hardware
  50. else
  51. LIBDIRSUFFIX=""
  52. GOARCH=386
  53. fi
  54. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  55. # the name of the created package would be, and then exit. This information
  56. # could be useful to other scripts.
  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. if [ "$ARCH" = "i586" ]; then
  82. # issue with gccgo+go1.16 on x86
  83. # https://www.linuxquestions.org/questions/showthread.php?p=6253507
  84. # hopefully this is not needed forever...
  85. tar -C $TMP -xf $CWD/go1.4-bootstrap-20171003.tar.gz
  86. pushd $TMP/go
  87. export GOROOT=$TMP/go
  88. cd ./src
  89. ./make.bash
  90. popd
  91. export GOROOT_BOOTSTRAP="$TMP/go"
  92. else
  93. # gcc 5+ is go1.4 API, so we'll bootstrap with it
  94. export GOROOT_BOOTSTRAP="/usr"
  95. fi
  96. # Default GOROOT is the parent directory of all.bash,
  97. # which is the current directory we're in.
  98. # Defining it here means we can use it below when building
  99. # shared libraries
  100. export GOROOT="$(pwd)"
  101. # The value of GOROOT once the package is installed
  102. export GOROOT_FINAL="/usr/lib${LIBDIRSUFFIX}/go${VERSION}/go"
  103. cd src
  104. if [ "x${RUN_TEST}" = "xtrue" ] ; then
  105. LC_ALL=C \
  106. ./all.bash
  107. else
  108. LC_ALL=C \
  109. ./make.bash
  110. fi
  111. # As of go1.5, golang supports shared libraries, so generate them for use.
  112. $GOROOT/bin/go install -buildmode=shared std
  113. cd ..
  114. # remove Go build cache
  115. rm -rf pkg/obj/go-build/*
  116. # remove the doc Makefile
  117. rm -f doc/Makefile
  118. mkdir -p $PKG$GOROOT_FINAL
  119. # Put the profile scripts for setting PATH and env variables
  120. mkdir -p $PKG/etc/profile.d
  121. cat > $PKG/etc/profile.d/go.csh << EOF
  122. #!/bin/csh
  123. setenv GOROOT ${GOROOT_FINAL}
  124. setenv PATH \${GOROOT}/bin:\${PATH}
  125. EOF
  126. cat > $PKG/etc/profile.d/go.sh << EOF
  127. #!/bin/sh
  128. export GOROOT="${GOROOT_FINAL}"
  129. export PATH="\${GOROOT}/bin:\${PATH}"
  130. EOF
  131. chmod 0755 $PKG/etc/profile.d/go.csh
  132. chmod 0755 $PKG/etc/profile.d/go.sh
  133. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  134. cp -a \
  135. AUTHORS CONTRIBUTING.md CONTRIBUTORS LICENSE PATENTS README.md VERSION \
  136. $PKG/usr/doc/$PRGNAM-$VERSION
  137. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  138. mkdir -p $PKG/install
  139. cat $CWD/slack-desc > $PKG/install/slack-desc
  140. cd $PKG
  141. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE