commit e175dd13a14ab5ba7bf1d24fdc7eeb5572f2f9bb
parent 6c5cecc27709a0d4600ef509790f735ba7584cd4
Author: ccx <root@dorje.wpr.cz>
Date: Mon, 29 Mar 2021 18:11:06 +0200
Put all generated files that depend on ./package into the main directory.
Diffstat:
M | install | | | 68 | ++++++++++++++++++++++++++++++++++++++------------------------------ |
1 file changed, 38 insertions(+), 30 deletions(-)
diff --git a/install b/install
@@ -37,25 +37,52 @@ install_package() {
exec env slashpackage=${sm_dst[$submodule]} ./install-all
}
-install_rc() {
+install_unpack() {
local dst=${sm_dst[$submodule]}
local cmd=${sm_dst[package]}/command
- mkdir -p $dst/s6-rc/source || exit $?
- git archive --format=tar ${sm_commit[$submodule]} | tar -xC $dst/s6-rc/source
+ s6-mkdir -p $dst || exit $?
+ git archive --format=tar ${sm_commit[$submodule]} | tar -xC $dst
((${(j.|.)pipestatus})) && exit 1 # exit if git archive or tar exited non-zero
- $cmd/s6-rc-compile $dst/s6-rc/compiled $dst/s6-rc/source || exit $?
}
-install_init() {
- mkdir -p ${sm_dst[$submodule]} || exit $?
- ./install ${sm_dst[$submodule]} || exit $?
+ln_sub() {
+ s6-ln -s ../${${sm_dst[$1]}:t} ${2:-$1} || exit $?
+}
+ln_from_sub() {
+ s6-ln -s ../${${sm_dst[$1]}:t}/$2 $3 || exit $?
+}
+ln_sub_command() {
+ local f
+ for f in ${${sm_dst[$1]}:}/{command,bin}/*(N); do
+ s6-ln -s ../$f ./command/ || exit $?
+ done
+}
+install_dot() {
+ local s f
+ # export sm_dst_* variables for each submodule
+ for s in "${(k@)sm_dst}"; do
+ eval "export sm_dst_${submodule//-/_}"='$sm_dst[$submodule]'
+ done
+
+ s6-mkdir -p command || exit $?
+ ln_from_sub package package package
+ ln_sub_command package
+ ln_sub s6-rc s6-rc-source
+ ./command/s6-rc-compile ./s6-rc-db ./s6-rc-source || exit $?
+ ln_sub init init-maker
+ ./init-maker/install . || exit $?
+ local f
+ for f in init/{command,bin}/*(N); do
+ s6-ln -s ../$f ./command/ || exit $?
+ done
}
install_submodule() {
case $submodule in
(package) install_package;;
- (s6-rc) install_rc;;
- (init) install_init;;
+ (s6-rc) install_unpack;;
+ (init-maker) install_unpack;;
+ (.) install_dot;;
(*) echo >&2 "unhandled submodule: ${(qqq)submodule}";;
esac
}
@@ -74,24 +101,6 @@ make_installed() {
}
typeset -f -t make_installed
-check_union() {
- [[ -f ${sm_dst[.]}/.done ]]
-}
-make_union() {
- mkdir -p ${sm_dst[.]} || exit $?
- local sm union_from f
- for sm union_from in "${(kv@)sm_dst}"; do
- if [[ $sm == . ]]; then
- continue
- fi
- for f in $union_from/*; do
- ln -s ../${union_from:t}/${f:t} ${sm_dst[.]}/ || exit $?
- done
- done
- touch ${sm_dst[.]}/.done
-}
-typeset -f -t make_union
-
check_current() {
local -A stat_out
[[ -L /current ]] || return 1
@@ -101,7 +110,7 @@ check_current() {
make_current() {
s6-ln -s -f -n "${${sm_dst[.]}#/}" /current
}
-typeset -f -t make_union
+typeset -f -t make_current
submodule() {
local -a do_commit
@@ -116,7 +125,6 @@ submodule() {
sm_dst[.]=/versions/all.${sm_commit[.]}
else
sm_dst[$submodule]=/versions/$submodule.${sm_commit[$submodule]}
- eval "export sm_dst_${submodule//-/_}"='$sm_dst[$submodule]'
fi
}
typeset -f -t submodule
@@ -141,5 +149,5 @@ submodule=init
require installed
submodule=.
-require union
+require installed
require current