From 48080d2d13e44ef35279f0f72fecc49086b32003 Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Tue, 26 Jan 2021 01:04:34 +0000 Subject: [PATCH] packages - allow adding of 3rd party module repos 3rd party repositories can be checked out to RetroPie-Setup/ext Repositories should be structured so you have: ext/REPOSITORY/scriptmodules Modules are only read from the following subfolders of scriptmodules * emulators * libretrocores * ports * supplementary * admin --- ext/README.txt | 13 +++++++++++++ scriptmodules/packages.sh | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 ext/README.txt diff --git a/ext/README.txt b/ext/README.txt new file mode 100644 index 00000000..43cbc62c --- /dev/null +++ b/ext/README.txt @@ -0,0 +1,13 @@ +You can checkout additional repositories here to add 3rd party modules. + +Repositories should be structured so you have: + +ext/REPOSITORY_NAME/scriptmodules + +Modules are only read from the following subfolders of scriptmodules: + * emulators + * libretrocores + * ports + * supplementary + * admin + diff --git a/scriptmodules/packages.sh b/scriptmodules/packages.sh index 09baebca..ed121df5 100644 --- a/scriptmodules/packages.sh +++ b/scriptmodules/packages.sh @@ -526,6 +526,8 @@ function rp_getPackageInfo() { function rp_registerModule() { local path="$1" local type="$2" + # type is the last folder in the path as we now send a full path to rp_registerModule + type="${type##*/}" local rp_module_id="" local rp_module_desc="" local rp_module_help="" @@ -599,10 +601,13 @@ function rp_registerModule() { function rp_registerModuleDir() { local dir="$1" + [[ ! -d "$dir" ]] && return 1 local module + while read module; do rp_registerModule "$module" "$dir" - done < <(find "$scriptdir/scriptmodules/$dir" -maxdepth 1 -name "*.sh" | sort) + done < <(find "$dir" -mindepth 1 -maxdepth 1 -type f -name "*.sh" | sort) + return 0 } function rp_registerAllModules() { @@ -610,11 +615,13 @@ function rp_registerAllModules() { declare -Ag __mod_idx=() declare -Ag __mod_info=() - rp_registerModuleDir "emulators" - rp_registerModuleDir "libretrocores" - rp_registerModuleDir "ports" - rp_registerModuleDir "supplementary" - rp_registerModuleDir "admin" + local dir + local type + while read dir; do + for type in emulators libretrocores ports supplementary admin; do + rp_registerModuleDir "$dir/$type" + done + done < <(find "$scriptdir"/scriptmodules "$scriptdir"/ext/*/scriptmodules -maxdepth 0 2>/dev/null) } function rp_getSectionIds() {