Skip to content

Commit 168f64d

Browse files
committed
go: install binaries to /usr/lib/go/bin/
- Before this, go and gofmt was installed to /usr/bin, which confuses Go as it can not figure out $GOROOT automatically by os.Executable, see [1] for details. By installing binaries to $GOROOT/bin (GOROOT points to /usr/lib/go), go can now figure out its GOROOT. - Provide symlinks in /usr/bin/go{,fmt}-google to ensure it is there. - Update alternatives file to point corresponding executables to the one installed in $GOROOT. [1]: golang/go#61921 (comment)
1 parent 952d85b commit 168f64d

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

lang-golang/go/autobuild/alternatives

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
alternative /usr/bin/go /usr/bin/go-google 80
2-
alternative /usr/bin/gofmt /usr/bin/gofmt-google 80
1+
alternative /usr/bin/go /usr/lib/go/bin/go 80
2+
alternative /usr/bin/gofmt /usr/lib/go/bin/gofmt 80

lang-golang/go/autobuild/build

+7-10
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ cp -rv "$SRCDIR"/{doc,misc} \
5959
ln -sv ../../share/go/doc \
6060
"$PKGDIR/usr/lib/go/doc"
6161
cp -av "$SRCDIR"/bin \
62-
"$PKGDIR/usr"
62+
"$PKGDIR/usr/lib/go/"
6363
cp -av "$SRCDIR"/pkg \
64-
"$PKGDIR/usr/lib/go"
64+
"$PKGDIR/usr/lib/go/"
6565
cp -av "$GOROOT/src" \
6666
"$PKGDIR/usr/lib/go/"
6767
cp -av "$GOROOT/src/cmd" \
@@ -83,10 +83,6 @@ abinfo "Setting executable bit for sql.go ..."
8383
find "$PKGDIR" \
8484
-type f -name sql.go -exec chmod -v -x {} \;
8585

86-
abinfo "Creating a symlink for /usr/lib/go/bin to /usr/bin ..."
87-
ln -svf ../../bin \
88-
"$PKGDIR/usr/lib/go/bin"
89-
9086
abinfo "Installing build scripts ..."
9187
install -Dvm755 "$SRCDIR"/src/make.bash \
9288
"$PKGDIR/usr/lib/go/src/make.bash"
@@ -103,17 +99,18 @@ install -Dvm644 "$SRCDIR"/VERSION \
10399
"$PKGDIR/usr/lib/go/VERSION"
104100

105101
abinfo "Touching all installed files ..."
106-
find "$PKGDIR"/usr/{lib/go/pkg,bin} \
102+
find "$PKGDIR"/usr/lib/go/{pkg,bin} \
107103
-type f -exec touch '{}' +
108104

109105
abinfo "Installing basic Go tools ..."
110106
install -dvm755 "$PKGDIR"/usr/lib/go/pkg/tool/"${GOOS}"_"$GOARCH"
111107
install -pvm755 "$SRCDIR"/pkg/tool/"${GOOS}"_"$GOARCH"/* \
112108
"$PKGDIR"/usr/lib/go/pkg/tool/"${GOOS}"_"$GOARCH"
113109

114-
abinfo "Renaming go and gofmt for alternatives ..."
115-
mv -v "$PKGDIR"/usr/bin/go{,-google}
116-
mv -v "$PKGDIR"/usr/bin/gofmt{,-google}
110+
abinfo "Linking go and gofmt installed in GOROOT to /usr/bin ..."
111+
mkdir "$PKGDIR"/usr/bin
112+
ln -sfv ../lib/go/bin/go "$PKGDIR"/usr/bin/go-google
113+
ln -sfv ../lib/go/bin/gofmt "$PKGDIR"/usr/bin/gofmt-google
117114

118115
abinfo "Preparing to build extra Go tools ..."
119116
mkdir -pv "$SRCDIR"/go-tools/src/golang.org/x/

lang-golang/go/autobuild/build.stage2

+7-10
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ cp -rv "$SRCDIR"/{doc,misc} \
6666
ln -sv ../../share/go/doc \
6767
"$PKGDIR/usr/lib/go/doc"
6868
cp -av "$SRCDIR"/bin \
69-
"$PKGDIR/usr"
69+
"$PKGDIR/usr/lib/go/"
7070
cp -av "$SRCDIR"/pkg \
71-
"$PKGDIR/usr/lib/go"
71+
"$PKGDIR/usr/lib/go/"
7272
cp -av "$GOROOT/src" \
7373
"$PKGDIR/usr/lib/go/"
7474
cp -av "$GOROOT/src/cmd" \
@@ -90,10 +90,6 @@ abinfo "Setting executable bit for sql.go ..."
9090
find "$PKGDIR" \
9191
-type f -name sql.go -exec chmod -v -x {} \;
9292

93-
abinfo "Creating a symlink for /usr/lib/go/bin to /usr/bin ..."
94-
ln -svf ../../bin \
95-
"$PKGDIR/usr/lib/go/bin"
96-
9793
abinfo "Installing build scripts ..."
9894
install -Dvm755 "$SRCDIR"/src/make.bash \
9995
"$PKGDIR/usr/lib/go/src/make.bash"
@@ -110,17 +106,18 @@ install -Dvm644 "$SRCDIR"/VERSION \
110106
"$PKGDIR/usr/lib/go/VERSION"
111107

112108
abinfo "Touching all installed files ..."
113-
find "$PKGDIR"/usr/{lib/go/pkg,bin} \
109+
find "$PKGDIR"/usr/lib/go/{pkg,bin} \
114110
-type f -exec touch '{}' +
115111

116112
abinfo "Installing basic Go tools ..."
117113
install -dvm755 "$PKGDIR"/usr/lib/go/pkg/tool/"${GOOS}"_"$GOARCH"
118114
install -pvm755 "$SRCDIR"/pkg/tool/"${GOOS}"_"$GOARCH"/* \
119115
"$PKGDIR"/usr/lib/go/pkg/tool/"${GOOS}"_"$GOARCH"
120116

121-
abinfo "Renaming go and gofmt for alternatives ..."
122-
mv -v "$PKGDIR"/usr/bin/go{,-google}
123-
mv -v "$PKGDIR"/usr/bin/gofmt{,-google}
117+
abinfo "Linking go and gofmt installed in GOROOT to /usr/bin ..."
118+
mkdir "$PKGDIR"/usr/bin
119+
ln -sfv ../lib/go/bin/go "$PKGDIR"/usr/bin/go-google
120+
ln -sfv ../lib/go/bin/gofmt "$PKGDIR"/usr/bin/gofmt-google
124121

125122
abinfo "Preparing to build extra Go tools ..."
126123
mkdir -pv "$SRCDIR"/go-tools/src/golang.org/x/

0 commit comments

Comments
 (0)