blob: b694d2cb4fa3e6a99cb937c4d952021c2d234e34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
# Configuration ################################################################
app_name := "map"
channel := "unstable"
builddir := "_build"
distdir := "_dist"
clean_images := ""
# Derived Values ---------------------------------------------------------------
architecture := arch()
filename := f"{{app_name}}-{{architecture}}-{{channel}}"
# Packaging --------------------------------------------------------------------
linuxdeploy_url := "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-" + `uname -m` + ".AppImage"
linuxdeploy := ".cache/linuxdeploy.AppImage"
flatpak_cargo_generator := home_directory() / "projects/vendor/flatpak-builder-tools/cargo"
# Build Containers -------------------------------------------------------------
fedora_versions := "fedora43 fedora44 fedora-rawhide"
debian_versions := "trixie forky sid"
appimage_container := "trixie"
all_containers := f"arch {{fedora_versions}} {{debian_versions}}"
container_image_prefix := "map-build"
# Distribution Hosts -----------------------------------------------------------
distribution_host := "deploy@build.r.bdr.sh"
distribution_path := f"/srv/http/build.r.bdr.sh/{{app_name}}-linux"
# Build ########################################################################
# Setup the meson build directory.
setup:
meson setup {{builddir}}
# Compile the project using meson
build: setup
meson compile -C {{builddir}}
# Create a dist tarball with meson
dist: setup
meson dist -C {{builddir}} --no-tests --allow-dirty
# Code Quality #################################################################
# Run tests
test:
cargo test
# Run tests with a coverage report
coverage:
cargo tarpaulin
# Format the source code and fix fixable code quality issues
format:
cargo fmt && cargo clippy --fix
# Check the source code for lint and code quality issues
lint:
cargo fmt -- --check && cargo clippy
# Internationalization / Localization ##########################################
# Find translatable strings in the source and create a reference in POTFILES
find_translatable_files:
find ./src -not -path '*/.*' -type f -name "*.rs" -exec grep -l "tr!(\"\|gettext" {} \; | sed 's|^\./||' | sort > po/POTFILES
find ./data -not -path '*/.*' -name "*.in.in" -type f | sed 's|^\./||' | sort >> po/POTFILES
# Extract the strings into the POT file
extract_strings: find_translatable_files
xgettext --files-from=po/POTFILES --output=po/systems.tranquil.Map.pot --from-code=UTF-8 --add-comments --keyword='tr!'
# Containers ###################################################################
# Builds the container specified by name
build-container name:
{{ if clean_images != "" { "podman system prune -af" } else { "" } }}
@echo "=== Building container image: {{container_image_prefix}}:{{name}} ==="
podman build -t {{container_image_prefix}}:{{name}} build-containers/{{name}}
# Builds all containers
build-containers:
for container in {{all_containers}}; do just build-container "$container"; done
# Packaging ####################################################################
# Updates the cargo-sources.json
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
flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo --install builddir ./build-aux/flatpak/systems.tranquil.Map.yml
flatpak build-bundle repo {{distdir}}/{{filename}}.flatpak systems.tranquil.Map
_fetch-linuxdeploy:
@mkdir -p .cache
@test -f {{linuxdeploy}} || curl -L -o {{linuxdeploy}} {{linuxdeploy_url}}
@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}}
# 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}}
# 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}}
# 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}}
# Build .rpm for every supported distro
package-rpm-all:
for distro in {{fedora_versions}}; do just package-rpm "$distro"; done
# Build .deb for every supported distro
package-deb-all:
for distro in {{debian_versions}}; do just package-deb "$distro"; done
# Build all distributable packages
package: package-flatpak package-appimage package-arch package-rpm-all package-deb-all
# Distribution #################################################################
# Sign and upload flatpak
distribute-flatpak: (_sign_and_upload f"{{distdir}}/{{filename}}.flatpak")
# Sign and upload 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")
# Sign and upload .rpm files
distribute-rpm:
for distro in {{fedora_versions}}; do just _distribute-rpm "$distro"; done
# Sign and upload .deb files
distribute-deb:
for distro in {{debian_versions}}; do just _distribute-deb "$distro"; done
# 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-deb distro: (_sign_and_upload f"{{distdir}}/{{filename}}-{{distro}}.deb")
# Release ######################################################################
# Creates, signs and uploads all distributable packages
release: package distribute
# CI/CD ########################################################################
# Intended to run in CI. Lints and releases.
ci: lint
#!/usr/bin/env bash
if [[ "$GIT_REF" == "refs/heads/main"]]; then
just release
elif [[ "$GIT_REF" == "refs/tags/*" ]]; then
just channel="${GIT_REF#refs/tags/}" release
else
echo "Not in CI environment."
fi
# Local Install ################################################################
# Locally installs
install: build
meson install -C {{builddir}}
uninstall:
ninja -C {{builddir}} 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
mkdir -p .cargo
# 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}"
# Rust Cargo.toml
echo -ne "\tUpdating: 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
echo -e "\r\tUpdated: PKGBUILD "
# Fedora RPM Spec
echo -ne "\tUpdating: 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:
{{ if clean_images != "" { f"podman rmi {{container_image_prefix}}:{{image}}" } else { "" } }}
# Ensures distdir exists
_ensure_distdir:
@mkdir -p {{distdir}}
# Signs a file
_sign file version platform:
#!/usr/bin/env bash
comment="Version: {{version}}, File: {{file_name(file)}} Built on: {{datetime('%Y-%m-%d %H:%M')}}, Platform: {{platform}}"
if [ -f ~/.minisign/minisign.pass ]; then
cat ~/.minisign/minisign.pass | minisign -Sm "{{file}}" -t "${comment}"
else
minisign -Sm "{{file}}" -t "${comment}"
fi
# Uploads a file and its signature.
_upload file:
rsync -avz {{file}}.minisig {{distribution_host}}:{{distribution_path}}
rsync -avz {{file}} {{distribution_host}}:{{distribution_path}}
# Sign and upload a file.
_sign_and_upload file: (_sign file channel architecture) (_upload file)
|