aports/main/lxc-templates-legacy/0010-alpine-only-create-missing-device-node.patch
Kaarle Ritvanen 19b3f4211e main/lxc-templates-legacy: upgrade to 3.0.4
and align the patch set with the commit history of the upstream main
branch
2024-12-12 06:39:14 +00:00

54 lines
1.3 KiB
Diff

From 2dc83ba3a28cf7080dfa6c11c5ae4694985bd30f Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Tue, 10 Dec 2024 15:15:28 +0200
Subject: [PATCH 10/11] alpine: only create missing device node
Avoid error out if some of the device nodes exists
---
templates/lxc-alpine.in | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in
index ce08f7f..4404521 100644
--- a/templates/lxc-alpine.in
+++ b/templates/lxc-alpine.in
@@ -304,18 +304,33 @@ install_packages() {
--update-cache --initdb add $packages
}
+_mknod() {
+ while getopts "m:" opt; do
+ case $opt in
+ m) MODE="-m $OPTARG";;
+ \?) return 1;;
+ esac
+ done
+ shift $((OPTIND - 1))
+
+ test -c "$1" && return 0 # device exists
+ test -f "$1" && rm -f "$1" # device is a regular file
+ mknod $MODE $@
+}
+
make_dev_nodes() {
mkdir -p -m 755 dev/pts
mkdir -p -m 1777 dev/shm
local i; for i in $(seq 0 4); do
- mknod -m 620 dev/tty$i c 4 $i
+ _mknod -m 620 dev/tty$i c 4 $i
chown 0:5 dev/tty$i # root:tty
done
- mknod -m 666 dev/tty c 5 0
+ _mknod -m 666 dev/tty c 5 0
chown 0:5 dev/tty # root:tty
- mknod -m 666 dev/ptmx c 5 2
+ _mknod -m 620 dev/console c 5 1
+ _mknod -m 666 dev/ptmx c 5 2
chown 0:5 dev/ptmx # root:tty
}
--
2.47.1