File tree Expand file tree Collapse file tree 3 files changed +107
-0
lines changed
overlayfs-tools-overlay/sbin Expand file tree Collapse file tree 3 files changed +107
-0
lines changed Original file line number Diff line number Diff line change 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+ umount " ${OVERLAY_DIR} " || true
26+ rmdir -v " ${OVERLAY_DIR} " || true
27+ }
28+
29+ trap cleanup EXIT
30+
31+ if ! [ -e " ${OVERLAY_IMG} " ]; then
32+ die " Overlay ${OVERLAY_IMG} not found"
33+ fi
34+
35+ if [ -d " ${OVERLAY_DIR} " ]; then
36+ die " Overlay tree already present; cleanup with umount ${MERGED_DIR} ${OVERLAY_DIR} && rmdir ${OVERLAY_DIR} "
37+ fi
38+
39+ mkdir -v " ${OVERLAY_DIR} "
40+ mount -o loop " ${OVERLAY_IMG} " " ${OVERLAY_DIR} "
41+ mount -t overlay \
42+ overlay \
43+ " -olowerdir=${LOWER_DIR} ,upperdir=${UPPER_DIR} ,workdir=${WORK_DIR} " \
44+ " ${MERGED_DIR} "
45+
46+ for fs in $BINDMOUNTS ; do
47+ mount --bind " ${fs} " " ${MERGED_DIR} /${fs} "
48+ done
49+
50+ echo " Running $* in merged chroot" >&2
51+ chroot " ${MERGED_DIR} " " $@ "
52+
Original file line number Diff line number Diff line change 1+ {{- $overlaysize := or .overlaysize "2GiB" }}
2+
3+ architecture : arm64
4+
5+ # this recipe uses overlayfs to install a few extra packages only relevant for
6+ # testing; the resulting image file can be used during factory testing to
7+ # provide extra commands, and then removed from the filesystem
8+ #
9+ # to run a command from the overlay:
10+ # /sbin/overlay-do <command ...>
11+ # to remove the overlay:
12+ # shred -n 1 -v -u /overlay.img
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+ # debug
24+ cat /proc/filesystems || true
25+ lsmod || true
26+ losetup -a || true
27+ ls /lib/modules || true
28+ uname -a || true
29+ mount -o loop /overlay.img /mnt
30+ # create directories needed to mount overlay
31+ mkdir -v /mnt/merged /mnt/upper /mnt/work
32+ umount /mnt
33+
34+ - action : overlay
35+ description : Apply overlayfs overlay
36+ source : overlayfs-tools-overlay
37+
38+ - action : run
39+ description : Modernize APT sources
40+ chroot : true
41+ command : |
42+ set -eux
43+ # install gst-launch and some difficult to redistribute gstreamer plugins
44+ /sbin/overlay-do \
45+ apt -y install \
46+ gstreamer1.0-libav \
47+ gstreamer1.0-plugins-bad \
48+ gstreamer1.0-plugins-ugly \
49+ gstreamer1.0-tools
50+
51+ # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
52+ # SPDX-License-Identifier: BSD-3-Clause
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments