Skip to content

Commit 1d87f4e

Browse files
authored
Merge pull request #4170 from cmitu/scraper-ftbfs
scraper: fix build and re-organize module
2 parents 730b682 + 967bfa4 commit 1d87f4e

File tree

2 files changed

+49
-57
lines changed

2 files changed

+49
-57
lines changed

scriptmodules/supplementary/golang.sh

Lines changed: 0 additions & 46 deletions
This file was deleted.

scriptmodules/supplementary/scraper.sh

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,63 @@ rp_module_desc="Scraper for EmulationStation by Steven Selph"
1414
rp_module_licence="MIT https://raw.githubusercontent.com/sselph/scraper/master/LICENSE"
1515
rp_module_repo="git https://github.com/sselph/scraper.git master"
1616
rp_module_section="opt"
17-
rp_module_flags="nobin"
17+
rp_module_flags=""
1818

19-
function depends_scraper() {
20-
rp_callModule golang install_bin
19+
function _update_hook_scraper() {
20+
# remove previously installed 'golang' module
21+
rm -fr "$rootdir/supplementary/golang"
22+
}
23+
24+
function _golang_scraper() {
25+
local target_version=1.13.15
26+
local goroot="$1"
27+
28+
if [[ -z "$1" ]]; then
29+
__ERRMSGS+=("Missing installation folder for 'go' !")
30+
return 1
31+
fi
32+
33+
rm -rf "$goroot"
34+
mkdir -p "$goroot"
35+
local arch="armv6l"
36+
if isPlatform "x86"; then
37+
if isPlatform "64bit"; then
38+
arch="amd64"
39+
else
40+
arch="386"
41+
fi
42+
fi
43+
if isPlatform "aarch64"; then
44+
arch="arm64"
45+
fi
46+
printMsgs "console" "Downloading go$target_version.linux-$arch.tar.gz"
47+
downloadAndExtract "https://go.dev/dl/go${target_version}.linux-$arch.tar.gz" "$goroot" --strip-components 1 --exclude="go/test"
2148
}
2249

2350
function sources_scraper() {
2451
gitPullOrClone
52+
# patch the TGDB API key since upstream's key is expired
53+
local tgdb_api_key="b76d00f4dbf3449267b06086426df3bd8cb4c19fdc64b3224fa619ec4cd57e25"
54+
sed -i "s/defaultGamesDbAPIKey = .*/defaultGamesDbAPIKey = \"$tgdb_api_key\"/" "$md_build/scraper.go"
2555
}
2656

2757
function build_scraper() {
28-
local goroot="$(_get_goroot_golang)"
29-
GOROOT="$goroot" "$goroot/bin/go" mod init github.com/sselph/scraper
30-
GOROOT="$goroot" "$goroot/bin/go" get github.com/J-Swift/thegamesdb-swagger-client-go@43ed8a0b364ed2d8521d0
31-
GOROOT="$goroot" "$goroot/bin/go" build -o scraper
58+
local goroot="$md_build/goinst"
59+
60+
# install a local 'golang' version
61+
_golang_scraper "$goroot"
62+
63+
rm -f go.mod
64+
(
65+
# use a subshell so the env vars here do not propagate globally
66+
export GOROOT="$goroot"
67+
export GOMODCACHE="$goroot/pkg-cache"
68+
export GOCACHE="$goroot/build-cache"
69+
"$goroot/bin/go" mod init github.com/sselph/scraper
70+
"$goroot/bin/go" mod tidy
71+
"$goroot/bin/go" get github.com/J-Swift/thegamesdb-swagger-client-go@43ed8a0b364ed2d8521d0
72+
"$goroot/bin/go" build -o scraper
73+
)
3274
}
3375

3476
function install_scraper() {
@@ -40,10 +82,6 @@ function install_scraper() {
4082
)
4183
}
4284

43-
function remove_scraper() {
44-
rp_callModule golang remove
45-
}
46-
4785
function get_ver_scraper() {
4886
[[ -f "$md_inst/scraper" ]] && "$md_inst/scraper" -version 2>/dev/null
4987
}

0 commit comments

Comments
 (0)