Lakka/retroarch: set update URL and target device name at build time

instead of relying on values in retroarch or parsing files to determine
the full URL to download updates, it is more flexibile to set these
values at build time to the current needs. much easier maintenance of
future changes (no need to change in retroarch code base), when e.g. URL
for devel or nightly builds will change (or even for releases). also
community members can set up their own update for their community builds
without the need to patch retroarch.

usage:
at build time add e.g. LAKKA_BUILD_TYPE=<type>, where type can be
release, nightly or devel (can be expanded in future) and based on the
build type matching URL will be set.

or add LAKKA_UPDATE_SERVER_URL=http://some.site/path/to/updates and this
URL will be used.

examples
make image LAKKA_BUILD_TYPE=nightly PROJECT=... DEVICE=... ARCH=...
make image LAKKA_UPDATE_SERVER_URL=... PROJECT=... ...
This commit is contained in:
Tomáš Kelemen (vudiq) 2024-05-24 23:39:49 +02:00
parent 08d672b54b
commit 64ae40c7ef
No known key found for this signature in database
GPG Key ID: 5CE55E600E0B3B22
7 changed files with 151 additions and 0 deletions

View File

@ -453,3 +453,20 @@
fi
done
fi
# Update server
LAKKA_BUILD_TYPE="${LAKKA_BUILD_TYPE:-release}"
if [ -z "${LAKKA_UPDATE_SERVER_URL}" ]; then
case ${LAKKA_BUILD_TYPE} in
release)
LAKKA_UPDATE_SERVER_URL="http://le.builds.lakka.tv"
;;
nightly)
LAKKA_UPDATE_SERVER_URL="http://nightly.builds.lakka.tv/.updater"
;;
devel)
LAKKA_UPDATE_SERVER_URL="http://nightly.builds.lakka.tv/.devbuild"
;;
esac
fi

View File

@ -22,6 +22,8 @@ PKG_CONFIGURE_OPTS_TARGET="--disable-vg \
PKG_MAKE_OPTS_TARGET="V=1 \
HAVE_LAKKA=1 \
HAVE_LAKKA_PROJECT="${DEVICE:-${PROJECT}}.${ARCH}" \
HAVE_LAKKA_SERVER="${LAKKA_UPDATE_SERVER_URL}" \
HAVE_CHEEVOS=1 \
HAVE_HAVE_ZARCH=0 \
HAVE_WIFI=1 \

View File

@ -0,0 +1,132 @@
diff --git a/Makefile.common b/Makefile.common
index 535dc94760..2a715f4786 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -1056,24 +1056,22 @@ endif
ifeq ($(HAVE_LAKKA), 1)
DEFINES += -DHAVE_LAKKA
+ ifneq ($(HAVE_LAKKA_PROJECT),)
+ DEFINES += -DHAVE_LAKKA_PROJECT=\"${HAVE_LAKKA_PROJECT}\"
+ else
+ $(error You asked for Lakka, but you did not specify a target device name in HAVE_LAKKA_PROJECT)
+ endif
+ ifneq ($(HAVE_LAKKA_SERVER),)
+ DEFINES += -DHAVE_LAKKA_SERVER=\"${HAVE_LAKKA_SERVER}\"
+ else
+ $(error You asked for Lakka, but you did not specify update server in HAVE_LAKKA_SERVER)
+ endif
endif
ifeq ($(HAVE_LAKKA_SWITCH), 1)
DEFINES += -DHAVE_LAKKA_SWITCH
endif
-ifeq ($(HAVE_LAKKA_NIGHTLY), 1)
- DEFINES += -DHAVE_LAKKA_NIGHTLY
-endif
-
-ifneq ($(HAVE_LAKKA_CANARY),)
- DEFINES += -DHAVE_LAKKA_CANARY=\"${HAVE_LAKKA_CANARY}\"
-endif
-
-ifeq ($(HAVE_LAKKA_DEVBUILD), 1)
- DEFINES += -DHAVE_LAKKA_DEVBUILD
-endif
-
ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += menu/menu_setting.o \
menu/menu_driver.o \
diff --git a/file_path_special.h b/file_path_special.h
index cd01bdc41d..6ffe51fb94 100644
--- a/file_path_special.h
+++ b/file_path_special.h
@@ -76,15 +76,6 @@ RETRO_BEGIN_DECLS
#define FILE_PATH_LOBBY_LIBRETRO_URL "http://lobby.libretro.com/"
#define FILE_PATH_CORE_THUMBNAILS_URL "http://thumbnails.libretro.com"
#define FILE_PATH_CORE_THUMBNAILPACKS_URL "http://thumbnailpacks.libretro.com"
-#ifdef HAVE_LAKKA_CANARY
-#define FILE_PATH_LAKKA_URL HAVE_LAKKA_CANARY
-#elif defined (HAVE_LAKKA_NIGHTLY)
-#define FILE_PATH_LAKKA_URL "http://nightly.builds.lakka.tv/.updater"
-#elif defined (HAVE_LAKKA_DEVBUILD)
-#define FILE_PATH_LAKKA_URL "http://nightly.builds.lakka.tv/.devbuild"
-#else
-#define FILE_PATH_LAKKA_URL "http://le.builds.lakka.tv"
-#endif
#define FILE_PATH_SHADERS_GLSL_ZIP "shaders_glsl.zip"
#define FILE_PATH_SHADERS_SLANG_ZIP "shaders_slang.zip"
#define FILE_PATH_SHADERS_CG_ZIP "shaders_cg.zip"
@@ -121,6 +112,19 @@ RETRO_BEGIN_DECLS
#define FILE_PATH_CORE_INFO_CACHE "core_info.cache"
#define FILE_PATH_CORE_INFO_CACHE_REFRESH "core_info.refresh"
+#ifdef HAVE_LAKKA
+ #ifdef HAVE_LAKKA_SERVER
+ #define FILE_PATH_LAKKA_URL HAVE_LAKKA_SERVER
+ #else
+ #error "Building for Lakka, but no update server was defined! Add -DHAVE_LAKKA_SERVER=\\\"http://...\\\""
+ #endif
+ #ifdef HAVE_LAKKA_PROJECT
+ #define LAKKA_PROJECT HAVE_LAKKA_PROJECT
+ #else
+ #error "Building for Lakka, but no target device name was defined! Add -DHAVE_LAKKA_PROJECT=\\\"DeviceName.arch\\\""
+ #endif
+#endif
+
enum application_special_type
{
APPLICATION_SPECIAL_NONE = 0,
diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c
index 351609df85..5a5d69fef9 100644
--- a/menu/cbs/menu_cbs_ok.c
+++ b/menu/cbs/menu_cbs_ok.c
@@ -246,30 +246,6 @@ static int (funcname)(const char *path, const char *label, unsigned type, size_t
return generic_action_ok_help(path, label, type, idx, entry_idx, _id, _id2); \
}
-#ifdef HAVE_NETWORKING
-#ifdef HAVE_LAKKA
-static char *lakka_get_project(void)
-{
-#ifndef HAVE_LAKKA_CANARY
- size_t len;
- static char lakka_project[128];
- FILE *command_file = popen("cat /etc/release | cut -d - -f 1", "r");
-
- fgets(lakka_project, sizeof(lakka_project), command_file);
- len = strlen(lakka_project);
-
- if (len > 0 && lakka_project[len-1] == '\n')
- lakka_project[--len] = '\0';
-
- pclose(command_file);
- return lakka_project;
-#else
- return "/";
-#endif
-}
-#endif
-#endif
-
static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
{
switch (lbl)
@@ -5049,7 +5025,7 @@ static int generic_action_ok_network(const char *path,
/* TODO unhardcode this path */
fill_pathname_join_special(url_path,
FILE_PATH_LAKKA_URL,
- lakka_get_project(), sizeof(url_path));
+ LAKKA_PROJECT, sizeof(url_path));
fill_pathname_join_special(url_path, url_path,
FILE_PATH_INDEX_URL,
sizeof(url_path));
@@ -5340,7 +5316,7 @@ static int action_ok_download_generic(const char *path,
#ifdef HAVE_LAKKA
/* TODO unhardcode this path*/
fill_pathname_join_special(s, FILE_PATH_LAKKA_URL,
- lakka_get_project(), sizeof(s));
+ LAKKA_PROJECT, sizeof(s));
#endif
break;
case MENU_ENUM_LABEL_CB_UPDATE_ASSETS: