Hello community, here is the log from the commit of package golang-packaging for openSUSE:Factory checked in at 2017-03-21 22:48:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/golang-packaging (Old) and /work/SRC/openSUSE:Factory/.golang-packaging.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "golang-packaging" Tue Mar 21 22:48:29 2017 rev:17 rq:479245 version:15.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/golang-packaging/golang-packaging.changes 2016-07-15 12:50:16.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.golang-packaging.new/golang-packaging.changes 2017-03-21 22:48:36.802719940 +0100 @@ -1,0 +2,29 @@ +Tue Mar 14 11:50:37 UTC 2017 - th...@suse.de + +- Update to version 15.0.1: + * Handle extra_flags for build/test correctly + * bump version to v15.0.1 + +------------------------------------------------------------------- +Wed Feb 15 16:07:57 UTC 2017 - th...@suse.de + +- Update to version 15.0.0: + * [SLE11]some commands need time to finish, immediate close will get wrong status, so use timeout 30s + * [SLE]ditch named group in regexp in golang.req, the oniguruma in ruby 1.8.7 doesn't support named group + * fix a typo in cli.rb + * increate timeout to 300s or go install can't finish + * Remove runtime dependency for Go API + * simplify rpmsysinfo.rb + * release 14.9.1 + * Added go_nostrip macro + * Refactor using plain bash + * small fixes + +------------------------------------------------------------------- +Fri Jul 22 12:47:09 UTC 2016 - tboer...@suse.com + +- Added refactoring.patch while trying new code base +- Dropped the sed for static architecture detection +- Updated files list to reflect new file structure + +------------------------------------------------------------------- Old: ---- golang-packaging-14.9.2.tar.xz New: ---- golang-packaging-15.0.1.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ golang-packaging.spec ++++++ --- /var/tmp/diff_new_pack.fgiI2h/_old 2017-03-21 22:48:37.654599507 +0100 +++ /var/tmp/diff_new_pack.fgiI2h/_new 2017-03-21 22:48:37.658598942 +0100 @@ -1,7 +1,7 @@ # # spec file for package golang-packaging # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,56 +16,53 @@ # -%define version_unconverted 14.9.2 - Name: golang-packaging -Version: 14.9.2 +Version: 15.0.1 Release: 0 Summary: A toolchain to help packaging golang License: GPL-3.0 Group: Development/Languages/Golang Url: https://github.com/marguerite/%{name} Source: %{name}-%{version}.tar.xz + BuildRequires: rpm -BuildRequires: ruby BuildRequires: xz Requires: go -Requires: ruby BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildArch: noarch %description A toolchain to help packaging golang, written in ruby. %prep %setup -q -GOARCH=`ruby ./golang-macros.rb --arch` -sed -i "s/GOARCH/$GOARCH/" macros.go %build %install mkdir -p %{buildroot}%{_sysconfdir}/rpm/ mkdir -p %{buildroot}%{_prefix}/lib/rpm/ + +install -m0755 golang.prov %{buildroot}%{_prefix}/lib/rpm/ +install -m0755 golang.req %{buildroot}%{_prefix}/lib/rpm/ +install -m0755 golang.sh %{buildroot}%{_prefix}/lib/rpm/ +install -m0644 macros.go %{buildroot}%{_sysconfdir}/rpm/ + %if 0%{?suse_version} >= 1320 mkdir -p %{buildroot}%{_prefix}/lib/rpm/fileattrs install -m0644 golang.attr %{buildroot}%{_prefix}/lib/rpm/fileattrs/ %endif -install -m0755 golang.prov %{buildroot}%{_prefix}/lib/rpm/ -install -m0755 golang.req %{buildroot}%{_prefix}/lib/rpm/ -cp -r golang %{buildroot}%{_prefix}/lib/rpm/ -install -m0755 golang-macros.rb %{buildroot}%{_prefix}/lib/rpm/ -install -m0644 macros.go %{buildroot}%{_sysconfdir}/rpm/ %files %defattr(-,root,root) -%doc COPYING README.md ChangeLog +%doc README.md CHANGELOG COPYING +%{_prefix}/lib/rpm/golang.prov +%{_prefix}/lib/rpm/golang.req +%{_prefix}/lib/rpm/golang.sh %config %{_sysconfdir}/rpm/macros.go + %if %{?suse_version} >= 1320 %{_prefix}/lib/rpm/fileattrs/golang.attr %endif -%{_prefix}/lib/rpm/golang -%{_prefix}/lib/rpm/golang.prov -%{_prefix}/lib/rpm/golang.req -%{_prefix}/lib/rpm/golang-macros.rb %changelog ++++++ _service ++++++ --- /var/tmp/diff_new_pack.fgiI2h/_old 2017-03-21 22:48:37.690594419 +0100 +++ /var/tmp/diff_new_pack.fgiI2h/_new 2017-03-21 22:48:37.694593853 +0100 @@ -4,8 +4,8 @@ <param name="scm">git</param> <param name="filename">golang-packaging</param> <param name="exclude">.git</param> - <param name="versionformat">14.9.2</param> - <param name="revision">v14.9.2</param> + <param name="versionformat">15.0.1</param> + <param name="revision">v15.0.1</param> <param name="changesgenerate">enable</param> </service> <service name="recompress" mode="disabled"> ++++++ golang-packaging-14.9.2.tar.xz -> golang-packaging-15.0.1.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/CHANGELOG new/golang-packaging-15.0.1/CHANGELOG --- old/golang-packaging-14.9.2/CHANGELOG 1970-01-01 01:00:00.000000000 +0100 +++ new/golang-packaging-15.0.1/CHANGELOG 2017-03-14 12:47:19.000000000 +0100 @@ -0,0 +1,152 @@ +== update version 15.0.1 == + + * Fix crash when running build or test with no argument + +== update version 15.0.0 == + + * Total refactoring of the codebase, dropped the ruby dependency and now we + are also using pure bash and go tooling + +== update version 14.9.2 == + + * Added go_nostrip macro to disable stripping of debug information and to + disable a debug package + +== update version 14.9.1 == + + * simplify rpmsysinfo.rb: don't guess variables' values can be passed in by + RPM environment variables. use RbConfig to get libdir. + * support s390x architecture + +== update version 14.9.0 == + + * Remove runtime dependency for Go API + +== update version 14.8.1 == + + * bugfix release + * fix a typo in cli.rb + * increase timeout to 300s, or go install can't finish itself sometimes + +== update version 14.8 == + + * rpmsysinfo.rb: fix encoding problem in open() + * cli.rb: ruby 1.8.7 doesn't support passing environment variables in open(), + some commands/tests need time to finish, an immediate io.close() will get us + wrong exitstatus (broken pipe, code 13). so use 'timeout' module with a 30s + and process.wait for them to quit successfully + * golang.req: the oniguruma in ruby 1.8.7 doesn't support named group in + regexp. so ditch the named group used in go_get_version() + +== update version 14.7 == + + * do not hardcode go version + +== update version 14.6 == + + * fix rbarch for Power Archtectures + +== update version 14.5 == + + * fix a typo that prevent golang.req from working (github#10) + +== update version 14.4 == + + * fix github#5 on golang.req + +== update version 14.3 == + + * fix: command not found error for go test on SLE + * fix #5 again: gsub importpath itself is not enough + +== update version 14.2 == + + * golang.req: fix ' // indirect' comment in import + +== update version 14.1 == + + * fix: uniq! returns nil if everything is unique + +== update version 14 == + + * if importpath has "test/example", it should survive (github#5) + * merge macros.go from openSUSE's go here + * add golang-macros.rb, replacement for the complicated macros in shell in + macros.go + * golang-macros.rb: + + support build with fake build id + + support build with custom tags (github#7) + + support pass any -<arg>="a b c" or -<arg>=<value> to go install, shared + build is possible now (not fully support, other macros need to be adapted) + + --filelist, to generate filelist used in %files section with excluding + support + + use IO.popen to break the build at the exact place + it fails (github#6) + +== update version 13 == + + * provides the importpath itself + * fix regex not to check files like .golden in -source + * filter "test/example" from Provides + * split common stuff to a module golang/rpmsysinfo.rb + * rewrite golang.req, now read from stdin RPM feeds, and check __.PKGDEF from + .a files for "import"s. (github#3 github#4) + +== update version 12 == + + * rewrite golang.prov. it should take filelist feeded by rpm in case not to + add provides for source/debuginfo/debugsource sub-packages + * simply golang.req: own is actually importpath, no need to call golang.prov + again + +== update version 11 == + + * support SLE11 + +== update version 10 == + + * support all archtectures like ppc/arm + +== update version 9 == + + * update golang(API) to 1.5 + +== update version 8 == + + * skip the last "/" in golang.prov, thanks to matwey + +== udpate version 7 == + + * handle gopkg.in/* requirements + +== update version 6 == + + * fix golang.req to not treat a sentence as importpath + * fix golang.attr to correctly detect /usr/bin/* + +== update version 5 == + + * if a sub-directory doesn't contain any *.go file, do not treat it as a + Provides candidate. + * add /usr/bin to golang.attr for go executes to be handled by + golang-packaging + +== update version 4 == + + * fix encoding error in golang-strip-builddep + * add macros.go-extra, extra golang macros for packaging + +== update version 3 == + + * skip *example*.go/*test*.go for Requires finding + * support alias format (import xx "xxx") for importpath + * add golang-strip-builddep, a tool to strip unneeded importpath from source + codes + +== update version 2 == + + * fix pkgname detection + +== update version 1 == + + * implement Requires/Provides diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/ChangeLog new/golang-packaging-15.0.1/ChangeLog --- old/golang-packaging-14.9.2/ChangeLog 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/ChangeLog 1970-01-01 01:00:00.000000000 +0100 @@ -1,145 +0,0 @@ -== update version 14.9.2 == - - * Added go_nostrip macro to disable stripping of debug - information and to disable a debug package - -== update version 14.9.1 == - - * simplify rpmsysinfo.rb: don't guess variables' - values can be passed in by RPM environment - variables. use RbConfig to get libdir. - * support s390x architecture - -== update version 14.9.0 == - - * Remove runtime dependency for Go API - -== update version 14.8.1 == - - * bugfix release - * fix a typo in cli.rb - * increase timeout to 300s, or go install can't - finish itself sometimes - -== update version 14.8 == - - * rpmsysinfo.rb: fix encoding problem in open() - * cli.rb: ruby 1.8.7 doesn't support passing environment - variables in open(), some commands/tests need time to - finish, an immediate io.close() will get us wrong - exitstatus (broken pipe, code 13). so use 'timeout' - module with a 30s and process.wait for them to quit - successfully - * golang.req: the oniguruma in ruby 1.8.7 doesn't support - named group in regexp. so ditch the named group used in - go_get_version() - -== update version 14.7 == - - * do not hardcode go version - -== update version 14.6 == - - * fix rbarch for Power Archtectures - -== update version 14.5 == - - * fix a typo that prevent golang.req from working (github#10) - -== update version 14.4 == - - * fix github#5 on golang.req - -== update version 14.3 == - - * fix: command not found error for go test on SLE - * fix #5 again: gsub importpath itself is not enough - -== update version 14.2 == - - * golang.req: fix ' // indirect' comment in import - -== update version 14.1 == - - * fix: uniq! returns nil if everything is unique - -== update version 14 == - - * if importpath has "test/example", it should survive (github#5) - * merge macros.go from openSUSE's go here - * add golang-macros.rb, replacement for the complicated - macros in shell in macros.go - * golang-macros.rb: - + support build with fake build id - + support build with custom tags (github#7) - + support pass any -<arg>="a b c" or -<arg>=<value> - to go install, shared build is possible now - (not fully support, other macros need to be adapted) - + --filelist, to generate filelist used in %files - section with excluding support - + use IO.popen to break the build at the exact place - it fails (github#6) - -== update version 13 == - - * provides the importpath itself - * fix regex not to check files like .golden in -source - * filter "test/example" from Provides - * split common stuff to a module golang/rpmsysinfo.rb - * rewrite golang.req, now read from stdin RPM feeds, and check __.PKGDEF from .a files for "import"s. (github#3 github#4) - -== update version 12 == - - * rewrite golang.prov. it should take filelist feeded by rpm in case not to add provides for source/debuginfo/debugsource sub-packages - * simply golang.req: own is actually importpath, no need to call golang.prov again - -== update version 11 == - - * support SLE11 - -== update version 10 == - - * support all archtectures like ppc/arm - -== update version 9 == - - * update golang(API) to 1.5 - -== update version 8 == - - * skip the last "/" in golang.prov, thanks to matwey - -== udpate version 7 == - - * handle gopkg.in/* requirements - -== update version 6 == - - * fix golang.req to not treat a sentence as importpath - * fix golang.attr to correctly detect /usr/bin/* - -== Version 5 == - - * if a sub-directory doesn't contain any *.go file, do not - treat it as a Provides candidate. - * add /usr/bin to golang.attr for go executes to be handled - by golang-packaging - -== Version 4 == - - * fix encoding error in golang-strip-builddep - * add macros.go-extra, extra golang macros for packaging - -== Version 3 == - - * skip *example*.go/*test*.go for Requires finding - * support alias format (import xx "xxx") for importpath - * add golang-strip-builddep, a tool to strip unneeded importpath from source codes - -== Version 2 == - - * fix pkgname detection - -== Version 1 == - - * implement Requires/Provides diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/golang/cli.rb new/golang-packaging-15.0.1/golang/cli.rb --- old/golang-packaging-14.9.2/golang/cli.rb 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/golang/cli.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,55 +0,0 @@ -module CLI - - require 'timeout' - - def write_status(status) - file = "/tmp/exitstatus.txt" - mode = "w:UTF-8" - if status == 0 - File.open(file,mode) {|f| f.puts(0)} - else - File.open(file,mode) {|f| f.puts(1)} - abort "[ERROR]Go command failed! Please check." - end - end - - # popen in 1.8 doesn't support env hash - def popen_env(hash, cmd) - # set ENV separately - hash.each {|k,v| ENV[k] = v} - - # some commands need time, an immediate close - # will get a wrong status, so wait them with - # timeout 30s - # set timeout 300s, because go install takes - # lots of time sometimes - begin - Timeout.timeout(300) do - @pipe = IO.popen(cmd) - Process.wait(@pipe.pid) - end - rescue Timeout::Error - Process.kill(9,@pipe.pid) - # collect status - Process.wait(@pipe.pid) - end - - write_status($?) - - end - - def self.run(env={},cmd="") - - puts "GOPATH: #{env}" - puts "Command: #{cmd}" - unless RUBY_VERSION.to_f > 1.8 - popen_env(env,cmd) {|f| f.each_line {|l| puts l}} - else - IO.popen(env,cmd) {|f| f.each_line {|l| puts l}} - write_status($?) - end - - end - -end - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/golang/filelists.rb new/golang-packaging-15.0.1/golang/filelists.rb --- old/golang-packaging-14.9.2/golang/filelists.rb 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/golang/filelists.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,90 +0,0 @@ -module Filelists - - require 'find' - require 'fileutils' - require File.join(File.dirname(__FILE__),'rpmsysinfo.rb') - include RpmSysinfo - - @@buildroot = RpmSysinfo.get_buildroot - @@contribdir = RpmSysinfo.get_go_contribdir - @@contribsrcdir = RpmSysinfo.get_go_contribsrcdir - @@tooldir = RpmSysinfo.get_go_tooldir - @@bindir = "/usr/bin" - - def self.new(path,outfile) - - File.open(outfile,"a:UTF-8") do |f| - - # make sure path like "/usr/bin" exists, some golang packages don't - # have a binrary, so "/usr/bin" may not exist in buildroot - if File.directory?(path) - - Find.find(path) do |f1| - - # ignore ".gitignore stuff" but let importpath like - # "code.google.com" go - unless f1.gsub(/^.*\//,'').index(/^\./) - # %file section doesn't need buildroot - f2 = f1.gsub(@@buildroot,"") - unless [@@contribdir, @@contribsrcdir, @@tooldir, @@bindir].include?(f2) - if File.directory?(f1) - f.puts("%dir " + f2) - else - f.puts(f2) - end - end - end - - end - - end - - end - - end - - def exclude(infile="",excludes=[]) - - # treat excludes as regex array, eg: - # ["/usr/bin/*","/usr/lib/debug/*"] - if excludes == nil - a = Array.new - else - a = excludes.split("\s") - end - - # expand the regex to actual file - list = Array.new - a.each do |i| - - Dir.glob(@@buildroot + i) do |f| - - list << f.gsub(@@buildroot,"") - - end - - end - - # delete the files excluded from buildroot - list.each { |f| File.delete(@@buildroot + f) } - - File.open(infile,"r:UTF-8") do |f| - - File.open(infile + ".new","w:UTF-8") do |f1| - - f.each_line do |l| - - f1.puts(l) unless list.include?(l.chomp!) - - end - - end - - end - - FileUtils.mv(infile + ".new",infile) - - end - -end - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/golang/opts.rb new/golang-packaging-15.0.1/golang/opts.rb --- old/golang-packaging-14.9.2/golang/opts.rb 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/golang/opts.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,53 +0,0 @@ -module Opts - - @@inputs = ARGV - - @@opts, @@mods = [],[] - - # ARGV: -buildmode=shared -linkshared -cflags="a b c" --with-buildid -tag tag d e... - @@inputs.each do |i| - - # options begin with "-" - if i.index(/^-/) - - if i.index("-tags") - - # the following ARG is actually for -tag, not the main script - - @@opts << i + "\s"+ @@inputs[@@inputs.index(i) + 1] - - @@inputs.delete_at(@@inputs.index(i) + 1) - - else - - @@opts << i - - end - - else - - @@mods << i - - end - - end - - def self.get_opts - - # remove the first opt which is "--build, --prep" and etc - if @@opts.length > 1 - return @@opts.reject! {|f| f == ARGV[0] } - else - return [] - end - - end - - def self.get_mods - - return @@mods - - end - -end - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/golang/rpmsysinfo.rb new/golang-packaging-15.0.1/golang/rpmsysinfo.rb --- old/golang-packaging-14.9.2/golang/rpmsysinfo.rb 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/golang/rpmsysinfo.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,84 +0,0 @@ -module RpmSysinfo - - require 'rbconfig' - - # x86_64-(gnu|linux|blabla...) - @@rbarch = RUBY_PLATFORM.gsub(/-.*$/,"") - # architectures are defined in /usr/lib/rpm/macros - @@ix86 = ["i386","i486","i586","i686","pentium3","pentium4","athlon","geode"] - @@arm = ["armv3l","armv4b","armv4l","armv4tl","armv5b","armv5l","armv5teb","armv5tel","armv5tejl","armv6l","armv6hl","armv7l","armv7hl","armv7hnl"] - if @@ix86.include?(@@rbarch) - @@go_arch = "386" - end - if @@rbarch == "x86_64" - @@go_arch = "amd64" - end - if @@arm.include?(@@rbarch) - @@go_arch = "arm" - end - if @@rbarch == "aarch64" - @@go_arch = "arm64" - end - if @@rbarch == "powerpc64" - @@go_arch = "ppc64" - end - if @@rbarch == "powerpc64le" - @@go_arch = "ppc64le" - end - if @@rbarch == "s390x" - @@go_arch = "s390x" - end - - def self.get_builddir - - return ENV["RPM_BUILD_DIR"] - - end - - def self.get_buildroot - - return ENV["RPM_BUILD_ROOT"] - - end - - def self.get_libdir - - return RbConfig::CONFIG['libdir'] - - end - - def self.get_go_arch - - return @@go_arch - - end - - def self.get_go_contribdir - - return self.get_libdir + "/go/contrib/pkg/linux_" + @@go_arch - - end - - def self.get_go_tooldir - - return "/usr/share/go/pkg/tool/linux_" + @@go_arch - - end - - def self.get_go_contribsrcdir - - return "/usr/share/go/contrib/src" - - end - - def self.get_go_importpath - - # this funtion is used in golang.prov/req only - # called after %go_prep - # so the simplest method is to read /tmp/importpath.txt - return open("/tmp/importpath.txt","r:UTF-8").gets.strip! - - end - -end - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/golang-macros.rb new/golang-packaging-15.0.1/golang-macros.rb --- old/golang-packaging-14.9.2/golang-macros.rb 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/golang-macros.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,248 +0,0 @@ -#!/usr/bin/env ruby - -require 'fileutils' -require 'securerandom' -require 'find' -require File.join(File.dirname(__FILE__),'golang/rpmsysinfo.rb') -require File.join(File.dirname(__FILE__),'golang/opts.rb') -require File.join(File.dirname(__FILE__),'golang/filelists.rb') -require File.join(File.dirname(__FILE__),'golang/cli.rb') -include RpmSysinfo -include Opts -include Filelists -include CLI - -# GLOBAL RPM MACROS - -$builddir = RpmSysinfo.get_builddir -$buildroot = RpmSysinfo.get_buildroot -$libdir = RpmSysinfo.get_libdir -$go_arch = RpmSysinfo.get_go_arch -$go_contribdir = RpmSysinfo.get_go_contribdir -$go_contribsrcdir = RpmSysinfo.get_go_contribsrcdir -$go_tooldir = RpmSysinfo.get_go_tooldir - -# ARGV[0], the called method itself -if ARGV[0] == "--arch" - - puts $go_arch - -elsif ARGV[0] == "--prep" - - puts "Preparation Stage:\n" - - # ARGV[1] the import path - if ARGV[1] == nil - puts "[ERROR]Empty IMPORTPATH! Please specify a valid one.\n" - else - gopath = $builddir + "/go" - puts "GOPATH set to: " + gopath + "\n" - - importpath = ARGV[1] - puts "IMPORTPATH set to: " + importpath + "\n" - - # export IMPORTPATH to a temp file, as ruby can't export system environment variables - # like shell scripts - File.open("/tmp/importpath.txt","w:UTF-8") do |f| - f.puts(importpath) - end - - # return current directory name, eg: ruby-2.2.4 - dir = File.basename(Dir.pwd) - destination = gopath + "/src/" + importpath - puts "Creating " + destination + "\n" - FileUtils.mkdir_p(destination) - - # copy everything to destination - puts "Copying everything under " + $builddir + "/" + dir + " to " + destination + " :\n" - Dir.glob($builddir + "/" + dir + "/*").each do |f| - puts "Copying " + f + "\n" - FileUtils.cp_r(f, File.join(destination, File.basename(f))) - end - puts "Files are moved!\n" - - # create target directories - puts "Creating directory for binaries " + $buildroot + "/usr/bin" + "\n" - FileUtils.mkdir_p($buildroot + "/usr/bin") - puts "Creating directory for contrib " + $buildroot + $go_contribdir + "\n" - FileUtils.mkdir_p($buildroot + $go_contribdir) - puts "Creating directory for source " + $buildroot + $go_contribsrcdir + "\n" - FileUtils.mkdir_p($buildroot + $go_contribsrcdir) - puts "Creating directory for tool " + $buildroot + $go_tooldir + "\n" - FileUtils.mkdir_p($buildroot + $go_tooldir) - end - - puts "Preparation Finished!\n" - -elsif ARGV[0] == "--build" - - puts "Build stage:\n" - - gopath = $builddir + "/go:" + $libdir + "/go/contrib" - gobin = $builddir + "/go/bin" - buildflags = "-s -v -p 4 -x" - - # get importpath from /tmp/importpath.txt saved by prep() - importpath = open("/tmp/importpath.txt","r:UTF-8").gets.strip! - - opts = Opts.get_opts - mods = Opts.get_mods - extraflags = "" - - unless opts.empty? - if opts.include?("--with-buildid") - buildid = "0x" + SecureRandom.hex(20) - # whitespace is important! - extraflags = extraflags + ' -ldflags "-B ' + buildid + '"' - opts.delete("--with-buildid") - end - - opts.each do |o| - extraflags = extraflags + " #{o}" - end - end - - # MODs: nil, "...", "/...", "foo...", "foo/...", "foo bar", "foo bar... baz" and etc - if mods.empty? - CLI.run({"GOPATH"=>gopath,"GOBIN"=>gobin}, "go install #{extraflags} #{buildflags} #{importpath}") - else - for mod in mods do - if mod == "..." - CLI.run({"GOPATH"=>gopath,"GOBIN"=>gobin}, "go install #{extraflags} #{buildflags} #{importpath}...") - break - else - CLI.run({"GOPATH"=>gopath,"GOBIN"=>gobin}, "go install #{extraflags} #{buildflags} #{importpath}/#{mod}") - end - end - end - - puts "Build Finished!\n" - -elsif ARGV[0] == "--install" - - puts "Installation stage:\n" - - # check exitstatus - File.open("/tmp/exitstatus.txt","r:UTF-8") {|f| abort "Previous stage failed! Abort!" if f.read != "0\n" } - - unless Dir["#{$builddir}/go/pkg/*"].empty? - puts "Copying generated stuff to " + $buildroot + $go_contribdir - Dir.glob($builddir + "/go/pkg/linux_" + $go_arch + "/*").each do |f| - puts "Copying " + f - FileUtils.cp_r(f, $buildroot + $go_contribdir) - end - puts "Done!" - end - - unless Dir["#{$builddir}/go/bin/*"].empty? - puts "Copyig binaries to " + $buildroot + "/usr/bin" - Dir.glob($builddir + "/go/bin/*").each do |f| - puts "Copying " + f - FileUtils.chmod_R(0755,f) - FileUtils.cp_r(f,$buildroot + "/usr/bin") - end - puts "Done!" - end - - puts "Install finished!\n" - -elsif ARGV[0] == "--source" - - puts "Source package creation:" - - # check exitstatus - File.open("/tmp/exitstatus.txt","r:UTF-8") {|f| abort "Previous stage failed! Abort!" if f.read != "0\n" } - - puts "This will copy all *.go files in #{$builddir}/go/src, but resource files needed are still not copyed" - - Find.find($builddir + "/go/src") do |f| - unless FileTest.directory?(f) - if f.index(/\.go$/) - puts "Copying " + f - FileUtils.chmod_R(0644,f) - - # create the same hierarchy - dir = $buildroot + $go_contribsrcdir + f.gsub($builddir + "/go/src",'') - dir1 = dir.gsub(File.basename(dir),'') - FileUtils.mkdir_p(dir1) - FileUtils.install(f,dir1) - end - end - end - - puts "Source package created!" - -elsif ARGV[0] == "--fix" - - puts "Fixing stuff..." - - # check exitstatus - File.open("/tmp/exitstatus.txt","r:UTF-8") {|f| abort "Previous stage failed! Abort!" if f.read != "0\n" } - - # only "--fix" is given, no other parameters - if ARGV.length == 1 - puts "[ERROR]gofix: please specify a valid importpath, see: go help fix" - else - gopath = $builddir + "/go" - CLI.run({"GOPATH"=>gopath},"go fix #{ARGV[1]}...") - end - - puts "Fixed!" - -elsif ARGV[0] == "--test" - - puts "Testing codes..." - - # check exitstatus - File.open("/tmp/exitstatus.txt","r:UTF-8") {|f| abort "Previous stage failed! Abort!" if f.read != "0\n" } - - # only "--test" is given, no other parameters - if ARGV.length == 1 - puts "[ERROR]gotest: please specify a valid importpath, see: go help test" - else - gopath = $builddir + "/go:" + $libdir + "/go/contrib" - CLI.run({"GOPATH"=>gopath}, "go test -x #{ARGV[1]}...") - end - - puts "Test passed!" - -# generate filelist for go_contribdir go_contribdir_dir -elsif ARGV[0] == "--filelist" - - puts "Processing filelists..." - - # check exitstatus - File.open("/tmp/exitstatus.txt","r:UTF-8") {|f| abort "Previous stage failed! Abort!" if f.read != "0\n" } - - opts = Opts.get_opts - excludes = Opts.get_mods[0] - # two directories, one is /BUILD/go. reject it, returns array with 1 element. - builddirs = Dir.glob($builddir + "/*").reject! { |f| f == $builddir + "/go" } - builddir = builddirs[0] - - # find shared build from linux_amd64_dynlink - if opts.include?("--shared") - Filelists.new($buildroot + $go_contribdir + "_dynlink", builddir + "/shared.lst") - Filelists.new($buildroot + "/usr/bin", builddir + "/shared.lst") - Filelists.new($buildroot + $go_tooldir,builddir + "/shared.lst") - Filelists.exclude(builddir + "/shared.lst",excludes) - # process for -source sub-package - elsif opts.include?("--source") - Filelists.new($buildroot + $go_contribsrcdir, builddir + "/source.lst") - Filelists.exclude(builddir + "/source.lst",excludes) - # default for main package, static build - else - Filelists.new($buildroot + $go_contribdir,builddir + "/file.lst") - Filelists.new($buildroot + "/usr/bin", builddir + "/file.lst") - Filelists.new($buildroot + $go_tooldir,builddir + "/file.lst") - Filelists.exclude(builddir + "/file.lst",excludes) - end - - puts "Filelists created!" - -else - - puts "Please specify a valid method: --prep, --build, --install, --fix, --test, --source, --filelist" - -end - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/golang.attr new/golang-packaging-15.0.1/golang.attr --- old/golang-packaging-14.9.2/golang.attr 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/golang.attr 2017-03-14 12:47:19.000000000 +0100 @@ -1,3 +1,3 @@ %__golang_requires %{_prefix}/lib/rpm/golang.req %__golang_provides %{_prefix}/lib/rpm/golang.prov -%__golang_path ^(%{_prefix}/lib(64)?/go/contrib/pkg/linux_(386|amd64|ppc.*|arm.*)/.*\\.a|%{_bindir}/.*)$ +%__golang_path ^(%{_prefix}/lib(64)?/go/contrib/src.*\\.go)$ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/golang.prov new/golang-packaging-15.0.1/golang.prov --- old/golang-packaging-14.9.2/golang.prov 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/golang.prov 2017-03-14 12:47:19.000000000 +0100 @@ -1,44 +1,16 @@ -#!/usr/bin/env ruby +#!/usr/bin/env bash -require '/usr/lib/rpm/golang/rpmsysinfo.rb' -include RpmSysinfo +export GOPATH=${RPM_BUILD_ROOT}/usr/share/go/contrib +export GO15VENDOREXPERIMENT=1 -buildroot = RpmSysinfo.get_buildroot -contribdir = RpmSysinfo.get_go_contribdir -importpath = RpmSysinfo.get_go_importpath +IMPORT="$(cat /tmp/importpath.txt)" +CHECK="${GOPATH}/src/${IMPORT}" -# read stdin for filelist rpm feeds us for a (sub) package -filelist = [] -prefix = buildroot + contribdir + "/" -ARGF.each do |l| - # if line has "*.a" - # buildroot + contribdir + golang.org/x/text/collate/colltab.a - filelist << l.gsub(prefix,'').strip! if ( l.index(".a\n") && ! l.gsub(prefix + importpath,'').index(/example|test/) ) -end - -# filelist: -# golang.org/x/text/collate/colltab.a - -provides = [] - -unless filelist.empty? then - - provides << "golang(" + importpath + ")" - - filelist.each do |f| - provides << "golang(" + f.gsub(".a","") + ")" - end - - uni = provides.uniq! - - unless uni == nil - - uni.each {|p| puts p} - - else - - provides.each {|p| puts p} - - end - -end +# Read from STDIN to not cause a broken pipe +while read INPUT; do + : +done + +for SEGMENT in $(go list -f '{{.ImportPath}}' ${IMPORT}/... | grep -v /vendor/); do + echo "golang(${SEGMENT})" +done diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/golang.req new/golang-packaging-15.0.1/golang.req --- old/golang-packaging-14.9.2/golang.req 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/golang.req 2017-03-14 12:47:19.000000000 +0100 @@ -1,52 +1,25 @@ -#!/usr/bin/env ruby +#!/usr/bin/env bash -require '/usr/lib/rpm/golang/rpmsysinfo.rb' -include RpmSysinfo -buildroot = RpmSysinfo.get_buildroot -contribdir = RpmSysinfo.get_go_contribdir -importpath = RpmSysinfo.get_go_importpath - -# read stdin for filelist rpm feeds us for a (sub) package -filelist = [] -ARGF.each do |l| - # if line has "*.a" - # buildroot + go_contribdir + github.com/stretchr/testify/assert.a - if l.index(".a\n") - unless l.gsub(buildroot + contribdir + '/' + importpath,'').index(/test|example/) - filelist << l.strip! - end - end -end - -requires = [] - -unless filelist.empty? then - filelist.each do |f| - # unarchive .a - system("ar -x #{f} __.PKGDEF") - # read imports - File.open("__.PKGDEF","r:UTF-8") do |f1| - f1.each do |l| - if l.index(/import\s/) - # import runtime "golang.org/x/net/uniform" - if ( l.index(/(\.com|\.net|\.org|gopkg\.in)/) && ! l.index(importpath) ) - # import splice "github.com/hanwen/go-fuse/splice" // indirect - if l.index("indirect") - v = l.strip!.gsub(/\s\/\/\sindirect/,'').gsub(/"$/,'').gsub(/^.*"/,'') - else - v = l.strip!.gsub(/"$/,'').gsub(/^.*"/,'') - end - requires << "golang(" + v + ")" - end - end - end - end - # clean - File.delete("__.PKGDEF") - end - - requires.each do |p| - puts p - end +export GOPATH=${RPM_BUILD_ROOT}/usr/share/go/contrib +export GO15VENDOREXPERIMENT=1 -end +IMPORT="$(cat /tmp/importpath.txt)" +CHECK="${GOPATH}/src/${IMPORT}" + +# /home/abuild/rpmbuild/BUILDROOT/golang-github-codegangsta-cli-1.17.1+git20160828.599ee69-0.x86_64/usr/share/go/contrib/src/github.com/codegangsta/cli +# /home/abuild/rpmbuild/BUILDROOT/golang-github-codegangsta-cli-1.17.1+git20160828.599ee69-0.x86_64/usr/share/go/contrib/src/github.com/codegangsta/cli/altsrc + +while read INPUT; do + # if [[ -d ${INPUT} ]] && [[ ${INPUT} == ${CHECK}* ]]; then + # echo "golang(${INPUT#${CHECK}/})" + # fi + : +done + +for SEGMENT in $(go list -f '{{range $deps := .Deps}}{{printf "%s\n" $deps}}{{end}}' ${IMPORT}/... | grep -v ${IMPORT}); do + STANDARD=$(go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' ${SEGMENT} 2> /dev/null) + + if [[ $? -ne 0 || "${STANDARD}" != "" ]]; then + echo "golang(${SEGMENT})" + fi +done diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/golang.sh new/golang-packaging-15.0.1/golang.sh --- old/golang-packaging-14.9.2/golang.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/golang-packaging-15.0.1/golang.sh 2017-03-14 12:47:19.000000000 +0100 @@ -0,0 +1,248 @@ +#!/usr/bin/env bash +set -e +set -x + +store_import_path() { + echo ${1} >| /tmp/importpath.txt +} + +check_import_path() { + if [[ "$(get_import_path)" == "" ]]; then + echo "Empty import path, please specify a valid one!" >&2 + exit 1 + fi +} + +get_import_path() { + head /tmp/importpath.txt +} + +get_build_path() { + echo "${RPM_BUILD_DIR}/go" +} + +get_buildcontrib_path() { + echo "${RPM_BUILD_DIR}/contrib" +} + +get_gobin_path() { + echo "${RPM_BUILD_DIR}/go/bin" +} + +get_gocontrib_path() { + echo "$(rpm --eval %{_datadir})/go/contrib" +} + +get_contrib_path() { + echo $(rpm --eval %go_contribdir) +} + +get_source_path() { + echo $(rpm --eval %go_contribsrcdir) +} + +get_tool_path() { + echo $(rpm --eval %go_tooldir) +} + +get_binary_path() { + echo $(rpm --eval %_bindir) +} + +get_destination_path() { + echo "$(get_build_path)/src/$(get_import_path)" +} + +process_arch() { + local arch=$(uname -m) + + case "${arch}" in + "x86_64") + echo "amd64" + ;; + "i386"|"i486"|"i586"|"i686"|"pentium3"|"pentium4"|"athlon"|"geode") + echo "386" + ;; + armv*) + echo "arm" + ;; + *) + echo $arch + ;; + esac +} + +process_prepare() { + store_import_path "${1}" + check_import_path + + echo "Creating build path $(get_destination_path)" + rm -rf $(get_destination_path) + mkdir -p $(get_destination_path) + + echo "Creating deps path $(get_buildcontrib_path)/src" + rm -rf $(get_buildcontrib_path)/src + mkdir -p $(get_buildcontrib_path)/src + + echo "Copying files to $(get_destination_path)" + cp -rT $(pwd) $(get_destination_path)/ + + echo "Copying deps to $(get_buildcontrib_path)" + cp -rT $(get_gocontrib_path)/src $(get_buildcontrib_path)/src + + local contrib_dir=${RPM_BUILD_ROOT}$(get_contrib_path) + echo "Creating contrib path ${contrib_dir}" + mkdir -p ${contrib_dir} + + local source_dir=${RPM_BUILD_ROOT}$(get_source_path) + echo "Creating source path ${source_dir}" + mkdir -p ${source_dir} + + local tool_dir=${RPM_BUILD_ROOT}$(get_tool_path) + echo "Creating tool path ${tool_dir}" + mkdir -p ${tool_dir} + + local binary_dir=${RPM_BUILD_ROOT}$(get_binary_path) + echo "Creating binary path ${binary_dir}" + mkdir -p ${binary_dir} +} + +process_build() { + check_import_path + + local modifier="${@: -1}" + + if [[ "$#" -eq 0 ]]; then + local last=0 + else + local last=$(($#-1)) + fi + + local build_flags="-s -v -p 4 -x" + local extra_flags="${@:1:$last}" + + case "${modifier}" in + "...") + GOPATH=$(get_build_path):$(get_buildcontrib_path) GOBIN=$(get_gobin_path) go \ + install ${build_flags} ${extra_flags} $(get_import_path)... + ;; + "") + GOPATH=$(get_build_path):$(get_buildcontrib_path) GOBIN=$(get_gobin_path) go \ + install ${build_flags} ${extra_flags} $(get_import_path) + ;; + *) + GOPATH=$(get_build_path):$(get_buildcontrib_path) GOBIN=$(get_gobin_path) go \ + install ${build_flags} ${extra_flags} $(get_import_path)/${modifier} + ;; + esac +} + +process_install() { + check_import_path + + for file in $(find $(get_gobin_path) -type f); do + echo "Copying $(basename ${file}) to ${RPM_BUILD_ROOT}$(get_binary_path)" + install -D -m0755 ${file} ${RPM_BUILD_ROOT}$(get_binary_path) + done +} + +process_source() { + echo "This will copy all *.go, *.s and *.h files in $(get_build_path)/src without resources" + + for file in $(find $(get_build_path)/src -type f -iname \*.go); do + local destination=${RPM_BUILD_ROOT}$(get_source_path)${file#$(get_build_path)/src/} + + echo "Copying ${file} to ${destination}" + install -D -m0644 ${file} ${destination} + done + + for file in $(find $(get_build_path)/src -type f -iname \*.s); do + local destination=${RPM_BUILD_ROOT}$(get_source_path)${file#$(get_build_path)/src/} + + echo "Copying ${file} to ${destination}" + install -D -m0644 ${file} ${destination} + done + + for file in $(find $(get_build_path)/src -type f -iname \*.h); do + local destination=${RPM_BUILD_ROOT}$(get_source_path)${file#$(get_build_path)/src/} + + echo "Copying ${file} to ${destination}" + install -D -m0644 ${file} ${destination} + done +} + +process_test() { + if [[ "${1}" == "" ]]; then + echo "Please specify a valid importpath, refernce: go help test" >&2 + exit 1 + fi + + local modifier="${@: -1}" + + if [[ "$#" -eq 0 ]]; then + local last=0 + else + local last=$(($#-1)) + fi + + local extra_flags="${@:1:$last}" + + GOPATH=$(get_build_path):$(get_buildcontrib_path) GOBIN=$(get_gobin_path) go \ + test ${extra_flags} -x ${modifier} +} + +process_filelist() { + local file_list="file.lst" + + rm -f ${file_list} + + for path in $(find ${RPM_BUILD_ROOT}$(get_source_path)); do + local destination=${path#${RPM_BUILD_ROOT}} + + if [[ -d ${path} ]]; then + echo "%dir ${destination}" >> ${file_list} + else + echo "${destination}" >> ${file_list} + fi + done +} + +process_godoc() { + echo "We should generate proper godocs!" +} + +main() { + local action="${1}" + + case "${action}" in + "--arch"|"arch") + process_arch ${@:2} + ;; + "--prep"|"prep") + process_prepare ${@:2} + ;; + "--build"|"build") + process_build ${@:2} + ;; + "--install"|"install") + process_install ${@:2} + ;; + "--source"|"source") + process_source ${@:2} + ;; + "--test"|"test") + process_test ${@:2} + ;; + "--filelist"|"filelist") + process_filelist ${@:2} + ;; + "--godoc"|"godoc") + process_godoc ${@:2} + ;; + *) + echo "Please specify a valid method: arch, prep, build, install, source, test, filelist, godoc" >&2 + ;; + esac +} + +main $@ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-14.9.2/macros.go new/golang-packaging-15.0.1/macros.go --- old/golang-packaging-14.9.2/macros.go 2016-06-21 11:32:43.000000000 +0200 +++ new/golang-packaging-15.0.1/macros.go 2017-03-14 12:47:19.000000000 +0100 @@ -6,135 +6,68 @@ # -%go_ver %(LC_ALL=C rpm -q --qf '%%{epoch}:%%{version}\\n' go | sed -e 's/(none)://' -e 's/ 0:/ /' | grep -v "is not") -%go_arch GOARCH -%go_build_ver %(go version | sed 's/^go version //' | sed 's:\/::g' | tr -d ' ' | cut -c 1-7 ) -%go_api_ver %(echo %{go_ver} | sed 's/\.[0-9]$//') - -%go_dir %{_libdir}/go -%go_sitedir %{_libdir}/go/pkg -%go_sitearch %{_libdir}/go/pkg/linux_%{go_arch} -%go_contribdir %{_libdir}/go/contrib/pkg/linux_%{go_arch} -%go_contribsrcdir %{_datadir}/go/contrib/src/ -%go_tooldir %{_datadir}/go/pkg/tool/linux_%{go_arch} +%go_ver %(LC_ALL=C rpm -q --qf '%%{epoch}:%%{version}\\n' go | sed -e 's/(none)://' -e 's/ 0:/ /' | grep -v "is not") +%go_arch %(%{_prefix}/lib/rpm/golang.sh arch) +%go_build_ver %(go version | sed 's/^go version //' | sed 's:\/::g' | tr -d ' ' | cut -c 1-7 ) +%go_api_ver %(echo %{go_ver} | sed 's/\.[0-9]$//') + +%go_dir %{_libdir}/go +%go_bindir %{_libdir}/go/bin +%go_srcdir %{_libdir}/go/src +%go_sitedir %{_libdir}/go/pkg +%go_sitearch %{_libdir}/go/pkg/linux_%{go_arch} +%go_contribdir %{_libdir}/go/contrib/pkg/linux_%{go_arch} +%go_contribsrcdir %{_datadir}/go/contrib/src/ +%go_tooldir %{_datadir}/go/pkg/tool/linux_%{go_arch} %go_nostrip \ %undefine _build_create_debug \ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true %go_exclusivearch \ -ExclusiveArch: aarch64 %ix86 x86_64 %arm ppc64 ppc64le s390x +ExclusiveArch: aarch64 %ix86 x86_64 %arm ppc64 ppc64le s390x %go_provides \ %if 0%{?suse_version} <= 1110 \ %global _use_internal_dependency_generator 0 \ %global __find_provides %{_prefix}/lib/rpm/golang.prov \ %global __find_requires %{_prefix}/lib/rpm/golang.req \ -%endif \ -%go_exclusivearch \ -Provides: %{name}-devel = %{version} \ -Provides: %{name}-devel-static = %{version} +%endif -# Prepare the expected Go package build environement. -# We need a $GOPATH: go help gopath -# We need a valid importpath: go help packages -%goprep %{_prefix}/lib/rpm/golang-macros.rb --prep - -# %%gobuild macro actually performs the command "go install", but the go -# toolchain will install to the $GOPATH which allows us then customise the final -# install for the distro default locations. -# -# gobuild accepts zero or more arguments. Each argument corresponds to -# a modifier of the importpath. If no arguments are passed, this is equivalent -# to the following go install statement: -# -# go install [importpath] -# -# Only the first or last arguement may be ONLY the wildcard argument "..." -# if the wildcard argument is passed then the importpath expands to all packages -# and binaries underneath it. If the argument contains only the wildcard no further -# arguments are considered. -# -# If no wildcard argument is passed, go install will be invoked on each $arg -# subdirectory under the importpath. -# -# Valid importpath modifier examples: -# -# example: %gobuild ... -# command: go install importpath... -# -# example: %gobuild /... -# command: go install importpath/... (All subdirs NOT including importpath) -# -# example: %gobuild foo... -# command: go install importpath/foo... (All subdirs INCLUDING foo) -# -# example: %gobuild foo ... (same as foo...) -# command: go install importpath/foo... (All subdirs INCLUDING foo) -# -# example: %gobuild foo/... -# commands: go install importpath/foo/... (All subdirs NOT including foo) -# -# example: %gobuild foo bar -# commands: go install importpath/foo -# go install importpath/bar -# -# example: %gobuild foo ... bar -# commands: go install importpath/foo... (bar is ignored) -# -# example: %gobuild foo bar... baz -# commands: go install importpath/foo -# go install importpath/bar... -# go install importpath/baz -# -# See: go help install, go help packages -%gobuild %{_prefix}/lib/rpm/golang-macros.rb --build +# goprep prepares the expected Go package build environement. We need a $GOPATH +# (for reference look at go help gopath) and we need a valid importpath (for +# reference look at go help packages) +%goprep \ +%{_prefix}/lib/rpm/golang.sh prep + +# gobuild macro actually performs the command "go install", but the go toolchain +# will install to the $GOPATH which allows us then customise the final install +# for the distro default locations. +%gobuild \ +%{_prefix}/lib/rpm/golang.sh build + +# goinstall moves the binary files into the bin folder, don't mix it with the go +# install command since this really just copies files and doesn't execute +# anything else. +%goinstall \ +%{_prefix}/lib/rpm/golang.sh install -# Install all compiled packages and binaries to the buildroot -%goinstall %{_prefix}/lib/rpm/golang-macros.rb --install - -%gofix %{_prefix}/lib/rpm/golang-macros.rb --fix - -%gotest %{_prefix}/lib/rpm/golang-macros.rb --test - -%gosrc %{_prefix}/lib/rpm/golang-macros.rb --source - -%go_filelist %{_prefix}/lib/rpm/golang-macros.rb --filelist - -# Template for source sub-package -%gosrc_package(n:r:) \ -%package %{-n:-n %{-n*}-}source \ -Summary: Source codes for package %{name} \ -Group: Development/Sources \ -Requires: %{-n:%{-n*}}%{!-n:%{name}} = %{version} \ -%{-r:Requires: %{-r*}} \ -Provides: %{-n:%{-n*}}%{!-n:%{name}}-doc = %{version}-%{release} \ -Obsoletes: %{-n:%{-n*}}%{!-n:%{name}}-doc < %{version}-%{release} \ -%description %{-n:-n %{-n*}-}source \ -This package provides source codes for package %{name}.\ -%{nil} - -# backward compatibility -%go_requires \ -%(if [ ! -f /usr/lib/rpm/golang.attr ] ; then \ -echo "Requires: go >= %go_build_ver" \ -fi) \ -%{nil} +# gosrc copies over all source files into the contrib source directory to be on +# a properly packaged location. +%gosrc \ +%{_prefix}/lib/rpm/golang.sh source -%go_recommends %{nil} +# gotest can execute the integrated test suite to make sure the software really +# works like expected in our environment. +%gotest \ +%{_prefix}/lib/rpm/golang.sh test +# godoc should generate useable documentations based on the inline godoc +# comments of the source files. %godoc \ -%gosrc \ -%{nil} +%{_prefix}/lib/rpm/golang.sh godoc -# Template for doc sub-package -%godoc_package(n:r:) \ -%package %{-n:-n %{-n*}-}doc \ -Summary: API documention for package %{name} \ -Group: Documentation/Other \ -Requires: %{-n:%{-n*}}%{!-n:%{name}} = %{version} \ -%{-r:Requires: %{-r*}} \ -%description %{-n:-n %{-n*}-}doc \ -This package provides API, examples and documentation \ -for package %{name}.\ -%{nil} +# go_filelist generates different lists of files to be consumed by the file +# section of an rpm. +%gofilelist \ +%{_prefix}/lib/rpm/golang.sh filelist