Skip to content

Commit 429b9d8

Browse files
committed
0 parents  commit 429b9d8

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2024 Davide Cavalca
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# fex-emu-rootfs-generator
2+
3+
WIP systemd generator for the fex rootfs

fex-emu-rootfs-generator.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
layers=""
6+
for f in /usr/share/fex-emu/layers/*; do
7+
[ -z "$layers" ] && layers=$f || layers="$layers $f"
8+
done
9+
dest="$1"
10+
11+
units=""
12+
mounts=""
13+
for layer in $layers; do
14+
name="$(basename $layer .erofs)"
15+
mount=/run/fex-emu/layers/$name
16+
unit="$(systemd-escape $mount --path --suffix mount)"
17+
cat > $dest/$unit <<EOF
18+
[Unit]
19+
Description=FEX RootFS layer for $name
20+
21+
[Mount]
22+
What=$layer
23+
Where=$mount
24+
EOF
25+
[ -z "$units" ] && units=$unit || units="$units $unit"
26+
[ -z "$mounts" ] && mounts=$mount || mounts="$mounts $mount"
27+
done
28+
29+
rootfs=$(systemd-escape /run/fex-emu/rootfs --path --suffix mount)
30+
cat > $dest/$rootfs <<EOF
31+
[Unit]
32+
Description=FEX RootFS
33+
BindsTo=$units
34+
After=$units
35+
36+
[Mount]
37+
What=overlay
38+
Where=/run/fex-emu/rootfs
39+
Type=overlay
40+
Options=lowerdir=$(echo $mounts|tr ' ' :),upperdir=/run/fex-emu/writable,workdir=/run/fex-emu/workdir
41+
42+
[Install]
43+
WantedBy=multi-user.target
44+
EOF
45+
46+
mkdir -p $dest/multi-user.target.wants/
47+
ln -sf "../$rootfs" $dest/multi-user.target.wants/$rootfs

0 commit comments

Comments
 (0)