aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--justfile137
-rwxr-xr-xscripts/build_appimage.sh35
-rwxr-xr-xscripts/build_arch.sh31
-rwxr-xr-xscripts/build_deb.sh29
-rwxr-xr-xscripts/build_rpm.sh34
6 files changed, 114 insertions, 161 deletions
diff --git a/README.md b/README.md
index 3296de2..7daaa1d 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,15 @@ Run `just test`
`meson.build` is the source of truth for the version. To sync versions to
Cargo.toml, rpm spec, etc. use `just sync-versions`
+The convention in this project is to use directories starting with `_` for
+generated ones to distinguish them from the source more easily. They are all
+configurable via the justfile. The defaults are:
+
+- `_build`: The meson build directory.
+- `_dist`: The location where built distributable packages are placed.
+- `_repo`: The flatpak repo
+- `_flatpak`: The flatpak build directory
+
## Distributing
Available package formats: deb, rpm, tar.gz, flatpak.
diff --git a/justfile b/justfile
index 1bcd0e3..4ef4b5b 100644
--- a/justfile
+++ b/justfile
@@ -11,6 +11,7 @@ clean_images := ""
# Derived Values ---------------------------------------------------------------
architecture := arch()
+version := `grep -m1 -o "[^_]version: '[^']*'" meson.build | awk -F"'" '{print $2}'`
filename := f"{{app_name}}-{{architecture}}-{{channel}}"
# Packaging --------------------------------------------------------------------
@@ -87,7 +88,7 @@ update_flatpak_dependencies:
cd {{flatpak_cargo_generator}} && `poetry env activate` && python3 flatpak-cargo-generator.py {{justfile_directory()}}/Cargo.lock -o {{justfile_directory()}}/build-aux/flatpak/cargo-sources.json && deactivate
# Builds a flatpak and exports the .flatpak file
-package-flatpak: _ensure_distdir update_flatpak_dependencies
+package-flatpak: _ensure-distdir update_flatpak_dependencies
flatpak-builder --force-clean --user --install-deps-from=flathub --repo={{repodir}} --install {{flatpakdir}} ./build-aux/flatpak/systems.tranquil.Map.yml
flatpak build-bundle {{repodir}} {{distdir}}/{{filename}}.flatpak systems.tranquil.Map
@@ -97,24 +98,95 @@ _fetch-linuxdeploy:
@chmod +x {{linuxdeploy}}
# Builds an AppImage
-package-appimage: _ensure_distdir (build-container appimage_container) _fetch-linuxdeploy && (_clean_image appimage_container)
- @echo "=== Building AppImage ==="
- ./scripts/build_appimage.sh {{container_image_prefix}} trixie {{app_name}} {{architecture}} {{channel}} {{linuxdeploy}}
+package-appimage: _ensure-distdir (build-container appimage_container) _fetch-linuxdeploy && (_clean-image appimage_container)
+ #!/usr/bin/env bash
+ echo "=== Building AppImage ==="
+ staging="$(mktemp -d)"
+
+ tar -xJf "{{builddir}}/meson-dist/map-{{version}}.tar.xz" -C "${staging}/"
+ cp {{linuxdeploy}} "${staging}/linuxdeploy.AppImage"
+
+ just _run-in-podman "${staging}" {{appimage_container}} "
+ cd /build/map-{{version}}
+ meson setup --prefix=/usr {{builddir}}
+ meson compile -C {{builddir}}
+ DESTDIR=/build/appdir meson install -C {{builddir}}
+ cd /build
+ APPIMAGE_EXTRACT_AND_RUN=1 NO_STRIP=true /build/linuxdeploy.AppImage \
+ --appdir=/build/appdir --output=appimage \
+ --desktop-file=/build/appdir/usr/share/applications/systems.tranquil.Map.desktop \
+ --icon-file=/build/appdir/usr/share/icons/hicolor/scalable/apps/systems.tranquil.Map.svg
+ mkdir -p /build/out
+ mv /build/Map*.AppImage /build/out/
+ "
+ mv "${staging}/out/"*.AppImage "{{distdir}}/{{app_name}}-{{architecture}}-{{channel}}.AppImage"
+ rm -rf "${staging}"
# Builds an arch .pkg.tar.gz
-package-arch: _ensure_distdir (build-container "arch") dist && (_clean_image "arch")
- @echo "=== Building Arch package ({{architecture}}) ==="
- ./scripts/build_arch.sh {{container_image_prefix}} arch {{app_name}} {{architecture}} {{channel}}
+package-arch: _ensure-distdir (build-container "arch") dist && (_clean-image "arch")
+ #!/usr/bin/env bash
+ echo "=== Building Arch package ({{architecture}}) ==="
+ staging="$(mktemp -d)"
+
+ cp {{builddir}}/meson-dist/map-{{version}}.tar.xz "${staging}/"
+ cp build-aux/arch/PKGBUILD "${staging}/"
+
+ just _run-in-podman "${staging}" arch "
+ mkdir -p /tmp/pkg
+ cp /build/*.tar.xz /tmp/pkg
+ cp /build/PKGBUILD /tmp/pkg
+ chown -R builder:builder /tmp/pkg
+ su builder -c 'cd /tmp/pkg && PKGEXT=.pkg.tar.gz makepkg -f'
+ mkdir -p /build/out
+ cp /tmp/pkg/map-{{version}}-1-{{architecture}}.pkg.tar.gz /build/out/
+ "
+ cp "${staging}/out/"*.pkg.tar.gz "{{distdir}}/{{app_name}}-{{architecture}}-{{channel}}-arch.pkg.tar.gz"
+ rm -rf "${staging}"
# Build .rpm for the given distro
-package-rpm distro: _ensure_distdir (build-container distro) dist && (_clean_image distro)
- @echo "=== Building RPM for {{distro}} ({{architecture}}) ==="
- ./scripts/build_rpm.sh {{container_image_prefix}} {{distro}} {{app_name}} {{architecture}} {{channel}}
+package-rpm distro: _ensure-distdir (build-container distro) dist && (_clean-image distro)
+ #!/usr/bin/env bash
+ echo "=== Building RPM for {{distro}} ({{architecture}}) ==="
+ staging="$(mktemp -d)"
+
+ cp {{builddir}}/meson-dist/map-{{version}}.tar.xz "${staging}/"
+
+ just vendor "${staging}/vendor"
+ tar -cJf "${staging}/map-{{version}}-vendor.tar.xz" -C "${staging}" vendor
+ rm -rf "${staging}/vendor"
+
+ cp build-aux/rpm/map.spec "${staging}/"
+
+ just _run-in-podman "${staging}" {{distro}} "
+ mkdir -p ~/rpmbuild/{SOURCES,SPECS}
+ cp /build/map-*.tar.xz ~/rpmbuild/SOURCES/
+ cp /build/map.spec ~/rpmbuild/SPECS/
+ rpmbuild -bb ~/rpmbuild/SPECS/map.spec
+ mkdir -p /build/out
+ cp ~/rpmbuild/RPMS/{{architecture}}/map-{{version}}-1.*.rpm /build/out/
+ "
+ cp "${staging}/out/"*.rpm "{{distdir}}/{{app_name}}-{{architecture}}-{{channel}}-{{distro}}.rpm"
+ rm -rf "${staging}"
# Build .deb for the given distro
-package-deb distro: _ensure_distdir (build-container distro) dist && (_clean_image distro)
- @echo "=== Building DEB for {{distro}} ({{architecture}}) ==="
- ./scripts/build_deb.sh {{container_image_prefix}} {{distro}} {{app_name}} {{architecture}} {{channel}}
+package-deb distro: _ensure-distdir (build-container distro) dist && (_clean-image distro)
+ #!/usr/bin/env bash
+ echo "=== Building DEB for {{distro}} ({{architecture}}) ==="
+ staging="$(mktemp -d)"
+
+ cp {{builddir}}/meson-dist/map-{{version}}.tar.xz "${staging}/{{app_name}}_{{version}}.orig.tar.xz"
+ tar -xJf "${staging}/{{app_name}}_{{version}}.orig.tar.xz" -C "${staging}"
+ mkdir -p "${staging}/{{app_name}}-{{version}}"
+ cp -r build-aux/debian "${staging}/{{app_name}}-{{version}}/debian"
+
+ just _run-in-podman "${staging}" {{distro}} "
+ cd /build/{{app_name}}-{{version}}
+ dpkg-buildpackage -us -uc -b
+ mkdir -p /build/out
+ cp /build/{{app_name}}_{{version}}*_*.deb /build/out/
+ "
+ cp "${staging}/out/"*.deb "{{distdir}}/{{app_name}}-{{architecture}}-{{channel}}-{{distro}}.deb"
+ rm -rf "${staging}"
# Build .rpm for every supported distro
package-rpm-all:
@@ -130,13 +202,13 @@ package: package-flatpak package-appimage package-arch package-rpm-all package-d
# Distribution #################################################################
# Sign and upload flatpak
-distribute-flatpak: (_sign_and_upload f"{{distdir}}/{{filename}}.flatpak")
+distribute-flatpak: (_sign-and-upload f"{{distdir}}/{{filename}}.flatpak")
# Sign and upload AppImage
-distribute-appimage: (_sign_and_upload f"{{distdir}}/{{filename}}.AppImage")
+distribute-appimage: (_sign-and-upload f"{{distdir}}/{{filename}}.AppImage")
# Sign and upload arch .pkg.tar.gz
-distribute-arch: (_sign_and_upload f"{{distdir}}/{{filename}}-arch.pkg.tar.gz")
+distribute-arch: (_sign-and-upload f"{{distdir}}/{{filename}}-arch.pkg.tar.gz")
# Sign and upload .rpm files
distribute-rpm:
@@ -149,9 +221,9 @@ distribute-deb:
# Sign and upload all distributable packages
distribute: distribute-flatpak distribute-appimage distribute-arch distribute-rpm distribute-deb
-_distribute-rpm distro: (_sign_and_upload f"{{distdir}}/{{filename}}-{{distro}}.rpm")
+_distribute-rpm distro: (_sign-and-upload f"{{distdir}}/{{filename}}-{{distro}}.rpm")
-_distribute-deb distro: (_sign_and_upload f"{{distdir}}/{{filename}}-{{distro}}.deb")
+_distribute-deb distro: (_sign-and-upload f"{{distdir}}/{{filename}}-{{distro}}.deb")
# Release ######################################################################
@@ -163,9 +235,9 @@ release: package distribute
# Intended to run in CI. Lints and releases.
ci: lint
#!/usr/bin/env bash
- if [[ "$GIT_REF" == "refs/heads/main"]]; then
+ if [[ "$GIT_REF" == "refs/heads/main" ]]; then
just release
- elif [[ "$GIT_REF" == "refs/tags/*" ]]; then
+ elif [[ "$GIT_REF" == refs/tags/* ]]; then
just channel="${GIT_REF#refs/tags/}" release
else
echo "Not in CI environment."
@@ -182,10 +254,6 @@ uninstall:
# Utility Tasks ################################################################
-# Print the Version
-version:
- @grep -m1 -o "[^_]version: '[^']*'" meson.build | awk -F"'" '{print $2}'
-
# Vendor the rust dependencies
vendor location:
cargo vendor {{location}} >/dev/null
@@ -194,32 +262,31 @@ vendor location:
# Syncs versions of different files to the meson.build
sync-versions:
#!/usr/bin/env bash
- version=`just version`
- echo "Using version from meson.build: ${version}"
+ echo "Using version from meson.build: {{version}}"
# Rust Cargo.toml
echo -ne "\tUpdating: Cargo.toml"
- sed -i "s/^version = \"[^\"]*\"$/version = \"$version\"/" Cargo.toml
+ sed -i "s/^version = \"[^\"]*\"$/version = \"{{version}}\"/" Cargo.toml
echo -e "\r\tUpdated: Cargo.toml "
# Arch PKGBUILD
echo -ne "\tUpdating: PKGBUILD"
- sed -i "s/^pkgver=.*$/pkgver=$version/" build-aux/arch/PKGBUILD
+ sed -i "s/^pkgver=.*$/pkgver={{version}}/" build-aux/arch/PKGBUILD
echo -e "\r\tUpdated: PKGBUILD "
# Fedora RPM Spec
echo -ne "\tUpdating: map.spec"
- sed -i "s/^Version: .*$/Version: $version/" build-aux/rpm/map.spec
+ sed -i "s/^Version: .*$/Version: {{version}}/" build-aux/rpm/map.spec
echo -e "\r\tUpdated: map.spec "
# Internal Tasks ###############################################################
# Cleans images if the flag is set (eg. for low-storage environments)
-_clean_image image:
+_clean-image image:
{{ if clean_images != "" { f"podman rmi {{container_image_prefix}}:{{image}}" } else { "" } }}
# Ensures distdir exists
-_ensure_distdir:
+_ensure-distdir:
@mkdir -p {{distdir}}
# Signs a file
@@ -238,4 +305,10 @@ _upload file:
rsync -avz {{file}} $DISTRIBUTION_HOST:$DISTRIBUTION_PATH
# Sign and upload a file.
-_sign_and_upload file: (_sign file channel architecture) (_upload file)
+_sign-and-upload file: (_sign file channel architecture) (_upload file)
+
+# Generic Podman Runner: Run a build script inside a container
+_run-in-podman staging tag commands:
+ podman run --rm -v "{{staging}}:/build:Z" \
+ {{container_image_prefix}}:{{tag}} \
+ bash -c "{{commands}}"
diff --git a/scripts/build_appimage.sh b/scripts/build_appimage.sh
deleted file mode 100755
index b409961..0000000
--- a/scripts/build_appimage.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-container_image_prefix=$1
-distro=$2
-app_name=$3
-arch=$4
-channel=$5
-linuxdeploy=$6
-
-version=`just version`
-staging="$(mktemp -d)"
-
-tar -xJf "_build/meson-dist/map-${version}.tar.xz" -C "${staging}/"
-cp ${linuxdeploy} "${staging}/linuxdeploy.AppImage"
-
-podman run --rm -v "${staging}:/build:Z" \
- ${container_image_prefix}:${distro} \
- bash -c "
- cd /build/map-${version}
- meson setup --prefix=/usr _build
- meson compile -C _build
- DESTDIR=/build/appdir meson install -C _build
- cd /build
- APPIMAGE_EXTRACT_AND_RUN=1 NO_STRIP=true /build/linuxdeploy.AppImage \
- --appdir=/build/appdir --output=appimage \
- --desktop-file=/build/appdir/usr/share/applications/systems.tranquil.Map.desktop \
- --icon-file=/build/appdir/usr/share/icons/hicolor/scalable/apps/systems.tranquil.Map.svg
- mkdir -p /build/out
- mv /build/Map*.AppImage /build/out/
- "
-
-mv ${staging}/out/*.AppImage "_dist/${app_name}-${arch}-${channel}.AppImage"
-rm -rf "${staging}"
diff --git a/scripts/build_arch.sh b/scripts/build_arch.sh
deleted file mode 100755
index c4a3c0c..0000000
--- a/scripts/build_arch.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-container_image_prefix=$1
-distro=$2
-app_name=$3
-arch=$4
-channel=$5
-
-version=`just version`
-staging="$(mktemp -d)"
-
-cp _build/meson-dist/map-${version}.tar.xz "${staging}/"
-
-cp build-aux/arch/PKGBUILD "${staging}/"
-
-podman run --rm -v "${staging}:/build:Z" \
- ${container_image_prefix}:${distro} \
- bash -c "
- mkdir -p /tmp/pkg
- cp /build/*.tar.xz /tmp/pkg
- cp /build/PKGBUILD /tmp/pkg
- chown -R builder:builder /tmp/pkg
- su builder -c 'cd /tmp/pkg && PKGEXT=.pkg.tar.gz makepkg -f'
- mkdir -p /build/out
- cp /tmp/pkg/map-${version}-1-${arch}.pkg.tar.gz /build/out/
- "
-
-cp ${staging}/out/*.pkg.tar.gz "_dist/${app_name}-${arch}-${channel}-${distro}.pkg.tar.gz"
-rm -rf "${staging}"
diff --git a/scripts/build_deb.sh b/scripts/build_deb.sh
deleted file mode 100755
index d7f978b..0000000
--- a/scripts/build_deb.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-container_image_prefix=$1
-distro=$2
-app_name=$3
-arch=$4
-channel=$5
-
-version=`just version`
-staging="$(mktemp -d)"
-
-cp _build/meson-dist/map-${version}.tar.xz "${staging}/${app_name}_${version}.orig.tar.xz"
-tar -xJf "${staging}/${app_name}_${version}.orig.tar.xz" -C "${staging}"
-mkdir -p ${staging}/${app_name}-${version}
-cp -r build-aux/debian "${staging}/${app_name}-${version}/debian"
-
-podman run --rm -v "${staging}:/build:Z" \
- ${container_image_prefix}:${distro} \
- bash -c "
- cd /build/${app_name}-${version}
- dpkg-buildpackage -us -uc -b
- mkdir -p /build/out
- cp /build/${app_name}_${version}*_*.deb /build/out/
- "
-
-cp ${staging}/out/*.deb "_dist/${app_name}-${arch}-${channel}-${distro}.deb"
-rm -rf "${staging}"
diff --git a/scripts/build_rpm.sh b/scripts/build_rpm.sh
deleted file mode 100755
index ac2510d..0000000
--- a/scripts/build_rpm.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-container_image_prefix=$1
-distro=$2
-app_name=$3
-arch=$4
-channel=$5
-
-version=`just version`
-staging="$(mktemp -d)"
-
-cp _build/meson-dist/map-${version}.tar.xz "${staging}/"
-
-just vendor "${staging}/vendor"
-tar -cJf "${staging}/map-${version}-vendor.tar.xz" -C "${staging}" vendor
-rm -rf "${staging}/vendor"
-
-cp build-aux/rpm/map.spec "${staging}/"
-
-podman run --rm -v "${staging}:/build:Z" \
- ${container_image_prefix}:${distro} \
- bash -c "
- mkdir -p ~/rpmbuild/{SOURCES,SPECS}
- cp /build/map-*.tar.xz ~/rpmbuild/SOURCES/
- cp /build/map.spec ~/rpmbuild/SPECS/
- rpmbuild -bb ~/rpmbuild/SPECS/map.spec
- mkdir -p /build/out
- cp ~/rpmbuild/RPMS/${arch}/map-${version}-1.*.rpm /build/out/
- "
-
-cp ${staging}/out/*.rpm "_dist/${app_name}-${arch}-${channel}-${distro}.rpm"
-rm -rf "${staging}"