dpkg-awk/0002755000000000000000000000000011730436474007464 5ustar dpkg-awk/debian/0002755000000000000000000000000011730436474010706 5ustar dpkg-awk/debian/manpages0000644000000000000000000000001311730436466012415 0ustar dpkg-awk.1 dpkg-awk/debian/rules0000755000000000000000000000003611730436474011763 0ustar #!/usr/bin/make -f %: dh $@ dpkg-awk/debian/changelog0000644000000000000000000001167411730436474012567 0ustar dpkg-awk (1.2) unstable; urgency=low * Rename dpkg-awk.lib to dpkg-awk.awk. * Remove shebang line and executable bit from awk include files. * Install awk files in /usr/share/awk instead of /usr/lib/awk. * Simplify dpkg-awk wrapper. * Update debian/copyright to copyright format 1.0. * Update debhelper version to 9. * Convert debian/rules to dh rules.tiny. * Update to Standards-Version 3.9.3 (no changes needed). * Drop unneeded 'Build-Depends-Indep: gawk'. -- Jeroen Schot Tue, 28 Feb 2012 14:41:59 +0100 dpkg-awk (1.1) unstable; urgency=low * New maintainer. (Closes: #635598) * debian/control: - bump Standards-Version to 3.9.2 (no changes needed) - add Depends on ${misc:Debhelper} - add Suggests of dctrl-tools * debian/copyright: - update DEP-5 format to CANDIDATE version (r174) - relicense to BSD-3-clause after approval from Adam Heath and Iulian Udrea (Closes: #133491) * debian/rules: - add build-indep and build-dep targets - remove dh_installdirs, add dh_installmanpages * debian/source/format: - 3.0 'native' -- Jeroen Schot Thu, 04 Aug 2011 10:27:22 +0200 dpkg-awk (1.0.3) unstable; urgency=low * debian/control: - add Vcs-* fields + dpkg-awk is now maintained in a GIT repository (git.debian.org) * debian/rules: - remove commented lines - merge 'rm -f' into dh_clean - rename build-indep target to build-stamp -- Iulian Udrea Fri, 14 Nov 2008 14:55:14 +0000 dpkg-awk (1.0.2) unstable; urgency=low * New maintainer (Closes: #491857). * dpkg-awk.lib: it's AWK instead of shell code. * debian/control: - change the Section to devel - bump Standards-Version to 3.8.0 - bump debhelper version from 1 to 7 and add compat file - add gawk to Build-Depends-Indep * debian/copyright: - switch to new format - debian/* is under the GPL-2 license * debian/rules: update as it was a bit rusty * Add debian/install file. * Fix lintian 'hyphen-used-as-minus-sign'. -- Iulian Udrea Wed, 12 Nov 2008 12:12:00 +0000 dpkg-awk (1.0.1.0.0.2) unstable; urgency=low * NMU * Correct typos in manpage. Closes: #362045, #104331 * Remove 'commented out' -of|--outform option from manpage. Closes: #247460 * Remove conflicts on ancient gawk version. Closes: #64358 * Unset POSIXLY_CORRECT because dpkg-awk needs gawk extensions. Closes: #170375 -- Jeroen Schot Wed, 16 Jul 2008 20:41:17 +0200 dpkg-awk (1.0.1.0.0.1) unstable; urgency=low * NMU * Rebuilt to finish /usr/doc transition. Closes: #322783 -- Joey Hess Tue, 10 Jan 2006 00:01:41 -0500 dpkg-awk (1.0.1) unstable; urgency=low * Oops. It really does need gawk. Closes: #64146, #64538. -- Adam Heath Fri, 12 Jan 2001 01:42:45 -0600 dpkg-awk (1.0.0) frozen unstable; urgency=low * Added conflicts on gawk << 3.0.4. (rc)Closes: #59157 * Removed depends on gawk, as it appears that awk(provided by mawk or gawk) is sufficient. Closes: #52350. -- Adam Heath Mon, 28 Feb 2000 21:13:03 -0600 dpkg-awk (0.9.2) unstable; urgency=low * Added -of|--outform, to specify the output type(normal, and xml). -- Adam Heath Mon, 6 Dec 1999 20:43:41 -0600 dpkg-awk (0.9.1) unstable; urgency=low * Changed priority to optional. Closes: #51977 -- Adam Heath Sun, 5 Dec 1999 20:09:49 -0600 dpkg-awk (0.9) unstable; urgency=low * If a multiline field had no text on the first line, the field name was being doubled. Fixed. * It a colon followed the separating colon in a paragraph, data was lost. Fixed. Closes: #50302 * Added build depends. * Added -n|--numeric which allows one to specify the fields that are numeric in nature. This allows for the comparison done while -s|--sort(ing) to be correct. Closes: #40214 * Added -h|--help option. Closes: #50078 * Now uas /usr/doc -> ../usr/share/doc symlink, txs to debhelper. -- Adam Heath Sat, 4 Dec 1999 05:57:12 -0600 dpkg-awk (0.7.3) unstable; urgency=low * s/dpkg-repack/dpkg-awk/ in the manpage. Closes: #37057, #39389 * Changed priority to optional. Closes: #37332 * Modified to fit with FHS. -- Adam Heath Sun, 8 Aug 1999 04:48:32 -0500 dpkg-awk (0.7.2) unstable; urgency=low * Removed fakeroot from the rules file. closes: #25783 * Removed errant '*' so that it could handle multiple ':' in a line. closes: #34551 * Lintian 1.0 clean. -- Adam Heath Tue, 16 Mar 1999 12:22:14 -0600 dpkg-awk (0.7.1) unstable; urgency=low * Some debugging code was left in, and this messed up register_netscape. -- Adam Heath Fri, 12 Jun 1998 14:53:57 -0500 dpkg-awk (0.7) unstable; urgency=low * First public release. -- Adam Heath Fri, 12 Jun 1998 14:53:57 -0500 dpkg-awk/debian/control0000644000000000000000000000167311730436474012316 0ustar Source: dpkg-awk Section: devel Priority: optional Maintainer: Jeroen Schot Standards-Version: 3.9.3 Build-Depends: debhelper (>= 9) Vcs-Git: git://git.debian.org/git/collab-maint/dpkg-awk.git Vcs-Browser: http://git.debian.org/?p=collab-maint/dpkg-awk.git Package: dpkg-awk Architecture: all Depends: gawk, ${misc:Depends} Suggests: dctrl-tools Description: Gawk script to parse /var/lib/dpkg/{status,available} and Packages This script can parse the dpkg database files. It can do regular expressions on the fields, and only get what you want. It can also be made to output certain fields. As an added bonus, there is an option to sort the output. . 'dpkg-awk "Status: .* installed$" -- Package Version Status' will output all installed packages, with only the listed fields. 'dpkg-awk -f=/var/lib/dpkg/available "Package:^[aA].*" -- Package Version' will output all available packages that start with the letter 'A.' dpkg-awk/debian/compat0000644000000000000000000000000211730436474012102 0ustar 9 dpkg-awk/debian/source/0002755000000000000000000000000011730436466012207 5ustar dpkg-awk/debian/source/format0000644000000000000000000000001511730436466013414 0ustar 3.0 (native) dpkg-awk/debian/install0000644000000000000000000000005411730436474012274 0ustar dpkg-awk /usr/bin/ *.awk /usr/share/awk/ dpkg-awk/debian/copyright0000644000000000000000000000336211730436474012643 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Files: * Copyright: 1998-2001, Adam Heath License: BSD-3-clause Files: debian/* Copyright: 2008-2010, Iulian Udrea 2008, 2011, 2012, Jeroen Schot License: BSD-3-clause License: BSD-3-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. dpkg-awk/dpkg-awk0000755000000000000000000000166611730436474011126 0ustar #!/bin/sh # be sure to chmod +x this! # ./script "fieldname: regex" "fieldname: regex" ... -- # "fieldname" "fieldname" ... # Find all records matching the regex expressions, and output the # requested fieldnames. # The fieldnames can be upper or lowercase. When outputing the # fieldnames, the case used is the same as specified on the # cmd line. # sample cmdline: # # dpkg-awk --sort "Package" "Status: .* installed$" -- ^Description ^Conffiles # --sort(-s) "" # --filename(-f) # dpkg-awk [options] -- # # If the first char is "^", then it is a list of fields *NOT* to output, # otherwise, it will output the listed fields. unset POSIXLY_CORRECT gawk -f /usr/share/awk/getlong.awk -f /usr/share/awk/dpkg-awk.awk \ -- "--exebase=$(basename $0)" "--exedir=$(dirname $0)" "$@" dpkg-awk/dpkg-awk.10000644000000000000000000000365611730436466011264 0ustar .TH DPKG-AWK 1 "Debian Utilities" "DEBIAN" \" -*- nroff -*- .SH NAME dpkg-awk \- Utility to read a dpkg style db file .SH SYNOPSIS \fBdpkg-awk\fP [\fB(\-f|--file) filename\fP] [\fB(\-d|--debug) ##\fP] [\fB(\-s|--sort) list\fP] [\fB(\-rs|--rec_sep) ??\fP] ':' ... -- .. .br .SH DESCRIPTION .I dpkg-awk Parses a dpkg status file (or other similarly formatted file) and outputs the resulting records. It can use regex on the field values to limit the returned records, it can also be told which fields to output, and it can sort the matched fields. .SH OPTIONS .TP .PD 0 .I -f filename .TP .I --file filename .PD The file to parse. The default is /var/lib/dpkg/status. .TP .PD 0 .I -d [#] .TP .I --debug [#] .PD Each time this is specified, it increased the debug level. .TP .PD 0 .I -s field(s) .TP .I --sort field(s) .PD A space or comma separated list of fields to sort on. .TP .PD 0 .I -n field(s) .TP .I --numeric field(s) .PD A space or comma separated list of fields that should be interpreted as numeric in value. .TP .PD 0 .I -rs ?? .TP .I --rec_sep ?? .PD Output this string at the end of each output paragraph. .TP .PD 0 .I -h .TP .I --help .PD Display some help. .TP .I fieldname The fields from the file, that are matched with the regex given. The fieldnames are case insensitive. .TP .I out_fieldname The fields from the file, that are output for each record. If the first field listed begins with .IR ^ , then the list of fields that follows will .I NOT be output. .SH BUGS Be warned that the author has only a shallow understanding of the dpkg packaging system, so there are probably tons of bugs in this program. This program comes with no warranties. If running this program causes fire and brimstone to rain down upon the earth, you will be on your own. This program accesses the dpkg database directly in places, querying for data that cannot be gotten via dpkg. .SH AUTHOR Adam Heath dpkg-awk/dpkg-awk.awk0000644000000000000000000001430311730436474011674 0ustar BEGIN { FS="\n" RS="" ORS="" help="\ -f Read , instead of the default\n\ --filename =? /var/lib/dpkg/status.\n\ \n\ -d Each time this is specified, increase\n\ --debug the debugging output.\n\ \n\ -s Store the output, and sort it based on\n\ --sort =? these fields. Each field is separated\n\ by or .\n\ \n\ -rs Output this string at the end of each\n\ --rec_sep paragraph.\n\ \n\ -n List the fields that should be treated\n\ --numeric numerically for sorting purposes.\n\ " opt_list = ":n :f #d :s :rs :numeric :filename #debug :sort :rec_sep :outform :of" opt_link = "n=numeric f=filename d=debug s=sort rs=rec_sep of=outform" options["rec_sep"] = "\n" options["outform"] = "normal" option_parse(opt_list, opt_link, help, ARGC, ARGV) for (c = 1; c <= ARGC; c++) { if (length(ARGV[c])) { itm = ARGV[c] if ( q == 2) { } if (q == 1) { if (itm == "--") { q = 2 } else { if (match(itm, /^\^/)) { # # Output *ALL* fields, but these. # sub(/^\^/, "", itm) if (!(1 SUBSEP tolower(itm) in outf)) { if(outf[1,0] >= 0) { outf[1,0]++ outf[1,outf[1,0]] = itm outf[1,tolower(itm)] = "" outf[0] = -1 } } } else { # # Output only these fields. # if (!(itm in outf)) { if(outf[0] >= 0) { outf[0]++ outf[outf[0]] = itm outf[itm] = "" outf[1,0] = -1 } } } } } if (q == 0) { # # Perform regex matchs on these fields. # if (itm == "--") { q = 1 } else { if ( p = index(itm,":")){ ndx = tolower(substr(itm,1, p - 1)) val = substr(itm, p + 1) regx[ndx] = val } } } # print "\n" } } split(options["numeric"], numeric_fields, " ") for (c = 1; c <= outf[0]; c++) delete outf[outf[c]] if (options["debug"] >= 1) for (a in outf) print "outf[" a "]=" outf[a] "\n" if (options["debug"] >= 1) print "ARGV[0]='" ARGV[0] "'\n" delete ARGV if (options["debug"] >= 1) for (a in options) print "options[" a "]='" options[a] "'\n" ARGV[1] = "/var/lib/dpkg/status" if ("filename" in options) ARGV[1] = options["filename"] num_fields=0 sort_fields["a"]=0 } function my_split(input, output, a, b, fields, save0) { delete output delete fields save0 = $0 $0 = input num_fields = split(input, fields, "\n") b = 0 if (options["debug"] >= 2) { print "my_split\n" for (a = 1; a <= num_fields; a++) print "fields[" a "]='" fields[a] "'\n" print "done\n" } for (a = 1; a <= num_fields; a++) { if (match(fields[a], /^[^ ].*:.*$/)) { split(fields[a], fld, ":") b = b + 1 output[1,++output[1,0]] = fld[1] output[1,tolower(fld[1])] = "" sub(/^[^:]*: */,"",fields[a]) if(a in numeric_fields) fields[a] = 0 + fields[a] output[tolower(fld[1])] = fields[a] } else { q = output[tolower(fld[1])] output[tolower(fld[1])] = q FS fields[a] delete fields[a] } } $0 = save0 return num_fields } function my_outrec(fields, outf, c) { if(outf[0] > 0) { if (options["debug"] >= 1) print "normal\n" for (c = 1; c <= outf[0]; c++) if ( tolower(outf[c]) in fields ) print outf[c] ": " fields[tolower(outf[c])] "\n" } else { if(outf[1,0] > 0) { if (options["debug"] >= 1) print "inverted " fields[1,0] "\n" for (c = 1; c <= fields[1,0]; c++) { if (options["debug"] >= 1) print "fields[1," c "]='" 1 SUBSEP tolower(fields[1,c]) "'\n" if (!(1 SUBSEP tolower(fields[1,c]) in outf )) { if(options["outform"] == "normal") print fields[1,c] ": " fields[tolower(fields[1,c])] "\n" } } } else { if (options["debug"] >= 1) print "all\n" for (c = 1; c <= fields[1,0]; c++) print fields[1,c] ": " fields[tolower(fields[1,c])] "\n" } } print options["rec_sep"] } function my_compare(mthd, i, j, c, fld) { if (mthd == 0) { if(num_fields) { my_split(i, fld_i) my_split(j, fld_j) for(c = 1; c <= num_fields; c++) { fld = tolower(sort_fields[c]) if(options["debug"] >=2) print "sort fld=" fld "\n" if (options["debug"] >= 2) { print "\tPackage[" fld "]='" fld_i[fld] "' " print "\tPackage[" fld "]='" fld_j[fld] "' " } if(match(fld, /.*:n$/)) { gsub(/:n$/, fld) if (fld_i[fld]+0 < fld_j[fld]+0) return -1 if (fld_i[fld]+0 > fld_j[fld]+0) return 1 } else { if (fld_i[fld] < fld_j[fld]) return -1 if (fld_i[fld] > fld_j[fld]) return 1 } } } } if (options["debug"] >= 2) print "-1\n" return 0 } function my_sort(line, outf, num_fields, sort_fields, c) { qsort(0, line, 1, mtchs) num_fields = split(options["sort"], sort_fields, " ,") for (c = 1; c <= mtchs; c++){ my_split(line[c], fields) my_outrec(fields, outf) } } function readline( Old_RS, line) { Old_RS=RS RS="\n" "read; echo $REPLY" | getline line close("read; echo $REPLY") RS=Old_RS return line } # # Begin of script # { my_split($0, fields) for (c in regx) if ( match(fields[c], regx[c])==0) next my_split($0, fields) # test = readline() # print "test='" test "'\n" if (options["debug"] >= 1) for (a in fields) print "fields[" a "]=" fields[a] "\n" if ("sort" in options) { line[++mtchs] = $0 if (options["debug"] >= 1) print mtchs " " } else my_outrec(fields, outf) } END { print "\n" if ("sort" in options) my_sort(line, outf) } # # # qsort functions # # function middle(mthd, x,y,z) #return middle of 3 { ret_xy = my_compare(mthd, x, y) ret_zy = my_compare(mthd, z, y) if (ret_xy <= 0 ) { if ( ret_zy >= 0 ) return y if ( my_compare(mthd, z, x) < 0 ) return x return z } if ( my_compare(mthd, z, x) >= 0 ) return x if ( ret_zy < 0 ) return y return z } # recursive quicksort function qsort(mthd, A, left, right ,i , j, pivot, hold) { pivot = middle(mthd, A[left], A[int((left + right)/2)], A[right]) i = left j = right while ( i <= j ) { while (my_compare(mthd, A[i], pivot) < 0) i++ while (my_compare(mthd, A[j], pivot) > 0) j-- if ( i <= j ) { hold = A[i] A[i++] = A[j] A[j--] = hold } } if ( j - left > 0 ) qsort(mthd, A, left, j) if ( right - i > 0 ) qsort(mthd, A, i, right) } dpkg-awk/getlong.awk0000644000000000000000000000634411730436474011634 0ustar BEGIN{ oflags = ":;#" } function option_split_helper(ndx, s_o, l_o, val) { if (length(ndx) == 1) s_o[ndx] = val else l_o[ndx] = val } function option_split(opt, s_o, s_o_f, l_o, l_o_f, a, opts, itm, flags) { split(opt, opts, " ") for (a in opts) { #print "opts[" a "]='" opts[a] "'\n" itm = opts[a] #print itm " " flags = "" while (match(itm, "^[" oflags "]")) { flags = flags substr(itm, 1, 1) itm = substr(itm, 2) #print itm " " } #print "\n" option_split_helper(itm, s_o, l_o, "") if (length(flags)) option_split_helper(itm, s_o_f, l_o_f, flags) delete opts[a] } } function option_match(header, text, opts, opts_flags, argv, argc, help_text, ret_val, fchar, flags, value) { itm = argv[c] gsub(/=.*$/, "", itm) #print "argv[" c "]='" argv[c] "' itm='" itm "'\n" ret_val = 0 #for (a in opts) print "o_m opts[" a "]='" opts[a] "'\n" if (match(itm, "^" header )){ #print "match!\n" sub("^" header, "", itm) if (itm in opts){ if (itm in opts_flags){ flags = opts_flags[itm] #print "o_m flags=" flags "\n" for (a = 1; a <= length(oflags); a++) { fchar = substr(oflags, a, 1) if (match(flags, "[" fchar "]")) { if ((fchar == ":") || (fchar == ";")) { if (match(argv[c], /=.*$/)){ sub(/^.*=/, "", argv[c]) value = argv[c] delete argv[c] } else { delete argv[c] if ((c++) <= argc) { if (((fchar == ";") && !(match(argv[c], /^-/))) || (fchar == ":")) { value = argv[c] delete argv[c] } } else value = "" } } if (fchar == "#") { #print "o_m number\n" value = options[itm] if (match(argv[c], /=.*$/)){ sub(/^.*=/, "", argv[c]) value = argv[c] delete argv[c] } else { delete argv[c] value++ } } } } } else value = "" options[itm] = value } else if (itm) { print "illegal " text " option! '" itm "'\n" if(help_text) print script_exedir "/" script_exebase " [args]\n\n" help_text "\n" exit } ret_val=1 } return ret_val } function option_parse(opt_list, relation, help_text, argc, argv, short_opts, short_opts_value, long_opts, long_opts_value, m, rels, short, long) { option_split(opt_list " :exebase :exedir help h", short_opts, short_opts_value, long_opts, long_opts_value) for (c = 1; c <= argc; c++) { if (option_match("--", "long", long_opts, long_opts_value, argv, argc, help_text)) continue if (option_match("-", "short", short_opts, short_opts_value, argv, argc, help_text)) continue } split(relation " h=help", rels, " ") for ( c in rels) { equal = index(rels[c], "=") first = substr(rels[c], 1, 1) if (first in options) { second = substr(rels[c], 3) if (!(second in options)) # Only move the 'first' option into the # 'second' slot if the 'second' one # hasn't been defined yet. options[second] = options[first] delete options[first] } } if ("exebase" in options) { script_exebase = options["exebase"] delete options["exebase"] } if ("exedir" in options) { script_exedir = options["exedir"] delete options["exedir"] } if ("help" in options) { print script_exedir "/" script_exebase " [args]\n\n" help_text "\n" exit } }