golang-vl.spec 16 KB

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