golang-github-jessevdk-go-flags-vl.spec 4.3 KB

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