Initial Commit

This commit is contained in:
CapCreeperGR
2024-07-08 12:03:10 +00:00
commit c87882cdab
2 changed files with 62 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
DOWNLOAD="https://go.dev/dl/go${BPM_PKG_VERSION}.src.tar.gz"
FILENAME="${DOWNLOAD##*/}"
# The prepare function is executed in the root of the temp directory
# This function is used for downloading files and putting them into the correct location
prepare() {
wget "$DOWNLOAD"
tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE"
}
# The build function is executed in the source directory
# This function is used to compile the source code
build() {
cd src
export GOOS=linux
export GOARCH=amd64
export GOROOT_FINAL=/usr/lib/go
export GOROOT_BOOTSTRAP=/usr/lib/go
./make.bash -v
}
# The check function is executed in the source directory
# This function is used to run tests to verify the package has been compiled correctly
check() {
cd src
export GO_TEST_TIMEOUT_SCALE=3
./run.bash --no-rebuild -v -v -v -k
}
# The package function is executed in the source directory
# This function is used to move the compiled files into the output directory
package() {
install -d "${BPM_OUTPUT}/usr/bin" "${BPM_OUTPUT}/usr/lib/go" "${BPM_OUTPUT}/usr/share/doc/go" \
"${BPM_OUTPUT}/usr/lib/go/pkg/linux_amd64_"{dynlink,race}
cp -a bin pkg src lib misc api test "${BPM_OUTPUT}/usr/lib/go"
cp -r doc/* "${BPM_OUTPUT}/usr/share/doc/go"
ln -sf /usr/lib/go/bin/go "${BPM_OUTPUT}/usr/bin/go"
ln -sf /usr/lib/go/bin/gofmt "${BPM_OUTPUT}/usr/bin/gofmt"
ln -sf /usr/share/doc/go "${BPM_OUTPUT}/usr/lib/go/doc"
install -Dm644 VERSION "${BPM_OUTPUT}/usr/lib/go/VERSION"
rm -rf "${BPM_OUTPUT}/usr/lib/go/pkg/bootstrap" "${BPM_OUTPUT}/usr/lib/go/pkg/tool/*/api"
install -Dm644 go.env "${BPM_OUTPUT}/usr/lib/go/go.env"
install -Dm644 LICENSE "${BPM_OUTPUT}/usr/share/licenses/go/LICENSE"
}