1# $MirOS: src/distrib/common/list2sh.awk,v 1.1 2006/08/17 19:34:15 tg Exp $ 2# $OpenBSD: list2sh.awk,v 1.12 2002/11/28 03:06:30 deraadt Exp $ 3# $NetBSD: list2sh.awk,v 1.2 1996/05/04 15:45:31 pk Exp $ 4 5BEGIN { 6 printf("cd ${OBJDIR}\n"); 7 printf("\n"); 8} 9/^$/ || /^#/ { 10 print $0; 11 next; 12} 13$1 == "COPY" { 14 printf("echo '%s'\n", $0); 15 printf("test -f ${TARGDIR}/%s && rm -fr ${TARGDIR}/%s\n", $3, $3); 16 printf("cp %s ${TARGDIR}/%s\n", $2, $3); 17 next; 18} 19$1 == "REMOVE" { 20 printf("echo '%s'\n", $0); 21 printf("rm -f ${TARGDIR}/%s\n", $2); 22 next; 23} 24$1 == "STRIP" { 25 printf("echo '%s'\n", $0); 26 printf("test -f ${TARGDIR}/%s && rm -fr ${TARGDIR}/%s\n", $3, $3); 27 printf("cp %s ${TARGDIR}/%s\n", $2, $3); 28 printf("strip ${TARGDIR}/%s\n", $3); 29 next; 30} 31$1 == "LINK" { 32 printf("echo '%s'\n", $0); 33 for (i = 3; i <= NF; i++) { 34 printf("test -f ${TARGDIR}/%s && rm -f ${TARGDIR}/%s\n", $i, $i); 35 printf("(cd ${TARGDIR}; ln %s %s)\n", $2, $i); 36 } 37 next; 38} 39$1 == "SYMLINK" { 40 printf("echo '%s'\n", $0); 41 for (i = 3; i <= NF; i++) { 42 printf("test -f ${TARGDIR}/%s && rm -f ${TARGDIR}/%s\n", $i, $i); 43 printf("(cd ${TARGDIR}; ln -s %s %s)\n", $2, $i); 44 } 45 next; 46} 47$1 == "ARGVLINK" { 48 # crunchgen directive; ignored here 49 next; 50} 51$1 == "SRCDIRS" { 52 # crunchgen directive; ignored here 53 next; 54} 55$1 == "LIBS" { 56 # crunchgen directive; ignored here 57 next; 58} 59$1 == "CRUNCHSPECIAL" { 60 # crunchgen directive; ignored here 61 next; 62} 63$1 == "COPYDIR" { 64 printf("echo '%s'\n", $0); 65 printf("(cd ${TARGDIR}/%s && find . ! -name . | xargs /bin/rm -rf)\n", 66 $3); 67 printf("(cd %s && pax -pe -rw . ${TARGDIR}/%s)\n", $2, $3); 68 next; 69} 70$1 == "SPECIAL" { 71# escaping shell quotation is ugly whether you use " or ', use cat <<'!' ... 72 work=$0; 73 gsub("[\\\\]", "\\\\", work); 74 gsub("[\"]", "\\\"", work); 75 gsub("[$]", "\\$", work); 76 gsub("[`]", "\\`", work); 77 printf("echo \"%s\"\n", work); 78 work=$0; 79 sub("^[ ]*" $1 "[ ]*", "", work); 80 printf("(cd ${TARGDIR}; %s)\n", work); 81 next; 82} 83$1 == "TERMCAP" { 84 printf("echo '%s'\n", $0); 85 printf("(cd ${TARGDIR}; tic -C -x -r -e %s ${TOPDIR}/../share/termtypes/termtypes.master | sed -e '/^#.*/d' -e 's,/usr/share/lib/tabset,/usr/share/tabset,g' -e 's,/usr/lib/tabset,/usr/share/tabset,g' >%s)\n", 86 $2, $3); 87 next; 88} 89$1 == "SCRIPT" { 90 printf("echo '%s'\n", $0); 91 printf("sed -e '/^[ ]*#[ ].*$/d' -e '/^[ ]*#$/d' -e \"s/^ARCH=ARCH$/ARCH=`arch -ks`/\" < %s > ${TARGDIR}/%s\n", 92 $2, $3); 93 next; 94} 95{ 96 printf("echo '%s'\n", $0); 97 printf("echo 'Unknown keyword \"%s\" at line %d of input.'\n", $1, NR); 98 printf("exit 1\n"); 99 exit 1; 100} 101END { 102 printf("\n"); 103 printf("exit 0\n"); 104 exit 0; 105} 106