From 9c07ff3c11695f7aab11d3ab50e9bb043edb2482 Mon Sep 17 00:00:00 2001 From: Nicolas Mailhot Date: Apr 19 2019 13:55:37 +0000 Subject: Use relative symlinks for goalts; workarounds https://pagure.io/golist/issue/12 https://github.com/rpm-software-management/rpm/issues/671 --- diff --git a/rpm/fileattrs/gosymlink.attr b/rpm/fileattrs/gosymlink.attr index 0f90f1d..ed77e0a 100644 --- a/rpm/fileattrs/gosymlink.attr +++ b/rpm/fileattrs/gosymlink.attr @@ -1,5 +1,5 @@ %__gosymlink_path ^%{gopath}/src/.*$ %__gosymlink_magic ^(.*, )?(broken )?symbolic link to .*$ %__gosymlink_flags magic_and_path -%__gosymlink_provides %{_rpmconfigdir}/gosymlink.deps provides --prefix "%{buildroot}" --go-path "%{gopath}" --go-source-dir "%{gobuilddir}" +%__gosymlink_provides %{_rpmconfigdir}/gosymlink.deps provides --prefix "%{buildroot}" --go-path "%{gopath}" %__gosymlink_requires %{_rpmconfigdir}/gosymlink.deps requires --prefix "%{buildroot}" --go-path "%{gopath}" diff --git a/rpm/gosymlink.deps b/rpm/gosymlink.deps index 55b8d51..72264ab 100755 --- a/rpm/gosymlink.deps +++ b/rpm/gosymlink.deps @@ -18,7 +18,6 @@ usage() { cat >&2 << EOF_USAGE Usage: $0 [ [-h] ] [ [-p ] [-g ] ] - [ [-s ] ] should be one of: provides, requires @@ -26,24 +25,20 @@ Most actions accept the same set of arguments, and will silently ignore those that do not apply to a specific action. Unless specified otherwise, all arguments are optional. -Common arguments: +Arguments: -h print this help -p : an optionnal prefix path such as %{buildroot} -g : the root of the Go source tree default value if not set: /usr/share/gocode -Provide arguments --s the source installation tree EOF_USAGE exit 1 } action='' -version='' prefix='' gopath=/usr/share/gocode -gosourcedir=/usr/share/gocode declare -A metadata flags_d=() flags_t=() @@ -61,7 +56,7 @@ fi shift if ! options=$(getopt -n $0 -o hp:g:s: \ - -l help,prefix:,go-path:,go-source-dir: \ + -l help,prefix:,go-path: \ -- "$@") then usage @@ -74,7 +69,6 @@ while [ $# -gt 0 ] ; do -h|--help) usage ;; -p|--prefix) prefix=$(realpath -sm "$2") ; shift;; -g|--go-path) gopath="$2" ; shift;; - -s|--go-source-dir) gosourcedir="$2" ; shift;; (--) shift; break;; (-*) usage ;; (*) break;; @@ -137,14 +131,13 @@ done provides() { local goipath="${1}" fullprovides golang-symlink "${goipath}" -GOPATH="${gosourcedir}" \ +GOPATH="${prefix}${gopath}" \ golist --provided --package-path "${goipath}" $(expandflags) |\ while read -r -d $'\n' prov ; do fullprovides golang "${prov}" done } -# Convert paths within gopath to version-constrained provides requires() { local r="golang-ipath(${1#${prefix}${gopath}/src/})" echo "${r}${metadata[version]:+ = ${metadata[version]}}" diff --git a/rpm/macros.d/macros.go-rpm.internal b/rpm/macros.d/macros.go-rpm.internal index e6a50d6..5bde43b 100644 --- a/rpm/macros.d/macros.go-rpm.internal +++ b/rpm/macros.d/macros.go-rpm.internal @@ -34,6 +34,7 @@ EOF_DESCR) %package -n %{currentgoaltname} Summary: %{currentgoaltsummary} BuildRequires: go-rpm-macros +BuildArch: noarch %{?currentgoaltheader} %description -n %{currentgoaltname} %(%reformatdescriptiontext << EOF_DESCR @@ -69,10 +70,8 @@ go-rpm-integration install -i "%{__godevelinstall_ipath}" \\ } %__goaltinstall() %{expand: -install -m 0755 -d "%{gobuilddir}/src/%(dirname %{currentgoaltipath})" -ln -s "%{gobuilddir}/src/%{currentgocanonipath}" "%{gobuilddir}/src/%{currentgoaltipath}" install -m 0755 -d "%{buildroot}%{gopath}/src/%(dirname %{currentgoaltipath})" -ln -s "%{gopath}/src/%{currentgocanonipath}" "%{buildroot}%{gopath}/src/%{currentgoaltipath}" +ln -rs "%{buildroot}%{gopath}/src/%{currentgocanonipath}" "%{buildroot}%{gopath}/src/%{currentgoaltipath}" echo "%{gopath}/src/%{currentgoaltipath}" >> "%{goworkdir}/%{currentgoaltfilelist}" }