123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #!/bin/bash
-
-
-
- mkit_import ini
-
- __deploy_item() {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- local src=$1
- local dst=$2
- local mode=${3:-$MKIT_DEFAULT_MODE}
- local item
- if test -d "$src"; then
- find "$src" -type f \
- | while read -r item; do
- [[ $item =~ .skel$ ]] \
- && grep -q "${item%.skel}" "$MKIT_LOCAL/built.lst" \
- && continue
- __deploy_item "$item" "$dst${item#$src}" "$mode"
- done
- else
- test "$mode" == "SRC" && mode=$(stat -c "%a" "$src")
- __maybe install -DTvm "$mode" "$src" "$dst"
- fi
- }
-
- __get_dst() {
-
-
-
- local grp=$1
- local src=$2
- local dst=$3
- test -n "$dst" || dst=${src##*/}
- echo "$(__get_root "$grp")/$dst"
- }
-
- __get_root() {
-
-
-
- local grp=$1
- local root
- local destdir
- root=$(ini 1value "roots:$grp")
- destdir=$(ini 1value ENV:DESTDIR)
- destdir=${destdir%/}
- case $destdir:$root in
- *:) die "missing in config.ini: roots:$grp" ;;
- :*) echo "$root" ;;
- *:*) echo "$destdir/$root" ;;
- esac
- }
-
- __maybe() {
-
-
-
- debug "$@"
- local cmd="$1"; shift
- $MKIT_DRY && return
- case "$cmd" in
- cp|rm|rmdir|chmod|mkdir) $cmd "$@" ;;
- install) command -p install "$@" ;;
- *) die "bad command called";;
- esac
- }
-
- install() {
-
-
-
- local group
- local mode
- local src
- local dst
- ini lskeys "files" \
- | sort \
- | uniq \
- | while read -r group; do
- mode=$(ini 1value "modes:$group")
- ini values "files:$group" \
- | while read -r src dst; do
- dst=$(__get_dst "$group" "$src" "$dst")
- __deploy_item "$src" "$dst" "$mode"
- done
- done
- test -f "$MKIT_LOCAL/autoclean" && clean
- true
- }
-
- uninstall() {
-
-
-
- local group
- local src
- local dst
- ini lskeys "files" \
- | sort \
- | uniq \
- | while read -r group; do
- ini values "files:$group" \
- | while read -r src dst; do
- dst=$(__get_dst "$group" "$src" "$dst")
- __maybe rm -vrf "$dst"
- done
- done
- }
|