#!/bin/sh -u # /usr/local/sbin install-split -i "-vDb" -- \ # install split text files RCS='$Revision: 1.46 $'; version(){ cat < This is free software; see the GNU General Public License version 2 or later for copying conditions. There is NO warranty. VRS err_set; } _install(){ if check; then XLS=$( ls xx* )|| err_set&& { rbr_nxt echo "$DG :"| tee $CHG| arkiv $OLD|| err_set;}&& rbr_nxt : "$DG"&& $DG touch -t 200101010000 $NEW&& { [ -z "$DG" ]|| mv $CHG ${CHG}.debug; } fi } _reinstall(){ restor "$NEW" "$OLD";} _uninstall(){ restor "$OLD" "$NEW";} arkiv(){ xargs -r ls 2>&3| $DG cpio -ovF $1 -H newc;} check(){ if [ ! -e $CHG ]; then if [ "$MD5" ]&& [ -e "$MD5" ]; then if [ $MWC -eq `wc -c <$MD5` ]; then md5sum -vc $MD5|| err_set; else error $MD5 size is not $MWC; fi fi else error ${Oi}ed previously\?; fi } evalu(){ eval "$@"|| err_set;} error(){ warn ERROR: "$@"; err_set;} err_get(){ return $errno;} err_set(){ errno=1; return 1;} help(){ echo "USAGE: $P0-[$ONE] [ -C config_file | -o eval_options . . . ] dir" for LR in $ONE; do evalu echo \"\ -$LR\ --\ \$O$LR\";done echo "second line of each file contains: $LN2" err_set; } restor(){ if [ -e $CHG ]; then if [ $2 -ot $1 ]; then arkiv $2 <$CHG|| err_set; err_get&& $DG xargs -r rm -f <$CHG&& $DG cpio -ivmuF $1|| err_set; else error $2 is newer than $1; fi else error not ${Oi}ed; fi } rbr_nxt(){ RBR=$1; NXT="$2"; for XXN in $XLS; do if { read LN1&& read $LN2;}<$XXN&& [ "$DIR" ]&&[ "$BAS" ]&&[ "$PRM" ];then evalu xxprm $PRM; fi; done; err_get&& evalu $ERN; } warn(){ echo "$@" >&2;} opt_c(){ $RBR "$FIL";} opt_i(){ $NXT $Oi "$@" $XXN "$FIL"&& $NXT rm $XXN|| err_set;} opt_s(){ local SYM; $NXT cd "$DIR"|| return 0; for SYM in "$@"; do $RBR "$DIR/$SYM"; $NXT ln -fvs "$BAS" "$SYM"|| err_set; done $NXT cd - >&3; } xxprm(){ FIL="$DIR/$BAS"; OPTIND=1; while getopts "ci:s:$EOP" LR; do [ "$LR" = '?' ]&& break|| opt_$LR ${OPTARG:-}; done; } OH=help; OV=version; Oi=install; Or=re$Oi; Ou=un$Oi; P0="$Oi-split "; CHG=change.list; EOP=; ERN=; LN2="COM DIR BAS PRM"; MD5=; MWC=; NEW=new.cpio; OLD=old.cpio; ONE="H V i r u"; DG=; [ -z "${INSTALL_SPLIT_DEBUG:-}" ]|| DG=warn; errno=0; exec 3<>/dev/null; SN=; hash cat cpio echo install ln md5sum mv rm tee touch wc xargs|| err_set; err_get&& while getopts "C:o:X$ONE" LR; do case $LR in C) . "$OPTARG";; H) $OH;; X) set -x;; V) $OV $RCS;; [iru]) SN=O$LR;; o) evalu $OPTARG;; \?) err_set;; esac|| break; done; shift $(($OPTIND-1)); [ $# -lt 2 ]|| set_err; if err_get; then [ $# -eq 0 ]|| cd "$1"&& evalu echo $P0 \$$SN&& evalu _\$$SN; fi err_get;