From 6dbcbe7a627c640888b711b04578f9a29b9074e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Date: Tue, 26 Sep 2023 19:56:59 -0700 Subject: [PATCH] config: List which Endless Key collections to preload Instead of loading every channel from every collection JSON from the Endless Key app, allow the image configuration to list which collections to include. https://github.com/endlessm/eos-image-builder/issues/117 --- config/defaults.ini | 6 ++++++ hooks/image/51-ek-content-list | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config/defaults.ini b/config/defaults.ini index 5210b540..d5cc476a 100644 --- a/config/defaults.ini +++ b/config/defaults.ini @@ -304,6 +304,12 @@ regular_users_can_manage_content = false # # Kolibri 0.12.2 User Guide for Admins [document] # 5bb37c1832c8489ab2940f31588305f6 +[endlesskey] +# Which Endless Key collections to preload in the image. +# Must match the name of one of the collections shipped with the Endless Key +# (ex. artist, explorer, spanish etc). +collections = + [usb] size = 16000000000 free_space = 1000 diff --git a/hooks/image/51-ek-content-list b/hooks/image/51-ek-content-list index 0c202539..0cddc483 100644 --- a/hooks/image/51-ek-content-list +++ b/hooks/image/51-ek-content-list @@ -1,5 +1,9 @@ # Populate the Endless Key home directory +if [ -z "${EIB_ENDLESSKEY_COLLECTIONS}" ]; then + exit 0 +fi + if [[ ! "${EIB_FLATPAK_REMOTE_FLATHUB_APPS}" =~ .*"org.endlessos.Key".* ]]; then exit 0 fi @@ -7,5 +11,10 @@ fi rm -f "${EIB_TMPDIR}"/ek-channels collections="${OSTREE_VAR}"/lib/flatpak/app/org.endlessos.Key/current/active/files/share/endless-key/collections/*.json for collection in ${collections}; do - jq -r '.channels[].id' "${collection}" >> "${EIB_TMPDIR}"/ek-channels + # Check if the file basename stripped off of -0001.json is part of the list + # of collections to be installed. + bn=$(basename ${collection}) + if [[ "${EIB_ENDLESSKEY_COLLECTIONS}" =~ .*"${bn%-????.json}".* ]] ; then + jq -r '.channels[].id' "${collection}" >> "${EIB_TMPDIR}"/ek-channels + fi done