#!/usr/bin/env runawk # Copyright (c) 2007-2008 Aleksey Cheusov # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ############################################################ #env "LC_ALL=C" #use "power_getopt.awk" #use "abort.awk" ############################################################ #.begin-str help # pkg_assignments2pkgpath - makes an ASSIGNMENTS section a part of PKGPATH # usage: pkg_assignments2pkgpath -h|--help\n\ # pkg_assignments2pkgpath [OPTIONS] [files...] # OPTIONS: # -h|--help display this help #.end-str ############################################################ $0 ~ /^PKGPATH=/ { pkgpath = $0 next } $0 ~ /^ASSIGNMENTS=/ { assigns = substr($0, 13) gsub(/ /, ",", assigns) next } NF == 0 { if (assigns != "") print pkgpath ":" assigns body "\n" else print pkgpath body "\n" pkgpath = assigns = body = "" next } { body = body "\n" $0 }