Home | History | Annotate | Line # | Download | only in common
      1  1.1  abs #	$NetBSD: list2sh.awk,v 1.1 2009/09/18 09:24:59 abs Exp $
      2  1.1  abs 
      3  1.1  abs BEGIN {
      4  1.1  abs 	printf("cd ${CURDIR}\n");
      5  1.1  abs 	printf("\n");
      6  1.1  abs }
      7  1.1  abs /^$/ || /^#/ {
      8  1.1  abs 	print $0;
      9  1.1  abs 	next;
     10  1.1  abs }
     11  1.1  abs $1 == "COPY" {
     12  1.1  abs 	printf("echo '%s'\n", $0);
     13  1.1  abs 	printf("rm -f ${TARGDIR}/%s\n", $3);
     14  1.1  abs 	printf("cp %s ${TARGDIR}/%s\n", $2, $3);
     15  1.1  abs 	next;
     16  1.1  abs }
     17  1.1  abs $1 == "LINK" {
     18  1.1  abs 	printf("echo '%s'\n", $0);
     19  1.1  abs 	printf("rm -f ${TARGDIR}/%s\n", $3);
     20  1.1  abs 	printf("(cd ${TARGDIR}; ln %s %s)\n", $2, $3);
     21  1.1  abs 	next;
     22  1.1  abs }
     23  1.1  abs $1 == "SYMLINK" {
     24  1.1  abs 	printf("echo '%s'\n", $0);
     25  1.1  abs 	printf("rm -f ${TARGDIR}/%s\n", $3);
     26  1.1  abs 	printf("(cd ${TARGDIR}; ln -s %s %s)\n", $2, $3);
     27  1.1  abs 	next;
     28  1.1  abs }
     29  1.1  abs $1 == "COPYDIR" {
     30  1.1  abs 	printf("echo '%s'\n", $0);
     31  1.1  abs 	printf("(cd ${TARGDIR}/%s && find . ! -name . | xargs /bin/rm -rf)\n",
     32  1.1  abs 	    $3);
     33  1.1  abs 	printf("(cd %s && find . ! -name . | cpio -pdamu ${TARGDIR}/%s)\n", $2,
     34  1.1  abs 	    $3);
     35  1.1  abs 	next;
     36  1.1  abs }
     37  1.1  abs $1 == "SPECIAL" {
     38  1.1  abs 	printf("echo '%s'\n", $0);
     39  1.1  abs 	printf("(cd ${TARGDIR};");
     40  1.1  abs 	for (i = 2; i <= NF; i++)
     41  1.1  abs 		printf(" %s", $i);
     42  1.1  abs 	printf(")\n");
     43  1.1  abs 	next;
     44  1.1  abs }
     45  1.1  abs {
     46  1.1  abs 	printf("echo '%s'\n", $0);
     47  1.1  abs 	printf("echo 'Unknown keyword \"%s\" at line %d of input.'\n", $1, NR);
     48  1.1  abs 	printf("exit 1\n");
     49  1.1  abs 	exit 1;
     50  1.1  abs }
     51  1.1  abs END {
     52  1.1  abs 	printf("\n");
     53  1.1  abs 	printf("exit 0\n");
     54  1.1  abs 	exit 0;
     55  1.1  abs }
     56