golang-github-pkg-errors-vl.spec 3.9 KB

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