go.spec 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. ##
  2. ## go.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2020 OpenPKG Project <http://openpkg.org/>
  4. ##
  5. ## Permission to use, copy, modify, and distribute this software for
  6. ## any purpose with or without fee is hereby granted, provided that
  7. ## the above copyright notice and this permission notice appear in all
  8. ## copies.
  9. ##
  10. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  11. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  14. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  20. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21. ## SUCH DAMAGE.
  22. ##
  23. # package information
  24. Name: go
  25. Summary: The Go Programming Language
  26. URL: http://golang.org/
  27. Vendor: Robert Griesemer, Rob Pike, Ken Thompson
  28. Packager: OpenPKG Project
  29. Distribution: OpenPKG Community
  30. Class: PLUS
  31. Group: Language
  32. License: BSD
  33. Version: 1.14.7
  34. Release: 20200807
  35. # list of sources
  36. Source0: http://golang.org/dl/go%{version}.src.tar.gz
  37. Patch0: go.patch
  38. # build information
  39. BuildPreReq: OpenPKG, openpkg >= 20160101, gcc, make, bison, flex
  40. PreReq: OpenPKG, openpkg >= 20160101, gcc, x509
  41. BuildPreReq: go-cc
  42. PreReq: go-cc
  43. %description
  44. Go is a concurrent garbage-collected system programming language,
  45. designed 2007 by Robert Griesemer, Rob Pike and Ken Thompson at
  46. Google. Go is expressive, concise, clean, and efficient. Its
  47. concurrency mechanisms make it easy to write programs that get
  48. the most out of multicore and networked machines, while its novel
  49. type system enables flexible and modular program construction. Go
  50. compiles quickly to machine code yet has the convenience of garbage
  51. collection and the power of run-time reflection. It's a fast,
  52. statically typed, compiled language that feels like a dynamically
  53. typed, interpreted language.
  54. %track
  55. prog go = {
  56. version = %{version}
  57. url = http://golang.org/dl/
  58. regex = go(\d+\.\d+(?:\.\d+)?)\.src\.tar\.gz
  59. }
  60. %prep
  61. %setup -q -n go
  62. %patch -p0
  63. %build
  64. # patch the patch
  65. %{l_shtool} subst %{l_value -s -a} \
  66. src/crypto/x509/root_unix.go
  67. # configure package
  68. export GOCACHE="`pwd`"
  69. export GOROOT="`pwd`"
  70. export GOBIN="`pwd`/bin"
  71. export GOROOT_FINAL="%{l_prefix}/lib/go"
  72. if [ -x %{l_prefix}/lib/go/bin/go ]; then
  73. export GOROOT_BOOTSTRAP="%{l_prefix}/lib/go"
  74. elif [ -x %{l_prefix}/lib/go-bootstrap/bin/go ]; then
  75. export GOROOT_BOOTSTRAP="%{l_prefix}/lib/go-bootstrap"
  76. else
  77. ( echo "ATTENTION! Because Go version 1.5 and higher is written in Go itself"
  78. echo "you either need an already (older) installed \"go\" package or you have"
  79. echo "to install at least once the \"go-bootstrap\" package for bootstrapping."
  80. ) | %{l_rpmtool} msg -b -t error
  81. exit 1
  82. fi
  83. export GOOS=""
  84. export GOARCH=""
  85. case "%{l_platform -t}" in
  86. *-freebsd* ) GOOS="freebsd" ;;
  87. *-linux* ) GOOS="linux" ;;
  88. *-macosx* ) GOOS="darwin" ;;
  89. esac
  90. case "%{l_platform -t}" in
  91. ix86-* ) GOARCH="386" ;;
  92. amd64-* ) GOARCH="amd64" ;;
  93. esac
  94. if [ ".$GOOS" = . -o ".$GOARCH" = . ]; then
  95. echo "ERROR: platform not supported" 1>&2
  96. exit 1
  97. fi
  98. # provide the dedicated C/C++ compiler wrappers
  99. # (which is also available later for Go to compile)
  100. export CC="%{l_prefix}/bin/go-cc"
  101. export CXX="%{l_prefix}/bin/go-c++"
  102. # build program
  103. %{l_shtool} mkdir -f -p -m 755 $GOBIN
  104. cd src
  105. %{l_bash} make.bash
  106. %install
  107. # cleanup source tree
  108. rm -rf bin-tmp
  109. rm -f favicon.ico
  110. rm -rf [0-9][0-9] [0-9][a-f] [a-f][0-9] [a-f][a-f]
  111. rm -rf [A-R]* doc misc test
  112. # create installation hierarchy
  113. %{l_shtool} mkdir -f -p -m 755 \
  114. $RPM_BUILD_ROOT%{l_prefix}/bin \
  115. $RPM_BUILD_ROOT%{l_prefix}/lib/go
  116. # install program
  117. cp -rp * $RPM_BUILD_ROOT%{l_prefix}/lib/go/
  118. # install wrapper executables
  119. for prg in go gofmt; do
  120. ( echo "#!/bin/sh"
  121. echo "if [ \".\$GOCACHE\" = . ]; then"
  122. echo " GOCACHE=\`pwd\`"
  123. echo " export GOCACHE"
  124. echo "fi"
  125. echo "exec %{l_prefix}/lib/go/bin/$prg \${1+\"\$@\"}"
  126. ) >$prg
  127. %{l_shtool} install -c -m 755 \
  128. $prg $RPM_BUILD_ROOT%{l_prefix}/bin/$prg
  129. done
  130. # determine installation files
  131. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  132. %files -f files
  133. %clean