pthbs

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

pthbs-makegen-downloads (640B)


      1 #!/bin/sh
      2 format=$1
      3 shift || exit $?
      4 exec awk -v format="$format" -v single_quote="'" '
      5 function q(s) {  # quote string for sh
      6 	gsub(single_quote, single_quote "\\" single_quote single_quote, s)
      7 	return single_quote s single_quote
      8 }
      9 
     10 function fatal(msg) {
     11 	printf "FATAL: pthbs-makegen: %s %s:%d: \"%s\"\n", msg, FILENAME, FNR, $0 >"/dev/stderr"
     12 	exit 1
     13 }
     14 
     15 /^$/ { next }
     16 /^#/ { next }
     17 
     18 /^[0-9a-f]{64} [0-9]+ /{
     19 	printf "%s:\n", "$(cache)/make/file."format"."$1".downloaded"
     20 	printf "\tpthbs-download "format
     21 	for(n=1; n<=NF; n++){
     22 		printf " %s", q($n)
     23 	}
     24 	printf "\n\t%s\n\n", "touch "q("$@")
     25 	next
     26 }
     27 
     28 {
     29 	fatal("unexpected line")
     30 }
     31 ' "$@"