pthbs

Packaging Through Hashed Build Scripts
git clone https://ccx.te2000.cz/git/pthbs
Log | Files | Refs | Submodules | README

pthbs-link-from-index (543B)


      1 #!/bin/sh -e
      2 link_dir=$1
      3 shift
      4 test -d "$link_dir" || exit 1
      5 exec >"$link_dir/.local.new"
      6 for index_file in "$@"; do
      7 	exec <"$index_file"
      8 	index_base=$(realpath "$index_file")
      9 	index_base=$(dirname "$index_base")
     10 	while IFS= read -r line; do
     11 		origin=$link_dir/${line%%  *}
     12 		target=${line#*  }
     13 		case $target in
     14 			(/*) ;;
     15 			(*) target=$index_base/$target
     16 		esac
     17 		if test -L "$origin"; then
     18 			rm "$origin"
     19 		fi
     20 		ln -s "$target" "$origin"
     21 	done
     22 	printf '%s  %s\n' "${line%%  *}" "$target"
     23 done
     24 mv "$link_dir/.local.new" "$link_dir/.local"