Skip to content

Commit c6b8cdb

Browse files
committed
debos: Add example overlay fs for factory tests
Signed-off-by: Loïc Minier <[email protected]>
1 parent 5a829d2 commit c6b8cdb

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
5+
set -eux
6+
7+
OVERLAY_IMG="/overlay.img"
8+
OVERLAY_DIR="/overlay"
9+
UPPER_DIR="/overlay/upper"
10+
MERGED_DIR="/overlay/merged"
11+
WORK_DIR="/overlay/work"
12+
LOWER_DIR="/"
13+
BINDMOUNTS="/dev /dev/pts /proc /run /sys"
14+
15+
die() {
16+
echo "$*" >&2
17+
exit 1
18+
}
19+
20+
cleanup() {
21+
for fs in $(echo ${BINDMOUNTS} | rev); do
22+
umount "${MERGED_DIR}/${fs}" || true
23+
done
24+
umount "${MERGED_DIR}" || true
25+
rmdir -v "${MERGED_DIR}" || true
26+
}
27+
28+
trap cleanup EXIT
29+
30+
if ! [ -e "${OVERLAY_IMG}" ]; then
31+
die "Overlay ${OVERLAY_IMG} not found"
32+
fi
33+
34+
if [ -d "${OVERLAY_DIR}" ]; then
35+
die "Overlay tree already present; cleanup with umount ${MERGED_DIR} ${OVERLAY_DIR} && rmdir ${OVERLAY_DIR}"
36+
fi
37+
38+
mkdir -v "${OVERLAY_DIR}"
39+
mount -t overlay \
40+
overlay \
41+
"-olowerdir=${LOWER_DIR},upperdir=${UPPER_DIR},workdir=${WORK_DIR}" \
42+
"${MERGED_DIR}"
43+
44+
for fs in $BINDMOUNTS; do
45+
mount --bind "${fs}" "${MERGED_DIR}/${fs}"
46+
done
47+
48+
echo "Running $* in merged chroot" >&2
49+
chroot "${MERGED_DIR}" "$@"
50+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{{- $overlaysize := or .overlaysize "2GiB" }}
2+
3+
# this recipe uses overlayfs to install a few extra packages only relevant for
4+
# testing; the resulting image file can be used during factory testing to
5+
# provide extra commands, and then removed from the filesystem
6+
#
7+
# to run a command from the overlay:
8+
# /sbin/overlay-do <command ...>
9+
# to remove the overlay:
10+
# shred -n 1 -v -u /overlay.img
11+
12+
architecture: arm64
13+
14+
actions:
15+
- action: run
16+
description: Create overlayfs
17+
chroot: true
18+
command: |
19+
set -eux
20+
# create a sparse file to hold the overlay filesystem
21+
truncate -s "{{$overlaysize}}" overlay.img
22+
mkfs.ext4 /overlay.img
23+
mount /overlay.img /mnt
24+
# create directories needed to mount overlay
25+
mkdir -v /mnt/upper /mnt/work
26+
umount /mnt
27+
28+
- actions: overlay
29+
description: Apply overlayfs overlay
30+
source: overlayfs-tools-overlay
31+
32+
- action: run
33+
description: Modernize APT sources
34+
chroot: true
35+
command: |
36+
set -eux
37+
# install gst-launch and some difficult to redistribute gstreamer plugins
38+
/sbin/overlay-do \
39+
apt -y install \
40+
gstreamer1.0-libav \
41+
gstreamer1.0-plugins-bad \
42+
gstreamer1.0-plugins-ugly \
43+
gstreamer1.0-tools
44+
45+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
46+
# SPDX-License-Identifier: BSD-3-Clause

debos-recipes/qualcomm-linux-debian-rootfs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ actions:
297297
qcom/qcs6490-rb3gen2.dtb \
298298
qcom/qrb2210-rb1.dtb
299299
300+
- action: recipe
301+
recipe: examples/overlayfs-tools.yaml
302+
300303
- action: pack
301304
description: Create root filesystem tarball
302305
file: rootfs.tar.gz

0 commit comments

Comments
 (0)