11name : build
22
3- # Builds GhostFS (normal + cybersec binaries) and packages them into a
4- # single .deb — "ghostfs" — which:
3+ # Builds GhostFS (normal and/or cybersec binaries — see the `variant` input
4+ # below) and packages them into a single .deb — "ghostfs" — which:
55# 1. installs the ghostfs / ghostfs-cybersec binaries + admin tooling +
66# initramfs early-boot hooks, and
77# 2. assumes Calamares is ALREADY installed on the target system, and
88# patches its configuration so the graphical installer offers ONLY
99# GhostFS as a root filesystem (no ext4/btrfs/xfs choice).
1010#
11+ # Manual runs (Actions tab -> Run workflow) let you pick which variant to
12+ # build via a dropdown: 'both' (default, matches push/PR/tag behaviour),
13+ # 'normal' only, or 'cybersec' only. Useful for a quick build of just the
14+ # variant you're testing, or to halve CI time when you don't need both.
15+ #
1116# This workflow does NOT install anything on the runner beyond build
1217# dependencies — it produces a .deb artifact for you to install elsewhere
1318# (`sudo apt install ./ghostfs_<version>_amd64.deb`, or `sudo dpkg -i` +
2732 - ' v*'
2833 pull_request :
2934 branches : [ main ]
30- workflow_dispatch : {}
35+ workflow_dispatch :
36+ inputs :
37+ variant :
38+ description : ' Which binary/binaries to build and package'
39+ required : true
40+ type : choice
41+ default : ' both'
42+ options :
43+ - both
44+ - normal
45+ - cybersec
3146
3247env :
3348 CARGO_TERM_COLOR : always
3651jobs :
3752 build-deb :
3853 runs-on : ubuntu-latest
54+ outputs :
55+ variant : ${{ steps.variant.outputs.variant }}
3956 steps :
4057 - name : Checkout
4158 uses : actions/checkout@v4
4259
60+ - name : Determine build variant
61+ id : variant
62+ run : |
63+ # workflow_dispatch lets you pick 'normal' / 'cybersec' / 'both'
64+ # from the Actions UI (Run workflow -> Variant dropdown). Push/PR/
65+ # tag triggers have no inputs at all, so default to 'both' — the
66+ # previous, always-build-everything behaviour.
67+ VARIANT="${{ github.event.inputs.variant || 'both' }}"
68+ case "$VARIANT" in
69+ both|normal|cybersec) : ;;
70+ *) echo "::error::Unknown variant '$VARIANT' — must be both/normal/cybersec"; exit 1 ;;
71+ esac
72+ echo "variant=$VARIANT" >> "$GITHUB_OUTPUT"
73+ echo "Building variant: $VARIANT"
74+
4375 - name : Install Rust toolchain
4476 uses : dtolnay/rust-toolchain@stable
4577
@@ -75,41 +107,61 @@ jobs:
75107 # Two separate binaries, per Makefile / build.hl convention:
76108 # normal — encryption optional (--encryption flag at mkfs time)
77109 # cybersec — encryption always on, MAC/IDS/forensics/canary active
110+ # Which one(s) get built is controlled by the `variant` workflow_dispatch
111+ # input (see "Determine build variant" step above) — both by default
112+ # (push/PR/tag triggers, which have no input to choose from).
78113 - name : cargo build (normal)
79- working-directory : .
114+ if : steps.variant.outputs.variant == 'normal' || steps.variant.outputs.variant == 'both'
80115 run : |
81116 cargo build --release --no-default-features \
82117 --features normal,zstd,lz4
83118
84119 - name : Stash normal binary
120+ if : steps.variant.outputs.variant == 'normal' || steps.variant.outputs.variant == 'both'
85121 run : |
86122 mkdir -p dist
87123 cp target/release/ghostfs dist/ghostfs-normal
88124
89125 - name : cargo build (cybersec)
126+ if : steps.variant.outputs.variant == 'cybersec' || steps.variant.outputs.variant == 'both'
90127 run : |
91128 cargo build --release --no-default-features \
92129 --features cybersec,zstd,lz4
93130
94131 - name : Stash cybersec binary
132+ if : steps.variant.outputs.variant == 'cybersec' || steps.variant.outputs.variant == 'both'
95133 run : |
134+ mkdir -p dist
96135 cp target/release/ghostfs dist/ghostfs-cybersec
97136
98137 - name : cargo test (best-effort — repo currently has no test suite)
99- run : cargo test --release --no-default-features --features cybersec,zstd,lz4 || \
100- echo "::warning::No tests ran (or tests failed) — see README 'testowanie' section. Not blocking the build."
138+ # Test whichever variant was actually built; prefer cybersec features
139+ # when both are available (exercises the larger feature surface).
140+ run : |
141+ if [ "${{ steps.variant.outputs.variant }}" = "normal" ]; then
142+ FEATURES="normal,zstd,lz4"
143+ else
144+ FEATURES="cybersec,zstd,lz4"
145+ fi
146+ cargo test --release --no-default-features --features "$FEATURES" || \
147+ echo "::warning::No tests ran (or tests failed) — see README 'testowanie' section. Not blocking the build."
101148
102149 # ── Assemble the .deb payload tree ───────────────────────────────────────
103150 - name : Assemble packaging tree
104151 run : |
105152 set -eux
153+ VARIANT="${{ steps.variant.outputs.variant }}"
106154 PKGROOT="$(mktemp -d)/ghostfs"
107155 mkdir -p "$PKGROOT"
108156 cp -r packaging/deb/. "$PKGROOT/"
109157
110- # Binaries
111- install -Dm755 dist/ghostfs-normal "$PKGROOT/usr/local/bin/ghostfs"
112- install -Dm755 dist/ghostfs-cybersec "$PKGROOT/usr/local/bin/ghostfs-cybersec"
158+ # Binaries — only the one(s) actually built for this variant.
159+ if [ "$VARIANT" = "normal" ] || [ "$VARIANT" = "both" ]; then
160+ install -Dm755 dist/ghostfs-normal "$PKGROOT/usr/local/bin/ghostfs"
161+ fi
162+ if [ "$VARIANT" = "cybersec" ] || [ "$VARIANT" = "both" ]; then
163+ install -Dm755 dist/ghostfs-cybersec "$PKGROOT/usr/local/bin/ghostfs-cybersec"
164+ fi
113165
114166 # Admin / mount helper scripts
115167 install -Dm755 scripts/ghostfs-admin.sh "$PKGROOT/usr/local/bin/ghostfs-admin.sh"
@@ -126,11 +178,22 @@ jobs:
126178 cp -r calamares/modules/ghostfs-umount "$PKGROOT/usr/lib/calamares/modules/"
127179 chmod 755 "$PKGROOT"/usr/lib/calamares/modules/*/*.py
128180
129- # Calamares config: static ghostfs-mkfs.conf installed directly;
130- # settings.conf + partition.conf patch shipped as docs and applied
131- # by postinst via calamares-patch.py (so we can revert on removal).
181+ # Calamares mkfs config: points at whichever binary the installer
182+ # should actually use for the format step. The static file checked
183+ # into the repo (calamares/config/ghostfs-mkfs.conf) defaults to
184+ # cybersec — correct for 'both' and 'cybersec'. For 'normal'-only
185+ # builds it would reference a binary that doesn't exist in this
186+ # .deb at all, so we patch those two lines with `sed` instead of
187+ # maintaining a second copy of the whole file (single source of
188+ # truth — avoids the two configs silently drifting apart).
132189 install -Dm644 calamares/config/ghostfs-mkfs.conf \
133190 "$PKGROOT/etc/calamares/modules/ghostfs-mkfs.conf"
191+ if [ "$VARIANT" = "normal" ]; then
192+ sed -i \
193+ -e 's#^ghostfsBin:.*#ghostfsBin: "/usr/local/bin/ghostfs"#' \
194+ -e 's#^cybersecMode:.*#cybersecMode: false#' \
195+ "$PKGROOT/etc/calamares/modules/ghostfs-mkfs.conf"
196+ fi
134197 install -Dm644 calamares/config/settings.conf.ghostfs \
135198 "$PKGROOT/usr/share/doc/ghostfs/settings.conf.ghostfs"
136199 install -Dm644 calamares/config/partition.conf.ghostfs-patch.yaml \
@@ -140,6 +203,11 @@ jobs:
140203 install -Dm644 README.md "$PKGROOT/usr/share/doc/ghostfs/README.md"
141204 install -Dm644 LICENSE "$PKGROOT/usr/share/doc/ghostfs/copyright"
142205
206+ # Note which variant this package was built with — visible via
207+ # `dpkg -s ghostfs` / `apt show ghostfs` for anyone debugging
208+ # "why is ghostfs-cybersec missing" later.
209+ sed -i "/^Description:/a Built-Variant: ${VARIANT}" "$PKGROOT/DEBIAN/control"
210+
143211 # Fill in Installed-Size (KB) — dpkg-deb doesn't require it but
144212 # apt/dpkg -l output is nicer with it present.
145213 SIZE_KB=$(du -sk "$PKGROOT" | cut -f1)
@@ -158,6 +226,7 @@ jobs:
158226 # build HERE if any are missing.
159227 run : |
160228 set -eu
229+ VARIANT="${{ steps.variant.outputs.variant }}"
161230 MISSING=0
162231 check() {
163232 if [ ! -e "$PKGROOT/$1" ]; then
@@ -166,8 +235,12 @@ jobs:
166235 fi
167236 }
168237 check "usr/lib/ghostfs/calamares-patch.py"
169- check "usr/local/bin/ghostfs"
170- check "usr/local/bin/ghostfs-cybersec"
238+ if [ "$VARIANT" = "normal" ] || [ "$VARIANT" = "both" ]; then
239+ check "usr/local/bin/ghostfs"
240+ fi
241+ if [ "$VARIANT" = "cybersec" ] || [ "$VARIANT" = "both" ]; then
242+ check "usr/local/bin/ghostfs-cybersec"
243+ fi
171244 check "usr/local/bin/ghostfs-admin.sh"
172245 check "sbin/mount.ghostfs"
173246 check "etc/initramfs-tools/hooks/ghostfs"
@@ -181,11 +254,10 @@ jobs:
181254 check "DEBIAN/postinst"
182255 check "DEBIAN/postrm"
183256 if [ "$MISSING" = "1" ]; then
184- echo "::error::Packaging tree is incomplete — see missing files above. \
185- Refusing to build a .deb that would silently fail its own postinst at install time."
257+ echo "::error::Packaging tree is incomplete — see missing files above. Refusing to build a .deb that would silently fail its own postinst at install time."
186258 exit 1
187259 fi
188- echo "✓ packaging tree complete"
260+ echo "✓ packaging tree complete for variant=$VARIANT "
189261
190262 - name : Verify initramfs script is POSIX sh (dash) compatible
191263 # update-initramfs runs local-top scripts via /bin/sh (dash on
@@ -233,7 +305,7 @@ Refusing to build a .deb that would silently fail its own postinst at install ti
233305 - name : Upload .deb artifact
234306 uses : actions/upload-artifact@v4
235307 with :
236- name : ghostfs-deb-${{ env.DEB_VERSION }}
308+ name : ghostfs-deb-${{ env.DEB_VERSION }}-${{ steps.variant.outputs.variant }}
237309 path : out/*.deb
238310 if-no-files-found : error
239311
@@ -251,6 +323,8 @@ Refusing to build a .deb that would silently fail its own postinst at install ti
251323 # package (real Calamares is heavy/GUI-oriented and not worth pulling
252324 # into CI just to check our postinst/postrm patch logic runs and
253325 # reverts without crashing).
326+ env :
327+ VARIANT : ${{ needs.build-deb.outputs.variant }}
254328 steps :
255329 - name : Checkout
256330 uses : actions/checkout@v4
@@ -314,9 +388,15 @@ Refusing to build a .deb that would silently fail its own postinst at install ti
314388 - name : Verify mount.ghostfs and binaries were installed
315389 run : |
316390 test -x /sbin/mount.ghostfs
317- test -x /usr/local/bin/ghostfs
318- test -x /usr/local/bin/ghostfs-cybersec
319- /usr/local/bin/ghostfs --help
391+ if [ "$VARIANT" = "normal" ] || [ "$VARIANT" = "both" ]; then
392+ test -x /usr/local/bin/ghostfs
393+ /usr/local/bin/ghostfs --help
394+ fi
395+ if [ "$VARIANT" = "cybersec" ] || [ "$VARIANT" = "both" ]; then
396+ test -x /usr/local/bin/ghostfs-cybersec
397+ /usr/local/bin/ghostfs-cybersec --help
398+ fi
399+ echo "OK: variant=$VARIANT binaries present as expected"
320400
321401 - name : Remove ghostfs and verify Calamares config was restored
322402 run : |
0 commit comments