commit bc1ee0ae9bef71dc33033c847cad4a0198931d71
parent 72b5759ce7a532d4ccacae193adcd7657d422c76
Author: ccx <root@dorje.wpr.cz>
Date: Mon, 29 Mar 2021 18:07:16 +0200
Don't generate scripts into skel, change them in target directory.
Diffstat:
M | install | | | 32 | ++++++++++++++++++++------------ |
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/install b/install
@@ -7,6 +7,10 @@ dst=$1
test -d "$sm_dst_s6_rc" || exit 1
test -d "$sm_dst_package" || exit 1
+cmd=$sm_dst_package/command
+
+src=$("$cmd/s6-dirname" "$0")
+test -d "$src/skel" || exit 1
q() {
"$sm_dst_package/command/s6-quote" "$@"
@@ -17,15 +21,26 @@ q_s6_rc=$(q "$sm_dst_s6_rc") || exit $?
q_package=$(q "$sm_dst_package") || exit $?
qc=$q_package/command
-cat >skel/rc.init <<EOF
-#!/$sm_dst_package/command/execline -S1
+# Generate init
+"$sm_dst_package/command/s6-linux-init-maker" \
+ -p "/command:/usr/local/bin:/usr/bin:/bin" \
+ -G "/usr/bin/env TERM=linux /sbin/getty 38400 tty9" \
+ -t 1 \
+ -f "$src/skel" \
+ -c "$dst/init" \
+ "$dst/init" || exit $?
+
+# Rewrite dynamically generated scripts
+"$cmd/s6-cat" >"$dst/init/scripts/rc.init" <<EOF
+#!$sm_dst_package/command/execline -S1
export TERM "linux"
if { $qc/s6-rc-init -d -c $q_s6_rc/compiled /run/service }
$q_init/scripts/runlevel \$1
EOF
+r=$?; if test 0 -ne $r; then exit $r; fi
-cat >skel/runlevel <<EOF
-#!/$sm_dst_package/command/execline -S1
+"$cmd/s6-cat" >"$dst/init/scripts/runlevel" <<EOF
+#!$sm_dst_package/command/execline -S1
export TERM "linux"
# The requested runlevel is in "\$1" but currently ignored.
@@ -44,11 +59,4 @@ ifelse -X {
foreground { $qc/s6-rc -v 2 -t 600000 -- change ok-all-but-tty }
$qc/s6-rc -v 2 -t 600000 -- change ok-all
EOF
-
-exec "$sm_dst_package/command/s6-linux-init-maker" \
- -p "/command:/usr/local/bin:/usr/bin:/bin" \
- -G "/usr/bin/env TERM=linux /sbin/getty 38400 tty9" \
- -t 1 \
- -f ./skel \
- -c "$dst/init" \
- "$dst/init"
+r=$?; if test 0 -ne $r; then exit $r; fi