Rework go support in autospec

This change allows autospec to build and ship go binaries but stops
autospec creating source directories for the packages. This means that
autospec is to be used only to create go binaries and thus those
binaries must vendor all their dependencies.

Go packages will likely need to be patched in order for go build to
work due to the directory naming and/or vendoring handling. Please see
the patch in the 0001 patch in Clear Linux's
golang-github-cpuguy83-go-md2man package for an example of this.
This commit is contained in:
William Douglas
2017-06-01 00:17:50 +00:00
parent cd23220c35
commit 4e52a2d178
5 changed files with 4 additions and 51 deletions
-9
View File
@@ -89,15 +89,6 @@ def failed_pattern(line, pattern, verbose, buildtool=None):
if not s:
return
must_restart += buildreq.add_buildreq(util.translate('%s-python' % s))
elif buildtool == 'go':
s = util.translate(s)
if not s:
return
elif s == match.group(1):
# the requirement it's also golang libpath format
# (e.g: github.com/<project>/<repo> so transform into pkg name
s = util.golang_name(s)
must_restart += buildreq.add_buildreq(s)
elif buildtool == 'ruby':
if s in config.gems:
must_restart += buildreq.add_buildreq(config.gems[s])
+2 -2
View File
@@ -466,10 +466,10 @@ def scan_for_configure(package, dir, autospecdir):
if dirpath != dir:
default_score = 1
if any(file.endswith(".go") for file in files) and tarball.go_pkgname:
if any(file.endswith(".go") for file in files):
add_buildreq("go")
tarball.name = tarball.go_pkgname
buildpattern.set_build_pattern("golang", default_score)
if "CMakeLists.txt" in files and "configure.ac" not in files:
add_buildreq("cmake")
buildpattern.set_build_pattern("cmake", default_score)
+2 -8
View File
@@ -1021,17 +1021,11 @@ class Specfile(object):
self._write_strip("%build")
self.write_proxy_exports()
self._write_strip("export LANG=C")
self._write_strip("export GOPATH=\"$PWD\"")
self._write_strip("go build")
self._write_strip("\n")
self._write_strip("%install")
self._write_strip('gopath="/usr/lib/golang-dist"')
self._write_strip('library_path="{}"'.format(library_path))
self._write_strip("rm -rf %{buildroot}")
self._write_strip("install -d -p %{buildroot}${gopath}/src/${library_path}/")
self._write_strip('for file in $(find . -iname "*.go" -o -iname "*.h" -o -iname "*.c") ; do')
self._write(" install -d -p %{buildroot}${gopath}/src/${library_path}/$(dirname $file)\n")
self._write(" cp -pav $file %{buildroot}${gopath}/src/${library_path}/$file\n")
self._write_strip("done")
self.write_make_install_append()
self._write_strip("\n")
def write_maven_pattern(self):
-9
View File
@@ -32,8 +32,6 @@ import urllib.request
import pycurl
from io import BytesIO
from util import call, print_fatal
# from util import golang_name
# from util import golang_libpath
name = ""
rawname = ""
@@ -43,9 +41,6 @@ url = ""
path = ""
tarball_prefix = ""
gcov_file = ""
golibpath = ""
go_pkgname = ""
def get_sha1sum(filename):
sh = hashlib.sha1()
@@ -129,9 +124,6 @@ def download_tarball(url_argument, name_arg, archives, target_dir):
global path
global tarball_prefix
global gcov_file
# go naming
global golibpath
global go_pkgname
tarfile = os.path.basename(url)
@@ -372,4 +364,3 @@ def load_specfile(specfile):
specfile.tarball_prefix = tarball_prefix
specfile.gcov_file = gcov_file
specfile.rawname = rawname
specfile.golibpath = golibpath
-23
View File
@@ -64,29 +64,6 @@ def translate(package):
return package
def golang_name(some_str):
""" get the golang-somesite-project-repo format pkg name"""
ret = some_str
pattern = re.compile(r".*(github)\.com/([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/?")
match = pattern.search(some_str)
if match:
domain = match.group(1).strip()
project = match.group(2).strip()
repo = match.group(3).strip()
ret = "golang-" + domain + "-" + project + "-" + repo
return ret
def golang_libpath(some_str):
""" get the import path for golang"""
ret = ""
pattern = re.compile(r".*(github\.com/[0-9a-zA-Z_\-]+/[0-9a-zA-Z_\-]+).*")
match = pattern.search(some_str)
if match:
ret = match.group(1).strip()
return ret
def print_fatal(message):
print("[\033[1m\033[91mFATAL\033[0m] {}".format(message))