From a11e1bbf3948316d398956b82d2d461cc3b10ab4 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 11 Dec 2024 14:53:38 +0900 Subject: [PATCH] LOCAL_BUILD: added manifest caching and experimental args for flatpak-builder [skip ci] --- .gitignore | 1 + automation_tools/flatpak_build_only.sh | 16 +++++++-- automation_tools/pre_build_automation.sh | 37 ++++++++++---------- developer_toolbox/build_retrodeck_locally.sh | 19 ++++++++-- 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 47b0316f..17a6e2a2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ incconfigs/ .github/workflows/cooker-monkeyx.yml *.flatpak *.flatpak.sha +net.retrodeck.retrodeck.cached.yml # Python # ########## diff --git a/automation_tools/flatpak_build_only.sh b/automation_tools/flatpak_build_only.sh index 33276379..5f0c632f 100755 --- a/automation_tools/flatpak_build_only.sh +++ b/automation_tools/flatpak_build_only.sh @@ -15,10 +15,20 @@ fi mkdir -vp ${GITHUB_WORKSPACE}/retrodeck-repo mkdir -vp ${GITHUB_WORKSPACE}/"$FOLDER" -flatpak-builder --user --force-clean \ +# Pass the args to Flatpak Builder +FLATPAK_BUILD_EXTRA_ARGS="${@}" +echo "Passing additional args to flatpak builder: $FLATPAK_BUILD_EXTRA_ARGS" + +command="flatpak-builder --user --force-clean $FLATPAK_BUILD_EXTRA_ARGS \ --install-deps-from=flathub \ --install-deps-from=flathub-beta \ --repo=${GITHUB_WORKSPACE}/retrodeck-repo \ --disable-download \ - "${GITHUB_WORKSPACE}/$FOLDER" \ - net.retrodeck.retrodeck.yml \ No newline at end of file + \"${GITHUB_WORKSPACE}/$FOLDER\" \ + net.retrodeck.retrodeck.yml" + +# Echo the command for verification +echo -e "Executing command:\n$command" + +# Execute the command +eval $command \ No newline at end of file diff --git a/automation_tools/pre_build_automation.sh b/automation_tools/pre_build_automation.sh index c05a9879..c935c81a 100755 --- a/automation_tools/pre_build_automation.sh +++ b/automation_tools/pre_build_automation.sh @@ -189,21 +189,22 @@ handle_thisrepo() { } # Process the task list -while IFS="^" read -r action placeholder url branch || [[ -n "$action" ]]; do - if [[ ! "$action" == "#"* ]] && [[ -n "$action" ]]; then - case "$action" in - "branch" ) handle_branch "$placeholder" ;; - "hash" ) handle_hash "$placeholder" "$url" ;; - "latestcommit" ) handle_latestcommit "$placeholder" "$url" "$branch" ;; - "latestghtag" ) handle_latestghtag "$placeholder" "$url" ;; - "latestghrelease" ) handle_latestghrelease "$placeholder" "$url" "$branch" ;; - "latestghreleasesha" ) handle_latestghreleasesha "$placeholder" "$url" "$branch" ;; - "outside_file" ) handle_outside_file "$placeholder" "$url" ;; - "outside_env_var" ) handle_outside_env_var "$placeholder" "$url" ;; - "custom_command" ) handle_custom_command "$url" ;; - "url" ) handle_url "$placeholder" "$url" ;; - "THISREPO" ) handle_thisrepo "$placeholder" ;; - esac - fi -done < "$automation_task_list" - +if [ "$use_cached" != "y" ]; then + while IFS="^" read -r action placeholder url branch || [[ -n "$action" ]]; do + if [[ ! "$action" == "#"* ]] && [[ -n "$action" ]]; then + case "$action" in + "branch" ) handle_branch "$placeholder" ;; + "hash" ) handle_hash "$placeholder" "$url" ;; + "latestcommit" ) handle_latestcommit "$placeholder" "$url" "$branch" ;; + "latestghtag" ) handle_latestghtag "$placeholder" "$url" ;; + "latestghrelease" ) handle_latestghrelease "$placeholder" "$url" "$branch" ;; + "latestghreleasesha" ) handle_latestghreleasesha "$placeholder" "$url" "$branch" ;; + "outside_file" ) handle_outside_file "$placeholder" "$url" ;; + "outside_env_var" ) handle_outside_env_var "$placeholder" "$url" ;; + "custom_command" ) handle_custom_command "$url" ;; + "url" ) handle_url "$placeholder" "$url" ;; + "THISREPO" ) handle_thisrepo "$placeholder" ;; + esac + fi + done < "$automation_task_list" +fi diff --git a/developer_toolbox/build_retrodeck_locally.sh b/developer_toolbox/build_retrodeck_locally.sh index cbd12fea..d132a9d5 100755 --- a/developer_toolbox/build_retrodeck_locally.sh +++ b/developer_toolbox/build_retrodeck_locally.sh @@ -4,8 +4,7 @@ # Check if script is running with elevated privileges if [ "$EUID" -ne 0 ]; then - echo "The build might fail without some superuser permissions, please run me with sudo. Continue without sudo? [y/N]" - read -r continue_without_sudo + read -rp "The build might fail without some superuser permissions, please run me with sudo. Continue without sudo? [y/N] " continue_without_sudo if [[ "$continue_without_sudo" != "y" ]]; then exit 1 fi @@ -18,9 +17,23 @@ export GITHUB_WORKSPACE="." # Initialize the Flatpak repo ostree init --mode=archive-z2 --repo=${GITHUB_WORKSPACE}/retrodeck-repo +# Backing up original manifest cp net.retrodeck.retrodeck.appdata.xml net.retrodeck.retrodeck.appdata.xml.bak cp net.retrodeck.retrodeck.yml net.retrodeck.retrodeck.yml.bak +if [[ -f "net.retrodeck.retrodeck.cached.yml" ]]; then + read -rp "A cached manifest file with placeholder substitutions already exists. Do you want to use it? [y/N] " use_cached + if [[ "${use_cached,,}" == "y" ]]; then + cp net.retrodeck.retrodeck.cached.yml net.retrodeck.retrodeck.yml + else + use_cached="n" + fi +else + use_cached="n" +fi + +export use_cached + automation_tools/install_dependencies.sh automation_tools/cooker_build_id.sh automation_tools/pre_build_automation.sh @@ -28,7 +41,7 @@ automation_tools/cooker_flatpak_portal_add.sh # THIS SCRIPT IS BROKEN HENCE DISABLED FTM # automation_tools/appdata_management.sh automation_tools/flatpak_build_download_only.sh -automation_tools/flatpak_build_only.sh +automation_tools/flatpak_build_only.sh "${@}" automation_tools/flatpak_build_bundle.sh rm -f net.retrodeck.retrodeck.appdata.xml