genlinks (1822B)
1 {% extends "generic" %} 2 {%- block template_deps -%} 3 {%- import "package_sets" as ps -%} 4 {{ ps.busybox_common() }} 5 #+{{pkg_install_name("busybox-findutils")}} 6 #+{{pkg_install_name("busybox-awk")}} 7 {% endblock template_deps %} 8 {%- block finish -%} 9 {{ super() -}} 10 cd "$pthbs_destdir{{versions}}/$pthbs_package" 11 find -type d -o -print | awk -F/ ' 12 BEGIN { 13 {%- block genlinks_begin -%} 14 {% endblock genlinks_begin -%} 15 } 16 17 function r1(s) { 18 sub("^[.]/[^/]*", ".", s) 19 return s 20 } 21 function s1(repl, s) { 22 sub("^[.]/[^/]*", "./"repl, s) 23 return s 24 } 25 function link(src) { 26 x[$0]=0 27 printf "%s\t%s\n", $0, src 28 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 29 } 30 $1!="."{exit 1} 31 32 {% block genlinks_rules -%} 33 {% endblock genlinks_rules %} 34 $2 == "config" { link($0); next } 35 $2 == "keys" { link($0); next } 36 $2 == "zsh" { link($0); next } 37 $2 == "env" { link($0); next } 38 $2 == "command" { link($0); next } 39 $2 == "bin" { link(s1("command", $0)); next } 40 41 $2 == "library.so" { link($0); next } 42 $2 == "library" { link($0); next } 43 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } 44 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("library.so", $0)); next } 45 46 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } 47 48 $2 == "man" { link($0); next } 49 $2 == "info" { link($0); next } 50 $2 == "doc" { link($0); next } 51 $2 == "icons" { link($0); next } 52 $2 == "terminfo" { link($0); next } 53 $2 == "data" { link($0); next } 54 $2 == "include" { link($0); next } 55 56 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } 57 58 END { 59 for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } 60 for(fname in x) { 61 if(x[fname]) { 62 printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" 63 exit 3 64 } 65 } 66 }' >.install-links.new 67 mv .install-links.new .install-links 68 {% endblock finish %}