diff --git a/scriptmodules/supplementary/golang.sh b/scriptmodules/supplementary/golang.sh deleted file mode 100644 index bbda21f54d..0000000000 --- a/scriptmodules/supplementary/golang.sh +++ /dev/null @@ -1,46 +0,0 @@ -# This file is part of The RetroPie Project -# -# The RetroPie Project is the legal property of its developers, whose names are -# too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source. -# -# See the LICENSE.md file at the top-level directory of this distribution and -# at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md -# - -rp_module_id="golang" -rp_module_desc="Golang binary install" -rp_module_licence="BSD https://golang.org/LICENSE" -rp_module_section="depends" -rp_module_flags="noinstclean" - -function _get_goroot_golang() { - echo "$rootdir/supplementary/golang" -} - -function install_bin_golang() { - local target_version=1.11.13 - local version - if [[ -e "$md_inst/bin/go" ]]; then - local version=$(GOROOT="$md_inst" "$md_inst/bin/go" version | sed 's/.*go\(1[^ ]*\).*/\1/') - fi - printMsgs "console" "Current Go version: $version" - if compareVersions "$version" ge "$target_version" ; then - return 0 - fi - - rm -rf "$md_inst" - mkdir -p "$md_inst" - local arch="armv6l" - if isPlatform "x86"; then - if isPlatform "64bit"; then - arch="amd64" - else - arch="386" - fi - fi - if isPlatform "aarch64"; then - arch="arm64" - fi - printMsgs "console" "Downloading go$target_version.linux-$arch.tar.gz" - downloadAndExtract "https://go.dev/dl/go${target_version}.linux-$arch.tar.gz" "$md_inst" --strip-components 1 --exclude="go/test" -} diff --git a/scriptmodules/supplementary/scraper.sh b/scriptmodules/supplementary/scraper.sh index e10a150e18..ed03433979 100644 --- a/scriptmodules/supplementary/scraper.sh +++ b/scriptmodules/supplementary/scraper.sh @@ -14,21 +14,63 @@ rp_module_desc="Scraper for EmulationStation by Steven Selph" rp_module_licence="MIT https://raw.githubusercontent.com/sselph/scraper/master/LICENSE" rp_module_repo="git https://github.com/sselph/scraper.git master" rp_module_section="opt" -rp_module_flags="nobin" +rp_module_flags="" -function depends_scraper() { - rp_callModule golang install_bin +function _update_hook_scraper() { + # remove previously installed 'golang' module + rm -fr "$rootdir/supplementary/golang" +} + +function _golang_scraper() { + local target_version=1.13.15 + local goroot="$1" + + if [[ -z "$1" ]]; then + __ERRMSGS+=("Missing installation folder for 'go' !") + return 1 + fi + + rm -rf "$goroot" + mkdir -p "$goroot" + local arch="armv6l" + if isPlatform "x86"; then + if isPlatform "64bit"; then + arch="amd64" + else + arch="386" + fi + fi + if isPlatform "aarch64"; then + arch="arm64" + fi + printMsgs "console" "Downloading go$target_version.linux-$arch.tar.gz" + downloadAndExtract "https://go.dev/dl/go${target_version}.linux-$arch.tar.gz" "$goroot" --strip-components 1 --exclude="go/test" } function sources_scraper() { gitPullOrClone + # patch the TGDB API key since upstream's key is expired + local tgdb_api_key="b76d00f4dbf3449267b06086426df3bd8cb4c19fdc64b3224fa619ec4cd57e25" + sed -i "s/defaultGamesDbAPIKey = .*/defaultGamesDbAPIKey = \"$tgdb_api_key\"/" "$md_build/scraper.go" } function build_scraper() { - local goroot="$(_get_goroot_golang)" - GOROOT="$goroot" "$goroot/bin/go" mod init github.com/sselph/scraper - GOROOT="$goroot" "$goroot/bin/go" get github.com/J-Swift/thegamesdb-swagger-client-go@43ed8a0b364ed2d8521d0 - GOROOT="$goroot" "$goroot/bin/go" build -o scraper + local goroot="$md_build/goinst" + + # install a local 'golang' version + _golang_scraper "$goroot" + + rm -f go.mod + ( + # use a subshell so the env vars here do not propagate globally + export GOROOT="$goroot" + export GOMODCACHE="$goroot/pkg-cache" + export GOCACHE="$goroot/build-cache" + "$goroot/bin/go" mod init github.com/sselph/scraper + "$goroot/bin/go" mod tidy + "$goroot/bin/go" get github.com/J-Swift/thegamesdb-swagger-client-go@43ed8a0b364ed2d8521d0 + "$goroot/bin/go" build -o scraper + ) } function install_scraper() { @@ -40,10 +82,6 @@ function install_scraper() { ) } -function remove_scraper() { - rp_callModule golang remove -} - function get_ver_scraper() { [[ -f "$md_inst/scraper" ]] && "$md_inst/scraper" -version 2>/dev/null }