Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions scriptmodules/supplementary/golang.sh

This file was deleted.

60 changes: 49 additions & 11 deletions scriptmodules/supplementary/scraper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}
Expand Down