From ea7ca55cd26c959e692dae83b4bed894f0fb7683 Mon Sep 17 00:00:00 2001 From: Bruno Pajdek Date: Sun, 15 Dec 2024 17:55:10 +0000 Subject: [PATCH] Use mkosi.output for build artifacts mkosi already provides us with a nice default directory it puts artifacts in called `mkosi.output` if `--output-directory` isn't explicitly set. For some reason, it _is_ explicitly set to `.`, so it puts them in the source tree itself which pollutes it and gets messy real quick. After build, the contents of the source tree are now ``` drwxrwxrwx 1 root root 100 Dec 15 15:18 .git -rw-rw-rw- 1 root root 226 Dec 15 15:18 .gitignore -rw-rw-rw- 1 root root 1.1K Dec 15 15:18 .gitlab-ci.yml drwxrwxrwx 1 root root 370 Dec 15 15:18 LICENSES -rw-rw-rw- 1 root root 337 Dec 15 15:18 README.md -rw-rw-rw- 1 root root 128 Dec 15 15:18 REUSE.toml -rwxrwxrwx 1 root root 824 Dec 15 15:18 addons.sh -rwxrwxrwx 1 root root 1.7K Dec 15 15:18 bootstrap.sh -rwxrwxrwx 1 root root 6.1K Dec 15 15:18 build.sh -rwxrwxrwx 1 root root 2.9K Dec 15 15:18 build_docker.sh -rwxrwxrwx 1 root root 427 Dec 15 15:18 in_docker.sh drwxrwxrwx 1 root root 96 Dec 15 15:25 kde-linux.cache drwxrwxrwx 1 root root 20 Dec 15 15:18 mkosi.cache -rw-rw-rw- 1 root root 1.8K Dec 15 15:18 mkosi.conf drwxrwxrwx 1 root root 420 Dec 15 15:18 mkosi.conf.d drwxrwxrwx 1 root root 20 Dec 15 15:18 mkosi.extra -rwxrwxrwx 1 root root 3.6K Dec 15 15:18 mkosi.finalize.chroot drwxr-xr-x 1 root root 500 Dec 15 15:37 mkosi.output -rwxrwxrwx 1 root root 5.2K Dec 15 15:18 mkosi.postinst.chroot -rwxrwxrwx 1 root root 1.3K Dec 15 15:18 mkosi.prepare.chroot drwxrwxrwx 1 root root 46 Dec 15 15:18 mkosi.repart drwxrwxrwx 1 root root 6 Dec 15 15:18 mkosi.skeleton -rwxrwxrwx 1 root root 742 Dec 15 15:18 permission-fix.sh drwxrwxrwx 1 root root 30 Dec 15 15:18 strip -rwxrwxrwx 1 root root 1.4K Dec 15 15:18 torrent-create.rb -rwxrwxrwx 1 root root 796 Dec 15 15:18 update.sh drwxrwxrwx 1 root root 94 Dec 15 15:18 upload-vacuum -rwxrwxrwx 1 root root 1.6K Dec 15 15:18 upload.sh ``` And the contents of `mkosi.output` are ``` drwxr-xr-x 1 root root 206 Dec 15 15:28 kde-linux_202412151518 -rw-r--r-- 1 root root 173M Dec 15 15:25 kde-linux_202412151518.efi -rw-r--r-- 1 root root 5.2G Dec 15 15:36 kde-linux_202412151518.raw -rw------- 1 root root 55K Dec 15 15:37 kde-linux_202412151518.torrent -rw-r--r-- 1 root root 14M Dec 15 15:25 kde-linux_202412151518.vmlinuz -rw-r--r-- 1 root root 1.6G Dec 15 15:23 kde-linux_202412151518_debug-x86-64.tar.zst -rw-r--r-- 1 root root 173M Dec 15 15:24 kde-linux_202412151518_live.efi -rw-r--r-- 1 root root 3.0G Dec 15 15:36 kde-linux_202412151518_root-x86-64.tar.zst ``` --- .gitignore | 11 ++++------- build.sh | 12 ++++++------ upload.sh | 10 +++++----- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 90d02a4..2a899d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,8 @@ # SPDX-License-Identifier: CC0-1.0 # SPDX-FileCopyrightText: none + /image/ /version -/*.raw -/*.tar -/*.efi /pacman-cache/ /systemdOS_*/ /kde-builder/ @@ -13,7 +11,6 @@ /upload-vacuum/vendor/ mkosi.local.conf - -kde-linux_* -/mkosi.sandbox/etc/pacman.conf -/mkosi.sandbox/etc/pacman.d/mirrorlist +mkosi.output +mkosi.sandbox/etc/pacman.conf +mkosi.sandbox/etc/pacman.d/mirrorlist diff --git a/build.sh b/build.sh index 75ef33f..31873a8 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ set -ex VERSION=$(date +%Y%m%d%H%M) # Build version, will just be YYYYmmddHHMM for now -OUTPUT=kde-linux_$VERSION # Built rootfs path (mkosi uses this directory by default) +OUTPUT=mkosi.output/kde-linux_$VERSION # Built rootfs path (mkosi uses this directory by default) # Canonicalize the path in $OUTPUT to avoid any possible path issues. OUTPUT="$(readlink --canonicalize-missing "$OUTPUT")" @@ -24,7 +24,8 @@ IMG=${OUTPUT}.raw # Output raw image path EFI=kde-linux_${VERSION}+3.efi # Name of primary UKI in the image's ESP # Clean up old build artifacts. -rm --recursive --force kde-linux.cache/*.raw kde-linux.cache/*.mnt +rm --recursive --force mkosi.output kde-linux.cache/*.raw kde-linux.cache/*.mnt +mkdir mkosi.output export SYSTEMD_LOG_LEVEL=debug @@ -37,7 +38,6 @@ mkosi \ --environment="CI_PIPELINE_URL=${CI_PIPELINE_URL:-https://invent.kde.org}" \ --image-version="$VERSION" \ --package-cache-dir=/var/cache/mkosi.pacman \ - --output-directory=. \ "$@" # Create a directory structure for the UKIs. @@ -168,7 +168,7 @@ truncate --size=-$SHRINK_SIZE root.raw cd .. # Create rootfs tarball for consumption by systemd-sysext (doesn't currently support consuming raw images :() -rm -rf "$ROOTFS_TAR" ./*.tar +rm -rf "$ROOTFS_TAR" tar -C "${OUTPUT}"/ --xattrs --xattrs-include=*.* -cf "$ROOTFS_TAR" . zstd -T0 --rm "$ROOTFS_TAR" @@ -182,5 +182,5 @@ systemd-repart --no-pager --empty=allow --size=auto --dry-run=no --root=kde-linu # TODO before accepting new uploads perform sanity checks on the artifacts (e.g. the tar being well formed) # efi images and torrents are 700, make them readable so the server can serve them -chmod go+r "$OUTPUT".* ./*.efi ./*.torrent -ls -lah +chmod go+r "$OUTPUT" +ls -lah . mkosi.output diff --git a/upload.sh b/upload.sh index 6af9a94..de0f015 100755 --- a/upload.sh +++ b/upload.sh @@ -27,12 +27,12 @@ echo "origin.files.kde.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILUjdH4S7otYIdLUk # More readable this way, ignore shellcheck # shellcheck disable=SC2129 -sha256sum -- *.efi >> SHA256SUMS -sha256sum -- *.raw >> SHA256SUMS -sha256sum -- *.tar.zst >> SHA256SUMS -sha256sum -- *.torrent >> SHA256SUMS +sha256sum -- mkosi.output/*.efi >> SHA256SUMS +sha256sum -- mkosi.output/*.raw >> SHA256SUMS +sha256sum -- mkosi.output/*.tar.zst >> SHA256SUMS +sha256sum -- mkosi.output/*.torrent >> SHA256SUMS gpg --homedir="$GNUPGHOME" --output SHA256SUMS.gpg --detach-sign SHA256SUMS -scp -i "$SSH_IDENTITY" ./*.efi ./*.raw ./*.tar.zst ./*.torrent "$REMOTE" +scp -i "$SSH_IDENTITY" mkosi.output/*.efi mkosi.output/*.raw mkosi.output/*.tar.zst mkosi.output/*.torrent "$REMOTE" scp -i "$SSH_IDENTITY" SHA256SUMS SHA256SUMS.gpg "$REMOTE" # upload as last artifact to finalize the upload