Commit 0b9c3720 authored by Kevin Daudt's avatar Kevin Daudt 💻

main/lxc-templates-legacy: account of existing nodes in alpine template

Creating an alpine-linux container errors out with the error:

> 'mknod: dev/zero: File exists'
parent dc626268
Pipeline #78431 passed with stages
in 1 minute and 32 seconds
......@@ -2,7 +2,7 @@
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=lxc-templates-legacy
pkgver=3.0.3
pkgrel=1
pkgrel=2
pkgdesc="Legacy LXC container templates"
url="https://linuxcontainers.org"
arch="noarch"
......@@ -11,6 +11,7 @@ depends="bash tar"
subpackages="$pkgname-alpine"
source="https://linuxcontainers.org/downloads/lxc/lxc-templates-$pkgver.tar.gz
add-mips64-s390x.patch
alpine-skip-mknod-when-existing.patch
"
builddir="$srcdir/lxc-templates-$pkgver"
......@@ -48,4 +49,5 @@ alpine() {
}
sha512sums="3e9d5304f5e06580eeb766570ddfebb0c80061c2d7e47c9ea37d834fe0cf4fabe7eedd667e4937df3f2451bc3e7aa1e98a1b386f3b19964dc218ff0e21011632 lxc-templates-3.0.3.tar.gz
e450bbf3219971955dbc6ac4388d7fea84288a55214ed47dcca93df31eb0ce119321072c5d01423709e3437e2148096947a05c2f4afa28ff8eb1277ebf40646a add-mips64-s390x.patch"
e450bbf3219971955dbc6ac4388d7fea84288a55214ed47dcca93df31eb0ce119321072c5d01423709e3437e2148096947a05c2f4afa28ff8eb1277ebf40646a add-mips64-s390x.patch
10218eb23e70af82c3e059e462b3decd7af47bf7bc26324ed30848d18e33a317489cc2b92bb91f3a82c5fac6b3d3649cec452df80f2cca2bd2ce0e8eb2b4fd0f alpine-skip-mknod-when-existing.patch"
Description: Some device nodes already exist, causing mknod to return an error
--- a/templates/lxc-alpine.in
+++ b/templates/lxc-alpine.in
@@ -273,24 +273,38 @@
--update-cache --initdb add $packages
}
+mkdev() {
+ 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
- mknod -m 666 dev/zero c 1 5
- mknod -m 666 dev/full c 1 7
- mknod -m 666 dev/random c 1 8
- mknod -m 666 dev/urandom c 1 9
+ mkdev -m 666 dev/zero c 1 5
+ mkdev -m 666 dev/full c 1 7
+ mkdev -m 666 dev/random c 1 8
+ mkdev -m 666 dev/urandom c 1 9
local i; for i in $(seq 0 4); do
- mknod -m 620 dev/tty$i c 4 $i
+ mkdev -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
+ mkdev -m 666 dev/tty c 5 0
chown 0:5 dev/tty # root:tty
- mknod -m 620 dev/console c 5 1
- mknod -m 666 dev/ptmx c 5 2
+ mkdev -m 620 dev/console c 5 1
+ mkdev -m 666 dev/ptmx c 5 2
chown 0:5 dev/ptmx # root:tty
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment