golang-vl.spec 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. # temporalily ignore test failures
  2. %ifarch %{ix86} x86_64
  3. %bcond_without ignore_tests
  4. %else
  5. %bcond_with ignore_tests
  6. %endif
  7. # Define arches for PA and SA
  8. %global golang_arches %{ix86} x86_64
  9. %global go_arches %{golang_arches}
  10. # Where to set GOPATH for builds
  11. %global gopath %{_datadir}/gocode
  12. # build ids are not currently generated:
  13. # https://code.google.com/p/go/issues/detail?id=5238
  14. #
  15. # also, debuginfo extraction currently fails with
  16. # "Failed to write file: invalid section alignment"
  17. %global debug_package %{nil}
  18. # we are shipping the full contents of src in the data subpackage, which
  19. # contains binary-like things (ELF data for tests, etc)
  20. %global _binaries_in_noarch_packages_terminate_build 0
  21. # Do not check any files in doc or src for requires
  22. #global __requires_exclude_from ^(%{_datadir}|/usr/lib)/%{name}/(doc|src)/.*$
  23. # Don't alter timestamps of especially the .a files (or else go will rebuild later)
  24. # Actually, don't strip at all since we are not even building debug packages and this corrupts the dwarf testdata
  25. %global __strip /bin/true
  26. # rpmbuild magic to keep from having meta dependency on libc.so.6
  27. %global __requires_exclude_from ^.*$
  28. %global __spec_install_post /usr/lib/rpm/check-rpaths \
  29. /usr/lib/rpm/check-buildroot \
  30. /usr/lib/rpm/brp-compress
  31. # Golang build options.
  32. # Buid golang using external/internal(close to cgo disabled) linking.
  33. %global external_linker 1
  34. # Build golang with cgo enabled/disabled(later equals more or less to internal linking).
  35. %global cgo_enabled 1
  36. # Use golang/gcc-go as bootstrap compiler
  37. %global golang_bootstrap 1
  38. # boostrap(with internal linking) using gcc-go fails due to bug in tests(https://github.com/golang/go/issues/12629)
  39. # make check not to fail due to it
  40. # Controls what ever we fail on failed tests
  41. %if %{with ignore_tests}
  42. %global fail_on_tests 0
  43. %else
  44. %global fail_on_tests 1
  45. %endif
  46. # TODO get more support for shared objects
  47. # Build golang shared objects for stdlib
  48. %ifarch x86_64
  49. %global shared 1
  50. %else
  51. %global shared 0
  52. %endif
  53. # Fedora GOROOT
  54. %global goroot /usr/lib/%{name}
  55. %ifarch x86_64
  56. %global gohostarch amd64
  57. %endif
  58. %ifarch %{ix86}
  59. %global gohostarch 386
  60. %endif
  61. %global go_api 1.10
  62. %global go_version 1.10.3
  63. Name: golang
  64. Version: %{go_version}
  65. Release: 1%{?_dist_release}
  66. Summary: The Go Programming Language
  67. Summary(ja): プログラミング言語 Go
  68. # source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
  69. License: BSD and Public Domain
  70. Group: Development/Languages
  71. URL: http://golang.org/
  72. # pre-processed by source.sh to make Mark.Twain-Tom.Sawyer.txt free again
  73. Source0: https://storage.googleapis.com/golang/go%{go_version}.src.tar.gz
  74. # The compiler is written in Go. Needs go(1.4+) compiler for build.
  75. BuildRequires: golang > 1.4
  76. BuildRequires: net-tools
  77. # for tests
  78. BuildRequires: pcre-devel, glibc-static
  79. Provides: go = %{version}-%{release}
  80. Requires: %{name}-bin
  81. Requires: %{name}-src = %{version}-%{release}
  82. # These are the only RHEL/Fedora architectures that we compile this package for
  83. ExclusiveArch: %{golang_arches}
  84. Source100: golang-gdbinit
  85. Source101: golang-prelink.conf
  86. Source102: macros.golang
  87. %description
  88. %{summary}.
  89. %package docs
  90. Summary: Golang compiler docs
  91. Requires: %{name} = %{version}-%{release}
  92. #BuildArch: noarch
  93. Obsoletes: %{name}-docs < 1.1-4
  94. %description docs
  95. %{summary}.
  96. %package misc
  97. Summary: Golang compiler miscellaneous sources
  98. Requires: %{name} = %{version}-%{release}
  99. #BuildArch: noarch
  100. %description misc
  101. %{summary}.
  102. %package tests
  103. Summary: Golang compiler tests for stdlib
  104. Requires: %{name} = %{version}-%{release}
  105. #BuildArch: noarch
  106. %description tests
  107. %{summary}.
  108. %package src
  109. Summary: Golang compiler source tree
  110. #BuildArch: noarch
  111. %description src
  112. %{summary}
  113. %package bin
  114. Summary: Golang core compiler tools
  115. Requires: go = %{version}-%{release}
  116. Requires(post): %{_sbindir}/update-alternatives
  117. Requires(postun): %{_sbindir}/update-alternatives
  118. # We strip the meta dependency, but go does require glibc.
  119. # This is an odd issue, still looking for a better fix.
  120. Requires: glibc
  121. Requires: gcc
  122. %description bin
  123. %{summary}
  124. # Workaround old RPM bug of symlink-replaced-with-dir failure
  125. %pretrans -p <lua>
  126. for _,d in pairs({"api", "doc", "include", "lib", "src"}) do
  127. path = "%{goroot}/" .. d
  128. if posix.stat(path, "type") == "link" then
  129. os.remove(path)
  130. posix.mkdir(path)
  131. end
  132. end
  133. %if %{shared}
  134. %package shared
  135. Summary: Golang shared object libraries
  136. %description shared
  137. %{summary}.
  138. %endif
  139. %prep
  140. %setup -q -n go
  141. %build
  142. # bootstrap compiler GOROOT
  143. %if !%{golang_bootstrap}
  144. export GOROOT_BOOTSTRAP=/
  145. %else
  146. export GOROOT_BOOTSTRAP=%{goroot}
  147. %endif
  148. # set up final install location
  149. export GOROOT_FINAL=%{goroot}
  150. export GOHOSTOS=linux
  151. export GOHOSTARCH=%{gohostarch}
  152. pushd src
  153. # use our gcc options for this build, but store gcc as default for compiler
  154. export CFLAGS="$RPM_OPT_FLAGS"
  155. export LDFLAGS="$RPM_LD_FLAGS"
  156. export CC="gcc"
  157. export CC_FOR_TARGET="gcc"
  158. export GOOS=linux
  159. export GOARCH=%{gohostarch}
  160. %if !%{external_linker}
  161. export GO_LDFLAGS="-linkmode internal"
  162. %endif
  163. %if !%{cgo_enabled}
  164. export CGO_ENABLED=0
  165. %endif
  166. ./make.bash --no-clean
  167. popd
  168. # build shared std lib
  169. %if %{shared}
  170. GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std
  171. %endif
  172. %install
  173. rm -rf $RPM_BUILD_ROOT
  174. # create the top level directories
  175. mkdir -p $RPM_BUILD_ROOT%{_bindir}
  176. mkdir -p $RPM_BUILD_ROOT%{goroot}
  177. # install everything into libdir (until symlink problems are fixed)
  178. # https://code.google.com/p/go/issues/detail?id=5830
  179. cp -apv api bin doc favicon.ico lib pkg robots.txt src misc test VERSION \
  180. $RPM_BUILD_ROOT%{goroot}
  181. # bz1099206
  182. find $RPM_BUILD_ROOT%{goroot}/src -exec touch -r $RPM_BUILD_ROOT%{goroot}/VERSION "{}" \;
  183. # and level out all the built archives
  184. touch $RPM_BUILD_ROOT%{goroot}/pkg
  185. find $RPM_BUILD_ROOT%{goroot}/pkg -exec touch -r $RPM_BUILD_ROOT%{goroot}/pkg "{}" \;
  186. # generate the spec file ownership of this source tree and packages
  187. cwd=$(pwd)
  188. src_list=$cwd/go-src.list
  189. pkg_list=$cwd/go-pkg.list
  190. shared_list=$cwd/go-shared.list
  191. misc_list=$cwd/go-misc.list
  192. docs_list=$cwd/go-docs.list
  193. tests_list=$cwd/go-tests.list
  194. rm -f $src_list $pkg_list $docs_list $misc_list $tests_list $shared_list
  195. touch $src_list $pkg_list $docs_list $misc_list $tests_list $shared_list
  196. pushd $RPM_BUILD_ROOT%{goroot}
  197. find src/ -type d -a \( ! -name testdata -a ! -ipath '*/testdata/*' \) -printf '%%%dir %{goroot}/%p\n' >> $src_list
  198. find src/ ! -type d -a \( ! -ipath '*/testdata/*' -a ! -name '*_test*.go' \) -printf '%{goroot}/%p\n' >> $src_list
  199. find bin/ pkg/ -type d -a ! -path '*_dynlink/*' -printf '%%%dir %{goroot}/%p\n' >> $pkg_list
  200. find bin/ pkg/ ! -type d -a ! -path '*_dynlink/*' -printf '%{goroot}/%p\n' >> $pkg_list
  201. find doc/ -type d -printf '%%%dir %{goroot}/%p\n' >> $docs_list
  202. find doc/ ! -type d -printf '%{goroot}/%p\n' >> $docs_list
  203. find misc/ -type d -printf '%%%dir %{goroot}/%p\n' >> $misc_list
  204. find misc/ ! -type d -printf '%{goroot}/%p\n' >> $misc_list
  205. %if %{shared}
  206. find pkg/*_dynlink/ -type d -printf '%%%dir %{goroot}/%p\n' >> $shared_list
  207. find pkg/*_dynlink/ ! -type d -printf '%{goroot}/%p\n' >> $shared_list
  208. %endif
  209. find test/ -type d -printf '%%%dir %{goroot}/%p\n' >> $tests_list
  210. find test/ ! -type d -printf '%{goroot}/%p\n' >> $tests_list
  211. find src/ -type d -a \( -name testdata -o -ipath '*/testdata/*' \) -printf '%%%dir %{goroot}/%p\n' >> $tests_list
  212. find src/ ! -type d -a \( -ipath '*/testdata/*' -o -name '*_test*.go' \) -printf '%{goroot}/%p\n' >> $tests_list
  213. # this is only the zoneinfo.zip
  214. find lib/ -type d -printf '%%%dir %{goroot}/%p\n' >> $tests_list
  215. find lib/ ! -type d -printf '%{goroot}/%p\n' >> $tests_list
  216. popd
  217. # remove the doc Makefile
  218. rm -rfv $RPM_BUILD_ROOT%{goroot}/doc/Makefile
  219. # put binaries to bindir, linked to the arch we're building,
  220. # leave the arch independent pieces in %{goroot}
  221. mkdir -p $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}
  222. ln -sf %{goroot}/bin/go $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}/go
  223. ln -sf %{goroot}/bin/gofmt $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}/gofmt
  224. # ensure these exist and are owned
  225. mkdir -p $RPM_BUILD_ROOT%{gopath}/src/github.com
  226. mkdir -p $RPM_BUILD_ROOT%{gopath}/src/bitbucket.org
  227. mkdir -p $RPM_BUILD_ROOT%{gopath}/src/code.google.com/p
  228. mkdir -p $RPM_BUILD_ROOT%{gopath}/src/golang.org/x
  229. # make sure these files exist and point to alternatives
  230. rm -f $RPM_BUILD_ROOT%{_bindir}/go
  231. ln -sf /etc/alternatives/go $RPM_BUILD_ROOT%{_bindir}/go
  232. rm -f $RPM_BUILD_ROOT%{_bindir}/gofmt
  233. ln -sf /etc/alternatives/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
  234. # gdbinit
  235. mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/gdbinit.d
  236. cp -av %{SOURCE100} $RPM_BUILD_ROOT%{_sysconfdir}/gdbinit.d/golang.gdb
  237. # prelink blacklist
  238. mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/prelink.conf.d
  239. cp -av %{SOURCE101} $RPM_BUILD_ROOT%{_sysconfdir}/prelink.conf.d/golang.conf
  240. # rpm macros
  241. mkdir -p %{buildroot}
  242. mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
  243. cp -av %{SOURCE102} $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.golang
  244. %check
  245. export GOROOT=$(pwd -P)
  246. export PATH="$GOROOT"/bin:"$PATH"
  247. cd src
  248. export CC="gcc"
  249. export CFLAGS="$RPM_OPT_FLAGS"
  250. export LDFLAGS="$RPM_LD_FLAGS"
  251. %if !%{external_linker}
  252. export GO_LDFLAGS="-linkmode internal"
  253. %endif
  254. %if !%{cgo_enabled} || !%{external_linker}
  255. export CGO_ENABLED=0
  256. %endif
  257. # make sure to not timeout
  258. export GO_TEST_TIMEOUT_SCALE=2
  259. %if %{fail_on_tests}
  260. ./run.bash --no-rebuild -v -v -v -k
  261. %else
  262. ./run.bash --no-rebuild -v -v -v -k || :
  263. %endif
  264. cd ..
  265. %post bin
  266. %{_sbindir}/update-alternatives --install %{_bindir}/go \
  267. go %{goroot}/bin/go 90 \
  268. --slave %{_bindir}/gofmt gofmt %{goroot}/bin/gofmt
  269. %preun bin
  270. if [ $1 = 0 ]; then
  271. %{_sbindir}/update-alternatives --remove go %{goroot}/bin/go
  272. fi
  273. %files
  274. %doc AUTHORS CONTRIBUTORS LICENSE PATENTS
  275. # VERSION has to be present in the GOROOT, for `go install std` to work
  276. %doc %{goroot}/VERSION
  277. %dir %{goroot}/doc
  278. %doc %{goroot}/doc/*
  279. # go files
  280. %dir %{goroot}
  281. %exclude %{goroot}/bin/
  282. %exclude %{goroot}/pkg/
  283. %exclude %{goroot}/src/
  284. %exclude %{goroot}/doc/
  285. %exclude %{goroot}/misc/
  286. %{goroot}/*
  287. # ensure directory ownership, so they are cleaned up if empty
  288. %dir %{gopath}
  289. %dir %{gopath}/src
  290. %dir %{gopath}/src/github.com/
  291. %dir %{gopath}/src/bitbucket.org/
  292. %dir %{gopath}/src/code.google.com/
  293. %dir %{gopath}/src/code.google.com/p/
  294. %dir %{gopath}/src/golang.org
  295. %dir %{gopath}/src/golang.org/x
  296. # gdbinit (for gdb debugging)
  297. %{_sysconfdir}/gdbinit.d
  298. # prelink blacklist
  299. %{_sysconfdir}/prelink.conf.d
  300. %{_sysconfdir}/rpm/macros.golang
  301. %files -f go-src.list src
  302. %files -f go-docs.list docs
  303. %files -f go-misc.list misc
  304. %files -f go-tests.list tests
  305. %files -f go-pkg.list bin
  306. %{_bindir}/go
  307. %{_bindir}/gofmt
  308. %if %{shared}
  309. %files -f go-shared.list shared
  310. %endif
  311. %changelog
  312. * Tue Jun 26 2018 IWAI, Masaharu <iwaim.sub@gmail.com> 1.10.3-1
  313. - update to 1.10.3
  314. - drop patches (Patch0, 212, 215)
  315. - export 'GO_TEST_TIMEOUT_SCALE=2' in %%check
  316. - add bcond for tests
  317. * Tue Jun 06 2017 IWAI, Masaharu <iwaim.sub@gmail.com> 1.8.3-1
  318. - update to 1.8.3
  319. * Mon Jun 5 2017 IWAI, Masaharu <iwaim.sub@gmail.com> 1.8.1-1
  320. - update to 1.8.1
  321. - remove BuildArch tags
  322. - drop Source1
  323. - drop patches
  324. - remove ECC p224 patch (Patch1)
  325. - X.509 patch (Patch2): upstream merged
  326. - disable TestGdbPython patch (Patch213)
  327. - disable TestCloneNEWUSERAndRemapNoRootDisableSetgroups patch (Patch214)
  328. - drop Patch216: upstream fixed
  329. - update bootstrap binary path patch (Patch212)
  330. * Mon Dec 21 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.5.2-1
  331. - new upstream release.
  332. * Sun Mar 8 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.4.2-1
  333. - new upstream release.
  334. * Mon Dec 15 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 1.2-2
  335. - added Group tag
  336. * Sat Feb 1 2014 IWAI, Masaharu <iwaim.sub@gmail.com> 1.2
  337. - initial build for Vine Linux
  338. - drop emacs and vim package
  339. * Fri Jan 24 2014 Vincent Batts <vbatts@redhat.com> 1.2-4
  340. - skip a flaky test that is sporadically failing on the build server
  341. * Thu Jan 16 2014 Vincent Batts <vbatts@redhat.com> 1.2-3
  342. - remove golang-godoc dependency. cyclic dependency on compiling godoc
  343. * Wed Dec 18 2013 Vincent Batts <vbatts@redhat.com> - 1.2-2
  344. - removing P224 ECC curve
  345. * Mon Dec 2 2013 Vincent Batts <vbatts@fedoraproject.org> - 1.2-1
  346. - Update to upstream 1.2 release
  347. - remove the pax tar patches
  348. * Tue Nov 26 2013 Vincent Batts <vbatts@redhat.com> - 1.1.2-8
  349. - fix the rpmspec conditional for rhel and fedora
  350. * Thu Nov 21 2013 Vincent Batts <vbatts@redhat.com> - 1.1.2-7
  351. - patch tests for testing on rawhide
  352. - let the same spec work for rhel and fedora
  353. * Wed Nov 20 2013 Vincent Batts <vbatts@redhat.com> - 1.1.2-6
  354. - don't symlink /usr/bin out to ../lib..., move the file
  355. - seperate out godoc, to accomodate the go.tools godoc
  356. * Fri Sep 20 2013 Adam Miller <maxamillion@fedoraproject.org> - 1.1.2-5
  357. - Pull upstream patches for BZ#1010271
  358. - Add glibc requirement that got dropped because of meta dep fix
  359. * Fri Aug 30 2013 Adam Miller <maxamillion@fedoraproject.org> - 1.1.2-4
  360. - fix the libc meta dependency (thanks to vbatts [at] redhat.com for the fix)
  361. * Tue Aug 27 2013 Adam Miller <maxamillion@fedoraproject.org> - 1.1.2-3
  362. - Revert incorrect merged changelog
  363. * Tue Aug 27 2013 Adam Miller <maxamillion@fedoraproject.org> - 1.1.2-2
  364. - This was reverted, just a placeholder changelog entry for bad merge
  365. * Tue Aug 20 2013 Adam Miller <maxamillion@fedoraproject.org> - 1.1.2-1
  366. - Update to latest upstream
  367. * Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.1-7
  368. - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
  369. * Wed Jul 17 2013 Petr Pisar <ppisar@redhat.com> - 1.1.1-6
  370. - Perl 5.18 rebuild
  371. * Wed Jul 10 2013 Adam Goode <adam@spicenitz.org> - 1.1.1-5
  372. - Blacklist testdata files from prelink
  373. - Again try to fix #973842
  374. * Fri Jul 5 2013 Adam Goode <adam@spicenitz.org> - 1.1.1-4
  375. - Move src to libdir for now (#973842) (upstream issue https://code.google.com/p/go/issues/detail?id=5830)
  376. - Eliminate noarch data package to work around RPM bug (#975909)
  377. - Try to add runtime-gdb.py to the gdb safe-path (#981356)
  378. * Wed Jun 19 2013 Adam Goode <adam@spicenitz.org> - 1.1.1-3
  379. - Use lua for pretrans (http://fedoraproject.org/wiki/Packaging:Guidelines#The_.25pretrans_scriptlet)
  380. * Mon Jun 17 2013 Adam Goode <adam@spicenitz.org> - 1.1.1-2
  381. - Hopefully really fix #973842
  382. - Fix update from pre-1.1.1 (#974840)
  383. * Thu Jun 13 2013 Adam Goode <adam@spicenitz.org> - 1.1.1-1
  384. - Update to 1.1.1
  385. - Fix basically useless package (#973842)
  386. * Sat May 25 2013 Dan Horák <dan[at]danny.cz> - 1.1-3
  387. - set ExclusiveArch
  388. * Fri May 24 2013 Adam Goode <adam@spicenitz.org> - 1.1-2
  389. - Fix noarch package discrepancies
  390. * Fri May 24 2013 Adam Goode <adam@spicenitz.org> - 1.1-1
  391. - Initial Fedora release.
  392. - Update to 1.1
  393. * Thu May 9 2013 Adam Goode <adam@spicenitz.org> - 1.1-0.3.rc3
  394. - Update to rc3
  395. * Thu Apr 11 2013 Adam Goode <adam@spicenitz.org> - 1.1-0.2.beta2
  396. - Update to beta2
  397. * Tue Apr 9 2013 Adam Goode <adam@spicenitz.org> - 1.1-0.1.beta1
  398. - Initial packaging.