dlocate/0002775000000000000000000000000014170451060007361 5ustar dlocate/.gitignore0000666000000000000000000000005413752640607011364 0ustar .gitignore dlocate-browse debian/.debhelper dlocate/Makefile0000664000000000000000000000133513705514023011023 0ustar #!/usr/bin/make -f all: clean: rm -rf debian/dlocate debian/dlocate.substvars debian/files build-stamp install-stamp new.output install: install -m 755 dlocate $(DESTDIR)/usr/bin/ install -m 755 update-dlocatedb $(DESTDIR)/usr/sbin/ install -m 755 updatedb $(DESTDIR)/usr/share/dlocate/ install -m 755 update-dpkg-list $(DESTDIR)/usr/share/dlocate/ install -m 755 spcrc-* $(DESTDIR)/usr/share/dlocate/ install -m 755 dpkg-hold $(DESTDIR)/usr/sbin/ install -m 755 dpkg-unhold $(DESTDIR)/usr/sbin/ install -m 755 dpkg-remove $(DESTDIR)/usr/sbin/ install -m 755 dpkg-purge $(DESTDIR)/usr/sbin/ update-test: ./test-dlocate.sh > test.output 2>&1 test: ./test-dlocate.sh > new.output 2>&1 diff -u test.output new.output dlocate/README.md0000664000000000000000000000042112732134477010647 0ustar # dlocate for Debian Fast alternative to 'dpkg -L', 'dpkg -S' etc. NOTE: `dlocate -l` is NOT the same as `dpkg -l`. It uses regular expressions for searches rather than glob-like wildcards. `dlocate -l` is a regexp-enhanced emulation of `dpkg -l`, not an exact clone. dlocate/debian/0002775000000000000000000000000014170451060010603 5ustar dlocate/debian/README.Debian0000664000000000000000000000044212732134477012656 0ustar dlocate for Debian ------------------ Fast alternative to 'dpkg -L', 'dpkg -S' etc. NOTE: `dlocate -l` is NOT the same as `dpkg -l`. It uses regular expressions for searches rather than glob-like wildcards. `dlocate -l` is a regexp-enhanced emulation of `dpkg -l`, not an exact clone. dlocate/debian/changelog0000664000000000000000000005226614170451060012466 0ustar dlocate (1.10) unstable; urgency=medium * Edited cron.daily script to stop piuparts complaining * Use grep-available instead of grep-dctrl (only need to read available file, not status) * Closes: #1003631 Removed unnecessary call to xargs apt-cache show -- Craig Sanders Sat, 15 Jan 2022 15:48:48 +1100 dlocate (1.09) unstable; urgency=medium * forgot to update debian/compat. fixed. Closes: #965492 -- Craig Sanders Tue, 28 Dec 2021 02:44:11 +1100 dlocate (1.08) unstable; urgency=medium * Closes: #601394 For --md5check: if any files have been diverted, list them with 'dpkg-divert --list' and perform an md5sum check on the diverted files. * Closes: #829473 Cron.daily only runs /usr/sbin/update-dlocatedb if it exists and is executable * Closes: #875773 Better multi-arch support for .list, .conffiles, and .md5sums files * Closes: #903773 Can not reproduce * Closes: #912850 Removed completions, so bash-completions package can take them over * Closes: #867735 dlocate no longer handles its own completions file * Closes: #919122 Removed some extra blank lines from error msg output * Closes: #965492 updated debhelper compat level to >= 13 * Closes: #843115, #874062 clarified help message for --filenames-only, --package-only * Changed dpkg-hold, dpkg-unhold, dpkg-purge to be wrappers around apt-mark * Modified updatedb to use output of 'dpkg-divert --list \*' * Got tired of forgetting to update the VERSION_BANNER in dlocate, so made it use $(dpkg-query -W -f '${version}' dlocate) * Deleted test.output file and check-version-banner.sh, not needed anymore * Fixed off-by-one fmt bug in -l output * Added -C, --colour option for -l and -s (requires supercat package) default colours can be changed by copying spcrc-dpkg-l and spcrc-package from /usr/share/dlocate to ~/.spc/ and editing. * dlocate now also looks in ./ for supercat colourisation files * update-dlocatedb now uses /usr/share/dlocate/update-dpkg-list * update-dpkg-list outputs details for all known packages, not just installed packages * Minor packaging fixes to keep lintian happy -- Craig Sanders Tue, 21 Jul 2020 17:13:32 +1000 dlocate (1.07) unstable; urgency=medium * updated VERSION_BANNER * (Closes: #532061, #407412, #532704, #563595, #567080, #614664, #733864, #788661, #567080) -- Craig Sanders Tue, 21 Jun 2016 13:33:28 +1000 dlocate (1.06) unstable; urgency=medium * added util-linux to dependencies -- Craig Sanders Tue, 21 Jun 2016 11:48:29 +1000 dlocate (1.05) unstable; urgency=low * completely rewrote option parsing, now uses getopt from util-linux long options now use --. Backwards-compatibility is maintained by using getopt's `-a` option. (Closes: #532061) * added `-p` and `-f` as short options for `--package-only` and `--filename-only` * improved `dlocate -k`, and sorted output. * added support for `+` characters in package names for 'dlocate -s' * fixed `--lsbin` to use `stat -c '%A %n'` rather than `ls -lLd` * added support for virtual packages in `-s` (Closes: #407412) * warnings and errors now go to stderr (Closes: #532704) * added note about update-dlocatedb to man page (Closes: #563595, #567080) * `dlocate -l` shows more of the package names (Closes: #614664) * added full path to error messages mentioning the .list file (Closes: #733864) * added --lsdir option to list directories (Closes: #788661) * update-dlocatedb now updates `dlocate -l` info (Closes: #567080) * now being maintained on github https://github.com/craig-sanders/dlocate forks and pull requests welcome. -- Craig Sanders Mon, 20 Jun 2016 20:01:14 +1000 dlocate (1.02+nmu3) unstable; urgency=low * Non-maintainer upload. * Fix handling of multiple arguments for several commands (Closes: #563881). * Fix dlocate return codes for several commands on exit (Closes: #564293). -- John Paul Adrian Glaubitz Sat, 29 Dec 2012 14:32:54 +0100 dlocate (1.02+nmu2) unstable; urgency=low * Non-maintainer upload. * Add missing "--" when invoking grep command (Closes: #587179). * Fix bash completion for package names in dlocate (Closes: # 658669). * Fix incorrect exit code 0 on failed search (Closes: #689647). * Fix parameter passing to dlocate_option_error() in dlocate (Closes: # 690758). -- John Paul Adrian Glaubitz Fri, 28 Dec 2012 15:42:16 +0100 dlocate (1.02+nmu1) unstable; urgency=low * Non-maintainer upload. * Fix several mistakes in manpages (Closes: #586483, #692896, #696479). -- John Paul Adrian Glaubitz Fri, 21 Dec 2012 11:47:08 +0100 dlocate (1.02) unstable; urgency=low * fixed example in dlocate.1 man page again (Closes: #466662) * added '-k', and '-K' commands to list kernels and related packages * added optional support for gzip compression of /var/lib/dlocate/dlocatedb.txt * added support output filters (--package-only, --filename-only) (Closes: #531641) -- Craig Sanders Wed, 03 Jun 2009 11:24:02 +1000 dlocate (1.01) unstable; urgency=low * added support for diversions (Closes: #304045) * fixed copy/paste error for -P (now correctly passes -P to grep rather than -E) * really moved the four dpkg-* man pages to section 8 -- Craig Sanders Mon, 01 Jun 2009 09:56:54 +1000 dlocate (1.0) unstable; urgency=low * no longer use frcode and locate, see discussion in 494673. removed dependency on locate package. (Closes: #505997, #494651, #494673) * added support for several GNU grep options, -E, -F, -G, -P, and -w * the extra grep options obsolete the request for shell glob patterns (Closes: #49922) * checked for empty $PKGS (Closes: #523501) * fixed '-man' option, so that it doesn't break on man directories with locales * tired of people filing the same bug because they misunderstand the purpose of '-man'. added 'sort -u'. (Closes: #501870) * updated and fixed dlocate.1 man page (Closes: #518309) * corrected 'dlocate -l' example in man page (Closes: #466662) * moved man pages for dpkg-hold, dpkg-unhold, dpkg-purge, dpkg-remove to section 8 (Closes: #512446) * added --verbose option to aid in debugging dlocate * fixed bug that broke support for multiple packages in most commands * fixed '-s' command so that it only calls grep-dctrl once if there are multiple package names * applied following 6 lintian fixes from era eriksson: (Closes: #513470) * debian/control: revert dependency on awk; as per Lintian error, it is in practice essential, and should not be declared * debian/copyright: add copyright year; disambiguate license as GPL v2 (fix lintian warning) * debian/rules: move binary-arch commands to binary-indep; do not ignore errors from "make clean" (fix lintian warnings) * debian/changelog: fix typo in 0.96.1 s/dancy/dency/ (fix lintian warning) * debian/postinst: don't use explicit path for /usr/sbin (fix lintian warning) * debian/postrm: add -e flag (fix lintian warning) -- Craig Sanders Sat, 30 May 2009 16:53:51 +1000 dlocate (0.96.2) unstable; urgency=low * Added bash completion rules. only one trivial change to the patch provided by Danilo Piazzalunga (Closes: #223718) -- Craig Sanders Fri, 27 Jun 2008 20:31:44 +1000 dlocate (0.96.1) unstable; urgency=low * version 0.95 introduced a dependency on awk, which is an optional package. the simple awk script has only been tested on my system with gawk, but it doesn't do anything gawkish so should work with mawk or original-awk. fixed Depends line. -- Craig Sanders Fri, 27 Jun 2008 19:58:57 +1000 dlocate (0.96) unstable; urgency=low * accidentally deleted cron.daily rather than updating it. restored it. (Closes: 488222) * updated postinst to generate /var/lib/dlocate/dpkg.list with tab- separated fields, the same way that /etc/cron.daily/dlocate does. also removed COLUMNS=200 because the postinst doesn't need it any more than the cron.daily does. * updated man page for update-dlocatedb to note additional author -- Craig Sanders Fri, 27 Jun 2008 18:46:38 +1000 dlocate (0.95) unstable; urgency=low * changed cron.daily to not use ionice if kernel version <2.6.13 * redirected stderr from ionice to >/dev/null to avoid error messages if running under vserver or other environments without CFQ scheduling (Closes: #456292) * added Pawel Chmielowski patch to update-dlocatedb which re-uses any old data from the existing dlocatedb. (Closes: #457572) * changed separator character when building the search regexp so that we don't end up grepping for everything. (Closes: #466662) * while/read loops in bash are abysmally slow. replaced that loop in 'dlocate -l' section with an awk script. vast improvement in speed. Note: this required changing the field separator in $DPKGLIST from space to tab, so anyone who parses that file directly (nobody, i think) may need to modify their scripts. (Closes: #487471) * finally close some bugs that were actually closed ages ago in NMUs. (Closes: #314276, #337711, #83196, #54073, #63902, #84018, #67650, #78621, #132930, #91785, #100694, #101426, #129251, #132931, #129186, #76149, #43145, #43146, #45057, #42314) -- Craig Sanders Thu, 26 Jun 2008 20:53:30 +1000 dlocate (0.94) unstable; urgency=low * optimisation for '-S' and 'DEFAULT' commands. run locate once only with multiple filenames on the command line. significantly faster when searching for multiple filenames. * the optimisation also means that $result is the exit-code of all searches combined, rather than just the exit-code of the last search to be run. -- Craig Sanders Thu, 29 Nov 2007 18:30:01 +1100 dlocate (0.93) unstable; urgency=low * minor fix to -lsbin. now excludes all non-files, rather than just directories. also follows symlinks. * added '--' option to make it possible to search for partial files like -conf, -ls, and other '-*' that happen to match dlocate options. did i already mention that dlocate's arg processing really sucks and needs a rewrite? * added Makefile rules ("make test") to automate testing of dlocate output, and to remind me to update the version banner in dlocate. * check for unknown options (Closes: #220351, #307371) (NOTE: breaks backwards-compatibility for anyone who relies on the old behaviour!) * only print header for 'dlocate -l' if there are any matching packages found. (Closes: #447140) * fixed dlocate's stderr redirection so that 'make test' works. (possible bug in bash - '>/dev/stderr' treated differently to '>&2') -- Craig Sanders Thu, 29 Nov 2007 18:27:22 +1100 dlocate (0.92) unstable; urgency=low * passed '--' to egrep so you can search for partial package names like '-utils', '-tools', etc. * fixed a bug in -md5check which prevented it from checking some packages with spaces in the filenames. * used '-r' ("--no-run-if-empty") everywhere with xargs. (Closes: #452746) * also changed numerous tests of [ -e $PKG.* ] to [ -s $PKG.* ] to test for 'exists and not empty' rather than just 'exists'. * removed output of double-quotes (0x22) surrounding $PKG to make stderr output more parser-friendly. * added simple script to test dlocate output prior to uploading a new version (script is in source package only) -- Craig Sanders Mon, 26 Nov 2007 19:26:50 +1100 dlocate (0.91) unstable; urgency=low * corrected minor mistake in dpkg-remove man page. -- Craig Sanders Thu, 22 Nov 2007 21:20:26 +1100 dlocate (0.9) unstable; urgency=low * cron.daily doesn't need to have COLUMNS=200. this was fixed in dpkg years ago. * redirect error output from -lsbin to /dev/null. (Closes: #452297) * made -lsbin output consistent with other -ls options * added dpkg-hold, dpkg-unhold, dpkg-remove, and dpkg-purge to /usr/sbin. simple command line tools that i've been using for years to flag/unflag a package for hold, or flag it to be removed or purged. They *ONLY* change the status of the package which will be noticed the next time dpkg, dselect, or apt-get is run. * wrote simple man pages for dpkg-{hold,unhold,remove,purge} * really fixed bad handling of first arg this time (Closes: #380081) * updated date in dlocate.1 man page -- Craig Sanders Thu, 22 Nov 2007 20:48:19 +1100 dlocate (0.8) unstable; urgency=low * call md5sum -c with '-' rather than /dev/stdin (Closes: #413804) * can not reproduce 61790, and nobody else has ever reported anything similar. probably some problem with cron on Lazarus' system at the time (Apr 2000). (Closes: #61790) * improved error messages from update-dlocatedb. also modified script to comply with 'use strict;'. (Closes: #361196) -- Craig Sanders Wed, 21 Nov 2007 10:29:20 +1100 dlocate (0.7) unstable; urgency=low * fixed small bug in arg handling * added more commentary and examples in the dlocate man page to resolve various searching issues (both locate and egrep are different to dpkg's shell-style pattern matching). Also added 'SEE ALSO locate(1)' to the man page. (Closes: #441183, #208425, #447141) * man page for dpkg is in section 1. (Closes: #354648) * added -lsman option to list full path/filename of man pages. (Closes: #361125, #289351) * added -lsbin option to list full path/filename of binaries (Closes: #441109) -- Craig Sanders Wed, 21 Nov 2007 01:53:17 +1100 dlocate (0.6) unstable; urgency=low * Applied patch from Andreas Metzler: GNU locate has been split off to a separate package. Adapt dlocate to work both with the new and the old setup. (Closes: #451750) * always pass '--' to locate. (Closes: #360824, #360824) * can not reproduce bug 65974. my guess is that update-dlocatedb hadn't been run. (Closes: #65974) * error messages now go to stderr (Closes: 375271) * first option is no longer a special case (Closes: #380081) * 'LINES=40' isn't needed. removed. (Closes: #224947) * shameful trailing blanks removed from -l output (Closes: #261733) * 'dlocate -l' no longer outputs one header for each package name. (Closes: #268288, #319251, #354285) * added '/' to start of dlocate -man regexp. (Closes: #290562) * dlocate now has --version and -V options (Closes: #223698) * dlocate really needs a rewrite. it started as a Q&D hack and grew beyond that. the remaining bugs need a rewrite to fix. expect a rewrite from scratch soon. -- Craig Sanders Tue, 20 Nov 2007 23:12:18 +1100 dlocate (0.5-0.3) unstable; urgency=low * Non-Maintainer Upload. * Updated Standards version to 3.7.2.1 * Depend on dctrl-tools or grep-dctrl (Closes: #314276) * Remove -v from md5check routine so md5checking works with md5sum from textutils (Closes: #318980) * Change Build-Depends-Indep to Build-Depends since debhelper is called from the clean target, this makes dlocate lintian clean. * Apply patch from Sam Morris to return non-zero if a package is not installed (Closes: #123777, #322290, #213292, 364318) * Make database backups atomic (Closes: #372151) * Apply patch from Nicolas Fancios to fix typos in manpage (Closes: #271328) * Use capital letters in long description (Closes: #374475) * Fix typo in cron file (Closes: #243620) -- Jon Bernard Thu, 31 Aug 2006 13:11:16 -0400 dlocate (0.5-0.2) unstable; urgency=low * NMU to fix RC bug * Updated Standards version to 3.6.2.1 * Use debhelper v5, Closes: #337711 - Puts link in /usr/doc * escape minus chars in man pages -- Bastian Kleineidam Fri, 25 Nov 2005 16:58:10 +0100 dlocate (0.5-0.1) unstable; urgency=low * Non-Maintainer Upload. * NMU, Craig Sanders seems to have lost his interest in this package, last upload was in 1999. * Upload sponsored by Thom May . * cron job conditional on package being installed (Closes: #83196, #54073) * remove /var/lib/dlocate on purge (Closes: #63902) * work with long package names. Patch from Peter Samuelson, modified to limit length of output to $COLUMNS characters (Closes: #84018, #67650, #78621) * Patch for #84018 adds "Hold" to the list of desired states, too. (Closes: #132930) * dpkg -ls works with packages containing many files (use xargs), patch from Peter Samuelson (Closes: #91785) * Works with slocate, using dpkg-divert --truename, patch from Robert Luberda, depend on dpkg 1.8.0, drop superfluous versioned conflicts on very old dpkg. Once this is uploaded I'll ask the slocate-maintainer to remove the "Conflicts: dlocate". (Closes: #100694, #101426, #129251) * depend on perl. (Closes: #132931) * Use nice quotation marks in dlocate(1) (Closes: #129186) * Add manpage for update-dlocatedb.8 (Closes: #76149) * dlocate -l already mimics dpkg -l good enough (Closes: #43145, #43146, #45057) * fix lintian warnings: findutils and bash are essential, depending on them is wrong copyright: fix location of GPL update-dlocatedb has no manpage. Add versioned Build-Depends-Indep: debhelper >= 3.0.0 (dh_installmanpages) Bump standards-version. * update debian/rules from dh_make-template * Use dh_installman instead of dh_installmanpages. * Use DH_COMPAT=3, get rid of debian/conffiles. * update dlocate(1) * -l uses egrep and accepts extended re, document it in manpage. * Old bug was already fixed: Generate initial database asynchronously (Closes: #42314) -- Andreas Metzler Sun, 10 Mar 2002 09:44:16 +0100 dlocate (0.5) unstable; urgency=low * make /etc/cron.daily/dlocate a conffile. (closes: 49458) * changed Depends: dpkg >= 1.4.1.10 to Conflicts: dpkg 1.4.1.[789] according to wichert's suggestion in bug 46614 * add closes line to changelog for all the bugs that were closed in previous versions but i didn't get the closes syntax right: (closes: #43194 #45239 #46614 #45057, #43145, #43146 #42234 #42314 #42210 #42248) -- Craig Sanders Tue, 2 Nov 1999 19:01:27 +1100 dlocate (0.4) unstable; urgency=low * changed 'dpkg -l' to 'dpkg -l "*"' so that the list includes purged packages as well. -- Craig Sanders Tue, 2 Nov 1999 19:01:27 +1100 dlocate (0.3-1) unstable; urgency=low * replaced cron.d script /etc/cron.daily/dlocate (fixes #43194 #45239) * added dependency on dpkg >= 1.4.10, (fixes #46614) * added simplistic emulation of 'dpkg -l' (fixes #45057, #43145, #43146) NOTE: this is NOT the same as 'dpkg -l' and i will ignore bug reports which point out this obvious fact. it is a simplistic emulation, not an exact clone. IMO, it is more useful than 'dpkg -l'. if you disagree, then you are free to use the slower original. -- Craig Sanders Tue, 2 Nov 1999 17:05:56 +1100 dlocate (0.2-1) unstable; urgency=low * use a version of the fast perl script submitted by hallon@debian.org rather than make, sed, and perl. it even finishes the job faster than make can decide whether to update the dlocatedb file or not. (fixes #42234) * this makes it viable to build initial db in background (fixes #42314) * doesn't depend on make anymore. * depends on grep-dctrl >= 0.11 (fixes #42210) * updated dlocate man page (fixes #42248) -- Craig Sanders Tue, 3 Aug 1999 08:34:12 +1000 dlocate (0.1-8) unstable; urgency=low * added postinst to create /var/lib/dlocate/dlocatedb at install time (fixes #42120) -- Craig Sanders Fri, 30 Jul 1999 11:09:27 +1000 dlocate (0.1-7) unstable; urgency=low * bashisms in scripts, #!/bin/sh is bad - change to #!/bin/bash * fixed bashism in cron.d script, use >/dev/null not >& * wrote a man page for dlocate(1) -- Craig Sanders Thu, 22 Jul 1999 08:46:56 +1000 dlocate (0.1-6) unstable; urgency=low * really add dependency on make this time * add copyright (GPL) -- Craig Sanders Tue, 20 Jul 1999 11:15:48 +1000 dlocate (0.1-5) unstable; urgency=low * depends on grep-dctrl, not dpkg-awk * also depends on make * made it use /usr/bin/locate.old if it exists - solves incompatibility with slocate. -- Craig Sanders Tue, 20 Jul 1999 10:58:21 +1000 dlocate (0.1-4) unstable; urgency=low * fixed minor bug in dlocate option handling. should be all done now. -- Craig Sanders Fri, 16 Jul 1999 12:45:04 +1000 dlocate (0.1-3) unstable; urgency=low * i'll get it right eventually - should be arch: all, not i386 * touching the initial dlocatedb makes it fail an md5sum check, so modify /usr/lib/dlocate/Makefile instead -- Craig Sanders Fri, 16 Jul 1999 12:23:28 +1000 dlocate (0.1-2) unstable; urgency=low * touch initial /var/lib/dlocate/dlocatedb -- Craig Sanders Fri, 16 Jul 1999 12:06:07 +1000 dlocate (0.1-1) unstable; urgency=low * Initial Release. -- Craig Sanders Wed, 23 Jun 1999 11:35:02 +1000 Local variables: mode: debian-changelog End: dlocate/debian/compat0000664000000000000000000000000314162357372012014 0ustar 13 dlocate/debian/control0000664000000000000000000000126013705503102012201 0ustar Source: dlocate Section: utils Priority: optional Maintainer: Craig Sanders Standards-Version: 3.7.2.1 Build-Depends: debhelper (>= 13) Package: dlocate Architecture: all Depends: dctrl-tools | grep-dctrl (>= 0.11), dpkg (>= 1.8.0), ${perl:Depends}, ${misc:Depends} Recommends: supercat Description: fast alternative to dpkg -L and dpkg -S Uses GNU grep and text dumps of dpkg's data to greatly speed up finding out which package a file belongs to (i.e. a very fast dpkg -S). Many other uses, including options to view all files in a package, calculate disk space used, view and check md5sums, list man pages, etc. Homepage: https://github.com/craig-sanders/dlocate dlocate/debian/copyright0000664000000000000000000000123112732134477012545 0ustar This package was debianized by Craig Sanders on Fri, 16 Jul 1999 11:31:28 +1000. It was created from original source code by Jim Pick , greatly modified and enhanced by myself. Various versions have been posted to the debian mailing lists and it's well past time to package it. Upstream Authors: Jim Pick Craig Sanders Copyright: Copyright (C) 1999 Jim Pick , Craig Sanders Copyright (C) 2007, 2008 Craig Sanders original script by Jim Pick , GPL'd of course see /usr/share/common-licenses/GPL-2 for details dlocate/debian/cron.daily0000775000000000000000000000021214170451060012564 0ustar #!/bin/sh # update databases for both files and packages. if [ -x /usr/sbin/update-dlocatedb ] ; then /usr/sbin/update-dlocatedb -b fi dlocate/debian/dirs0000664000000000000000000000012512732134477011477 0ustar usr/bin usr/sbin usr/share/dlocate var/lib/dlocate etc/bash_completion.d etc/default dlocate/debian/dlocate.default0000664000000000000000000000034212732134477013575 0ustar # You can enable compression if you are short on disk space and don't # mind dlocate being about 10 times slower. # # 1 = enable compression # anything else = disable compression # # disabled by default. COMPRESS_DLOCATE="0" dlocate/debian/dlocate.manpages0000664000000000000000000000012212732134477013740 0ustar dlocate.1 update-dlocatedb.8 dpkg-hold.8 dpkg-unhold.8 dpkg-remove.8 dpkg-purge.8 dlocate/debian/postinst0000664000000000000000000000305113705513714012416 0ustar #!/bin/sh # postinst script for dlocate # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-deconfigure' `in-favour' # `removing' # # for details, see /usr/doc/packaging-manual/ # # quoting from the policy: # Any necessary prompting should almost always be confined to the # post-installation script, and should be protected with a conditional # so that unnecessary prompting doesn't happen if a package's # installation fails and the `postinst' is called with `abort-upgrade', # `abort-remove' or `abort-deconfigure'. # remove old versions of dlocatedb if any exist #[ -e /var/lib/dlocate/dlocatedb ] && rm -f /var/lib/dlocate/dlocatedb #[ -e /var/lib/dlocate/dlocatedb.old ] && rm -f /var/lib/dlocate/dlocatedb.old [ -e /var/lib/dlocate/dlocatedb.txt ] && rm -f /var/lib/dlocate/dlocatedb.txt [ -e /var/lib/dlocate/dlocatedb.txt.old ] && rm -f /var/lib/dlocate/dlocatedb.txt.old case "$1" in configure) # generate initial dlocate database and package list update-dlocatedb -b ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 0 ;; esac #DEBHELPER# exit 0 dlocate/debian/postrm0000664000000000000000000000020113705514112012042 0ustar #!/bin/sh set -e if [ "$1" = "purge" ]; then rm -f /var/lib/dlocate/* rmdir /var/lib/dlocate/ fi #DEBHELPER# dlocate/debian/rules0000775000000000000000000000261213705514126011670 0ustar #!/usr/bin/make -f #-*- makefile -*- # Made with the aid of dh_make, by Craig Small # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. # Some lines taken from debmake, by Christoph Lameter. build-arch: build-stamp build-indep: build-stamp build: build-stamp build-stamp: dh_testdir touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp install-stamp $(MAKE) clean dh_clean install: install-stamp install-stamp: build-stamp dh_testdir dh_testroot #dh_clean -k dh_prep dh_installdirs $(MAKE) DESTDIR=`pwd`/debian/`dh_listpackages` install touch install-stamp # Build architecture-independent files here. binary-indep: build install dh_testdir dh_testroot # dh_installdebconf dh_installdocs # dh_installexamples # dh_installmenu # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime dh_installinit -n -r --no-start dh_installcron dh_installman # dh_installinfo # dh_undocumented dh_installchangelogs # dh_link # dh_strip dh_compress dh_fixperms # dh_makeshlibs dh_installdeb dh_perl dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb # Build architecture-dependent files here. binary-arch: build install # We have nothing to do by definition (arch is indep). source diff: @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary dlocate/debian/source/0002775000000000000000000000000012732134477012117 5ustar dlocate/debian/source/options0000664000000000000000000000002412732134477013527 0ustar tar-ignore = ".git" dlocate/dlocate0000775000000000000000000004077613705511730010742 0ustar #!/bin/bash # Original script by Jim Pick , GPL'd of course # # Completely rewritten several times with many new features and # enhancements (plus numerous patches and by others, see the changelog) # by Craig Sanders DLOCATE="$0" DLOCATEDB=/var/lib/dlocate/dlocatedb DPKGLIST=/var/lib/dlocate/dpkg-list DPKG_INFO=/var/lib/dpkg/info DPKG_ARCH=$(dpkg --print-architecture) COMPRESS_DLOCATEDB=0 GREP='grep' [ -e /etc/default/dlocate ] && . /etc/default/dlocate [ "$COMPRESS_DLOCATE" = "1" ] && GREP='zgrep' function usage { [ -n "$*" ] && printf "%s\n" "$*" > /dev/stderr && exit 1 cat <<__EOF__ Usage: dlocate [option...] [command] [PATTERN...] Commands: none PATTERN List records that match either package or files names -S PATTERN List records that match filenames -L package List all files in package -l package Regexp-enhanced emulation of 'dpkg -l' -s package Print package's status --ls package 'ls -ldF' of all files in package --du package 'du -sck' of all files in package --conf package List conffiles in package --lsconf package 'ls -ldF' of conffiles in package --md5sum package List package's md5sums (if any) --md5check package Check package's md5sums (if any) --man package List package's man pages (if any) --lsman package List full path/filenames of man pages --lsbin package List full path/filenames of executable files --lsdir package List only the directories in package Output directory names only when searching for files -K List installed kernel & related packages -k detailed list of installed kernel & related packages -- Stop processing commands and options. Remainder of command-line is filename(s)/package-name(s) The -l, and -S commands are approximately the same as the equivalent dpkg options except that the search is performed using regular expressions rather than fixed strings. Options -f, --filename-only Strip 'package: ' prefix from search output -p, --package-only Output package names only when searching Regular Expression Options (see grep(1) for details): -E, --extended-regexp -F, --fixed-strings -G, --basic-regexp -P, --perl-regexp -w, --word-regexp Restrict matches to whole words -i, --ignore-case Case-insensitive match Miscellaneous Options: -h, --help Display this help message and exit. -V, --version Display dlocate's version number and exit. -v, --verbose, --debug Verbose/debug output -c, --columns [cols] Set COLUMN width. Without -c, dlocate defaults to using the entire terminal line width. -C, --colour Colourise -l or -s output (requires supercat to be installed) __EOF__ exit 1 } function warn() { printf "%s\n" "$*" >&2 } function dlocate_version { VERSION_BANNER=$(dpkg-query -W -f '${version}' dlocate) echo "dlocate version $VERSION_BANNER" exit 0 } function dlocate_option_error () { echo "dlocate: unknown option '$1'" echo echo "Use: 'dlocate -- $1' if you want to search for '$1'" exit 1 } # Thanks to "A. Costa" in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=407412 # What provided an installed virtual package? # What programs provide a given virtual package? deb_provided_by() { grep-status -F Provides "$1" -a -F Status installed -ns Package: ; } list_deb_providers() { grep-available -F Provides "$1" -ns Package: ; } OPTION='DEFAULT' # default to extended regexp RE_TYPE="-E" RE_SEPARATOR="|" # default to case-sensitive IGNORE_CASE='' # default to non- word-based searches WORD_RE='' WSEP1='\<' WSEP2='\>' # output filters for -S and DEFAULT option OUTPUT_FILTER="none" function output_filter() { [ -n "$VERBOSE" ] && warn "OUTPUT FILTER: $OUTPUT_FILTER" case "$OUTPUT_FILTER" in filenames) awk -F': ' '{ print $NF }' ;; packages) awk -F': ' '{ print $1 }' | sort -u ;; *) cat ;; esac } function colourise_dpkg() { case "$COLOURISE" in 1) spc -c "$CCONFD" ;; *) cat ;; esac } function colourise_packages() { case "$COLOURISE" in 1) spc -c "$CCONFP" ;; *) cat ;; esac } VERBOSE='' KERNEL='' COLOURISE='' CCONFP='' CCONFD='' for d in /etc/supercat /usr/share/dlocate ~/.spcrc ./ ; do [ -e "$d/spcrc-dpkg-l" ] && CCONFD="$d/spcrc-dpkg-l" [ -e "$d/spcrc-package" ] && CCONFP="$d/spcrc-package" done # getopt is only safe if GETOPT_COMPATIBLE is not set. unset GETOPT_COMPATIBLE # POSIXLY_CORRECT disables getopt parameter shuffling, so nuke it. # parameter shuffling moves all non-option args to the end, after # all the option args. e.g. args like "-x -y file1 file2 file3 -o optval" # become "-x -y -o optval -- file1 file2 file3" unset POSIXLY_CORRECT OPTS_SHORT='hVvdc:KkSLlsiEFGPwfpC' OPTS_LONG='help,version,verbose,debug,columns:,ls,du,conf,lsconf,md5sum,md5check,man,lsman,lsbin,ignore-case,extended-regexp,fixed-strings,basic-regexp,perl-regexp,filename-only,package-only,lsdir,colour,color' # check options and shuffle them # use getopt's `-a` option to provide backwards-compatibility # with the old, broken option handling. TEMP=$(getopt -a -o "$OPTS_SHORT" --long "$OPTS_LONG" -n "$0" -- "$@") if [ $? != 0 ] ; then usage "Terminating..." ; fi # assign the re-ordered options & args to this shell instance eval set -- "$TEMP" while true ; do case "$1" in -h|--help) usage ; shift ;; -V|--vers*) dlocate_version ; shift ;; -v|--verb*|--deb*) VERBOSE=1 ; shift ;; -C|--colo*) COLOURISE=1 ; shift ;; -c|--col*) COLUMNS="${2:-80}" ; shift 2 ;; -E|--ext*) RE_TYPE='-E' ; shift ;; -F|--fix*) RE_TYPE='-F' ; RE_SEPARATOR=$'\n' ; shift ;; -G|--bas*) RE_TYPE='-G' ; shift ;; -P|--per*) RE_TYPE='-P' ; WSEP1='\b' ; WSEP2='\b' ; shift ;; -w|--wor*) WORD_RE="-w" ; shift ;; -i|--ign*) IGNORE_CASE='-i' ; shift ;; -f|--fil*) OUTPUT_FILTER='filenames' ; shift ;; -p|--pac*) OUTPUT_FILTER='packages' ; shift ;; -K|-k) OPTION="$1" ; KERNEL=1 ; shift ;; -S) OPTION="$1" ; shift ;; -L) OPTION="$1" ; shift ;; -l) OPTION="$1" ; shift ;; -s) OPTION="$1" ; shift ;; --ls) OPTION="$1" ; shift ;; --du) OPTION="$1" ; shift ;; --conf) OPTION="$1" ; shift ;; --lsconf) OPTION="$1" ; shift ;; --md5sum) OPTION="$1" ; shift ;; --md5check) OPTION="$1" ; shift ;; --man) OPTION="$1" ; shift ;; --lsman) OPTION="$1" ; shift ;; --lsbin) OPTION="$1" ; shift ;; --lsdir) OPTION="$1" ; shift ;; --) shift ; break ;; *) usage ;; esac done [ -z "$*${KERNEL}" ] && usage PKGS=("$@") joinargs() { local IFS="$1"; shift; echo "$*"; } PKGS_REGEXP=$(joinargs "$RE_SEPARATOR" "$@") [ "$RE_TYPE" = "-G" ] && PKGS_REGEXP=$(printf "%s" "$PKGS_REGEXP" | sed -E -e 's/\|/\\|/g') FILES_REGEXP="($PKGS_REGEXP)" [ "$WORD_RE" = "-w" ] && FILES_REGEXP="${WSEP1}$FILES_REGEXP${WSEP2}" [ -z "$COLUMNS" ] && COLUMNS=$(stty -a 2>&- | sed -ne '/columns/s/.*columns \([0-9]*\)[^0-9].*/\1/p'); [ 0"$COLUMNS" -lt 80 ] && COLUMNS=80; if [ -n "$VERBOSE" ] ; then declare -p COLUMNS TEMP PKGS OPTION RE_SEPARATOR PKGS_REGEXP FILES_REGEXP | sed -e 's/^declare [^ ]\+ //' >&2 echo >&2 fi [ -z "$PKGS_REGEXP" ] && PKGS_REGEXP='^$' if [ "$OPTION" = '-l' ] ; then ((fieldw=(COLUMNS-24)/4)); # dpkg uses ((fieldd=fieldw*2+16)); # # limiting the output to COLUMNS-2 characters and losing up to # additional 3 characters due to the rounding error. ((fieldd=COLUMNS-fieldw*2-6)); fmt_eq=$(echo ==================================================== | cut -c-$fieldw) HEADER=$( printf \ "Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ %-${fieldw}s %-${fieldw}s %s +++-${fmt_eq}-${fmt_eq}-${fmt_eq}${fmt_eq}==================\\n" \ Name Version Description) BODY_FMT_STRING="%-3s %-${fieldw}.${fieldw}s %-${fieldw}.${fieldw}s %-${fieldd}.${fieldd}s\\n" [ -n "$VERBOSE" ] && warn RUNNING: $GREP $RE_TYPE $WORD_RE $IGNORE_CASE -- "'$PKGS_REGEXP'" "$DPKGLIST" BODY=$($GREP $RE_TYPE $WORD_RE $IGNORE_CASE -- "$PKGS_REGEXP" "$DPKGLIST" | \ awk -F'\t' -v fmt="$BODY_FMT_STRING" '{ printf fmt, $1, $2, $3, $4 }' | sed -e 's/ *$//g' ) [ -n "$BODY" ] && printf "%s\n" "$HEADER" "$BODY" | colourise_dpkg elif [ "$OPTION" = '-S' ] ; then if [ "$RE_TYPE" = '-F' ] ; then warn "Error: -F Fixed String searches are incompatible with -S" exit 1 fi PREFIX="^([-a-zA-Z0-9_.+]+:|diversion by )" [ "$RE_TYPE" = "-G" ] && PREFIX="^\([-a-zA-Z0-9_.+]+:\|diversion by \)" [ -n "$VERBOSE" ] && warn RUNNING: $GREP $RE_TYPE $IGNORE_CASE -- "'$PREFIX.*$FILES_REGEXP'" "$DLOCATEDB" $GREP $RE_TYPE $IGNORE_CASE -- "$PREFIX.*$FILES_REGEXP" "$DLOCATEDB" | output_filter result=${PIPESTATUS[0]} elif [ "$OPTION" = 'DEFAULT' ] ; then [ -n "$VERBOSE" ] && warn RUNNING: $GREP $RE_TYPE $IGNORE_CASE -- $WORD_RE "'$PKGS_REGEXP'" "$DLOCATEDB" $GREP $RE_TYPE $IGNORE_CASE $WORD_RE -- "$PKGS_REGEXP" "$DLOCATEDB" | output_filter result=${PIPESTATUS[0]} #[ "$result" -eq 1 ] && echo "not in package: $PKGS_REGEXP" >&2 elif [ "$OPTION" = '-s' ] ; then for p in "${PKGS[@]}" ; do grep-status -P -X "$p" | colourise_packages result=$? if [ "$result"0 -ne 0 ] ; then (printf "%s\n" "Package: $p (virtual package, currently provided by '$(deb_provided_by "$p")')" printf "%s\n\n" "X-Available-Providers: $(list_deb_providers "$p" | sort -u | xargs | sed -e 's/ / | /g')") | colourise_packages # use X-Available-Provides: to provide a hint that it's a synthetic status field. fi done elif [ "$OPTION" = '-k' ] ; then kmodules=( $(grep-status -s Package -n -e ' (module-assistant|dkms)([, ]|$)' | grep -v 'module-assistant') ) kmods_re=$(joinargs '|' "${kmodules[@]}") linux_pkgs='^(linux-(image|source|headers|doc|debug|kbuild|perf|support|tools|manual))' [ -n "$kmods_re" ] && linux_pkgs="$linux_pkgs|^($kmods_re)$" [ -n "$VERBOSE" ] && warn RUNNING: grep-status -P -e "'$linux_pkgs'" grep-status -P -e "$linux_pkgs" | \ grep-dctrl -n -s Package -F status " installed" - | sort -V result=$? elif [ "$OPTION" = '-K' ] ; then KERN_RE=$(joinargs '|' $("$DLOCATE" -k)) [ -n "$VERBOSE" ] && warn RUNNING: dlocate -E -w -l "'($KERN_RE)'" "$DLOCATE" -c "$COLUMNS" -E -w -l "($KERN_RE)" | grep -v '^.n' result=$? else for PKG in "${PKGS[@]}" ; do PLIST="$DPKG_INFO/$PKG.list" PLISTARCH="$DPKG_INFO/$PKG:$DPKG_ARCH.list" [ ! -s "$PLIST" ] && [ -s "$PLISTARCH" ] && PLIST="$PLISTARCH" PCONF="$DPKG_INFO/$PKG.conffiles" PCONFARCH="$DPKG_INFO/$PKG:$DPKG_ARCH.conffiles" [ ! -s "$PCONF" ] && [ -s "$PCONFARCH" ] && PCONF="$PCONFARCH" PMD5="$DPKG_INFO/$PKG.md5sums" PMD5ARCH="$DPKG_INFO/$PKG:$DPKG_ARCH.md5sums" [ ! -s "$PMD5" ] && [ -s "$PMD5ARCH" ] && PMD5="$PMD5ARCH" case "$OPTION" in -L) if [ -s "$PLIST" ] ; then cat "$PLIST" result=$? else warn "Package $PKG is not installed or $PLIST is empty." result=1 fi ;; --ls) if [ -s "$PLIST" ] ; then xargs -d '\n' -r ls -ldF < "$PLIST" result=$? else warn "Package $PKG is not installed or $PLIST is empty." result=1 fi ;; --du) if [ -s "$PLIST" ] ; then sed '1d' "$PLIST" | xargs -d '\n' -r ls -1dF | sed -e '/@$\|\/$/d; s/\*$//;' | xargs du -sck result=$? else warn "Package $PKG is not installed or $PLIST is empty." result=1 fi ;; --conf) if [ -s "$PCONF" ] ; then cat "$PCONF" result=$? else warn "Package $PKG is not installed or has no conffiles." result=1 fi ;; --lsconf) if [ -s "$PCONF" ] ; then xargs -a "$PCONF" -d '\n' -r ls -ldF result=$? else warn "Package $PKG is not installed or has no conffiles." result=1 fi ;; --md5sum) if [ -s "$PMD5" ] ; then cat "$PMD5" result=$? else warn "Package $PKG is not installed or has no md5sums." result=1 fi ;; --md5check) MD5TMP=$(mktemp) DIVTMP=$(mktemp) #MD5TMP='/tmp/md5temp' #DIVTMP='/tmp/divtemp' if [ -s "$PMD5" ] ; then pushd / >/dev/null 2>&1 cat "$PMD5" | \ md5sum -c - 2>/dev/null | tee "$MD5TMP" result=$? if grep -q FAILED "$MD5TMP" ; then echo echo "Some files in package '$PKG' may have been diverted by other packages" echo "which will cause false FAILED errors:" awk -F: '/FAILED/ {print "/"$1}' "$MD5TMP" | xargs -d'\n' -r dpkg-divert --list | tee "$DIVTMP" if [ -s "$DIVTMP" ] ; then echo echo Checking diverted files: awk '/^diversion of/ {gsub(/ \//," ");print "s|"$3"|"$5"|gp"}' "$DIVTMP" | sed -n -f /dev/stdin <("$DLOCATE" -md5sum perl) | md5sum -c - 2>/dev/null fi fi popd >/dev/null 2>&1 else warn "Package $PKG is not installed or has no md5sums." result=1 fi rm -f "$MD5TMP" "$DIVTMP" ;; --lsman) if [ -s "$PLIST" ] ; then "$DLOCATE" -L "$PKG" | \ grep -E '/man[0-9]+/' result=$? else warn "Package $PKG is not installed or $PLIST is empty." result=1 fi ;; --man) if [ -s "$PLIST" ] ; then "$DLOCATE" -L "$PKG" | \ grep -E '/man[0-9]+/' | \ sed -e 's/\.gz$//' \ -e 's:.*/::' \ -e 's/\(^.*\)\.\(.*\)/\2 \1/' | \ sort -u result=$? else warn "Package $PKG is not installed or $PLIST is empty." result=1 fi ;; --lsbin) if [ -s "$PLIST" ] ; then "$DLOCATE" -L $PKG | \ xargs -d '\n' -r stat -c '%A %n' | \ awk '!/^[^-]/ && /^-.{2,8}[xs]/ {print $2}' result=$? else warn "Package $PKG is not installed or $PLIST is empty." result=1 fi ;; --lsdir) if [ -s "$PLIST" ] ; then "$DLOCATE" -L $PKG | \ xargs -d '\n' -r stat -c '%A %n' | \ awk '/^d/ {print $2}' result=$? else warn "Package $PKG is not installed or $PLIST is empty." result=1 fi ;; esac done fi test -n "$result" && exit $result # Local variables: # mode: shell-script # End: # ex: ts=2 sts=2 sw=2 et filetype=sh dlocate/dlocate-browse0000775000000000000000000002362513705514020012226 0ustar #!/usr/bin/perl # debian package browser # # simple ncurses wrapper around `grep-dctrl` and `apt-cache show` # for viewing details of one or more packages. # # (C) Copyright Craig Sanders , 2016 # # This program is licensed under the terms of the GNU General Public # License (GPL) Version 2 ((or later, at your option). use strict; use File::Basename; my $program = basename($0); my $pversion = '0.1'; use Curses::UI; use Term::ReadKey qw(GetTerminalSize); #use Getopt::Long; use Data::Dump qw(pp dd); my $debug = 0; use diagnostics; #use Carp; # pre-declare subroutines (see below for implementation) #use subs qw( clear_sel fork_shell run_search show_pkgs tag untag help quit ); # external binary locations #my $dlocate = '/usr/bin/dlocate'; # use system dlocate my $dlocate = './dlocate'; # use dev version my $aptcache = '/usr/bin/apt-cache'; my $dctrl = '/usr/bin/grep-dctrl'; my $dctrl_f = '/var/lib/dpkg/status /var/lib/dpkg/available'; my $less = '/usr/bin/less +Gg'; my $debtags = '/usr/bin/debtags'; # TODO: maybe add debtags support to generate pkg list? my $supercat = '/usr/bin/spc'; my $scat=''; foreach my $dir (qw(/etc/supercat /usr/share/dlocate ~/.spcrc . )) { $scat="$supercat -c $dir/spcrc-package | $less -R" if (-e "$dir/spcrc-package") ; }; my $pager = $ENV{'DLOCATE_PAGER'} || "$scat" || "$less"; # option processing # this is good enough for testing with. Use Getopt::Long later. # TODO: options for: # - fixed pkg names # - pass-through of grep-dctrl options # - grep-dctrl of /var/lib/apt/lists/*_Packages # - dlocate -l search # - debtags search # - anything else that can generate a list of pkg names (eliminate need for `xargs | dlocate-browse`) # # read all of the above from stdin in their native output formats # # TODO: signal handling, SIGTSTP and SIGCONT my $dctrl_args = '-e'; # -f == fixed package names if ($ARGV[0] eq '-f') { shift ; $dctrl_args = '-P -e'; }; my @search = @ARGV; my $search = join('|',sort(@search)); $search = '^(' . $search . ')$' if ($dctrl_args =~ /-P/o); my (@values, %labels, @help); run_search(@search); # Create the root Curses::UI object. my $cui = new Curses::UI(-clear_on_exit => 0, -mouse_support => 0, -color_support => 1, # -bg => "blue", # -fg => "white", -debug => $debug, ); # create window objects my ($w,$w0); my %args = (-border => 0, -titlereverse => 1, -padtop => 0, -padbottom => 2, -ipad => 0, # -bg => "blue", # -fg => "white", ); $w = $cui->add('w', 'Window', -title => "Debian Package Browser", %args ); $w0 = $cui->add('w0', 'Window', -border => 0, -y => -1, -height => 2, # -bg => "blue", # -fg => "white", ); $w0->add('explain', 'Label', # -text => "v=view c=clear selection t=tag u=untag \n" . -text => "v=view c=clear selection \n" . "/,?=search s=fork shell q=quit" ); sub listbox_callback() { # add/remove current item to/from @sel when space/enter is pressed my $listbox = shift; my $label = $listbox->parent->getobj('pkgboxlabel'); my @sel = $listbox->get; @sel = ('') unless @sel; my $sel = join (", ", @sel); $sel =~ s/::::[^ ]*( |$)/$1/og; # TODO: wrap $sel, based on tty width. $label->text("Selected: $sel"); } $w->add('pkgbox', 'Listbox', -y => 0, -padbottom => 2, -values => \@values, -labels => \%labels, -border => 1, -title => 'Package List', -vscrollbar => 0, -multi => 1, -wraparound => 1, -onchange => \&listbox_callback, ); $w->add('pkgboxlabel', 'Label', -y => -1, -bold => 1, -text => "Select package(s) to view", -textwrap => 1, -width => -1, -height => 2, ); # ---------------------------------------------------------------------- # Setup bindings and focus # ---------------------------------------------------------------------- sub bindkey { # (keys), subroutine, help-message my $msg = pop; my $sub = pop; push @help, $msg if ($msg ne ''); foreach (@_) { $cui->set_binding( $sub, $_); }; }; bindkey( qw( v V ), \&show_pkgs, "v - View selected packages" ); bindkey( qw( c C ), \&clear_sel, "c - Clear current selection" ); #bindkey( qw( t T ), \&tag, "t - tag - search & select" ); #bindkey( qw( u U ), \&untag, "u - untag - search & unselect" ); bindkey( qw( s S ), \&fork_shell, "\ns - Fork a shell, without losing selections" ); bindkey( qw( q Q ), \&quit, "q - Quit" ); bindkey( qw( h H ), \&help, "h - This help" ); #bindkey( qw( "\cL" "\cR" ), sub{ $cui->draw; $w->draw}, "\n^L - Redraw" ); bindkey( qw( "\cZ" ), sub{ \&STOP}, ''); # ---------------------------------------------------------------------- # Get things rolling... # ---------------------------------------------------------------------- $w->focus; # start the event loop $cui->mainloop; ### ### ### subroutines ### ### sub maxlen { # return the maximum string length of elements in an array my $width = 0; foreach (@_) { $width = length($_) if (length($_) > $width); }; return($width); }; sub run_search { @values = (); # global %labels = (); # global local $/=''; my $pwidth=0; my $vwidth=0; my $dwidth=0; my %p = (); my %d = (); my %v = (); my $cmd="$dctrl -s Package,Version,Description $dctrl_args '$search' $dctrl_f"; open(DCTRL,'-|',$cmd); while () { my ($pkg,$version,$desc) = ('',''); foreach (split /\n/) { next unless (m/^(Package|Version|Description)/io); chomp; my ($key,$val) = split /\s*:\s*/,$_,2; $pkg = $val if ($key eq 'Package'); $version = $val if ($key eq 'Version'); $desc = $val if ($key =~ m/^Description/io); }; my $key = "${pkg}::::${version}"; $p{$key} = $pkg; $d{$key} = $desc; $v{$key} = $version; #$pwidth = length($pkg) if (length($pkg) > $pwidth); #$vwidth = length($version) if (length($version) > $vwidth); }; close(DCTRL); $pwidth = maxlen(keys %p); $vwidth = maxlen(keys %v); my ($cols,$rows) = GetTerminalSize; my $c2 = int(($cols - 8) / 2); # half of the usable space my $pmax = int($c2 * 2/3); # maximum of 1/3 of term. width for pkg name my $vmax = int($c2 * 1/3); # maximum of 1/6 of term. width for pkg version $pwidth = $pmax if ($pwidth gt $pmax); $vwidth = $vmax if ($vwidth gt $vmax); $dwidth = $cols - $pwidth - $vwidth - 8; # remainder of term. width for desc %labels = map { $_ => sprintf( "%-${pwidth}s %${vwidth}s %-${dwidth}s", substr($p{$_},0,($pwidth-1)), substr($v{$_},0,($vwidth-1)), substr($d{$_},0,($dwidth-1)) ) } keys %p; @values = sort keys %labels; # if ($debug) { print STDERR "cmd='$cmd'\n"; print STDERR "c=$cols r=$rows c2=$c2\n"; print STDERR "pw=$pwidth vw=$vwidth dw=$dwidth\n"; print STDERR "pm=$pmax vm=$vmax\n"; # print STDERR pp(\@values), "\n"; # print STDERR pp(\%labels), "\n"; #exit; # }; }; sub tag { # TODO: dialog box to search and select packages # e.g. like mutt, but much more primitive. }; sub untag { # TODO: dialog box to search and unselect packages }; sub clear_sel { my $listbox = $w->getobj('pkgbox'); $listbox->clear_selection(); $listbox->draw; }; sub show_pkgs { my $listbox = $w->getobj('pkgbox'); my $sel = ''; my @sel = $listbox->get; if (@sel) { # show the current selections, if any $sel = join(' ',@sel); } else { # else show the package under the cursor $sel = $listbox->get_active_value; }; $sel =~ s/::::[^ ]*( |$)/$1/og; return unless $sel; $cui->leave_curses(); system("(echo ; $aptcache show $sel) | $pager"); $cui->reset_curses(); $cui->draw; $w->draw; }; sub fork_shell { my $listbox = $w->getobj('pkgbox'); my $shell = $ENV{'SHELL'} || '/bin/bash'; $cui->leave_curses(); print "Forking shell. Type 'exit' to return to $program\n\n"; # print the selections, if any for convenient copy-pasting. my @sel = $listbox->get; if (@sel) { my $sel = join(' ',@sel); $sel =~ s/::::[^ ]*( |$)/$1/og; print "Packages selected: $sel\n"; }; print STDERR "exec shell\n" if $debug; system($shell); $cui->reset_curses(); $cui->draw; $w->draw; }; sub quit { my $listbox = $w->getobj('pkgbox'); $cui->leave_curses(); # print the selections, if any for convenient copy-pasting or # for populating a bash array with pkgs=`( $(dlocate-browser ... ) )` my @sel = $listbox->get; if (@sel) { my $sel = join(' ',@sel); $sel =~ s/::::[^ ]*( |$)/$1/og; print "$sel\n"; } ; exit ; }; sub help { $cui->dialog( # TODO: height and width options aren't used by cui->dialog. # create a new window instead. # -height => (@help + 5), # -width => (maxlen(@help) + 10), -title => "$program $pversion help", -message => join("\n",@help,"\n\nIf any packages are selected, they will be printed\nto STDOUT on quitting or forking.\n"), ); }; sub TSTP { $cui->leave_curses(); kill 'STOP', $$; }; sub CONT { $cui->reset_curses(); $cui->draw; $w->draw; } $SIG{TSTP} = &TSTP; $SIG{CONT} = &CONT; # Local variables: # mode: shell-script # End: # ex: ts=2 sts=2 sw=2 et filetype=perl dlocate/dlocate.10000664000000000000000000002014012750257117011062 0ustar .TH DLOCATE 1 "2016-06-20" "Debian Project" "dlocate" .\" Please adjust this date whenever revising the manpage. .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME dlocate - program to view debian package information .SH SYNOPSIS .B dlocate .RI [ OPTIONS ] .RI [ command ] .RB [ .IR package .\|.\|. | .IR PATTERN .\|.\|.] . .SH "DESCRIPTION" .PP .B dlocate is a fast alternative to dpkg for queries like `dpkg \-L' and `dpkg \-S' .SH COMMANDS .TP .BR (none) List all records where either the package name or the filename matches .IR PATTERN . Note that dlocate uses GNU grep, so normal regexp metacharacters need to be taken into account or avoided by using the '\-F' (Fixed String) grep option. For example, to search for `/usr/bin/[', you might try: \fBdlocate '/usr/bin/\\['\fP or \fBdlocate \-F '/usr/bin/['\fP .TP .BR \-S List all records where only the filename matches .IR PATTERN . Note that dlocate uses GNU grep, so normal regexp metacharacters need to be taken into account. Fixed String searches are incompatible with \-S. For example, to search for `/usr/bin/[', you need to type: \fBdlocate '/usr/bin/\\['\fP .TP .BR \-l Regexp-enhanced emulation of `dpkg \-l'. Shows all packages which match .IR package . Internally this uses grep on a file containing the reformatted output of 'dpkg \-l' (four fields separated by tabs; status, package-name, installed version, short description) so it will return packages whose version or short description matches, too. Various flavours of regular expression are supported. For example, Extended Regexp: \fBdlocate \-l '^..[[:space:]]libc6'\fP or Perl Regexp: \fBdlocate \-P \-l '^..\\slibc6'\fP Both of these will list all the packages whose names start with `libc6'. Note that because of the difference between regular expressions and dpkg's shell\-style pattern matching, the output from \fBdlocate \-l\fP is occasionally different to the output from \fBdpkg \-l\fP. This is not a bug, regular expressions are far more flexible than shell pattern matching. This is the way dlocate is supposed to run, but it may require some knowledge of regular expressions to get the output you want. .TP .BR \-k List package names of installed kernels and all related packages .TP .BR \-K Detailed list of installed kernels and all related packages .TP .BR \-L List all files in .IR package . .TP .BR \-s Print status of .IR package . .TP .BR \-\^\-ls `ls \-ldF' of all files in .IR package . .TP .BR \-\^\-lsconf `ls \-ldF' of conffiles in .IR package . .TP .BR \-\^\-conf List conffiles in .IR package . .TP .BR \-\^\-du `du \-sck' of all files in .IR package . .TP .BR \-\^\-md5sum List md5sums (if any) of .IR package . .TP .BR \-\^\-md5check Check md5sums (if any) of .IR package . .TP .BR \-\^\-man List man pages (if any) in .IR package . .TP .BR \-\^\-lsman List full path/filenames of man pages (if any) in .IR package . .TP .BR \-\^\-lsbin List full path/filenames of executable files (if any) in .IR package . .TP .BR \-\^\-lsdir List only the directories in .IR package . .SH OPTIONS .TP .BR \-\^\-filename\-only Only output file names when searching for files .TP .BR \-\^\-package\-only Only output package names when searching for files .TP .BR \-w ", " \-\^\-word\-regexp Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore. .TP .BR \-i ", " --ignore-case Ignore case distinctions in the PATTERN .TP .BR \-E ", " \-\^\-extended\-regexp Interpret .I PATTERN as an extended regular expression. This is the default. .TP .BR \-F ", " \-\^\-fixed\-strings Interpret .I PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. .TP .BR \-G ", " \-\^\-basic\-regexp Interpret .I PATTERN as a basic regular expression. .TP .BR \-P ", " \-\^\-perl\-regexp Interpret .I PATTERN as a Perl regular expression. This is considered to be highly experimental within GNU grep and may warn of unimplemented features. .TP .BR \-h ", " \-\-help Display help message and exit. .TP .BR \-V ", " \-\-version Display dlocate's version number and exit. .TP .BR \-v ", " \-\-verbose ", " \-\-debug Produce verbose debugging output .PP .TP .BR \-c ", " \-\-columns [ =\fIcolumns\fP ] Set COLUMN width to override the \fBdlocate\fP default of using the entire terminal line width. Any value for \fIcolumns\fP less than 80 will be increaed to 80. .TP .BR \-C ", " \-\-colour ", " \-\-color Colourise -l or -s output (requires supercat to be installed) .SH FILES .TP .I /etc/default/dlocate Configuration file with default options. Currently the only option is to enable/disable gzip compression of /var/lib/dlocate/dlocatedb. .TP .I /var/lib/dlocate/dlocatedb Plain text listing of all files belonging to all packages (optionally compressed) .TP .I /var/lib/dlocate/dpkg-list Listing of all packages known to dpkg. See \fBupdate\-dlocatedb\fP(8) for details. .SH EXAMPLES To find which package `/usr/bin/[' belongs to: .br \fB dlocate '/usr/bin/\\['\fP .br To view all man pages contained within the dpkg package: .br \fB man $(dlocate \-man dpkg)\fP .br To purge kernel version 2.6.28.7 and all related module packages: .br \fB dlocate \-k | grep \-\- \-2.6.28.7 | xargs apt\-get purge\fP .br To check the md5sums of the dlocate package: .br \fB dlocate \-\-md5check dlocate\fP .br To use dpkg-repack to make a backup copy of all installed mythtv packages just before upgrading them: .br \fB dlocate \-l mythtv | awk '/^.i/ {print $2}' | xargs dpkg\-repack\fP .br .br .nf # dlocate \-l mythtv | awk '/^.i/ {print $2}' | xargs dpkg\-repack .br dpkg-deb: building package `libmythtv-perl' in `./libmythtv-perl_0.21.svn20090414-0.0_amd64.deb'. .br dpkg-deb: building package `mythtv' in `./mythtv_0.21.svn20090414-0.0_amd64.deb'. .br dpkg-deb: building package `mythtv-backend' in `./mythtv-backend_0.21.svn20090414-0.0_amd64.deb'. .br dpkg-deb: building package `mythtv-common' in `./mythtv-common_0.21.svn20090414-0.0_amd64.deb'. .br dpkg-deb: building package `mythtv-database' in `./mythtv-database_0.21.svn20090414-0.0_amd64.deb'. .br dpkg-deb: building package `mythtv-doc' in `./mythtv-doc_0.21.svn20090414-0.0_amd64.deb'. .br dpkg-deb: building package `mythtv-frontend' in `./mythtv-frontend_0.21.svn20090414-0.0_amd64.deb'. .br dpkg-deb: building package `mythtv-perl' in `./mythtv-perl_0.21.svn20090414-0.0_amd64.deb'. .br dpkg-deb: building package `mythtv-status' in `./mythtv-status_0.9.0-5_amd64.deb'. .br dpkg-deb: building package `mythtv-themes' in `./mythtv-themes_0.21-0.0_amd64.deb'. .br dpkg-deb: building package `mythtvfs' in `./mythtvfs_0.5.2-2_amd64.deb'. .br dpkg-deb: building package `python-mythtv' in `./python-mythtv_0.21.svn20090414-0.0_amd64.deb'. .br .fi .SH NOTES \fBdlocate\fP does not update its databases (see \fBFILES\fP section) automatically after new or upgraded packages have been installed with \fBdpkg\fP or \fBapt-get\fP etc. .br .br A daily cron job is run to perform the update. Or the root user can run \fPupdate-dlocatedb\fP at any time to force an update. .br .SH ENVIRONMENT VARIABLES .TP .BR COLUMNS Sets the number of columns \fBdlocate\fP should use when displaying formatted text. Currently only used by \-l. Values lower than 80 are increased to 80. .SH "SEE ALSO" \fBdpkg\fP(1), \fBupdate\-dlocatedb\fP(8), \fBgrep\fP(1) and \fBgrep\-dctrl\fP(1). .SH AUTHOR \fBdlocate\fP was written by Jim Pick and Craig Sanders . dlocate is Free Software licensed under the GNU General Public License. dlocate/dpkg-hold0000775000000000000000000000103313705513654011166 0ustar #!/bin/bash # dpkg-hold -- command line tool to flag package(s) as held. # # by Craig Sanders, 1998-10-26. This script is hereby placed into the # public domain. # # 2017-09-06 update: apt-mark does this better. My dpkg-hold etc # scripts are now wrappers around apt-mark and continue to exist only so # that any existing scripts that depend on them don't break.. if [ -z "$*" ] ; then echo "Usage:" echo " dpkg-hold " exit 1 fi #for i in $@ ; do # echo "$i hold" #done | dpkg --set-selections apt-mark hold "$@" dlocate/dpkg-hold.80000664000000000000000000000166112732134477011341 0ustar .TH DPKG-HOLD 8 "2009-06-02" "Debian Project" "dlocate" .\" Please adjust this date whenever revising the manpage. .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH NAME dpkg-hold - mark packages as `hold' to prevent installation .SH SYNOPSIS .B dpkg-hold .RI [ PACKAGE .\|.\|.] .SH "DESCRIPTION" .PP .B dpkg-hold marks package(s) to be held. It achieves this by running `dpkg \-\-set\-selections' and piping in the package name(s) followed by `hold'. NOTE: This program does not install, remove, purge any package. It ONLY sets the status of the package. Any actual removal or purging is done the next time dselect, apt-get, aptitude, etc are run. .SH "SEE ALSO" \fBdpkg\fP(1), \fBdpkg-unhold\fP(1), \fBdpkg-remove\fP(1), \fBdpkg-purge\fP(1) .SH AUTHOR dpkg-hold was written Craig Sanders . dpkg-hold is Free Software placed in the public domain. dlocate/dpkg-purge0000775000000000000000000000104313705513656011365 0ustar #!/bin/bash # dpkg-purge -- command line tool to flag package(s) to be purged. # # by Craig Sanders, 1998-10-26. This script is hereby placed into the # public domain. # # 2017-09-06 update: apt-mark does this better. My dpkg-hold etc # scripts are now wrappers around apt-mark and continue to exist only so # that any existing scripts that depend on them don't break.. if [ -z "$*" ] ; then echo "Usage:" echo " dpkg-hold " exit 1 fi #for i in $@ ; do # echo "$i purge" #done | dpkg --set-selections apt-mark purge "$@" dlocate/dpkg-purge.80000664000000000000000000000164112732134477011533 0ustar .TH DPKG-PURGE 8 "2009-06-02" "Debian Project" "dlocate" .\" Please adjust this date whenever revising the manpage. .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH NAME dpkg-purge - mark packages for purge .SH SYNOPSIS .B dpkg-purge .RI [ PACKAGE .\|.\|.] .SH "DESCRIPTION" .PP .B dpkg-purge marks package(s) to be purged. It achieves this by running `dpkg \-\-set\-selections' and piping in the package name(s) followed by `purge'. NOTE: This program does not install, remove, purge any package. It ONLY sets the status of the package. Any actual removal or purging is done the next time dselect, apt-get, aptitude, etc are run. .SH "SEE ALSO" \fBdpkg\fP(1), \fBdpkg-hold\fP(1), \fBdpkg-unhold\fP(1), \fBdpkg-remove\fP(1) .SH AUTHOR dpkg-purge was written Craig Sanders . dpkg-purge is Free Software placed in the public domain. dlocate/dpkg-remove0000775000000000000000000000105513705513660011536 0ustar #!/bin/bash # dpkg-remove -- command line tool to flag package(s) for removal. # # by Craig Sanders, 1998-10-26. This script is hereby placed into the # public domain. # # 2017-09-06 update: apt-mark does this better. My dpkg-hold etc # scripts are now wrappers around apt-mark and continue to exist only so # that any existing scripts that depend on them don't break.. if [ -z "$*" ] ; then echo "Usage:" echo " dpkg-deinstall " exit 1 fi #for i in $@ ; do # echo "$i deinstall" #done | dpkg --set-selections apt-mark remove "$@" dlocate/dpkg-remove.80000664000000000000000000000165512732134477011713 0ustar .TH DPKG-REMOVE 8 "2009-06-02" "Debian Project" "dlocate" .\" Please adjust this date whenever revising the manpage. .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH NAME dpkg-remove - mark packages for removal .SH SYNOPSIS .B dpkg-remove .RI [ PACKAGE .\|.\|.] .SH "DESCRIPTION" .PP .B dpkg-remove marks package(s) to be removed. It achieves this by running `dpkg \-\-set\-selections' and piping in the package name(s) followed by `deinstall'. NOTE: This program does not install, remove, purge any package. It ONLY sets the status of the package. any actual removal or purging is done the next time dselect, apt-get, aptitude, etc are run. .SH "SEE ALSO" \fBdpkg\fP(1), \fBdpkg-hold\fP(1), \fBdpkg-unhold\fP(1), \fBdpkg-purge\fP(1) .SH AUTHOR dpkg-remove was written Craig Sanders . dpkg-remove is Free Software placed in the public domain. dlocate/dpkg-unhold0000775000000000000000000000105713705513662011536 0ustar #!/bin/bash # dpkg-unhold -- command line tool to remove the hold flag on package(s). # # by Craig Sanders, 1998-10-26. This script is hereby placed into the # public domain. # # 2017-09-06 update: apt-mark does this better. My dpkg-hold etc # scripts are now wrappers around apt-mark and continue to exist only so # that any existing scripts that depend on them don't break.. if [ -z "$*" ] ; then echo "Usage:" echo " dpkg-unhold " exit 1 fi #for i in $@ ; do # echo "$i install" #done | dpkg --set-selections apt-mark unhold "$@" dlocate/dpkg-unhold.80000664000000000000000000000223412732134477011701 0ustar .TH DPKG-UNHOLD 8 "2009-06-02" "Debian Project" "dlocate" .\" Please adjust this date whenever revising the manpage. .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH NAME dpkg-unhold - mark held packages for installation .SH SYNOPSIS .B dpkg-unhold .RI [ PACKAGE .\|.\|.] .SH "DESCRIPTION" .PP .B dpkg-unhold marks package(s) to be installed. It achieves this by running `dpkg \-\-set\-selections' and piping in the package name(s) followed by `install'. NOTE: This program does not install, remove, purge any package. It ONLY sets the status of the package. Any actual removal or purging is done the next time dselect, apt-get, aptitude, etc are run. .SH "BUGS" The name is little bit of a misnomer in that it marks the package for installation. This effectively "unholds" the package if it is held, but will cause dselect/apt/etc to install it if it wasn't already installed. .SH "SEE ALSO" \fBdpkg\fP(1), \fBdpkg-hold\fP(1), \fBdpkg-remove\fP(1), \fBdpkg-purge\fP(1) .SH AUTHOR dpkg-unhold was written Craig Sanders . dpkg-unhold is Free Software placed in the public domain. dlocate/spcrc-dpkg-l0000664000000000000000000000152512744713631011605 0ustar # HTML COLOR NAME COL A N T STRING or REGULAR EXPRESSION #################### ### # # # ################################################################ # default bold white (I don't like bold much but need to highlight installed vs uninstalled packages) White whi b 1 (.*) # Header White whi 1 (^[D|+].*) # Versions Green grn 1 [[:space:]]([0-9~:.]{2,}[-+:.0-9a-z~]+)[[:space:]] Magenta mag 1 (<[^:]*>) # # See `man dpkg-query` for details. # # Desired Red red b 1 ^(u[^n]) White whi 1 ^(un.*) Cyan cya 1 ^([h].*) White whi 1 ^([rp][^n].*) Magenta mag 1 ^([rp])[^n] # Status Magenta mag 1 ^.([cHUFWt]) # Errors Red red b 1 ^([uirph][ncHUFWti]R.*) dlocate/spcrc-package0000664000000000000000000000075713705514030012016 0ustar # HTML COLOR NAME COL A N T STRING or REGULAR EXPRESSION #################### ### # # # ################################################################ # field names Green grn (^[^ :]*): # Version strings Red red [[:space:]]([0-9]+\.[-+:.0-9a-z~]+)([^,)]|$) # Maintainer name Yellow yel ^Maintainer: ([^<]*) # Maintainer address Magenta mag (<[^>]+@[^>]+>) # URL Yellow yel ([a-z]+://.*) dlocate/test-dlocate.sh0000775000000000000000000000152513705513674012326 0ustar #!/bin/bash # simple script to test # run like so: # # ./test-dlocate.sh > new.output 2>&1 ; diff -u test.output new.output # # or just 'make test' FILE="/usr/bin/dlocate /usr/sbin/cron /usr/bin/dpkg /usr/bin/apt" NONFILE=/tmp/foo/bar/filedoesnotexist EXIST="dlocate bash dpkg apt" NOTEXIST=packagedoesnotexist EMPTY="xmp" for opt in " " "-S" ; do for file in $FILE $NONFILE; do echo '-------------------------------' echo "running: ./dlocate $opt $file" ./dlocate -v $opt $file echo '-------------------------------' echo done done for opt in -l -du -conf -lsconf -md5sum -md5check -man -lsman -lsbin ; do for pkg in $EXIST $NOTEXIST $EMPTY ; do echo '-------------------------------' echo "running: ./dlocate $opt $pkg" ./dlocate -v $opt $pkg echo '-------------------------------' echo done done dlocate/update-dlocatedb0000775000000000000000000000242313705513702012514 0ustar #!/bin/sh DPKGLIST='/var/lib/dlocate/dpkg-list' pkgs=1 files=1 usage() { [ -n "$*" ] && printf "%s\n" "$*" > /dev/stderr && exit 1 cat <<__EOF__ Usage: $0 [options] Options: -p Update the packages list only -f Update the files list only -b Update both (default) -h This help message __EOF__ exit 1 } while getopts "pfbh" opt; do case "$opt" in p) pkgs=1 ; files='' ;; f) pkgs='' ; files=1 ;; b) pkgs=1 ; files=1 ;; h) usage ;; *) usage "%s\n" "Unknown option: '$opt'" ;; esac done shift $((OPTIND-1)) # See ionice(1) if [ -x /usr/bin/ionice ]; then # don't run ionice if kernel version < 2.6.13 KVER=$(uname -r) case "$KVER" in 2.[012345]*) ;; 2.6.[0-9]) ;; 2.6.[0-9].*) ;; 2.6.1[012]*) ;; # Redirect ionice output to /dev/null because VSERVER & OPENVZ # & probably other container environments don't like it. See # Bug#456292 *) ionice -c3 -p$$ > /dev/null 2>&1 ;; esac fi if [ -n "$files" ] ; then # update dlocate database test -x /usr/share/dlocate/updatedb && /usr/share/dlocate/updatedb >/dev/null fi if [ -n "$files" ] ; then # update dpkg-list test -x /usr/share/dlocate/update-dpkg-list && /usr/share/dlocate/update-dpkg-list >/dev/null fi dlocate/update-dlocatedb.80000664000000000000000000000365712732134477012700 0ustar .TH UPDATE\-DLOCATEDB 8 "2016-06-20" "Debian Project" "dlocate" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME update\-dlocatedb - generate text database of installed files for dlocate .SH SYNOPSIS .B update\-dlocatedb .SH DESCRIPTION .B update\-dlocatedb generates a plain text package contents listing from the files /var/lib/dpkg/info/*.list .PP This program is usually called from cron.daily. .SH OPTIONS .TP .BR \-p Update the packages list only .TP .BR \-j Update the files list only .TP .BR \-b Update both (default) .TP .BR \-h This help message .SH FILES .TP .I /etc/default/dlocate Configuration file with default options. Currently the only option is to enable/disable gzip compression of the dlocatedb file. .TP .I /var/lib/dpkg/info Directory containing dpkg file lists .TP .TP .I /var/lib/dlocate/dlocatedb Plain text listing of all files belonging to all packages (optionally compressed) .TP .I /var/lib/dlocate/dpkg-list Listing of all packages known to dpkg. This contains the reformatted output output of 'dpkg \-l'. The file format is four fields separated by tabs: status [TAB] package-name [TAB] installed version [TAB] short description The "installed version" field may contain an architecture, e.g. ":arch" .SH SEE ALSO .BR "dlocate(1)" .P .SH AUTHOR This version of update\-dlocatedb was written by Fredrik Hallenberg, Craig Sanders, and Pawel Chmielowski. .PP The manual page was written by Andreas Metzler for the Debian GNU/Linux system (but may be used by others, under the terms of the GNU GPL). dlocate/update-dpkg-list0000775000000000000000000000515514170451060012471 0ustar #!/usr/bin/perl use strict; use warnings; use File::Basename; my $program = basename($0); my %packages = (); my $myarch = qx(dpkg --print-architecture); chomp $myarch; # pre-declare subroutines (see below for implementation) use subs qw(parse_pkg); # get details for all packages known by dpkg open(DPKG,'-|','dpkg -l "*"'); while() { next unless (m/^[uihrp][ncHUFWti]/); chomp; my ($status,$pkg,$version,$arch,$desc) = split /\s+/,$_,5; $pkg =~ s/:.*//; $packages{"$pkg"}->{$arch}->{'status'} = sprintf('%-3s',$status); $packages{"$pkg"}->{$arch}->{'version'} = $version; $packages{$pkg}->{$arch}->{'desc'} = $desc; } close(DPKG); # now get missing details for uninstalled packages $/=''; open(DCTRL,'-|',"grep-available -e . -s Package,Description,Architecture,Version"); while() { parse_pkg('DCTRL',$_); }; close(DCTRL); my $dlist = '/var/lib/dlocate/dpkg-list'; open(DPKGLIST,'>', "$dlist.new") or die "$program: couldn't open $dlist.new for write: $!\n"; foreach (sort keys %packages) { foreach my $arch (sort keys %{ $packages{$_} } ) { next if ($arch eq ''); my $pkg = ($arch =~ m/^($myarch|all)$/io) ? $_ : "$_:$arch"; printf DPKGLIST "%s\t%s\t%s:%s\t%s\n", #printf DPKGLIST "%s\t%s\t%s\t%s\t%s\n", $packages{$_}->{$arch}->{'status'}, $pkg, $packages{$_}->{$arch}->{'version'}, $arch, $packages{$_}->{$arch}->{'desc'}; }; }; close(DPKGLIST); rename("$dlist.new", $dlist); ### ### subroutines ### sub parse_pkg { my $calltype = shift; my ($pkg,$desc,$status,$version,$arch) = ('','(no description available)','un ','',''); # split package details by newline foreach (split /\n/,$_) { next unless (m/^(Package|Description(?:-..)?|Architecture|Version):/o); my ($field, $val) = split /: /,$_,2; if ($field eq 'Package') { $pkg = $val ; } elsif ($field =~ m/Description(?:-..)?/io) { $desc = $val; } elsif ($field eq 'Version') { $version = $val; } elsif ($field eq 'Architecture') { $arch = $val; }; }; #$desc = "$calltype $desc"; return unless ($pkg && $arch); return if ($arch ne $myarch && !defined($packages{$pkg}->{$arch})); $packages{$pkg}->{$arch}->{'desc'} = $desc; if (!defined($packages{$pkg}->{$arch}->{'status'})) { $packages{$pkg}->{$arch}->{'status'} = 'un '; }; if ( ! defined($packages{$pkg}->{$arch}->{'version'}) || $packages{$pkg}->{$arch}->{'version'} eq '' ) { $packages{$pkg}->{$arch}->{'version'} = $version; }; if (!defined($packages{$pkg}->{$arch})) { $packages{$pkg}->{$arch}->{'arch'} = $arch; }; }; dlocate/updatedb0000775000000000000000000000706113705514040011102 0ustar #!/usr/bin/perl # perl script originally by hallon@debian.org, much faster than sed & sh. # # modified by cas to pipe its output through frcode and then > to the # db file. # # caching of .list timestamps and re-use of old locatedb data added by # Pawel Chmielowski , see Bug #457572 # 2009-05-30 Craig Sanders # - rewrote script to output a plain text listing rather than use frcode # # 2009-06-03 # Craig Sanders # - added optional support for compressing /var/lib/dlocatedb use strict; use File::Basename; my $program = basename($0); my $dbfile='/var/lib/dlocate/dlocatedb'; my $stampsfile='/var/lib/dlocate/dlocatedb.stamps'; #my $dbfile='/tmp/dlocate'; #my $stampsfile='/tmp/dlocate.stamps'; my $infodir='/var/lib/dpkg/info'; my $compress=0; my $defaults='/etc/default/dlocate'; if (open(DEFAULTS,'<', $defaults)) { while () { chomp; s/#.*|^\s*|\s*$//g; next if (/^$/); s/\s|"//g; my ($key,$val) = split /=/; if ($key eq 'COMPRESS_DLOCATE') { $compress = $val; }; }; close(DEFAULTS); }; my (%old_stamps, %stamps); if (open(STAMPS, '<', $stampsfile)) { while () { chomp; my ($stamp, $file) = split /:/, $_, 2; $old_stamps{$file} = $stamp; } close(STAMPS); } open(DBFILE,'>', "$dbfile.new") or die "$program: couldn't open $dbfile.new for write: $!\n"; opendir(DIR, $infodir) or die "$program: can't open directory $infodir: $!\n"; while (defined(my $pkg = readdir(DIR))) { next unless $pkg =~ s/\.list$// and -s "$infodir/$pkg.list"; $stamps{$pkg} = (stat(_))[10]; #ctime } closedir DIR; my @new_pkgs; my %processed; chdir $infodir; if (%old_stamps and open(DB, '<', $dbfile)) { while () { my ($pkg) = /^(\S+?):/; if (not exists $stamps{$pkg}) { # skip packages which are no longer installed } elsif (exists $old_stamps{$pkg} and $stamps{$pkg} == $old_stamps{$pkg}) { print DBFILE $_; } elsif (not exists $processed{$pkg}) { open(FILE, "$pkg.list") or die "$program: can't open file $pkg.list: $!\n"; foreach () { print DBFILE "$pkg: $_"; } close FILE; } $processed{$pkg} = 1; } close(DB); my %tmp = %stamps; delete $tmp{$_} for keys %processed; @new_pkgs = keys %tmp; } else { @new_pkgs = keys %stamps; } foreach my $pkg (@new_pkgs) { open(FILE, '<', "$pkg.list") or die "$program: can't open new $pkg.list for read: $!\n"; foreach () { print DBFILE $pkg, ': ', $_; } close FILE; } # append diversions info to dlocatedb my $divpipe = 'dpkg-divert --list \*'; open(DIVERSIONS,"-|",$divpipe) or die "$program: can't open pipe from '$divpipe': $!\n"; while () { print DBFILE $_ } close(DIVERSIONS); close DBFILE; # Create a backup to the database before replacing it with the new database. # This is effectively two rename's done atomically. if (-e $dbfile) { unlink("$dbfile.old") if (-e "$dbfile.old"); link($dbfile, "$dbfile.old") if (-e $dbfile); } rename("$dbfile.new", $dbfile); # optionally compress dlocatedb if ($compress eq "1") { system('gzip','--quiet','--force',$dbfile); rename("$dbfile.gz", $dbfile); }; open(STAMPS, '>', "$stampsfile.new") or die "$program: can't create stamps file $stampsfile.new: $!\n"; print STAMPS "$stamps{$_}:$_\n" for keys %stamps; close STAMPS; if (-e $stampsfile) { unlink($stampsfile); }; rename("$stampsfile.new", $stampsfile);