golang-vl.spec 15 KB

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