carbon-config

config submodule of carbon-core-system
git clone https://ccx.te2000.cz/git/carbon-config
Log | Files | Refs

install (1447B)


      1 #!/bin/zsh
      2 setopt no_unset warn_create_global extended_glob
      3 zmodload -F zsh/stat b:zstat || exit $?
      4 zmodload -m -F zsh/files b:zf_\* || exit $?
      5 #zmodload zsh/zutil || exit $?  # for zparseopts
      6 #zmodload zsh/datetime || exit $?  # for $EPOCHREALTIME
      7 
      8 die_ret() {
      9 	local ret
     10 	ret=$1
     11 	shift
     12 	printf >&2 '%s\n' "$@"
     13 	exit $ret
     14 }
     15 die() {
     16 	die_ret 1 "$@"
     17 }
     18 die100() {  # 100: wrong usage
     19 	die_ret 100 "$@"
     20 }
     21 die111() {  # 111: system call failed
     22 	die_ret 111 "$@"
     23 }
     24 
     25 install_to_all() {
     26 	local orig_cwd=$PWD
     27 	cd $ALL_DIR || exit $?
     28 	mkdir s6-rc-source || exit $?
     29 	./command/fsapply ./s6-rc-source $PWD/conf/s6-rc.fileset || exit $?
     30 	[[ -f ./s6-rc-source/ok-all/type ]] || die111 \
     31 		"Failed to generate s6-rc source directory"
     32 	./command/s6-rc-compile ./s6-rc-db ./s6-rc-source || exit $?
     33 	./init-maker/install $PWD || exit $?
     34 	local cmd
     35 	for cmd in init/bin/*; do
     36 		s6-ln -s ../$cmd ./command/$cmd:t || exit $?
     37 	done
     38 	cat >motd <<EOF
     39 Welcome to $(<conf/static/etc/hostname)!
     40 This system has configuration managed in $orig_cwd (last change on $(GIT_DIR=$orig_cwd/.git git show -s --pretty='format:%ai by %an'))
     41 EOF
     42 }
     43 typeset -f -t install_to_all
     44 
     45 typeset -g ALL_DIR=$0:h:h
     46 if [[ $ALL_DIR == /versions/all.* ]]; then
     47 	path=( $ALL_DIR/command "$path[@]" )
     48 	#fpath=( $ALL_DIR/zsh-functions "$fpath[@]" )
     49 	install_to_all || exit $?
     50 else
     51 	die100 "Fatal: ${(qqq)0}: This script needs to be run from versioned directory as a part of installation procedure."
     52 fi