Debian Codegraph @

debian/local/setup-translators

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # Set up device nodes and /servers translators.
3 #
4 # Use cases:
5 # - from d-i's /libexec/runsystem, to create a minimal set of device nodes
6 # and translators for the installer environment;
7 # - from debootstrap on initial installation, to create device and server
8 # nodes before /dev and /servers are firmlinked to the host system.
9 # - from hurd.postinst, on upgrade, where only non-existant nodes should be
10 # created, and the other ones should be left alone.
11
12
13 PATH=/bin:/sbin:/usr/bin:/usr/sbinscip-shell filesystem . . `/bin:/sbin:/usr/bin:/usr/sbin`.
14 export PATH
15
16 usagescip-shell shell hurd 1:0.9.git20260527-1 usage(). () {
17 catscip-shell system . . cat. >&2 <<EOU
18 Usage: $0 [OPTIONS]
19 Set up device nodes and /servers translators.
20
21 -k, --keep-active Keep active translators running
22 -K, --keep-all Don't even set passive translators on existing files
23 -m, --minimal Create a minimal subset of nodes only
24 -p, --parted Prefer parted stores for partition devices
25
26 At least one of -k or -K must be given.
27 EOU
28 }
29
30 # Parse command-line arguments
31 REPLACE=
32 MDFLAGS=
33 MINIMAL=
34 while [scip-shell system . . `[`. $# -gt 0 ]; do
35 case "$1" in
36 -k|--keep-active)
37 MDFLAGS="$MDFLAGS -k"
38 REPLACE=y
39 shift;;
40 -K|--keep-all)
41 MDFLAGS="$MDFLAGS -K"
42 REPLACE=n
43 shift;;
44 -m|--minimal)
45 MINIMAL=y
46 shift;;
47 -p|--parted)
48 MDFLAGS="$MDFLAGS -p"
49 shift;;
50 *)
51 usagescip-shell shell hurd 1:0.9.git20260527-1 usage().
52 exit 1;;
53 esac
54 done
55
56 if [scip-shell system . . `[`. -z "$REPLACE" ]; then
57 usagescip-shell shell hurd 1:0.9.git20260527-1 usage().
58 exit 1
59 fi
60
61 # Usage: foldsubst <pat> xxxx yyyy zzzz ...
62 # <pat> is substituted for every character of xxxx with sed, the character in
63 # question being accessible as a '\0' in <pat>, and the result is used as the
64 # new pattern to handle the remaining arguments.
65 foldsubstscip-shell shell hurd 1:0.9.git20260527-1 foldsubst(). () {
66 [scip-shell system . . `[`. "$2" ] || { echoscip-shell system . . echo. $1; return; }
67 expanded=$(echoscip-shell system . . echo. "$2" | sedscip-shell system . . sed. "s/./ $1/g"); shift 2
68 foldsubstscip-shell shell hurd 1:0.9.git20260527-1 foldsubst(). "$expanded" $@;
69 }
70
71 # Verbosely attach a translator.
72 stscip-shell shell hurd 1:0.9.git20260527-1 st(). () {
73 node=$1
74 cmdl=$2
75 name=${3:-$cmdl}
76
77 echoscip-shell system . . echo. -n " $name"
78 if [scip-shell system . . `[`. "$REPLACE" = y ] || ! showtrans $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 ; then
79 # Work around a bug in ext2fs, which crashes if a non-empty
80 # file is turned into a symlink through settrans, by clearing
81 # the passive translator first.
82 settrans -ck $node
83 settrans -ck $node $cmdl
84 fi
85 }
86
87 # Verbosely create device nodes, with some help from foldsubst.
88 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). () {
89 pattern=$1; shift
90 sedrepl=$(echoscip-shell system . . echo. $pattern | sedscip-shell system . . sed. -e 's/X/\\0/' -e 's/Y/\\\\0/')
91 devs=$(foldsubstscip-shell shell hurd 1:0.9.git20260527-1 foldsubst(). "$sedrepl" $@)
92
93 echoscip-shell system . . echo. -n " $pattern"
94 /sbin/MAKEDEVscip-shell filesystem . . `/sbin/MAKEDEV`. $MDFLAGS $devs
95 }
96
97
98 echoscip-shell system . . echo. -n "Setting up translators:"
99 cd /serversscip-shell filesystem . . `/servers`.
100 mkdirscip-shell system . . mkdir. -p socket
101 mkdirscip-shell system . . mkdir. -p bus
102
103 stscip-shell shell hurd 1:0.9.git20260527-1 st(). exec /hurd/execscip-shell filesystem . . `/hurd/exec`.
104 touchscip-shell system . . touch. default-pager 2> /dev/nullscip-shell filesystem . . `/dev/null`.
105 chmodscip-shell system . . chmod. 755 default-pager
106 stscip-shell shell hurd 1:0.9.git20260527-1 st(). default-pager /hurd/proxy-defpagerscip-shell filesystem . . `/hurd/proxy-defpager`.
107 stscip-shell shell hurd 1:0.9.git20260527-1 st(). socket/1 /hurd/pflocalscip-shell filesystem . . `/hurd/pflocal`.
108 stscip-shell shell hurd 1:0.9.git20260527-1 st(). socket/local '/hurd/symlink 1scip-shell filesystem . . `/hurd/symlink 1`.' '(+link)'
109 stscip-shell shell hurd 1:0.9.git20260527-1 st(). socket/2 '/hurd/pfinet -6 /servers/socket/26scip-shell filesystem . . `/hurd/pfinet -6 /servers/socket/26`.' inet
110 stscip-shell shell hurd 1:0.9.git20260527-1 st(). socket/inet '/hurd/symlink 2scip-shell filesystem . . `/hurd/symlink 2`.' '(+link)'
111 stscip-shell shell hurd 1:0.9.git20260527-1 st(). socket/26 '/hurd/pfinet -4 /servers/socket/2scip-shell filesystem . . `/hurd/pfinet -4 /servers/socket/2`.' inet6
112 stscip-shell shell hurd 1:0.9.git20260527-1 st(). socket/inet6 '/hurd/symlink 26scip-shell filesystem . . `/hurd/symlink 26`.' '(+link)'
113 stscip-shell shell hurd 1:0.9.git20260527-1 st(). bus/pci /hurd/pci-arbiterscip-shell filesystem . . `/hurd/pci-arbiter`.
114 stscip-shell shell hurd 1:0.9.git20260527-1 st(). acpi /hurd/acpiscip-shell filesystem . . `/hurd/acpi`.
115 stscip-shell shell hurd 1:0.9.git20260527-1 st(). shutdown /hurd/shutdownscip-shell filesystem . . `/hurd/shutdown`.
116 touchscip-shell system . . touch. startup 2> /dev/nullscip-shell filesystem . . `/dev/null`.
117
118 if [scip-shell system . . `[`. -z "$MINIMAL" ]; then
119 stscip-shell shell hurd 1:0.9.git20260527-1 st(). password /hurd/passwordscip-shell filesystem . . `/hurd/password`.
120 stscip-shell shell hurd 1:0.9.git20260527-1 st(). crash-kill '/hurd/crash --killscip-shell filesystem . . `/hurd/crash --kill`.' crash-kill
121 stscip-shell shell hurd 1:0.9.git20260527-1 st(). crash-suspend '/hurd/crash --suspendscip-shell filesystem . . `/hurd/crash --suspend`.' crash-suspend
122 stscip-shell shell hurd 1:0.9.git20260527-1 st(). crash-dump-core '/hurd/crash --dump-corescip-shell filesystem . . `/hurd/crash --dump-core`.' crash-dump-core
123 if [scip-shell system . . `[`. "$(unamescip-shell system . . uname. -m)" = x86_64 ]; then
124 stscip-shell shell hurd 1:0.9.git20260527-1 st(). crash '/hurd/symlink crash-killscip-shell filesystem . . `/hurd/symlink crash-kill`.' crash
125 else
126 stscip-shell shell hurd 1:0.9.git20260527-1 st(). crash '/hurd/symlink crash-dump-corescip-shell filesystem . . `/hurd/symlink crash-dump-core`.' crash
127 fi
128 fi
129
130 echoscip-shell system . . echo. .
131
132
133 echoscip-shell system . . echo. -n "Creating device nodes:"
134 cd /devscip-shell filesystem . . `/dev`.
135
136 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). fd
137 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). fdX 01
138 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). std
139 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). vcs
140 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). hdX 012345
141 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). hdXsY 012345 123456789
142 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). hdXs1Y 012345 0123456
143 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). sdX 012345
144 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). sdXsY 012345 123456789
145 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). sdXs1Y 012345 0123456
146 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). rumpdisk
147 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). wdX 012345
148 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). wdXsY 012345 123456789
149 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). wdXs1Y 012345 0123456
150 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). rumpusbdisk
151 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). udX 012345
152 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). udXsY 012345 123456789
153 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). udXs1Y 012345 0123456
154 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). cdX 01
155 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). ucdX 01
156 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). netdde
157 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). ethX 0123
158 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). pseudo-root
159 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). rtc
160
161 [scip-shell system . . `[`. -r /var/lib/random-seedscip-shell filesystem . . `/var/lib/random-seed`. ] || datescip-shell system . . date. ${SOURCE_DATE_EPOCH:+--date=@${SOURCE_DATE_EPOCH}} > /var/lib/random-seedscip-shell filesystem . . `/var/lib/random-seed`. 2> /dev/nullscip-shell filesystem . . `/dev/null`.
162 chmodscip-shell system . . chmod. 600 /var/lib/random-seedscip-shell filesystem . . `/var/lib/random-seed`.
163
164 if [scip-shell system . . `[`. "$MINIMAL" ]; then
165 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). loopX 0123
166 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). ttyX 1234
167 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). ptypX 0123456789
168 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). comX 0123
169 else
170 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). loopX 01234567
171 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). ttyX 123456
172 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). ptyp
173 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). ptyq
174 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). lprX 012
175 mdscip-shell shell hurd 1:0.9.git20260527-1 md(). comX 0123
176 fi
177
178 stscip-shell shell hurd 1:0.9.git20260527-1 st(). random "/hurd/random --seed-file /var/lib/random-seedscip-shell filesystem . . `/hurd/random --seed-file /var/lib/random-seed`." random
179 stscip-shell shell hurd 1:0.9.git20260527-1 st(). urandom "/hurd/random --seed-file /var/lib/random-seed --fastscip-shell filesystem . . `/hurd/random --seed-file /var/lib/random-seed --fast`." urandom
180
181 stscip-shell shell hurd 1:0.9.git20260527-1 st(). kbd '/hurd/symlink cons/kbdscip-shell filesystem . . `/hurd/symlink cons/kbd`.' kbd
182 stscip-shell shell hurd 1:0.9.git20260527-1 st(). mouse '/hurd/symlink cons/mousescip-shell filesystem . . `/hurd/symlink cons/mouse`.' mouse
183 ! [scip-shell system . . `[`. -L shm ] || rmscip-shell system . . rm. -f shm
184 ! [scip-shell system . . `[`. -d shm ] || rmdirscip-shell system . . rmdir. shm
185
186 # TODO let initscript make it a tmpfs when tmpfs open/mmap/close/unlink/dereference crash is fixed, see #923078 and /lib/init/tmpfs.sh
187 stscip-shell shell hurd 1:0.9.git20260527-1 st(). shm '/hurd/symlink /tmpscip-shell filesystem . . `/hurd/symlink /tmp`.' shm
188
189 echoscip-shell system . . echo. .
190