summaryrefslogtreecommitdiff
path: root/update-kernel.in
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-10-27 11:16:20 +0200
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-10-27 11:16:20 +0200
commitef798bbd1a77991aebb105402b7989509c32f40f (patch)
treeb25f1cdef89c1b0f52bf24c8a8dcb943c2ecdd38 /update-kernel.in
parent82ae0882589a9a5dd528059fbfab71fa2a9e8875 (diff)
downloadalpine-conf-ef798bbd1a77991aebb105402b7989509c32f40f.zip
update-kernel: override options for flavor, features, and packages
Diffstat (limited to 'update-kernel.in')
-rw-r--r--update-kernel.in71
1 files changed, 52 insertions, 19 deletions
diff --git a/update-kernel.in b/update-kernel.in
index 3a3b4a7..35a9375 100644
--- a/update-kernel.in
+++ b/update-kernel.in
@@ -9,16 +9,47 @@
# Copyright (c) 2014 Kaarle Ritvanen
-TMPDIR=
-SIGNALS="HUP INT TERM"
SCRIPT=update-kernel
VIRTUAL=.tmp-$SCRIPT
-
-DESTDIR=$1
+FLAVOR=
MNTDIR=
+PACKAGES=
+SIGNALS="HUP INT TERM"
+TMPDIR=
+features=
+
+OPTS=$(getopt -l flavor:,feature:,package: -n $SCRIPT -o f:F:p: -- "$@")
+eval set -- "$OPTS"
+while :; do
+ case "$1" in
+ -f|--flavor)
+ FLAVOR=$2
+ ;;
+ -F|--feature)
+ features="$features $2"
+ ;;
+ -p|--package)
+ PACKAGES="$PACKAGES $2"
+ ;;
+ --)
+ break
+ ;;
+ esac
+ shift 2
+done
+
+DESTDIR=$2
+
+
+error() {
+ echo "$1" >&2
+ exit 1
+}
if [ -z "$DESTDIR" ]; then
+ [ "$FLAVOR" ] && error "Cannot specify flavor when updating the current kernel"
+
while read MOUNT; do
set -- $MOUNT
[ $2 = /.modloop ] || continue
@@ -27,10 +58,7 @@ if [ -z "$DESTDIR" ]; then
break
done < /proc/mounts
- if [ -z "$MNTDIR" ]; then
- echo "Module loopback device not mounted" >&2
- exit 1
- fi
+ [ "$MNTDIR" ] || error "Module loopback device not mounted"
fi
remount() {
@@ -55,13 +83,13 @@ trap clean_up EXIT $SIGNALS
apk add -qU -t $VIRTUAL mkinitfs squashfs-tools
-. /etc/mkinitfs/mkinitfs.conf
+if [ -z "$features" ]; then
+ . /etc/mkinitfs/mkinitfs.conf
+fi
-FLAVOR=$(uname -r | cut -d - -f 3-)
-KVER_FLAVOR=-$FLAVOR
if [ -z "$FLAVOR" ]; then
- FLAVOR=vanilla
- KVER_FLAVOR=
+ FLAVOR=$(uname -r | cut -d - -f 3-)
+ [ "$FLAVOR" ] || FLAVOR=vanilla
fi
TMPDIR=$(mktemp -dt $SCRIPT.XXXXXX)
@@ -85,13 +113,17 @@ extra_pkgs() {
fi
}
-add_pkgs -U --initdb alpine-base linux-$FLAVOR linux-firmware
-extra_pkgs dahdi-linux-$FLAVOR dahdi-linux
-extra_pkgs xtables-addons-$FLAVOR
+add_pkgs -U --initdb alpine-base "linux-$FLAVOR" linux-firmware $PACKAGES
+if [ -z "$PACKAGES" ]; then
+ extra_pkgs "dahdi-linux-$FLAVOR" dahdi-linux
+ extra_pkgs "xtables-addons-$FLAVOR"
+fi
-KVER=$(ls "$ROOT/lib/modules")
-depmod -b "$ROOT" $KVER
+KVER_FLAVOR=
+[ "$FLAVOR" = vanilla ] || KVER_FLAVOR=-$FLAVOR
+KVER=$(basename $(ls -d "$ROOT"/lib/modules/*"$KVER_FLAVOR"))
+depmod -b "$ROOT" "$KVER"
STAGING=$TMPDIR/boot
@@ -103,7 +135,8 @@ cp -a "$ROOT/lib/modules" "$MODLOOP"
cp -a "$ROOT/lib/firmware" "$MODLOOP/modules"
mksquashfs "$MODLOOP" "$STAGING/$MODIMG" -comp xz
-mkinitfs -q -F "$features squashfs" -b "$ROOT" -o "$STAGING/$FLAVOR.gz" $KVER
+mkinitfs -q -b "$ROOT" -F "$features base squashfs" -o "$STAGING/$FLAVOR.gz" \
+ "$KVER"
cp "$ROOT/boot/vmlinuz$KVER_FLAVOR" "$STAGING/$FLAVOR"