@@ -7,13 +7,13 @@ _mnt_dmsnapshot() {
77 local img=" ${1} "
88 local newroot=" ${2} "
99 local mnt=" ${3} "
10- local img_fullname=" ${img##*/ } " ;
10+ local img_fullname=" ${img##*/ } "
1111 local img_name=" ${img_fullname%% .* } "
1212 local dm_snap_name=" ${dm_snap_prefix} _${img_name} "
1313 local ro_dev ro_dev_size rw_dev
1414
1515 ro_dev=" $( losetup --find --show --read-only -- " ${img} " ) "
16- echo " ${ro_dev} " >> /run/archiso/used_block_devices
16+ printf ' %s\n ' " ${ro_dev} " >> /run/archiso/used_block_devices
1717 ro_dev_size=" $( blockdev --getsz " ${ro_dev} " ) "
1818
1919 if [ " ${cow_persistent} " = " P" ]; then
@@ -33,7 +33,7 @@ _mnt_dmsnapshot() {
3333 fi
3434
3535 rw_dev=" $( losetup --find --show " /run/archiso/cowspace/${cow_directory} /${img_name} .cow" ) "
36- echo " ${rw_dev} " >> /run/archiso/used_block_devices
36+ printf ' %s\n ' " ${rw_dev} " >> /run/archiso/used_block_devices
3737
3838 dmsetup create " ${dm_snap_name} " --table \
3939 " 0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} ${cow_chunksize} "
@@ -43,7 +43,7 @@ _mnt_dmsnapshot() {
4343 fi
4444
4545 _mnt_dev " /dev/mapper/${dm_snap_name} " " ${newroot}${mnt} " " -w" " defaults"
46- readlink -f " /dev/mapper/${dm_snap_name} " >> /run/archiso/used_block_devices
46+ readlink -f " /dev/mapper/${dm_snap_name} " >> /run/archiso/used_block_devices
4747}
4848
4949# args: source, newroot, mountpoint
@@ -53,11 +53,10 @@ _mnt_overlayfs() {
5353 local mnt=" ${3} "
5454 mkdir -p " /run/archiso/cowspace/${cow_directory} /upperdir" " /run/archiso/cowspace/${cow_directory} /workdir"
5555 mount -t overlay -o \
56- " lowerdir=${src} ,upperdir=/run/archiso/cowspace/${cow_directory} /upperdir,workdir=/run/archiso/cowspace/${cow_directory} /workdir" \
57- airootfs " ${newroot}${mnt} "
56+ " lowerdir=${src} ,upperdir=/run/archiso/cowspace/${cow_directory} /upperdir,workdir=/run/archiso/cowspace/${cow_directory} /workdir" \
57+ airootfs " ${newroot}${mnt} "
5858}
5959
60-
6160# args: /path/to/image_file, mountpoint
6261_mnt_sfs () {
6362 local img=" ${1} "
@@ -69,24 +68,61 @@ _mnt_sfs() {
6968 # defined via initcpio's parse_cmdline()
7069 if [ " ${copytoram} " = " y" ]; then
7170 msg -n " :: Copying squashfs image to RAM..."
72- if ! cp -- " ${img} " " /run/archiso/copytoram/${img_fullname} " ; then
71+
72+ # in case we have pv use it to display copy progress feedback otherwise
73+ # fallback to using plain cp
74+ if command -v pv > /dev/null 2>&1 ; then
75+ echo " "
76+ (pv " ${img} " > " /run/archiso/copytoram/${img_fullname} " )
77+ local rc=$?
78+ else
79+ (cp -- " ${img} " " /run/archiso/copytoram/${img_fullname} " )
80+ local rc=$?
81+ fi
82+
83+ if [ $rc != 0 ]; then
7384 echo " ERROR: while copy '${img} ' to '/run/archiso/copytoram/${img_fullname} '"
7485 launch_interactive_shell
7586 fi
87+
7688 img=" /run/archiso/copytoram/${img_fullname} "
7789 msg " done."
7890 fi
7991 sfs_dev=" $( losetup --find --show --read-only -- " ${img} " ) "
80- echo " ${sfs_dev} " >> /run/archiso/used_block_devices
92+ echo " ${sfs_dev} " >> /run/archiso/used_block_devices
8193 _mnt_dev " ${sfs_dev} " " ${mnt} " " -r" " defaults"
8294}
8395
96+ # args: /path/to/image_file, mountpoint
97+ _mnt_erofs () {
98+ local img=" ${1} "
99+ local mnt=" ${2} "
100+ local img_fullname=" ${img##*/ } "
101+ local erofs_dev
102+
103+ # shellcheck disable=SC2154
104+ # defined via initcpio's parse_cmdline()
105+ if [ " ${copytoram} " = " y" ]; then
106+ msg -n " :: Copying EROFS image to RAM..."
107+ if ! cp -- " ${img} " " /run/archiso/copytoram/${img_fullname} " ; then
108+ echo " ERROR: while copy '${img} ' to '/run/archiso/copytoram/${img_fullname} '"
109+ launch_interactive_shell
110+ fi
111+ img=" /run/archiso/copytoram/${img_fullname} "
112+ msg " done."
113+ fi
114+ erofs_dev=" $( losetup --find --show --read-only -- " ${img} " ) "
115+ echo " ${erofs_dev} " >> /run/archiso/used_block_devices
116+ _mnt_dev " ${erofs_dev} " " ${mnt} " " -r" " defaults" " erofs"
117+ }
118+
84119# args: device, mountpoint, flags, opts
85120_mnt_dev () {
86121 local dev=" ${1} "
87122 local mnt=" ${2} "
88123 local flg=" ${3} "
89124 local opts=" ${4} "
125+ local fstype=" ${5:- auto} "
90126
91127 mkdir -p " ${mnt} "
92128
@@ -99,7 +135,7 @@ _mnt_dev() {
99135 launch_interactive_shell
100136 done
101137
102- if mount -o " ${opts} " " ${flg} " " ${dev} " " ${mnt} " ; then
138+ if mount -t " ${fstype} " - o " ${opts} " " ${flg} " " ${dev} " " ${mnt} " ; then
103139 msg " :: Device '${dev} ' mounted successfully."
104140 else
105141 echo " ERROR; Failed to mount '${dev} '"
@@ -112,16 +148,17 @@ _mnt_dev() {
112148_verify_checksum () {
113149 local _status
114150 cd " /run/archiso/bootmnt/${archisobasedir} /${arch} " || exit 1
115- sha512sum -c airootfs.sha512 > /tmp/checksum.log 2>&1
151+ sha512sum -c airootfs.sha512 > /tmp/checksum.log 2>&1
116152 _status=$?
117153 cd -- " ${OLDPWD} " || exit 1
118154 return " ${_status} "
119155}
120156
121157_verify_signature () {
122158 local _status
159+ local sigfile=" ${1} "
123160 cd " /run/archiso/bootmnt/${archisobasedir} /${arch} " || exit 1
124- gpg --homedir /gpg --status-fd 1 --verify airootfs.sfs.sig 2> /dev/null | grep -qE ' ^\[GNUPG:\] GOODSIG'
161+ gpg --homedir /gpg --status-fd 1 --verify " ${sigfile} " 2> /dev/null | grep -qE ' ^\[GNUPG:\] GOODSIG'
125162 _status=$?
126163 cd -- " ${OLDPWD} " || exit 1
127164 return ${_status}
@@ -135,8 +172,7 @@ run_hook() {
135172 # shellcheck disable=SC2154
136173 # defined via initcpio's parse_cmdline()
137174 [ -z " ${archisodevice} " ] && archisodevice=" /dev/disk/by-label/${archisolabel} "
138- # [ -z "${cow_spacesize}" ] && cow_spacesize="256M"
139- [ -z " ${cow_spacesize} " ] && cow_spacesize=" %COWSPACE%"
175+ [ -z " ${cow_spacesize} " ] && cow_spacesize=" 256M"
140176 # shellcheck disable=SC2154
141177 # defined via initcpio's parse_cmdline()
142178 if [ -n " ${cow_label} " ]; then
@@ -161,11 +197,12 @@ run_hook() {
161197# args: /path/to/newroot
162198archiso_mount_handler () {
163199 local newroot=" ${1} "
200+ local sigfile
164201
165202 if ! mountpoint -q " /run/archiso/bootmnt" ; then
166203 _mnt_dev " ${archisodevice} " " /run/archiso/bootmnt" " -r" " defaults"
167204 if [ " ${copytoram} " != " y" ]; then
168- readlink -f " ${archisodevice} " >> /run/archiso/used_block_devices
205+ readlink -f " ${archisodevice} " >> /run/archiso/used_block_devices
169206 fi
170207 fi
171208
@@ -191,15 +228,20 @@ archiso_mount_handler() {
191228 # defined via initcpio's parse_cmdline()
192229 if [ " ${verify} " = " y" ]; then
193230 if [ -f " /run/archiso/bootmnt/${archisobasedir} /${arch} /airootfs.sfs.sig" ]; then
231+ sigfile=" airootfs.sfs.sig"
232+ elif [ -f " /run/archiso/bootmnt/${archisobasedir} /${arch} /airootfs.erofs.sig" ]; then
233+ sigfile=" airootfs.erofs.sig"
234+ fi
235+ if [ -n " ${sigfile} " ]; then
194236 msg -n " :: Signature verification requested, please wait..."
195- if _verify_signature; then
237+ if _verify_signature " ${sigfile} " ; then
196238 msg " done. Signature is OK, continue booting."
197239 else
198240 echo " ERROR: one or more files are corrupted"
199241 launch_interactive_shell
200242 fi
201243 else
202- echo " ERROR: verify=y option specified but ${archisobasedir} /${arch} /airootfs.sfs.sig not found "
244+ echo " ERROR: verify=y option specified but GPG signature not found in ${archisobasedir} /${arch} /"
203245 launch_interactive_shell
204246 fi
205247 fi
@@ -212,7 +254,7 @@ archiso_mount_handler() {
212254
213255 if [ -n " ${cow_device} " ]; then
214256 _mnt_dev " ${cow_device} " " /run/archiso/cowspace" " -r" " ${cow_flags} "
215- readlink -f " ${cow_device} " >> /run/archiso/used_block_devices
257+ readlink -f " ${cow_device} " >> /run/archiso/used_block_devices
216258 mount -o remount,rw " /run/archiso/cowspace"
217259 else
218260 msg " :: Mounting /run/archiso/cowspace (tmpfs) filesystem, size=${cow_spacesize} ..."
@@ -222,15 +264,20 @@ archiso_mount_handler() {
222264 mkdir -p " /run/archiso/cowspace/${cow_directory} "
223265 chmod 0700 " /run/archiso/cowspace/${cow_directory} "
224266
225- _mnt_sfs " /run/archiso/bootmnt/${archisobasedir} /${arch} /airootfs.sfs" " /run/archiso/sfs/airootfs"
226- if [ -f " /run/archiso/sfs/airootfs/airootfs.img" ]; then
227- _mnt_dmsnapshot " /run/archiso/sfs/airootfs/airootfs.img" " ${newroot} " " /"
267+ if [ -f " /run/archiso/bootmnt/${archisobasedir} /${arch} /airootfs.sfs" ]; then
268+ _mnt_sfs " /run/archiso/bootmnt/${archisobasedir} /${arch} /airootfs.sfs" " /run/archiso/airootfs"
269+ elif [ -f " /run/archiso/bootmnt/${archisobasedir} /${arch} /airootfs.erofs" ]; then
270+ _mnt_erofs " /run/archiso/bootmnt/${archisobasedir} /${arch} /airootfs.erofs" " /run/archiso/airootfs"
271+ fi
272+ if [ -f " /run/archiso/airootfs/airootfs.img" ]; then
273+ _mnt_dmsnapshot " /run/archiso/airootfs/airootfs.img" " ${newroot} " " /"
228274 else
229- _mnt_overlayfs " /run/archiso/sfs/ airootfs" " ${newroot} " " /"
275+ _mnt_overlayfs " /run/archiso/airootfs" " ${newroot} " " /"
230276 fi
231277
232278 if [ " ${copytoram} " = " y" ]; then
233279 umount -d /run/archiso/bootmnt
280+ rmdir /run/archiso/bootmnt
234281 fi
235282}
236283
0 commit comments