Hello community, here is the log from the commit of package golang-packaging for openSUSE:Factory checked in at 2016-01-12 16:13:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 2016-01-07 00:24:37.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.golang-packaging.new/golang-packaging.changes 2016-01-12 16:13:34.000000000 +0100 @@ -1,0 +2,31 @@ +Mon Jan 11 11:19:26 UTC 2016 - [email protected] + +- update version 14.2 + * golang.req: fix ' // indirect' comment in import + +------------------------------------------------------------------- +Mon Jan 11 02:06:17 UTC 2016 - [email protected] + +- update version 14.1 + * golang.prov fix: uniq! returns nil if everything is unique + +------------------------------------------------------------------- +Tue Jan 5 12:09:20 UTC 2016 - [email protected] + +- 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) + +------------------------------------------------------------------- @@ -10 +41 @@ - and check __.PKGDEF from .a files for "import"s. + and check __.PKGDEF from .a files for "import"s. (github#3, github#4) Old: ---- golang-packaging-13.tar.gz New: ---- golang-packaging-14.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ golang-packaging.spec ++++++ --- /var/tmp/diff_new_pack.kKdg36/_old 2016-01-12 16:13:35.000000000 +0100 +++ /var/tmp/diff_new_pack.kKdg36/_new 2016-01-12 16:13:35.000000000 +0100 @@ -17,17 +17,17 @@ Name: golang-packaging -Version: 13 +Version: 14.2 Release: 0 Summary: A toolchain to help packaging golang License: GPL-3.0 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 +BuildRequires: ruby +Requires: go Requires: ruby -Requires: golang(API) = %{go_api_ver} BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch @@ -36,6 +36,8 @@ %prep %setup -q +GOARCH=`ruby ./golang-macros.rb --arch` +sed -i "s/GOARCH/$GOARCH/" macros.go %build @@ -49,19 +51,19 @@ 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/ +install -m0755 golang-macros.rb %{buildroot}%{_prefix}/lib/rpm/ +install -m0644 macros.go %{buildroot}%{_sysconfdir}/rpm/ %files %defattr(-,root,root) %doc COPYING README.md TODO ChangeLog -%config %{_sysconfdir}/rpm/macros.golang-packaging +%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-strip-builddep +%{_prefix}/lib/rpm/golang-macros.rb %changelog ++++++ golang-packaging-13.tar.gz -> golang-packaging-14.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-13/ChangeLog new/golang-packaging-14.2/ChangeLog --- old/golang-packaging-13/ChangeLog 2016-01-04 17:16:19.000000000 +0100 +++ new/golang-packaging-14.2/ChangeLog 2016-01-11 12:16:49.000000000 +0100 @@ -1,3 +1,41 @@ +== 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-13/TODO new/golang-packaging-14.2/TODO --- old/golang-packaging-13/TODO 2016-01-04 17:16:19.000000000 +0100 +++ new/golang-packaging-14.2/TODO 2016-01-11 12:16:49.000000000 +0100 @@ -1,5 +1,3 @@ # 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 +* multithreading diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-13/golang/cli.rb new/golang-packaging-14.2/golang/cli.rb --- old/golang-packaging-13/golang/cli.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/golang-packaging-14.2/golang/cli.rb 2016-01-11 12:16:49.000000000 +0100 @@ -0,0 +1,20 @@ +module CLI + + def self.run(command="") + + # echo the command we run to the buildlog + puts command + + IO.popen(command) {|f| f.each_line {|l| puts l}} + + if $? == 0 + File.open("/tmp/exitstatus.txt","w:UTF-8") {|f| f.puts(0)} + else + File.open("/tmp/exitstatus.txt","w:UTF-8") {|f| f.puts(1)} + abort "[ERROR]Go command failed! Please check." + end + + end + +end + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-13/golang/filelists.rb new/golang-packaging-14.2/golang/filelists.rb --- old/golang-packaging-13/golang/filelists.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/golang-packaging-14.2/golang/filelists.rb 2016-01-11 12:16:49.000000000 +0100 @@ -0,0 +1,90 @@ +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-13/golang/opts.rb new/golang-packaging-14.2/golang/opts.rb --- old/golang-packaging-13/golang/opts.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/golang-packaging-14.2/golang/opts.rb 2016-01-11 12:16:49.000000000 +0100 @@ -0,0 +1,53 @@ +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-13/golang/rpmsysinfo.rb new/golang-packaging-14.2/golang/rpmsysinfo.rb --- old/golang-packaging-13/golang/rpmsysinfo.rb 2016-01-04 17:16:19.000000000 +0100 +++ new/golang-packaging-14.2/golang/rpmsysinfo.rb 2016-01-11 12:16:49.000000000 +0100 @@ -12,10 +12,35 @@ @@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] - + # 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" + end + if @@rbarch == "x86_64" + @@libdir = "/usr/lib64" + @@go_arch = "amd64" + end + if @@arm.include?(@@rbarch) + @@libdir = "/usr/lib" + @@go_arch = "arm" + end + if @@rbarch == "aarch64" + @@libdir = "/usr/lib64" + @@go_arch = "arm64" + end + if @@rbarch == "ppc64" + @@libdir = "/usr/lib64" + @@go_arch = "ppc64" + end + if @@rbarch == "ppc64le" + @@libdir = "/usr/lib64" + @@go_arch = "ppc64le" + end def self.set_topdir(top) @@ -29,23 +54,57 @@ end + def self.get_builddir + + return @@topdir + "/BUILD" + + end + def self.get_buildroot return @@buildroot end - def self.get_archdir + def self.get_libdir + + return @@libdir + + end + + def self.get_go_arch + + return @@go_arch + + end + + def self.get_go_contribdir + + go_contribdir = @@libdir + "/go/contrib/pkg/linux_" + @@go_arch + return go_contribdir + + end + + def self.get_go_tooldir - return @@archdir + go_tooldir = "/usr/share/go/pkg/tool/linux_" + @@go_arch + return go_tooldir end - def self.get_importpath + def self.get_go_contribsrcdir + + return "/usr/share/go/contrib/src" + + end + + def self.get_go_importpath importpath = "" - File.open(@@specfile) do |f| + specfile = Dir.glob(@@topdir + "/SOURCES/*.spec")[0] + + File.open(specfile) do |f| f.each_line do |l| @@ -88,7 +147,7 @@ # code.google.com/p/log4go/, remove the ending "/" importpath = importpath.gsub(/\/$/,'') if importpath.index(/\/$/) - + return importpath end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-13/golang-macros.rb new/golang-packaging-14.2/golang-macros.rb --- old/golang-packaging-13/golang-macros.rb 2016-01-04 17:16:19.000000000 +0100 +++ new/golang-packaging-14.2/golang-macros.rb 2016-01-11 12:16:49.000000000 +0100 @@ -3,70 +3,31 @@ 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 -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 +$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 -# 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 +# ARGV[0], the called method itself +if ARGV[0] == "--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 + puts $go_arch -# ARGV[0], the called method itself -if ARGV[0] == "--prep" +elsif ARGV[0] == "--prep" puts "Preparation Stage:\n" @@ -101,8 +62,8 @@ 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 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" @@ -124,34 +85,33 @@ # 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") + 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? - system("GOPATH=\"#{gopath}\" GOBIN=\"#{gobin}\" go install #{sharedflags} #{buildidflags} #{buildflags} #{importpath}") + CLI.run("GOPATH=\"#{gopath}\" GOBIN=\"#{gobin}\" go install #{extraflags} #{buildflags} #{importpath}") else for mod in mods do if mod == "..." - system("GOPATH=\"#{gopath}\" GOBIN=\"#{gobin}\" go install #{sharedflags} #{buildidflags} #{buildflags} #{importpath}...") + CLI.run("GOPATH=\"#{gopath}\" GOBIN=\"#{gobin}\" go install #{extraflags} #{buildflags} #{importpath}...") break else - system("GOPATH=\"#{gopath}\" GOBIN=\"#{gobin}\" go install #{sharedflags} #{buildidflags} #{buildflags} #{importpath}/#{mod}") + CLI.run("GOPATH=\"#{gopath}\" GOBIN=\"#{gobin}\" go install #{extraflags} #{buildflags} #{importpath}/#{mod}") end end end @@ -162,6 +122,9 @@ 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| @@ -172,11 +135,11 @@ end unless Dir["#{$builddir}/go/bin/*"].empty? - puts "Copyig binaries to " + $buildroot + $bindir + 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 + $bindir) + FileUtils.cp_r(f,$buildroot + "/usr/bin") end puts "Done!" end @@ -187,6 +150,9 @@ 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| @@ -213,12 +179,15 @@ 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" - system("GOPATH=#{gopath} go fix #{ARGV[1]}...") + CLI.run("GOPATH=#{gopath} go fix #{ARGV[1]}...") end puts "Fixed!" @@ -227,19 +196,56 @@ 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" - system("GOPATH=#{gopath} go test -x #{ARGV[1]}...") + 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." + 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-13/golang-strip-builddep new/golang-packaging-14.2/golang-strip-builddep --- old/golang-packaging-13/golang-strip-builddep 2016-01-04 17:16:19.000000000 +0100 +++ new/golang-packaging-14.2/golang-strip-builddep 1970-01-01 01:00:00.000000000 +0100 @@ -1,144 +0,0 @@ -#!/usr/bin/env ruby -# strip unneeded build dependencies from golang source codes - -def find_build_directory() - - if File.directory?("/usr/src/packages") & File.writable?("/usr/src/packages") - topdir = "/usr/src/packages" - else - topdir = ENV["HOME"] + "/rpmbuild" - end - - builddir = "/BUILD" - sourcedir = "/SOURCES" - specfile = Dir.glob(sourcedir + "/*.spec")[0] - - pkgname = "" - - File.open(specfile) do |f| - - f.each_line do |l| - - build_found = 0 - - if l.index("Source:") then - - unless l.index("%{name}") then - - pkgname = l.gsub(/Source:/,'').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(builddir + "/*#{pkgname}*")[0] - - return build - -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 - - if ( d.index(".go") && ! d.index(/(test|example)/) ) then - - result << "#{dir}/#{d}" - - end - - end - - end - - end - - return result - -end - -def get_commandline_options() - - options = [] - - $*.each do |o| - - options << o - - end - - return options - -end - -def delete_line(filepath="",line="") - - require 'fileutils' - - newpath = filepath + ".new" - - File.open(filepath,'r') do |f1| - - File.open(newpath,'w') do |f2| - - f1.each_line do |l| - - f2.write(l) unless l.index(line) - - end - - end - - end - - FileUtils.mv newpath, filepath - -end - -def strip_unneed_dependency() - - build = find_build_directory() - - source = all_file(build) - - options = get_commandline_options() - - options.each do |opt| - - source.each do |s| - - if File.readlines(s, :encoding => "UTF-8").grep(/#{opt}/).size > 0 - - delete_line(s,opt) - - end - - end - - end - -end - -strip_unneed_dependency() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-13/golang.prov new/golang-packaging-14.2/golang.prov --- old/golang-packaging-13/golang.prov 2016-01-04 17:16:19.000000000 +0100 +++ new/golang-packaging-14.2/golang.prov 2016-01-11 12:16:49.000000000 +0100 @@ -3,15 +3,16 @@ require '/usr/lib/rpm/golang/rpmsysinfo.rb' include RpmSysinfo -archdir = RpmSysinfo.get_archdir -importpath = RpmSysinfo.get_importpath +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" 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/)) + # if line has "*.a" + # buildroot + contribdir + golang.org/x/text/collate/colltab.a + filelist << l.gsub(buildroot + contribdir + "/",'').strip! if ( l.index(/\.a\n/) && ! l.gsub(importpath,'').index(/example|test/) ) end # filelist: @@ -27,8 +28,16 @@ provides << "golang(" + f.gsub(".a","") + ")" end - provides.each do |p| - puts p + uni = provides.uniq! + + unless uni == nil + + uni.each {|p| puts p} + + else + + provides.each {|p| puts p} + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-13/golang.req new/golang-packaging-14.2/golang.req --- old/golang-packaging-13/golang.req 2016-01-04 17:16:19.000000000 +0100 +++ new/golang-packaging-14.2/golang.req 2016-01-11 12:16:49.000000000 +0100 @@ -2,13 +2,13 @@ require '/usr/lib/rpm/golang/rpmsysinfo.rb' include RpmSysinfo -importpath = RpmSysinfo.get_importpath +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" or "*.so" - # archdir + golang.org/x/text/collate/colltab.a + # if line has "*.a" + # buildroot + go_contribdir + golang.org/x/text/collate/colltab.a filelist << l.strip! if ( l.index(/\.a\n$/) && ! l.index(/test|example/) ) end @@ -26,7 +26,15 @@ 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) ) + 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-13/macros.go new/golang-packaging-14.2/macros.go --- old/golang-packaging-13/macros.go 2016-01-04 17:16:19.000000000 +0100 +++ new/golang-packaging-14.2/macros.go 2016-01-11 12:16:49.000000000 +0100 @@ -7,7 +7,7 @@ %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_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]$//') @@ -22,6 +22,11 @@ ExclusiveArch: aarch64 %ix86 x86_64 %arm ppc64 ppc64le %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} @@ -29,7 +34,7 @@ # 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 +%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 @@ -79,16 +84,18 @@ # go install importpath/baz # # See: go help install, go help packages -%gobuild /usr/lib/rpm/golang-macros.rb --build +%gobuild %{_prefix}/lib/rpm/golang-macros.rb --build # Install all compiled packages and binaries to the buildroot -%goinstall /usr/lib/rpm/golang-macros.rb --install +%goinstall %{_prefix}/lib/rpm/golang-macros.rb --install -%gofix /usr/lib/rpm/golang-macros.rb --fix +%gofix %{_prefix}/lib/rpm/golang-macros.rb --fix -%gotest /usr/lib/rpm/golang-macros.rb --test +%gotest %{_prefix}/lib/rpm/golang-macros.rb --test -%gosrc /usr/lib/rpm/golang-macros.rb --source +%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:) \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/golang-packaging-13/macros.golang-packaging new/golang-packaging-14.2/macros.golang-packaging --- old/golang-packaging-13/macros.golang-packaging 2016-01-04 17:16:19.000000000 +0100 +++ new/golang-packaging-14.2/macros.golang-packaging 1970-01-01 01:00:00.000000000 +0100 @@ -1,26 +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 %{_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}
