Merge casper:intergrate-20iso_scan into casper:main

Proposed by Łukasz Zemczak
Status: Merged
Merged at revision: 28b7525e3bb3ac0ab5dfefa045e2d10dbd01bfbd
Proposed branch: casper:intergrate-20iso_scan
Merge into: casper:main
Diff against target: 144 lines (+121/-0)
3 files modified
debian/changelog (+9/-0)
scripts/casper-helpers (+73/-0)
scripts/casper-premount/20iso_scan (+39/-0)
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Approve
Review via email: mp+419469@code.launchpad.net

Commit message

Integrate 20iso_scan into casper (from lupin-casper)"

Description of the change

I tried to cherry-pick only the relevant bits from lupin-casper into casper itself.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 0fb5823..a7f8ee0 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,12 @@
6+casper (1.469) UNRELEASED; urgency=medium
7+
8+ * Integrate lupin-casper's 20iso_scan casper-premount script so that users
9+ can continue to use images that provide multiple iso's to choose to boot
10+ from. This was no longer possible after the removal of the lupin packages
11+ from jammy (LP: #1960457).
12+
13+ -- Łukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> Thu, 14 Apr 2022 15:04:19 +0200
14+
15 casper (1.468) jammy; urgency=medium
16
17 * casper-md5check: correctly detect fsck.mode=skip if last
18diff --git a/scripts/casper-helpers b/scripts/casper-helpers
19index 6fed1f9..72a0cfe 100644
20--- a/scripts/casper-helpers
21+++ b/scripts/casper-helpers
22@@ -363,4 +363,77 @@ find_files()
23 done
24 }
25
26+# Helpers originally from lupin-helpers
27+is_supported_fs(){
28+ [ -z "${1}" ] && return 1
29+ case ${1} in
30+ ext2|ext3|ext4|xfs|jfs|reiserfs|vfat|ntfs|iso9660|btrfs)
31+ return 0
32+ ;;
33+ esac
34+ return 1
35+}
36+
37+wait_for_devs(){
38+ if [ -e /dev/.initramfs/lupin-waited-for-devs ]; then
39+ return
40+ fi
41+ [ "$quiet" != "y" ] && log_begin_msg "...waiting for devs..."
42+ udevadm trigger --subsystem-match=block
43+ udevadm settle
44+ #TBD, modprobe on demand?
45+ modprobe ext3
46+ modprobe ext4
47+ modprobe reiserfs
48+ modprobe xfs
49+ modprobe jfs
50+ modprobe vfat
51+ modprobe fuse
52+ [ "$quiet" != "y" ] && log_end_msg "...devs loaded..."
53+ touch /dev/.initramfs/lupin-waited-for-devs
54+}
55+
56+find_path()
57+{
58+ local path="${1}"
59+ # must match find_path_cleanup
60+ local default_mountpoint="${2:-/tmpmountpoint}"
61+ local mountoptions="${3:-ro}"
62+ local mountpoint=
63+ local dev devname devfstype
64+ local trial_number
65+ FOUNDDEV=
66+ FOUNDPATH=
67+ [ -z "${path}" ] && return 1
68+ wait_for_devs
69+ mkdir -p "${default_mountpoint}"
70+ for trial_number in 1 2 3; do
71+ [ $trial_number -gt 1 ] && sleep 3
72+ for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v /ram | grep -v /loop | grep -v /fd); do
73+ for dev in $(subdevices "${sysblock}"); do
74+ devname=$(sys2dev "${dev}")
75+ devfstype="$(get_fstype ${devname})"
76+ if is_supported_fs "${devfstype}" ; then
77+ #if device is already mounted, do not remount
78+ if grep -q "^${devname} " /proc/mounts; then
79+ mountpoint=$(grep "^${devname} " /proc/mounts|cut -d ' ' -f 2)
80+ unmount=false
81+ else
82+ mountpoint="${default_mountpoint}"
83+ try_mount "$devname" "$mountpoint" "$mountoptions" || continue
84+ unmount=true
85+ fi
86+ if [ -e "${mountpoint}${path}" ]; then
87+ FOUNDDEV="${devname}"
88+ FOUNDPATH="${mountpoint}${path}"
89+ return 0
90+ fi
91+ [ "${unmount}" = "true" ] && umount ${mountpoint} 2> /dev/null || true
92+ fi
93+ done
94+ done
95+ done
96+ return 1
97+}
98+
99
100diff --git a/scripts/casper-premount/20iso_scan b/scripts/casper-premount/20iso_scan
101new file mode 100755
102index 0000000..117011b
103--- /dev/null
104+++ b/scripts/casper-premount/20iso_scan
105@@ -0,0 +1,39 @@
106+#!/bin/sh
107+
108+PREREQ=""
109+
110+prereqs()
111+{
112+ echo "$PREREQ"
113+}
114+
115+case $1 in
116+# get pre-requisites
117+ prereqs)
118+ prereqs
119+ exit 0
120+ ;;
121+esac
122+
123+. /scripts/casper-functions
124+
125+iso_path=
126+for x in $(cat /proc/cmdline); do
127+ case ${x} in
128+ iso-scan/filename=*)
129+ iso_path=${x#iso-scan/filename=}
130+ ;;
131+ esac
132+done
133+if [ "$iso_path" ]; then
134+ if find_path "${iso_path}" /isodevice rw; then
135+ echo "LIVEMEDIA=${FOUNDPATH}" >> /conf/param.conf
136+ if [ -f "${FOUNDPATH}" ]; then
137+ echo "LIVEMEDIA_OFFSET=0" >> /conf/param.conf
138+ fi
139+ else
140+ panic "
141+Could not find the ISO $iso_path
142+"
143+ fi
144+fi

Subscribers

People subscribed via source and target branches