Hello community,

here is the log from the commit of package golang-packaging for 
openSUSE:Factory checked in at 2016-01-07 00:24:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/golang-packaging (Old)
 and      /work/SRC/openSUSE:Factory/.golang-packaging.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "golang-packaging"

Changes:
--------
--- /work/SRC/openSUSE:Factory/golang-packaging/golang-packaging.changes        
2015-09-08 17:46:51.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.golang-packaging.new/golang-packaging.changes   
2016-01-07 00:24:37.000000000 +0100
@@ -1,0 +2,25 @@
+Mon Jan  4 01:52:15 UTC 2016 - [email protected]
+
+- 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.
+
+-------------------------------------------------------------------
+Sun Jan  3 03:50:28 UTC 2016 - [email protected]
+
+- update version 12
+  * don't find provides/requires on -source, -debuginfo, -debugsource
+    subpackages
+  * add scripts to generate file lists.
+
+-------------------------------------------------------------------
+Sat Jan  2 05:57:41 UTC 2016 - [email protected]
+
+- update version 11
+  * fix for sles and openSUSE < 13.2
+
+-------------------------------------------------------------------

Old:
----
  golang-packaging-10.tar.gz

New:
----
  golang-packaging-13.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ golang-packaging.spec ++++++
--- /var/tmp/diff_new_pack.U4QuTn/_old  2016-01-07 00:24:39.000000000 +0100
+++ /var/tmp/diff_new_pack.U4QuTn/_new  2016-01-07 00:24:39.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package golang-packaging
 #
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 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,22 +16,20 @@
 #
 
 
-%if %{?sles_version}
-%define _rpmconfigdir %{_libexecdir}/rpm
-%endif
-
 Name:           golang-packaging
-Version:        10
+Version:        13
 Release:        0
 Summary:        A toolchain to help packaging golang
 License:        GPL-3.0
-Group:          Development/Languages/Other
+Group:          Development/Languages/Golang
 Url:            https://github.com/marguerite/%{name}
 Source:         
https://github.com/marguerite/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
+BuildRequires:  go
 BuildRequires:  rpm
 Requires:       ruby
-Requires:       golang(API) = 1.5
+Requires:       golang(API) = %{go_api_ver}
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+BuildArch:      noarch
 
 %description
 A toolchain to help packaging golang, written in ruby.
@@ -43,20 +41,27 @@
 
 %install
 mkdir -p %{buildroot}%{_sysconfdir}/rpm/
-mkdir -p %{buildroot}%{_rpmconfigdir}/fileattrs
-install -m0644 golang.attr %{buildroot}%{_rpmconfigdir}/fileattrs/
-install -m0755 golang.prov %{buildroot}%{_rpmconfigdir}/
-install -m0755 golang.req %{buildroot}%{_rpmconfigdir}/
-install -m0755 golang-strip-builddep %{buildroot}%{_rpmconfigdir}/
-install -m0644 macros.go-extra %{buildroot}%{_sysconfdir}/rpm/
+mkdir -p %{buildroot}%{_prefix}/lib/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-strip-builddep %{buildroot}%{_prefix}/lib/rpm/
+install -m0644 macros.golang-packaging %{buildroot}%{_sysconfdir}/rpm/
 
 %files
 %defattr(-,root,root)
 %doc COPYING README.md TODO ChangeLog
-%config %{_sysconfdir}/rpm/macros.go-extra
-%{_rpmconfigdir}/fileattrs/golang.attr
-%{_rpmconfigdir}/golang.prov
-%{_rpmconfigdir}/golang.req
-%{_rpmconfigdir}/golang-strip-builddep
+%config %{_sysconfdir}/rpm/macros.golang-packaging
+%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-strip-builddep
 
 %changelog

++++++ golang-packaging-10.tar.gz -> golang-packaging-13.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/README.md 
new/golang-packaging-13/README.md
--- old/golang-packaging-10/README.md   2015-09-04 18:21:25.000000000 +0200
+++ new/golang-packaging-13/README.md   2016-01-04 17:16:19.000000000 +0100
@@ -1,3 +1,14 @@
 # golang-packaging
 
 RPM macros and utilities for golang packaging.
+
+A golang packager can just say
+
+>  BuildRequires: golang-packaging 
+
+and let the included scripts handle Provides/Requires for
+you automatically. You can also say 
+
+>  BuildRequires: golang(xxx) 
+
+in specifications for packages built with golang-packaging.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/TODO new/golang-packaging-13/TODO
--- old/golang-packaging-10/TODO        2015-09-04 18:21:25.000000000 +0200
+++ new/golang-packaging-13/TODO        2016-01-04 17:16:19.000000000 +0100
@@ -1,3 +1,5 @@
 # TODO
 
 * implements all kinds of `import`. now we only supports `import ""`, `import 
{ }` and `import ()`.
+* a macro "get_filelist" "get_source_filelist" and related macros
+  to delete item from the list 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/golang/rpmsysinfo.rb 
new/golang-packaging-13/golang/rpmsysinfo.rb
--- old/golang-packaging-10/golang/rpmsysinfo.rb        1970-01-01 
01:00:00.000000000 +0100
+++ new/golang-packaging-13/golang/rpmsysinfo.rb        2016-01-04 
17:16:19.000000000 +0100
@@ -0,0 +1,97 @@
+module RpmSysinfo
+
+       if File.directory?("/usr/src/packages") & 
File.writable?("/usr/src/packages")
+               @@topdir = "/usr/src/packages"
+       else
+               @@topdir = ENV["HOME"] + "/rpmbuild"
+       end
+
+        @@buildroot = Dir.glob(@@topdir + "/BUILDROOT/*")[0]
+
+        # sometimes buildroot locates in tmppath/name-version-build
+
+        @@buildroot = Dir.glob("/var/tmp/*-build")[0] if @@buildroot == nil
+
+       @@archdir = Dir.glob(@@buildroot + "/usr/lib*/go/contrib/pkg/*")[0] + 
"/"
+
+       @@specfile = Dir.glob(@@topdir+ "/SOURCES/*.spec")[0]
+
+
+       def self.set_topdir(top)
+
+               @@topdir = top
+
+       end
+
+       def self.get_topdir
+
+               return @@topdir
+
+       end
+
+       def self.get_buildroot
+
+               return @@buildroot
+
+       end
+
+       def self.get_archdir
+
+               return @@archdir
+
+       end
+
+       def self.get_importpath
+
+               importpath = ""
+
+                File.open(@@specfile) do |f|
+
+                        f.each_line do |l|
+
+                                found = 0
+
+                                # see if there's any packager definition for 
importpath
+                                if 
l.index(/%(define|global)[\s]+(import_path|importpath)/i) then
+
+                                        importpath = 
l.gsub(/%(define|global)[\s]+(import_path|importpath)/i,'').lstrip!.chomp!.gsub(/"/,'').gsub(/"/,'')
+
+                                        found = 1
+
+                                end
+
+                                # use the one in "%goprep 
code.google.com/p/log4go"
+                                if (found == 0 && l.index("%goprep")) then 
+
+                                        importpath = 
l.gsub(/%goprep/,'').lstrip!.chomp!
+
+                                        found = 1
+
+                                end
+
+                                # sometimes packager didn't package using the 
macros we give, extract from URL tag
+                                if (found == 0 && l.index("Url:")) then
+
+                                        # eg: "URL: 
https://code.google.com/p/log4go/";
+                                        # "URL: 
http://download.fcitx-im.org/fcitx/fcitx";
+
+                                        # gsub
+                                        # 1. remove "Url:" then leading 
whitespace and ending "\n"
+                                        # 2. remove "http://"; or "https://";
+                                        importpath = 
l.gsub(/Url:/,'').lstrip!.chomp!.gsub(/^(http|https)\:\/\//,'')
+
+                                end
+
+                        end
+
+                end
+
+                # code.google.com/p/log4go/, remove the ending "/"
+                importpath = importpath.gsub(/\/$/,'') if 
importpath.index(/\/$/)
+            
+                return importpath
+        
+        end
+
+end
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/golang-macros.rb 
new/golang-packaging-13/golang-macros.rb
--- old/golang-packaging-10/golang-macros.rb    1970-01-01 01:00:00.000000000 
+0100
+++ new/golang-packaging-13/golang-macros.rb    2016-01-04 17:16:19.000000000 
+0100
@@ -0,0 +1,245 @@
+#!/usr/bin/env ruby
+
+require 'fileutils'
+require 'securerandom'
+require 'find'
+
+# GLOBAL RPM MACROS
+if File.directory?("/usr/src/packages") & File.writable?("/usr/src/packages")
+       $topdir = "/usr/src/packages"
+else
+       $topdir = ENV["HOME"] + "/rpmbuild"
+end
+
+$builddir = $topdir + "/BUILD"
+$buildrootdir = $topdir + "/BUILDROOT"
+$bindir = "/usr/bin"
+$datadir = "/usr/share"
+
+$arch = ""
+# 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)
+       $libdir = "/usr/lib"
+       $go_arch = "386"
+       $arch = "i386"
+end
+if $rbarch == "x86_64"
+        $libdir = "/usr/lib64"
+        $go_arch = "amd64"
+       $arch = $rbarch
+end
+if arm.include?($rbarch)
+        $libdir = "/usr/lib"
+        $go_arch = "arm"
+       $arch = $rbarch
+end
+if $rbarch == "aarch64"
+       $libdir = "/usr/lib64"
+       $go_arch = "arm64"
+       $arch = $rbarch
+end
+if $rbarch == "ppc64"
+       $libdir = "/usr/lib64"
+       $go_arch = "ppc64"
+       $arch = $rbarch
+end
+if $rbarch == "ppc64le"
+       $libdir = "/usr/lib64"
+       $go_arch = "ppc64le"
+       $arch = $rbarch
+end
+
+# we don't need to create buildroot which is 
$buildrootdir/%{name}-%{version}-%{release}.%{_arch},
+# we just find the only directory under $buildrootdir
+$buildroot = Dir.glob($buildrootdir + "/*." + $arch)[0]
+# sometimes buildroot locates in tmppath/name-version-build
+if $buildroot == nil
+       $buildroot = Dir.glob("/var/tmp/*-build")[0]
+end
+
+$go_contribdir = $libdir + "/go/contrib/pkg/linux_" + $go_arch
+$go_contribsrcdir = $datadir + "/go/contrib/src"
+$go_tooldir = $datadir + "/go/pkg/tool/linux_" + $go_arch
+
+# ARGV[0], the called method itself
+if 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") 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 + $bindir 
+ "\n"  
+               FileUtils.mkdir_p($buildroot + $bindir)
+               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").gets.strip!
+
+       # ARGV[0] is "--build" itself, there can be "--with-buildid" or 
"--shared"
+        # all else are treated as MODs
+       mods = ARGV
+       mods.delete_at(0) # drop "--build"
+       sharedflags = ""
+       buildidflags = ""
+
+       if mods.include?("--shared")
+               sharedflags = "-buildmode=shared -linkshared"
+               mods.delete("--shared")
+       end
+
+       if mods.include?("--with-buildid")
+               buildid = "0x" + SecureRandom.hex(20)
+               buildidflags = '-ldflags "-B ' + buildid + '"'
+               mods.delete("--with-buildid")
+       end
+
+       # MODs: nil, "...", "/...", "foo...", "foo/...", "foo bar", "foo bar... 
baz" and etc
+       if mods.empty?
+               system("GOPATH=\"#{gopath}\" GOBIN=\"#{gobin}\" go install 
#{sharedflags} #{buildidflags} #{buildflags} #{importpath}") 
+       else
+               for mod in mods do
+                       if mod == "..."
+                               system("GOPATH=\"#{gopath}\" GOBIN=\"#{gobin}\" 
go install #{sharedflags} #{buildidflags} #{buildflags} #{importpath}...")
+                               break
+                       else
+                               system("GOPATH=\"#{gopath}\" GOBIN=\"#{gobin}\" 
go install #{sharedflags} #{buildidflags} #{buildflags} #{importpath}/#{mod}")
+                       end
+               end
+       end
+
+       puts "Build Finished!\n"
+
+elsif ARGV[0] == "--install"
+
+       puts "Installation stage:\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 + $bindir
+               Dir.glob($builddir + "/go/bin/*").each do |f|
+                       puts "Copying " + f
+                       FileUtils.chmod_R(0755,f)
+                       FileUtils.cp_r(f,$buildroot + $bindir)
+               end
+               puts "Done!"
+       end
+
+       puts "Install finished!\n"
+
+elsif ARGV[0] == "--source"
+
+       puts "Source package creation:"
+
+       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
+
+       # remove previous created tmp file
+       File.delete("/tmp/importpath.txt")
+
+       puts "Source package created!"
+
+elsif ARGV[0] == "--fix"
+
+       puts "Fixing stuff..."
+
+        # 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"
+                system("GOPATH=#{gopath} go fix #{ARGV[1]}...")
+        end
+
+       puts "Fixed!"
+
+elsif ARGV[0] == "--test"
+
+       puts "Testing codes..."
+
+       # 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"
+               system("GOPATH=#{gopath} go test -x #{ARGV[1]}...")
+       end
+
+       puts "Test passed!"
+
+else
+
+       puts "Please specify a valid method: --prep, --build, --install, --fix, 
--test, --source."
+
+end
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/golang-strip-builddep 
new/golang-packaging-13/golang-strip-builddep
--- old/golang-packaging-10/golang-strip-builddep       2015-09-04 
18:21:25.000000000 +0200
+++ new/golang-packaging-13/golang-strip-builddep       2016-01-04 
17:16:19.000000000 +0100
@@ -3,10 +3,15 @@
 
 def find_build_directory()
 
-        path = "/home/abuild/rpmbuild/SOURCES"
-        #path = `pwd`.gsub(/\n/,'')
+        if File.directory?("/usr/src/packages") & 
File.writable?("/usr/src/packages")
+                topdir = "/usr/src/packages"
+        else
+                topdir = ENV["HOME"] + "/rpmbuild"
+        end
 
-        specfile = Dir.glob(path + "/*.spec")[0]
+       builddir = "/BUILD"
+        sourcedir = "/SOURCES"
+        specfile = Dir.glob(sourcedir + "/*.spec")[0]
 
         pkgname = ""
 
@@ -38,8 +43,7 @@
 
         end
 
-        build = Dir.glob("/home/abuild/rpmbuild/BUILD/*#{pkgname}*")[0]
-        #build = Dir.glob(path + "/*#{pkgname}*")[0]
+        build = Dir.glob(builddir + "/*#{pkgname}*")[0]
 
         return build
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/golang.attr 
new/golang-packaging-13/golang.attr
--- old/golang-packaging-10/golang.attr 2015-09-04 18:21:25.000000000 +0200
+++ new/golang-packaging-13/golang.attr 2016-01-04 17:16:19.000000000 +0100
@@ -1,3 +1,3 @@
-%__golang_requires  %{_rpmconfigdir}/golang.req
-%__golang_provides  %{_rpmconfigdir}/golang.prov
-%__golang_path  
^(/usr/lib(64)?/go/contrib/pkg/linux_(386|amd64|ppc.*|arm.*)/.*\\.a|%{_bindir}/.*)$
+%__golang_requires  %{_perfix}/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}/.*)$
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/golang.prov 
new/golang-packaging-13/golang.prov
--- old/golang-packaging-10/golang.prov 2015-09-04 18:21:25.000000000 +0200
+++ new/golang-packaging-13/golang.prov 2016-01-04 17:16:19.000000000 +0100
@@ -1,131 +1,34 @@
 #!/usr/bin/env ruby
 
-def prepare()
+require '/usr/lib/rpm/golang/rpmsysinfo.rb'
+include RpmSysinfo
 
-       specfile = Dir.glob("/home/abuild/rpmbuild/SOURCES/*.spec")[0]
-       #specfile = Dir.glob(`pwd`.gsub(/\n/,'') + "/*.spec")[0]
-
-       importpath,pkgname,version = "","",""
-
-       File.open(specfile) do |f|
-
-               f.each_line do |l|
-
-                       build_found = 0
-
-                       if l.index(/Source(0)?:/) then
-
-                               unless l.index("%{name}") then
-
-                                       pkgname = 
l.gsub(/Source(0)?:/,'').lstrip!.chomp!.gsub(/^.*\//,'').gsub(/-%.*$/,'')
-
-                                       build_found = 1
-
-                               end
-
-                       end
-
-                        if (build_found == 0 && l.index("Name:")) then
-
-                                pkgname = 
l.gsub(/Name:/,'').lstrip!.chomp!.gsub(/^(go|golang)-/,'')
-
-                        end
-
-                        if l.index("Version:") then
-
-                                version = l.gsub(/Version:/,'').lstrip!.chomp!
-
-                        end
-
-                       found = 0
-
-                       if 
l.index(/%(define|global)[\s]+(import_path|importpath)/i) then
-
-                               importpath = 
l.gsub(/%(define|global)[\s]+(import_path|importpath)/i,'').lstrip!.chomp!.gsub(/"/,'').gsub(/"/,'')
-
-                               found = 1
-
-                       end
-
-                       if (found == 0 && l.index("%goprep")) then 
-
-                               importpath = l.gsub(/%goprep/,'').lstrip!.chomp!
-
-                               found = 1
-
-                       end
-
-                       if (found == 0 && l.index("Url:")) then
-
-                               importpath = 
l.gsub(/Url\:/,'').lstrip!.chomp!.gsub(/^(http|https)\:\/\//,'')
-
-                       end
-
-               end
-
-       end
-
-        build = Dir.glob("/home/abuild/rpmbuild/BUILD/*#{pkgname}*")[0]
-        #build = Dir.glob(`pwd`.gsub(/\n/,'') + "/*#{pkgname}*/")[0]
-
-       importpath = importpath.gsub(/\/$/,'') if importpath.index(/\/$/)
-
-       return importpath,build,version
-
-end
-
-def all_dir(dir="",result=nil)
-
-       result = [] unless result
-
-       Dir.entries(dir).each do |d|
-
-               unless (d == "." || d == ".." || d.index("example") || 
d.index("test")) then
-
-                        if File.directory?("#{dir}/#{d}") then
-
-                               result << "#{dir}/#{d}" if ! 
Dir["#{dir}/#{d}/*.go"].empty?
-
-                                all_dir("#{dir}/#{d}",result)
-
-                        end
-
-               end
-
-       end
-
-       return result
+archdir = RpmSysinfo.get_archdir
+importpath = RpmSysinfo.get_importpath
 
+# read stdin for filelist rpm feeds us for a (sub) package
+filelist = []
+ARGF.each do |l|
+       # if line has "*.a" or "*.so"
+       # archdir + golang.org/x/text/collate/colltab.a
+       filelist << l.gsub(archdir,'').strip! if (l.index(/\.(a|so)\n/) && ! 
l.index(/example|test/))
 end
 
-def get_provides_list()
-
-       importpath = prepare()[0]
-
-       build = prepare()[1]
+# filelist:
+# golang.org/x/text/collate/colltab.a
 
-       version = prepare()[2]
+provides = []
 
-       source,list = [],[]
+unless filelist.empty? then
 
-       # all_dir return strings containing build, replace w/ importpath
-
-       all_dir(build).each do |r|
-
-               source << importpath + r.gsub(build,'')
+       provides << "golang(" + importpath + ")"
 
+       filelist.each do |f|
+               provides << "golang(" + f.gsub(".a","") + ")"
        end
 
-       list << "golang(" + importpath + ") = " + version
-
-       source.each do |s|
-
-               list << "golang(" + s + ") = " + version
-
+       provides.each do |p|
+               puts p  
        end
 
-       return list
-
 end
-
-puts get_provides_list()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/golang.req 
new/golang-packaging-13/golang.req
--- old/golang-packaging-10/golang.req  2015-09-04 18:21:25.000000000 +0200
+++ new/golang-packaging-13/golang.req  2016-01-04 17:16:19.000000000 +0100
@@ -1,152 +1,41 @@
 #!/usr/bin/env ruby
 
-def find_build_directory()
-
-       path = "/home/abuild/rpmbuild/SOURCES"
-       #path = `pwd`.gsub(/\n/,'')
-
-       specfile = Dir.glob(path + "/*.spec")[0]
-
-       pkgname = ""
-
-       File.open(specfile) do |f|
-
-               f.each_line do |l|
-
-                       build_found = 0
-
-                        if l.index(/Source(0)?:/) then
-
-                                unless l.index("%{name}") then
-
-                                        pkgname = 
l.gsub(/Source(0)?:/,'').lstrip!.chomp!.gsub(/^.*\//,'').gsub(/-%.*$/,'')
-
-                                        build_found = 1
-
-                                end
-
-                        end
-
-                        if (build_found == 0 && l.index("Name:")) then
-
-                                pkgname = 
l.gsub(/Name:/,'').lstrip!.chomp!.gsub(/^(go|golang)-/,'')
-
-                        end
-
-               end
-
-       end
-
-       build = Dir.glob("/home/abuild/rpmbuild/BUILD/*#{pkgname}*")[0]
-       #build = Dir.glob(path + "/*#{pkgname}*/")[0]
-
-       return build
-
+require '/usr/lib/rpm/golang/rpmsysinfo.rb'
+include RpmSysinfo
+importpath = RpmSysinfo.get_importpath
+
+# read stdin for filelist rpm feeds us for a (sub) package
+filelist = []
+ARGF.each do |l|
+       # if line has "*.a" or "*.so"
+       # archdir + golang.org/x/text/collate/colltab.a
+       filelist << l.strip! if ( l.index(/\.a\n$/) && ! 
l.index(/test|example/) )
 end
 
-def all_file(dir="",result=nil)
-
-       result = [] unless result
-
-       Dir.entries(dir).each do |d|
-
-               unless (d == "." || d == ".." || d.index("example") || 
d.index("test")) then
-
-                       if File.directory?("#{dir}/#{d}") then
-
-                               all_file("#{dir}/#{d}",result)
-
-                       else
+requires = []
 
-                               if ( d.index(".go") && ! 
d.index(/(test|example)/) ) then
+unless filelist.empty? then
 
-                                       result << "#{dir}/#{d}"
+       requires << "golang(API) = 1.5"
 
+       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"
+                                       requires << "golang(" + 
l.strip!.gsub(/"$/,'').gsub(/^.*"/,'') + ")" if ( 
l.index(/(\.com|\.net|\.org|gopkg\.in)/) && ! l.index(importpath) )
                                end
-
                        end
-
                end
-
+               # clean
+               File.delete("__.PKGDEF")
        end
 
-       return result
-
-end
-
-def get_imports_list()
-
-       build = find_build_directory()
-
-       source = all_file(build)
-
-       list,importlist = [],[]
-
-       own = 
`/usr/lib/rpm/golang.prov`.split(/\n/)[0].gsub(/golang\(/,'').gsub(/\)[\s]+=.*/,'')
-       #own = 
`./golang.prov`.split(/\n/)[0].gsub(/golang\(/,'').gsub(/\)[\s]+=.*/,'')
-
-       source.each do |g|
-
-               File.open(g,:encoding => "UTF-8") do |f|
-
-                       f.each_line do |l|
-
-                               # import should be the first word in a line, or 
it could be comment
-
-                               if l.index(/^import/) then
-
-                                       if l.index(/({|\()/)then
-
-                                               t = ""
-       
-                                               f.each_line do |l1|
-
-                                                       t = t + l1
-
-                                                       # we don't need that 
much, just a few lines, not whole text
-                                                       break if l1.index(/\)/)
-
-                                               end
-
-                                               imports = 
t.gsub(/(\n|\t)/,'').gsub(/(\)|}).*$/,'').split(/"/)
-
-                                               imports.each do |i|
-
-                                                       # .com|.net|.org 
matches all URL, own strips its own url, [\s] (whitespace)
-                                                       # guarantees it doens't 
match a sentence like comments
-                                                       list << i if ( 
i.index(/(\.com|\.net|\.org|gopkg\.in)/) && ! i.index(own) && ! i.index(/[\s]/) 
)
-
-                                               end
-
-                                       else
-
-
-                                               list << 
l.gsub(/import/,'').gsub(/"/,'').lstrip!.chomp!.gsub(/.*[\s]+/,'') if ( 
l.index(/(\.com|\.net|\.org)/) && ! l.index(own) )
-
-                                       end
-
-                               end
-
-                       end
-
-               end
-
-       end
-
-       unless list == nil then
-
-               list.uniq.each do |l|
-
-                       importlist << "golang(" + l + ")"
-
-               end
-
+       requires.each do |p|
+               puts p  
        end
 
-       importlist << "golang(API) = 1.5"
-
-       return importlist
-
 end
-
-puts get_imports_list()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/macros.go 
new/golang-packaging-13/macros.go
--- old/golang-packaging-10/macros.go   1970-01-01 01:00:00.000000000 +0100
+++ new/golang-packaging-13/macros.go   2016-01-04 17:16:19.000000000 +0100
@@ -0,0 +1,129 @@
+# Macros for Go module building.
+#
+# Copyright: (c) 2011 Sascha Peilicke <[email protected]>
+# Copyright: (c) 2012 Graham Anderson <[email protected]>
+# Copyright: (c) 2015 SUSE Linux GmbH
+#
+
+
+%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_exclusivearch \
+ExclusiveArch:  aarch64 %ix86 x86_64 %arm ppc64 ppc64le
+
+%go_provides \
+%go_exclusivearch \
+Provides:       %{name}-devel = %{version} \
+Provides:       %{name}-devel-static = %{version}
+
+# Prepare the expected Go package build environement.
+# We need a $GOPATH: go help gopath
+# We need a valid importpath: go help packages
+%goprep /usr/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 /usr/lib/rpm/golang-macros.rb --build 
+
+# Install all compiled packages and binaries to the buildroot
+%goinstall /usr/lib/rpm/golang-macros.rb --install
+
+%gofix /usr/lib/rpm/golang-macros.rb --fix
+
+%gotest /usr/lib/rpm/golang-macros.rb --test
+
+%gosrc /usr/lib/rpm/golang-macros.rb --source
+
+# 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}
+
+%go_recommends %{nil}
+
+%godoc \
+%gosrc \
+%{nil}
+
+# 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}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/macros.go-extra 
new/golang-packaging-13/macros.go-extra
--- old/golang-packaging-10/macros.go-extra     2015-09-04 18:21:25.000000000 
+0200
+++ new/golang-packaging-13/macros.go-extra     1970-01-01 01:00:00.000000000 
+0100
@@ -1,12 +0,0 @@
-# Macros from golang-packaging for Go module building.
-#
-# Copyright: (c) 2015 <[email protected]>
-#
-
-# Strip unneeded build dependencies
-# Sometimes there're additional importpath(s) in examples/tests.
-# You can usually delete the examples/tests to avoid such
-# unneeded BuildRequires/Requires. If they also exists in
-# productional codes, you can use this macro to strip them.
-# eg: %%go_strip_builddep golang.org/x/oauth2
-%go_strip_builddep %{_rpmconfigdir}/golang-strip-builddep
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/golang-packaging-10/macros.golang-packaging 
new/golang-packaging-13/macros.golang-packaging
--- old/golang-packaging-10/macros.golang-packaging     1970-01-01 
01:00:00.000000000 +0100
+++ new/golang-packaging-13/macros.golang-packaging     2016-01-04 
17:16:19.000000000 +0100
@@ -0,0 +1,26 @@
+# Macros from golang-packaging for Go module building.
+#
+# Copyright: (c) 2015 <[email protected]>
+#
+
+# Strip unneeded build dependencies
+# Sometimes there're additional importpath(s) in examples/tests.
+# You can usually delete the examples/tests to avoid such
+# unneeded BuildRequires/Requires. If they also exists in
+# productional codes, you can use this macro to strip them.
+# eg: %%go_strip_builddep golang.org/x/oauth2
+%go_strip_builddep %{_prefix}/lib/rpm/golang-strip-builddep
+
+# redefine go_provides here to insert dependency check scripts
+# because go_provides is a macro appeared on every golang spec
+# file
+%go_provides \
+%{?go_provides: %undefine go_provides} \
+%if 0%{?suse_version} < 1320 \
+%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}


Reply via email to