From 2576366fefabbbae88ef7390bdd7d275932f3ffd Mon Sep 17 00:00:00 2001 From: Ada Phillips Date: Mon, 5 Feb 2024 13:48:49 -0500 Subject: [PATCH 1/8] Config Changes: Move config files instead of copying Switch to `mv` for config files into appropriate locations, and delete the prometheus_config folder when finished to avoid user confusion regarding duplicate files --- src/modules/prometheus_config/start_chroot_script | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/prometheus_config/start_chroot_script b/src/modules/prometheus_config/start_chroot_script index ca2bff1..6bf2d28 100644 --- a/src/modules/prometheus_config/start_chroot_script +++ b/src/modules/prometheus_config/start_chroot_script @@ -23,14 +23,16 @@ for dir in ${PROMETHEUS_CONFIG_DIRS}; do sudo -u "${BASE_USER}" mkdir -p "${dir}" done -sudo -u "${BASE_USER}" cp prometheus_config/klipper/.config klipper/ -sudo -u "${BASE_USER}" cp prometheus_config/klipper/config/* printer_data/config/ +sudo -u "${BASE_USER}" mv prometheus_config/klipper/.config klipper/ +sudo -u "${BASE_USER}" mv prometheus_config/klipper/config/* printer_data/config/ # Only copy nanodlp files if neccessary if [[ $MODULES == *"nanodlp"* ]]; then - sudo -u "${BASE_USER}" cp prometheus_config/nanodlp/* nanodlp/db/ + sudo -u "${BASE_USER}" mv prometheus_config/nanodlp/* nanodlp/db/ fi +sudo -u "${BASE_USER}" rm -rf prometheus_config + # if Odyssey is included in this build, then include the relevant klipper config # at the head of printer.cfg if [[ $MODULES == *"odyssey"* ]]; then From e3dd1916a7ab520d2ceaa2b30216f4ef4e9fd459 Mon Sep 17 00:00:00 2001 From: Ada Phillips Date: Wed, 13 Mar 2024 16:42:32 -0400 Subject: [PATCH 2/8] Remove unnecessary files from github runner --- .github/workflows/build_variant.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build_variant.yml b/.github/workflows/build_variant.yml index bb4964d..5483cb4 100644 --- a/.github/workflows/build_variant.yml +++ b/.github/workflows/build_variant.yml @@ -9,6 +9,12 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: Install Dependencies run: | sudo apt update From 3d6134f618d0b9df1f291da8679a292351076053 Mon Sep 17 00:00:00 2001 From: Ada Phillips Date: Wed, 13 Mar 2024 17:52:48 -0400 Subject: [PATCH 3/8] Base Image: Refactor build processes to rely on an initial base image Update base image config Modify variant configs to only install modules which differ from base image Modify github workflows to run the base image creation first, then re-use that artifact for the following variant image workflows --- .github/workflows/build.yml | 6 +++ .github/workflows/build_base.yml | 67 +++++++++++++++++++++++++++++ .github/workflows/build_variant.yml | 15 ++++--- src/config | 2 +- src/variants/nanodlp-based/config | 2 +- src/variants/odyssey-based/config | 2 +- 6 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/build_base.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed93ffc..df85ae0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,12 +6,18 @@ on: - cron: '0 0 * * *' jobs: + build_base: + uses: ./.github/workflows/build_base.yml build_nanodlp: + needs: build_base uses: ./.github/workflows/build_variant.yml with: variant: nanodlp-based + image_name: ${{ needs.build_base.outputs.image_name }} build_odyssey: + needs: build_base uses: ./.github/workflows/build_variant.yml with: variant: odyssey-based + image_name: ${{ needs.build_base.outputs.image_name }} diff --git a/.github/workflows/build_base.yml b/.github/workflows/build_base.yml new file mode 100644 index 0000000..a4430e1 --- /dev/null +++ b/.github/workflows/build_base.yml @@ -0,0 +1,67 @@ +on: + workflow_call: + outputs: + image_name: + description: "The filename of the uploaded base image" + value: ${{ jobs.build.outputs.image_name }} + +jobs: + build: + runs-on: ubuntu-latest + outputs: + image_name: ${{ steps.artifact.outputs.image }} + steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - name: Install Dependencies + run: | + sudo apt update + sudo apt install coreutils p7zip-full qemu-user-static + - name: Checkout CustomPiOS + uses: actions/checkout@v4 + with: + repository: 'guysoft/CustomPiOS' + path: CustomPiOS + ref: '70f1ae537a02195f1ba4f0a51ed381628e575c66' + + - name: Checkout Project Repository + uses: actions/checkout@v4 + with: + path: repository + submodules: true + + - name: Download Raspbian Image + run: | + cd repository/src/image + wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest' + - name: Update CustomPiOS Paths + run: | + cd repository/src + ../../CustomPiOS/src/update-custompios-paths + + - name: Build Image + id: build + run: | + sudo modprobe loop + cd repository/src + sudo bash -x ./build_dist + + - name: Prepare artifact + id: artifact + run: | + source repository/src/config + NOW=$(date +"%Y-%m-%d-%H%M") + IMAGE=$NOW-prometheusos-BASE-$DIST_VERSION + cp repository/src/workspace/*.img $IMAGE.img + tar -czvf $IMAGE.tar.gz $IMAGE.img + echo "image=$IMAGE" >> $GITHUB_OUTPUT + echo "dist_version=$DIST_VERSION" >> $GITHUB_OUTPUT + + - uses: actions/upload-artifact@v4 + with: + name: ${{ steps.artifact.outputs.image }} + path: ${{ steps.artifact.outputs.image }}.img diff --git a/.github/workflows/build_variant.yml b/.github/workflows/build_variant.yml index 5483cb4..d4e6c99 100644 --- a/.github/workflows/build_variant.yml +++ b/.github/workflows/build_variant.yml @@ -4,6 +4,9 @@ on: variant: required: true type: string + image_name: + required: true + type: string jobs: build: @@ -27,15 +30,17 @@ jobs: ref: '70f1ae537a02195f1ba4f0a51ed381628e575c66' - name: Checkout Project Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: repository submodules: true - - name: Download Raspbian Image - run: | - cd repository/src/image - wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest' + - name: Download base image + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.image_name }} + path: repository/src/image + - name: Update CustomPiOS Paths run: | cd repository/src diff --git a/src/config b/src/config index 4d8226e..07779ce 100644 --- a/src/config +++ b/src/config @@ -16,7 +16,7 @@ export BASE_RELEASE_IMAGE_NAME="PrometheusOS" # Prometheus Settings export KLIPPER_REPO_SHIP="https://github.com/TheContrappostoShop/klipper.git" -export MODULES="base(pkgupgrade,network,klipper,nanodlp,odyssey,prometheus_config,openocd)" +export MODULES="base(pkgupgrade,network,auto-mount-removable,klipper,prometheus_config,openocd,user_rename)" # Prevent known wifi issues export NETWORK_DISABLE_PWRSAVE=no diff --git a/src/variants/nanodlp-based/config b/src/variants/nanodlp-based/config index b5fca96..c4b6a8c 100644 --- a/src/variants/nanodlp-based/config +++ b/src/variants/nanodlp-based/config @@ -1 +1 @@ -export MODULES="base(pkgupgrade,network,klipper,nanodlp,prometheus_config,openocd,user_rename)" \ No newline at end of file +export MODULES="base(nanodlp)" \ No newline at end of file diff --git a/src/variants/odyssey-based/config b/src/variants/odyssey-based/config index c52d568..97ec963 100644 --- a/src/variants/odyssey-based/config +++ b/src/variants/odyssey-based/config @@ -1 +1 @@ -export MODULES="base(pkgupgrade,network,auto-mount-removable,klipper,moonraker,mainsail,odyssey,prometheus_config,openocd,user_rename)" \ No newline at end of file +export MODULES="base(moonraker,mainsail,odyssey)" \ No newline at end of file From 48250f9cad14d88936b1fc6ecac7c0ce72a2a9ac Mon Sep 17 00:00:00 2001 From: Ada Phillips Date: Wed, 13 Mar 2024 18:30:01 -0400 Subject: [PATCH 4/8] Upload compressed base image --- .github/workflows/build_base.yml | 4 ++-- .github/workflows/build_variant.yml | 6 +++--- src/variants/nanodlp-based/config | 3 ++- src/variants/odyssey-based/config | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_base.yml b/.github/workflows/build_base.yml index a4430e1..b9b2da9 100644 --- a/.github/workflows/build_base.yml +++ b/.github/workflows/build_base.yml @@ -57,11 +57,11 @@ jobs: NOW=$(date +"%Y-%m-%d-%H%M") IMAGE=$NOW-prometheusos-BASE-$DIST_VERSION cp repository/src/workspace/*.img $IMAGE.img - tar -czvf $IMAGE.tar.gz $IMAGE.img + tar -cJf $IMAGE.xz $IMAGE.img echo "image=$IMAGE" >> $GITHUB_OUTPUT echo "dist_version=$DIST_VERSION" >> $GITHUB_OUTPUT - uses: actions/upload-artifact@v4 with: name: ${{ steps.artifact.outputs.image }} - path: ${{ steps.artifact.outputs.image }}.img + path: ${{ steps.artifact.outputs.image }}.xz diff --git a/.github/workflows/build_variant.yml b/.github/workflows/build_variant.yml index d4e6c99..d8b1271 100644 --- a/.github/workflows/build_variant.yml +++ b/.github/workflows/build_variant.yml @@ -38,7 +38,7 @@ jobs: - name: Download base image uses: actions/download-artifact@v4 with: - name: ${{ inputs.image_name }} + name: ${{ inputs.image_name }}.xz path: repository/src/image - name: Update CustomPiOS Paths @@ -60,7 +60,7 @@ jobs: NOW=$(date +"%Y-%m-%d-%H%M") IMAGE=$NOW-prometheusos-${{ inputs.variant }}-$DIST_VERSION cp repository/src/workspace-${{ inputs.variant }}/*.img $IMAGE.img - tar -czvf $IMAGE.tar.gz $IMAGE.img + tar -cJf $IMAGE.xz $IMAGE.img echo "image=$IMAGE" >> $GITHUB_OUTPUT echo "dist_version=$DIST_VERSION" >> $GITHUB_OUTPUT @@ -73,7 +73,7 @@ jobs: uses: ncipollo/release-action@v1 if: github.ref == 'refs/heads/main' with: - artifacts: ${{ steps.compress.outputs.image }}.tar.gz + artifacts: ${{ steps.compress.outputs.image }}.xz tag: v${{ steps.compress.outputs.dist_version }} skipIfReleaseExists: true omitBodyDuringUpdate: true diff --git a/src/variants/nanodlp-based/config b/src/variants/nanodlp-based/config index c4b6a8c..27229e7 100644 --- a/src/variants/nanodlp-based/config +++ b/src/variants/nanodlp-based/config @@ -1 +1,2 @@ -export MODULES="base(nanodlp)" \ No newline at end of file +export MODULES="base(nanodlp)" +export BASE_ZIP_IMG="image/*.xz" \ No newline at end of file diff --git a/src/variants/odyssey-based/config b/src/variants/odyssey-based/config index 97ec963..0c69165 100644 --- a/src/variants/odyssey-based/config +++ b/src/variants/odyssey-based/config @@ -1 +1,2 @@ -export MODULES="base(moonraker,mainsail,odyssey)" \ No newline at end of file +export MODULES="base(moonraker,mainsail,odyssey)" +export BASE_ZIP_IMG="image/*.xz" \ No newline at end of file From fdcde5979315d38ddc97f2b1cd6a1835162bf436 Mon Sep 17 00:00:00 2001 From: Ada Phillips Date: Wed, 13 Mar 2024 19:17:38 -0400 Subject: [PATCH 5/8] Remove unnecessary file extension from artifact name --- .github/workflows/build_variant.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_variant.yml b/.github/workflows/build_variant.yml index d8b1271..a185a39 100644 --- a/.github/workflows/build_variant.yml +++ b/.github/workflows/build_variant.yml @@ -38,7 +38,7 @@ jobs: - name: Download base image uses: actions/download-artifact@v4 with: - name: ${{ inputs.image_name }}.xz + name: ${{ inputs.image_name }} path: repository/src/image - name: Update CustomPiOS Paths From 106f40e11988bc355653a47758f441c59ec78d48 Mon Sep 17 00:00:00 2001 From: Ada Phillips Date: Wed, 13 Mar 2024 23:08:51 -0400 Subject: [PATCH 6/8] Fix img path spec --- src/variants/nanodlp-based/config | 2 +- src/variants/odyssey-based/config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/variants/nanodlp-based/config b/src/variants/nanodlp-based/config index 27229e7..c269870 100644 --- a/src/variants/nanodlp-based/config +++ b/src/variants/nanodlp-based/config @@ -1,2 +1,2 @@ export MODULES="base(nanodlp)" -export BASE_ZIP_IMG="image/*.xz" \ No newline at end of file +export BASE_ZIP_IMG=$(ls -t image/*.xz | head -n 1) \ No newline at end of file diff --git a/src/variants/odyssey-based/config b/src/variants/odyssey-based/config index 0c69165..2887994 100644 --- a/src/variants/odyssey-based/config +++ b/src/variants/odyssey-based/config @@ -1,2 +1,2 @@ export MODULES="base(moonraker,mainsail,odyssey)" -export BASE_ZIP_IMG="image/*.xz" \ No newline at end of file +export BASE_ZIP_IMG=$(ls -t image/*.xz | head -n 1) \ No newline at end of file From c345d6e92fad59af9be6aa2d42ab40324415e691 Mon Sep 17 00:00:00 2001 From: Ada Phillips Date: Thu, 14 Mar 2024 00:01:26 -0400 Subject: [PATCH 7/8] Fix img path spec again --- src/variants/nanodlp-based/config | 2 +- src/variants/odyssey-based/config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/variants/nanodlp-based/config b/src/variants/nanodlp-based/config index c269870..42d6c51 100644 --- a/src/variants/nanodlp-based/config +++ b/src/variants/nanodlp-based/config @@ -1,2 +1,2 @@ export MODULES="base(nanodlp)" -export BASE_ZIP_IMG=$(ls -t image/*.xz | head -n 1) \ No newline at end of file +export BASE_ZIP_IMG=$(ls -t ${DIST_PATH}/image/*.xz | head -n 1) \ No newline at end of file diff --git a/src/variants/odyssey-based/config b/src/variants/odyssey-based/config index 2887994..55ed7b0 100644 --- a/src/variants/odyssey-based/config +++ b/src/variants/odyssey-based/config @@ -1,2 +1,2 @@ export MODULES="base(moonraker,mainsail,odyssey)" -export BASE_ZIP_IMG=$(ls -t image/*.xz | head -n 1) \ No newline at end of file +export BASE_ZIP_IMG=$(ls -t ${DIST_PATH}/image/*.xz | head -n 1) \ No newline at end of file From a8918d2a023861cc9fa083dda618c2b37bcb37bc Mon Sep 17 00:00:00 2001 From: Ada Phillips Date: Thu, 14 Mar 2024 00:07:08 -0400 Subject: [PATCH 8/8] Fix .img.xz extensions --- .github/workflows/build_base.yml | 4 ++-- .github/workflows/build_variant.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_base.yml b/.github/workflows/build_base.yml index b9b2da9..73ea529 100644 --- a/.github/workflows/build_base.yml +++ b/.github/workflows/build_base.yml @@ -57,11 +57,11 @@ jobs: NOW=$(date +"%Y-%m-%d-%H%M") IMAGE=$NOW-prometheusos-BASE-$DIST_VERSION cp repository/src/workspace/*.img $IMAGE.img - tar -cJf $IMAGE.xz $IMAGE.img + tar -cJf $IMAGE.img.xz $IMAGE.img echo "image=$IMAGE" >> $GITHUB_OUTPUT echo "dist_version=$DIST_VERSION" >> $GITHUB_OUTPUT - uses: actions/upload-artifact@v4 with: name: ${{ steps.artifact.outputs.image }} - path: ${{ steps.artifact.outputs.image }}.xz + path: ${{ steps.artifact.outputs.image }}.img.xz diff --git a/.github/workflows/build_variant.yml b/.github/workflows/build_variant.yml index a185a39..c40da2a 100644 --- a/.github/workflows/build_variant.yml +++ b/.github/workflows/build_variant.yml @@ -60,7 +60,7 @@ jobs: NOW=$(date +"%Y-%m-%d-%H%M") IMAGE=$NOW-prometheusos-${{ inputs.variant }}-$DIST_VERSION cp repository/src/workspace-${{ inputs.variant }}/*.img $IMAGE.img - tar -cJf $IMAGE.xz $IMAGE.img + tar -cJf $IMAGE.img.xz $IMAGE.img echo "image=$IMAGE" >> $GITHUB_OUTPUT echo "dist_version=$DIST_VERSION" >> $GITHUB_OUTPUT @@ -73,7 +73,7 @@ jobs: uses: ncipollo/release-action@v1 if: github.ref == 'refs/heads/main' with: - artifacts: ${{ steps.compress.outputs.image }}.xz + artifacts: ${{ steps.compress.outputs.image }}.img.xz tag: v${{ steps.compress.outputs.dist_version }} skipIfReleaseExists: true omitBodyDuringUpdate: true