#! /usr/bin/gawk -f # # FILE1 -- The packages to be installed # FILE2 -- The cygwin setup.ini file BEGIN { FS = "(:|[ \t]+)"; # STDERR = "/dev/stderr"; STDERR = "/dev/null"; skip_prev = 1; DS = "#"; } FILENAME==ARGV[1] { delete words num_words = 0; for(i=1; i<=NF; i++) { if($i != "") { num_words++; words[num_words] = $i; # printf("%s--", $i) >STDERR; } } # printf("\n") >STDERR; switch(words[1]) { case "@": skip_prev = 0; cur_package = words[2]; printf("@ %s\n", cur_package) >STDERR; break; case "install": if(!skip_prev) { pkg_path = words[2]; all_packages[pkg_path] = cur_package; printf("install: %s\n", pkg_path) >STDERR; } skip_prev = 0; break; case "[prev]": skip_prev = 1; break; } } FILENAME==ARGV[2] && $1 { i = index($1, PREFIX); if(i > 0) package = substr($1, i+length(PREFIX)); else package = $1; # print " * " package >"/dev/stderr" if( package in all_packages ) print all_packages[package]; }