aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2021-01-18 12:27:01 -0500
committerNatanael Copa <ncopa@alpinelinux.org>2021-02-15 12:10:16 +0000
commit59cea34505cfc8563e1164d1ba81cb5ea2f3369f (patch)
treef96bceade621ab3acb3c1a3d29a634966bb10426
parent6fff80e3d5211e708337f0c486c5a3607133ce77 (diff)
downloadalpine-conf-59cea34505cfc8563e1164d1ba81cb5ea2f3369f.tar.gz
alpine-conf-59cea34505cfc8563e1164d1ba81cb5ea2f3369f.tar.bz2
alpine-conf-59cea34505cfc8563e1164d1ba81cb5ea2f3369f.tar.xz
split modloop copy to a separate script
fixes #10468
-rw-r--r--Makefile3
-rw-r--r--copy-modloop.in25
-rw-r--r--libalpine.sh.in11
-rw-r--r--setup-disk.in14
4 files changed, 41 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 370ef44..a25b733 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,8 @@ sysconfdir ?= /etc/lbu
PREFIX ?=
LIB_FILES := libalpine.sh dasd-functions.sh
-SBIN_FILES := lbu\
+SBIN_FILES := copy-modloop\
+ lbu\
setup-acf\
setup-alpine\
setup-apkcache\
diff --git a/copy-modloop.in b/copy-modloop.in
new file mode 100644
index 0000000..0c0d3a2
--- /dev/null
+++ b/copy-modloop.in
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+set -e
+
+if ! rc-service -q modloop status; then
+ echo "modloop is not started"
+ exit 1
+fi
+
+if [ -n "$DO_UMOUNT" ] && [ -z "$modloop_media" ]; then
+ modloop_media=$(find_modloop_media)
+fi
+
+modulesdir=/lib/modules
+if [ -L "$modulesdir" ]; then
+ modulesdir=$(readlink "$modulesdir")
+fi
+cp -a "$modulesdir" /lib/modules.tmp
+rc-service modloop stop
+rm -r /lib/modules
+mv /lib/modules.tmp /lib/modules
+
+if [ -n "$DO_UMOUNT" ]; then
+ umount "$modloop_media"
+fi
diff --git a/libalpine.sh.in b/libalpine.sh.in
index 75b94ae..3185b55 100644
--- a/libalpine.sh.in
+++ b/libalpine.sh.in
@@ -286,3 +286,14 @@ ask_which() {
echo "'$resp' is not a valid choice."
done
}
+
+find_modloop_media() {
+ devnum=$(mountpoint -d /.modloop) || return
+ test -n "$devnum" || return
+ modloop_file=$(cat /sys/dev/block/$devnum/loop/backing_file) || return
+ test -n "$modloop_file" || return
+ # assume that device name and mount point don't contain spaces
+ modloop_media=$(df "$modloop_file" | awk 'NR==2{print $6}') || return
+ test -n "$modloop_media" || return
+ echo "$modloop_media"
+}
diff --git a/setup-disk.in b/setup-disk.in
index c31b0b6..656b5bc 100644
--- a/setup-disk.in
+++ b/setup-disk.in
@@ -1336,22 +1336,14 @@ while [ -z "$disks" ]; do
[ -n "$disks" ] && break
# ask to unmount the boot mmc for rpi and similar
- modloop_media=$(grep -h '^/media.*/modloop.*' /sys/block/*/loop/backing_file 2>/dev/null | cut -d/ -f1-3)
+ modloop_media=$(find_modloop_media)
- if [ -z "$modloop_media" ] || ! ask_yesno "No avaliable disks found. Unmount $modloop_media and retry? (y/n)" n; then
+ if [ -z "$modloop_media" ] || ! ask_yesno "No disks available. Try boot media $modloop_media? (y/n)" n; then
[ -z "$QUIET" ] && echo "No disks found." >&2
exit 0
fi
- # save kernel modules, stop modloop and umount boot media
- mkdir -p /lib/modules.tmp \
- && echo -n "Copying kernel modules..." \
- && cp -a /lib/modules/* /lib/modules.tmp/ \
- && echo "ok" \
- && rc-service modloop stop \
- && umount $modloop_media \
- && rm /lib/modules \
- && mv /lib/modules.tmp /lib/modules
+ DO_UMOUNT=1 modloop_media=$modloop_media copy-modloop
done
if [ $# -gt 0 ]; then