Codebase list debian-goodies / ad20e21
Add new command check-enhancements by George Danchev Closes: #679927 Add build-dependency on help2man for check-enhancements' man page Axel Beckert 10 years ago
8 changed file(s) with 155 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 #!/bin/bash
1
2 # Copyright (C) 2012 George Danchev <danchev@spnet.net>
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 # 02111-1307, USA.
18
19 SELF=$(basename "$0")
20 VER=0.3
21
22 OPT_CHECK_INSTALLED_PACKAGES=0
23 OPT_SHOW_INSTALLED_ENHANCEMENTS=0
24 OPT_VERBOSE=0
25
26 print_version() {
27 echo "$VER"
28 }
29
30 print_help() {
31 cat << HLP
32 ${SELF} - show enhancement packages.
33 Options:
34 Program options start with dash or double dash, otherwise they
35 are interpreted as package names. Only non-installed enhancement
36 packages are printed out by default, use -ie to show them all.
37
38 -ip|--ip|-installed-packages|--installed-packages
39 Show enhancements of all installed packages (could be slow)
40 -ie|--ie|-installed-enhancements|--installed-enhancements
41 Show installed enhancement packages too
42 -h|-help|--help
43 -version|--version
44 -verbose|--verbose
45
46 Examples:
47 # check enhancement packages of all installed packages
48 ${SELF} -ip
49 # check enhancement packages of selected packages
50 ${SELF} pkg1 pkgN
51
52 HLP
53 }
54
55 pkgs_enhancing_pkg_status() {
56 # Figure out package Enhances:'ing a given package
57 EN=`grep-dctrl -n -s Package -F Enhances -X "${1}" /var/lib/apt/lists/*Packages`
58 case $? in
59 0) if test $OPT_VERBOSE != 0; then echo -e "Package <<$1>> could be Enhanced by:"; fi
60 ;;
61 1) continue
62 ;;
63 *) echo "${SELF}: Internal Error!"
64 exit 1
65 ;;
66 esac
67 for e in `echo "${EN}" | sort | uniq | xargs` # now sort and unify
68 do
69 # Figure out whether those enhancements are installed or not.
70 # By default only output non-installed enhancements
71 OUT=""
72 case "${OPT_SHOW_INSTALLED_ENHANCEMENTS}" in
73 0) OUT=`apt-cache policy ${e} | head -3 | paste -s | grep "Installed: (none)"`
74 ;;
75 1) OUT=`apt-cache policy ${e} | head -3 | paste -s`
76 ;;
77 esac
78 if test x"$OUT" != x""; then printf "%2s => " "$1" && echo "${OUT}"; fi
79 done
80 }
81
82 # main
83 declare -a PKGS=()
84 for op in $@
85 do
86 case "${op}" in
87 -ip|--ip|-installed-packages|--installed-packages)
88 OPT_CHECK_INSTALLED_PACKAGES=1
89 ;;
90
91 -ie|--ie|-installed-enhancements|--installed-enhancements)
92 OPT_SHOW_INSTALLED_ENHANCEMENTS=1
93 ;;
94
95 -h|-help|--help)
96 print_help
97 exit 0
98 ;;
99
100 -version|--version)
101 print_version
102 exit 0
103 ;;
104
105 -verbose|--verbose)
106 OPT_VERBOSE=1
107 ;;
108
109 -*)
110 echo "invalid option ${op}"
111 print_help
112 exit 1
113 ;;
114
115 *)
116 # PKGS[$[${#PKGS[@]}+1]]="${op}"
117 PKGS+=(${op})
118 ;;
119 esac
120 done
121
122 # no options, just show help
123 if test x"$1" == x""; then print_help; exit 0; fi
124
125 # process package names given on the cmdline
126 for cmdline_pkg in "${PKGS[@]}"
127 do
128 pkgs_enhancing_pkg_status $cmdline_pkg
129 done
130
131 # process installed packages, as well
132 case $OPT_CHECK_INSTALLED_PACKAGES in
133 1)
134 for installed in $(grep-status -FStatus "install ok installed" -n -s Package | sort | uniq)
135 do
136 pkgs_enhancing_pkg_status $installed
137 done
138 ;;
139 esac
140
141 exit 0
77 * [dgrep]
88 - Support (d)zegrep and (d)zfgrep.
99 - Fix quoting to allow patterns with blanks
10 * [check-enhancements]
11 - New command by George Danchev (Closes: #679927)
12 - Add build-dependency on help2man for check-enhancements' man page
1013 * Bump debhelper compatibility to 9 to be able to use some more recent
1114 features. Update versioned debhelper build-dependency accordingly.
1215 * Revamp debian/rules
0 check-enhancements.1
22 Priority: optional
33 Maintainer: Javier Fernandez-Sanguino Pen~a <jfs@debian.org>
44 Uploaders: Axel Beckert <abe@debian.org>
5 Build-Depends: debhelper (>= 9~)
5 Build-Depends: debhelper (>= 9~),
6 help2man
67 Vcs-Git: git://anonscm.debian.org/collab-maint/debian-goodies.git
78 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/debian-goodies.git
89 Standards-Version: 3.9.4
3333 - debpaste
3434
3535 Copyright (C) 2009 Hanno Hecker <vetinari@ankh-morp.org>
36
37 - check-enhancements
38
39 Copyright (C) 2012 George Danchev <danchev@spnet.net>
3640
3741 - debian/ contents
3842
0 dgrep dglob debget dpigs debman popbugs which-pkg-broke dhomepage debmany/debmany usr/bin
0 dgrep dglob debget dpigs debman popbugs which-pkg-broke dhomepage debmany/debmany check-enhancements usr/bin
11 checkrestart usr/sbin
22
33 bash_completion/debian-goodies.pkgnames etc/bash_completion.d
66 dpigs.1
77 popbugs.1
88 which-pkg-broke.1
9 check-enhancements.1
910
1011 debmany/man/debmany.1
1112 debmany/man/debmany.de.1
99
1010 override_dh_auto_install:
1111 for prog in $(PODDOC); do pod2man -c "Debian-goodies documentation" $$prog.pod > $$prog.1; done
12 help2man -N -m "Debian-goodies documentation" -o check-enhancements.1 ./check-enhancements
1213
1314 override_dh_auto_clean:
1415 for prog in $(PODDOC); do rm -f $$prog.1; done