golang-github-google-btree.spec 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. %if 0%{?fedora} || 0%{?rhel} == 6
  2. %global with_devel 1
  3. %global with_bundled 0
  4. %global with_debug 0
  5. %global with_check 1
  6. %global with_unit_test 1
  7. %else
  8. %global with_devel 0
  9. %global with_bundled 0
  10. %global with_debug 0
  11. %global with_check 0
  12. %global with_unit_test 0
  13. %endif
  14. %if 0%{?with_debug}
  15. %global _dwz_low_mem_die_limit 0
  16. %else
  17. %global debug_package %{nil}
  18. %endif
  19. %define copying() \
  20. %if 0%{?fedora} >= 21 || 0%{?rhel} >= 7 \
  21. %license %{*} \
  22. %else \
  23. %doc %{*} \
  24. %endif
  25. %global provider github
  26. %global provider_tld com
  27. %global project google
  28. %global repo btree
  29. # https://github.com/google/btree
  30. %global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
  31. %global import_path %{provider_prefix}
  32. %global commit cc6329d4279e3f025a53a83c397d2339b5705c45
  33. %global shortcommit %(c=%{commit}; echo ${c:0:7})
  34. Name: golang-%{provider}-%{project}-%{repo}
  35. Version: 0
  36. Release: 0.1.git%{shortcommit}%{?dist}
  37. Summary: BTree implementation for Go
  38. License: ASL 2.0
  39. URL: https://%{provider_prefix}
  40. Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
  41. # If go_arches not defined fall through to implicit golang archs
  42. %if 0%{?go_arches:1}
  43. ExclusiveArch: %{go_arches}
  44. %else
  45. ExclusiveArch: %{ix86} x86_64 %{arm}
  46. %endif
  47. %description
  48. %{summary}
  49. %if 0%{?with_devel}
  50. %package devel
  51. Summary: %{summary}
  52. BuildArch: noarch
  53. %if 0%{?with_check}
  54. %endif
  55. Provides: golang(%{import_path}) = %{version}-%{release}
  56. %description devel
  57. %{summary}
  58. This package contains library source intended for
  59. building other packages which use import path with
  60. %{import_path} prefix.
  61. %endif
  62. %if 0%{?with_unit_test}
  63. %package unit-test
  64. Summary: Unit tests for %{name} package
  65. # If go_arches not defined fall through to implicit golang archs
  66. %if 0%{?go_arches:1}
  67. ExclusiveArch: %{go_arches}
  68. %else
  69. ExclusiveArch: %{ix86} x86_64 %{arm}
  70. %endif
  71. # If gccgo_arches does not fit or is not defined fall through to golang
  72. %ifarch 0%{?gccgo_arches}
  73. BuildRequires: gcc-go >= %{gccgo_min_vers}
  74. %else
  75. BuildRequires: golang
  76. %endif
  77. %if 0%{?with_check}
  78. #Here comes all BuildRequires: PACKAGE the unit tests
  79. #in %%check section need for running
  80. %endif
  81. # test subpackage tests code from devel subpackage
  82. Requires: %{name}-devel = %{version}-%{release}
  83. %description unit-test
  84. %{summary}
  85. This package contains unit tests for project
  86. providing packages with %{import_path} prefix.
  87. %endif
  88. %prep
  89. %setup -q -n %{repo}-%{commit}
  90. %build
  91. %install
  92. # source codes for building projects
  93. %if 0%{?with_devel}
  94. install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
  95. # find all *.go but no *_test.go files and generate unit-test.file-list
  96. for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
  97. install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
  98. cp $file %{buildroot}/%{gopath}/src/%{import_path}/$file
  99. echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
  100. done
  101. %endif
  102. # testing files for this project
  103. %if 0%{?with_unit_test}
  104. install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
  105. # find all *_test.go files and generate unit-test.file-list
  106. for file in $(find . -iname "*_test.go"); do
  107. install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
  108. cp $file %{buildroot}/%{gopath}/src/%{import_path}/$file
  109. echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
  110. done
  111. %endif
  112. %check
  113. %if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
  114. %ifarch 0%{?gccgo_arches}
  115. function gotest { %{gcc_go_test} "$@"; }
  116. %else
  117. %if 0%{?golang_test:1}
  118. function gotest { %{golang_test} "$@"; }
  119. %else
  120. function gotest { go test "$@"; }
  121. %endif
  122. %endif
  123. export GOPATH=%{buildroot}/%{gopath}:%{gopath}
  124. gotest %{import_path}
  125. %endif
  126. %if 0%{?with_devel}
  127. %files devel -f devel.file-list
  128. %copying LICENSE
  129. %doc README.md
  130. %dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
  131. %dir %{gopath}/src/%{import_path}
  132. %endif
  133. %if 0%{?with_unit_test}
  134. %files unit-test -f unit-test.file-list
  135. %copying LICENSE
  136. %doc README.md
  137. %endif
  138. %changelog
  139. * Tue Jul 28 2015 jchaloup <jchaloup@redhat.com> - 0-0.1.gitcc6329d
  140. - First package for Fedora
  141. resolves: #1245967