mrrl

Minimal Reliable Reproducible Linux
git clone https://ccx.te2000.cz/git/mrrl
Log | Files | Refs | Submodules | README

genlinks_mini (2150B)


      1 {% extends "generic" %}
      2 {%- import "package_sets" as ps -%}
      3 {%- block template_deps -%}
      4 {{ ps.busybox_common() }}
      5 #+{{pkg_install_name(findutils_impl|default("busybox-findutils"))}}
      6 #+{{pkg_install_name(awk_impl|default("nawk"))}}
      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_all_rules -%}
     33 {%- block genlinks_rules %}
     34 {%- endblock genlinks_rules %}
     35 $2 == "env" { link($0); next }
     36 $2 == ".env-template" { link($0); next }
     37 
     38 $2 == "{{bindir}}" { link($0); next }
     39 $2 == "{{sbindir}}" { link($0); next }
     40 $2 == "bin" { link(s1("{{bindir}}", $0)); next }
     41 $2 == "sbin" { link(s1("{{sbindir}}", $0)); next }
     42 
     43 $2 == "{{dynlibdir}}" { link($0); next }
     44 $2 == "{{libdir}}" { link($0); next }
     45 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("{{libdir}}", $0)); next }
     46 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("{{dynlibdir}}", $0)); next }
     47 
     48 $2 == "share" && $3 == "info" { link(s1("{{infodir}}", r1($0))); next }
     49 $2 == "share" && $3 == "man" { link(s1("{{mandir}}", r1($0))); next }
     50 $2 == "share" && $3 == "doc" { link(s1("{{docdir}}", r1($0))); next }
     51 
     52 $2 == "{{configdir}}" { link($0); next }
     53 $2 == "{{mandir}}" { link($0); next }
     54 $2 == "{{infodir}}" { link($0); next }
     55 $2 == "{{docdir}}" { link($0); next }
     56 $2 == "{{datadir}}" { link($0); next }
     57 $2 == "{{includedir}}" { link($0); next }
     58 {% endblock genlinks_all_rules %}
     59 
     60 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
     61 
     62 END {
     63 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
     64 	retcode = 0
     65 	for(fname in x) {
     66 		if(x[fname]) {
     67 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
     68 			retcode = 3
     69 		}
     70 	}
     71 	exit retcode
     72 }' >.install-links.new
     73 mv .install-links.new .install-links
     74 {% endblock finish %}