#9 Use relative symlinks for goalts; workarounds https://pagure.io/golist/issue/12 https://github.com/rpm-software-management/rpm/issues/671
Merged 5 years ago by nim. Opened 5 years ago by nim.
nim/go-rpm-macros symlink-rework  into  master

file modified
+1 -1
@@ -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}"

file modified
+3 -10
@@ -18,7 +18,6 @@ 

  cat >&2 << EOF_USAGE

  Usage: $0 <action> [ [-h] ]

                     [ [-p <prefix>] [-g <go path>] ]

-                    [ [-s <go source dir> ] ]

  

  <action>             should be one of: provides, requires

  
@@ -26,24 +25,20 @@ 

  that do not apply to a specific action. Unless specified otherwise, all

  arguments are optional.

  

- Common arguments:

+ Arguments:

  

  -h                   print this help

  -p <prefix>:         an optionnal prefix path such as %{buildroot}

  -g <go path>:        the root of the Go source tree

                       default value if not set: /usr/share/gocode

  

- Provide arguments

- -s <go source dir>   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 @@ 

  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 @@ 

      -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 @@ 

  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]}}"

@@ -34,6 +34,7 @@ 

  %package     -n %{currentgoaltname}

  Summary:        %{currentgoaltsummary}

  BuildRequires:  go-rpm-macros

+ BuildArch:      noarch

  %{?currentgoaltheader}

  %description -n %{currentgoaltname}

  %(%reformatdescriptiontext << EOF_DESCR
@@ -69,10 +70,8 @@ 

  }

  

  %__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}"

  }