Package list debian-goodies / 69bd2c3
Imported Debian version 0.42 Javier Fernandez-Sanguino 9 years ago
15 changed file(s) with 604 addition(s) and 260 deletion(s). Raw diff Collapse all Expand all
00 #!/usr/bin/python
11
22 # Copyright (C) 2001 Matt Zimmerman <mdz@debian.org>
3 #
4 # Further updated by Javier Fernandez-Sanguino <jfs@debian.org>
3 # Copyright (C) 2007,2008 Javier Fernandez-Sanguino <jfs@debian.org>
54 # - included patch from Justin Pryzby <justinpryzby_AT_users.sourceforge.net>
65 # to work with the latest Lsof - modify to reduce false positives by not
76 # complaining about deleted inodes/files under /tmp/, /var/log/,
87 # /var/run or named /SYSV.
8 # - introduced a verbose option
99
1010 # PENDING:
1111 # - included code from 'psdel' contributed by Sam Morris <sam_AT_robots.org.uk> to
4040 import sys
4141 import string
4242 import subprocess
43 import getopt
4344 from stat import *
4445
4546 if os.getuid() != 0:
5758 return location
5859 return 0
5960
61 def usage():
62 sys.stderr.write('usage: checkrestart [-v]\n')
6063
6164 def main():
6265 process = None
6366 toRestart = {}
6467
68 # Process options
69 try:
70 opts, args = getopt.getopt(sys.argv[1:], "hv", ["help", "verbose"])
71 except getopt.GetoptError, err:
72 # print help information and exit:
73 print str(err) # will print something like "option -a not recognized"
74 usage()
75 sys.exit(2)
76 verbose = False
77 for o, a in opts:
78 if o == "-v":
79 verbose = True
80 elif o in ("-h", "--help"):
81 usage()
82 sys.exit()
83 else:
84 assert False, "unhandled option"
85
86 # Start checking
6587 toRestart = lsofcheck()
6688 # Check if we have lsof, if not, use psdel
6789 # if find_cmd('lsof'):
85107 else:
86108 print "(%d distinct programs)" % len(programs)
87109
110 # Verbose information
111 if verbose:
112 for process in toRestart:
113 print "Process %s (PID: %d) " % (process.program, process.pid)
114 process.listDeleted()
115
116
88117 packages = {}
89118 diverted = None
90119 dpkgQuery = ["dpkg", "--search"] + programs.keys()
91 dpkgProc = subprocess.Popen(dpkgQuery, stdout=subprocess.PIPE)
120 dpkgProc = subprocess.Popen(dpkgQuery, stdout=subprocess.PIPE, stderr=None)
92121 for line in dpkgProc.stdout.readlines():
93122 if line.startswith('local diversion'):
94123 continue
117146 for package in packages.values():
118147 if package == 'util-linux':
119148 continue
120 #dpkgQuery = 'dpkg-query --listfiles ' + package.name
121 dpkgQuery = 'dpkg --listfiles ' + package.name
122 for line in os.popen(dpkgQuery).readlines():
149 dpkgQuery = ["dpkg", "--listfiles ", + package.name]
150 dpkgProc = subprocess.Popen(dpkgQuery, stdout=subprocess.PIPE, stderr=None)
151 for line in dpkgProc.stdout.readlines():
123152 path = line[:-1]
124153 if path.startswith('/etc/init.d/'):
125154 if path.endswith('.sh'):
180209 elif field == 'k':
181210 process.links.append(data)
182211 elif field == 'n':
183 # Remove the previous entry to check if this is something we should do
212 # Remove the previous entry to check if this is something we should use
184213 if data.startswith('/SYSV'):
214 # If we find SYSV we discard the previous descriptor
185215 last = process.descriptors.pop()
186 if not re.compile("DEL").search(last):
187 process.files.append(data)
188 elif data.startswith('/dev/zero') or data.startswith('/dev/pts/'):
216 elif data.startswith('/'):
189217 last = process.descriptors.pop()
190 if not re.compile("DEL").search(last):
218 # Add it to the list of deleted files if the previous descriptor
219 # was DEL or lsof marks it as deleted
220 if re.compile("DEL").search(last) or re.compile("deleted").search(data):
191221 process.files.append(data)
192222 else:
193 process.files.append(data)
223 # We discard the previous descriptors and drop it
224 last = process.descriptors.pop()
194225 elif field == 'f':
226 # Save the descriptor for later comparison
195227 process.descriptors.append(data)
196228
197229 toRestart = filter(lambda process: process.needsRestart(),
198230 processes.values())
199231 return toRestart
232
233 # Tells if a file has to be considered a deleted file
234 # Returns:
235 # - 0 (NO) for known locations of files which might be delted
236 # - 1 (YES) for valid deleted files we are interested in
237 def isdeletedFile (f):
238 # We don't care about log files
239 if f.startswith('/var/log/'):
240 return 0
241 # Or about files under temporary locations
242 if f.startswith('/var/run/'):
243 return 0
244 # Or about files under /tmp
245 if f.startswith('/tmp/'):
246 return 0
247 # Or /dev/zero
248 if f.startswith('/dev/zero'):
249 return 0
250 # Or /dev/pts (used by gpm)
251 if f.startswith('/dev/pts/'):
252 return 0
253 # Or /usr/lib/locale
254 if f.startswith('/usr/lib/locale/'):
255 return 0
256 # Skip automatically generated files
257 if f.endswith('icon-theme.cache'):
258 return 0
259 # TODO: it should only care about library files (i.e. /lib, /usr/lib and the like)
260 # build that check with a regexp to exclude others
261 if f.endswith(' (deleted)'):
262 return 1
263 if re.compile("\(path inode=[0-9]+\)$").search(f):
264 return 1
265 # Default: it is a deleted file we are interested in
266 return 1
200267
201268 def psdelcheck():
202269 # TODO - Needs to be fixed to work here
213280 processes = {}
214281 process = processes.setdefault(pid,Process(int(pid)))
215282 deleted = re.compile(r'(.*) \(deleted\)$')
216 boring = re.compile(r'/(dev/zero|SYSV([\da-f]{8}))')
283 boring = re.compile(r'/(dev/zero|SYSV([\da-f]{8}))|/usr/lib/locale')
217284
218285 mapline = re.compile(r'^[\da-f]{8}-[\da-f]{8} [r-][w-][x-][sp-] '
219286 r'[\da-f]{8} [\da-f]{2}:[\da-f]{2} (\d+) *(.+)( \(deleted\))?\n$')
298365 # Support symlinked /usr
299366 if f.startswith('/usr'):
300367 statinfo = os.lstat('/usr')[ST_MODE]
368 # If /usr is a symlink then find where it points to
301369 if S_ISLNK(statinfo):
302370 newusr = os.readlink('/usr')
303371 if not newusr.startswith('/'):
304 newusr = os.path.join(os.path.dirname('/tmp/test'), newusr)
372 # If the symlink is relative, make it absolute
373 newusr = os.path.join(os.path.dirname('/usr'), newusr)
305374 f = re.sub('^/usr',newusr, f)
306 print "Changing usr to " + newusr + " result:" +f;
375 # print "Changing usr to " + newusr + " result:" +f; # Debugging
307376 return re.sub('( \(deleted\)|.dpkg-new).*$','',f)
377
378 def listDeleted(self):
379 listfiles = []
380 listdescriptors = []
381 for f in self.files:
382 if isdeletedFile(f):
383 listfiles.append(f)
384 if listfiles != []:
385 print "List of deleted files in use:"
386 for file in listfiles:
387 print "\t" + file
308388
309389 # Check if a process needs to be restarted, previously we would
310390 # just check if it used libraries named '.dpkg-new' since that's
311391 # what dpkg would do. Now we need to be more contrieved.
392 # Returns:
393 # - 0 if there is no need to restart the process
394 # - 1 if the process needs to be restarted
312395 def needsRestart(self):
313396 for f in self.files:
314 # We don't care about log files
315 if f.startswith('/var/log/'):
316 continue
317 # Or about files under temporary locations
318 if f.startswith('/var/run/'):
319 continue
320 # Or about files under /tmp
321 if f.startswith('/tmp/'):
322 continue
323 # Or /dev/zero
324 if f.startswith('/dev/zero'):
325 continue
326 # Or /dev/pts (used by gpm)
327 if f.startswith('/dev/pts/'):
328 continue
329 # TODO: it should only care about library files (i.e. /lib, /usr/lib and the like)
330 # build that check with a regexp to exclude others
331 if f.endswith(' (deleted)'):
332 return 1
333 if re.compile("\(path inode=[0-9]+\)$").search(f):
334 return 1
335 for f in self.descriptors:
336 # Notice that if it begins with SYSV or /dev/zero
337 # it is not a deleted file and the descriptor was popped already
338 # (see above)
339 # We don't care about log files
340 if f.startswith('/var/log/'):
341 continue
342 # Or about files under temporary locations
343 if f.startswith('/var/run/'):
344 continue
345 # Or about files under /tmp
346 if f.startswith('/tmp/'):
347 continue
348 # Or /dev/zero
349 if f.startswith('/dev/zero'):
350 continue
351 # We care about any other DEL files
352 if re.compile("DEL").search(f):
397 if isdeletedFile(f):
353398 return 1
354399 for f in self.links:
355400 if f == 0:
55 .SH NAME
66 checkrestart \- check which processes need to be restarted after an upgrade
77 .SH SYNOPSIS
8 .B checkrestart
8 .B checkrestart [ -hv ]
99 .SH DESCRIPTION
1010 The
1111 .B checkrestart
2727 .P
2828 This script needs to run as root in order to obtain the information it needs
2929 for analysis.
30
31 .SH OPTIONS
32
33 .TP
34 .BI -h, --help
35 Show the program help and exit.
36
37 .TP
38 .BI -v, --verbose
39 Generate detailed output. This output includes the list of all
40 processes found using deleted files or descriptors as well as the deleted files
41 and descriptors found.
3042
3143 .SH EXIT STATUS
3244
0 debian-goodies (0.42) unstable; urgency=low
1
2 * Updated to version 1.3 of debmany provided by Michael Arlt:
3 - add bash_completion example into examples
4 - add less to Depends, as it is the default viewer for other files.
5 - add zenity to Suggests, it is a graphical alternative for dialog.
6 * Fix popbugs to prevent it from removing temporary files before the browser
7 has opened them, thanks to Chris Lamb for the bug report and the fix
8 (Closes: #471752)
9 * checkrestart:
10 - Add /usr/lib/locale/ to the list of exceptions to prevent false
11 positives when locales are reconfigured.
12 - Change os.popen call to a subprocess.Popen call since python 2.5 does
13 not seem to like lists in os.popen and because subprocess is preferable
14 here.
15 - Recode the utility so that the checks for deleted files and descriptors
16 is not duplicated.
17 - Remove the (useless) check for deleted descriptor
18 - Rewrite the handling of lsof results to be more accurate and
19 understandable.
20 - Add a 'verbose' option that makes it list all the (supposedly) deleted
21 files and descriptors used by the processes (Closes: #466811, #475397) -
22 Add icon-theme.cache to the list of deleted files that will be flagged
23 (Closes: #469133)
24 - Fix properly the handling of /usr as a symlink, the code had some stuff
25 that was used as test case and should have been replaced before
26 uploading, oops. (Closes: #405040)
27 * Add myself to author list in debian/copyright, and fixed a lintian
28 warning there too.
29
30 -- Javier Fernandez-Sanguino Pen~a <jfs@debian.org> Thu, 10 Jul 2008 00:30:39 +0200
31
32 debian-goodies (0.41) unstable; urgency=low
33
34 * Make the dpkg --list query use an array to call the shell so that odd
35 package names will not affect it.
36
37 -- Javier Fernandez-Sanguino Pen~a <jfs@debian.org> Sat, 29 Mar 2008 21:38:20 +0100
38
039 debian-goodies (0.40) unstable; urgency=low
140
241 * checkrestart:
66
77 Package: debian-goodies
88 Architecture: all
9 Depends: dctrl-tools | grep-dctrl, curl, python (>= 2.4), lsof, whiptail | dialog
10 Suggests: popularity-contest, xdg-utils
9 Depends: dctrl-tools | grep-dctrl, curl, python (>= 2.4), lsof, whiptail | dialog, less
10 Suggests: popularity-contest, xdg-utils, zenity
1111 Conflicts: debget
1212 Replaces: debget
1313 Description: Small toolbox-style utilities for Debian systems
22
33 It has no home other than Debian.
44
5 Upstream Author(s): Matt Zimmerman <mdz@debian.org>
5 Upstream Authors: Matt Zimmerman <mdz@debian.org>
6 Javier Fernandez-Sanguino <jfs@debian.org>
67
78 Copyright:
89
0 debmany/debmany.bash_completion
0
1 Provide a desktop menu file that uses "debmany.png". When configuring the desktop
2 call follow this table:
3
4 kde gnome xfce
5 required zenity zenity zenity,xdg-utils
6 parameters -k -z -g -z -x -z
7
8 It is better to use the -l parameter for ISO 639 two-letter language code and
9 "*" at the end.
10
11 Example parameters for a german Kde user: -k -z -l "de*"
12
13 Optionally, Depend: on xdg-utils package, too. Then the desktop file can use the arguments
14 -x instead of -k, -g or -x for all desktops.
15
+0
-48
debmany/bash_completion less more
0 # Debian debmany(1) completion.
1 #
2 have debmany &&
3 _debmany()
4 {
5 local cur prev
6
7 COMPREPLY=()
8 cur=${COMP_WORDS[COMP_CWORD]}
9 prev=${COMP_WORDS[COMP_CWORD-1]}
10
11 case "$prev" in
12 -L) if [[ "$cur" != "" && "${cur//[0-9]/}" == "" ]]
13 then
14 COMPREPLY=( K M G T )
15 fi
16 # not perfect - 10M<tab> and the cursor sticks on the M but should paste a " "
17 return;;
18 -l) COMPREPLY=( $( ls /usr/share/man 2>/dev/null | cut -f1 -d'.' | grep -v ^man | sort -u ) );;
19 -m)
20 case "${cur:0:1}" in
21 \"|\') local manpageviewer="${cur:1}";;
22 *) local manpageviewer="$cur";;
23 esac
24 COMP_WORDS=(COMP_WORDS[0] $manpageviewer)
25 COMP_CWORD=1
26 _command
27 # not perfect: '-m "konquer<tab' gets completed to '-m "konqueror"'
28 # and '-m konquer<tab' gets completed to '-m konqueror'
29 # both shall complete to '-m "konqueror man:%s"' ?!
30 # but [ ${#COMPREPLY[@]} -eq 1 ] && [ ${COMPREPLY:0:1} != '"' ] && COMPREPLY[0]='"'$COMPREPLY' man:%s"'
31 # completes to debmany -m \"konqueror\ man\:%s\"
32 # my knowledge is too low concerning completion
33 # whole -m section should be rewritten by someone with knowledge
34 ;;
35 *)
36 if [[ "$cur" == -* ]]; then
37 COMPREPLY=( $( compgen -W '-? -h --help -m -k -g -x -L -l' -- $cur ) )
38 else
39 COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null; ) )
40 [ ${#COMPREPLY[@]} -eq 0 ] && _filedir deb
41 fi
42 ;;
43 esac
44
45 return 0
46 } &&
47 complete -F _debmany $filenames debmany
00 #!/bin/bash
11 # script: debmany
22 # author: Michael Arlt
3 # description: select the manpages of any [not] installed debian package
3 # description: select manpages+docs of any [not] installed debian package
44 # comment: debmany is based on the work of debman and debget
5 # uses: whiptail (preferred) or dialog as well as curl
5 # gui uses: whiptail (preferred), dialog or zenity as well
6 # other uses: curl, less (can be overwritten: -o)
7 # optional: -k -g -x: kfmexec gnome-open xdg-open (xdg-utils)
68 # This is free software. You may redistribute copies of it under the terms of
79 # the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
810 # There is NO WARRANTY, to the extent permitted by law.
911
12 # Tests for new releases:
13 # -L test downloadlimit and correct display of different sizes and units (http)
14 # -l several languages with and without "*" on installed and not installed packages
15 # -m -o test default and using parameters
16 # -z -k -g -x test
17 # open manpage,other file (usr/share/doc/...),manpage,other file
18 # check delivered debmany manpages
19 # check and test bash_completion
20 # check includes of installed (bash: bash-builtins) and uninstalled (ax25-tools:netrom-tools)
21 # test additionally the next operationg system (e.g. lenny)
22
1023 LC_ALL=C
1124
12 # choose the manpageviewer
13 mancmdline="man %s" # default manpageviewer
25 # defaults
26 mancmdline="man %s" # manpageviewer
27 othercmdline="less %s" # viewer for other files
1428
1529 curdir=`pwd`
1630
1832 {
1933 # show errorcode and quit
2034 echo "ERROR: $*" >&2
35 if [ "$cmd" = "zenity" ]
36 then
37 $cmd --error --text="$*"
38 fi
2139 exit 1
2240 }
2341
42 debug()
43 {
44 # show debugging
45 test $debug && echo "$*" >&2
46 }
47
2448 usage()
2549 {
26 echo "debmany 1.2 Mon Aug 27 19:06:55 CEST 2007
27 Description: Display a manpage from a Debian package.
28 The list of manpages is displayed in a dialog.
50 echo "debmany $version Thu May 15 16:56:19 CEST 2008
51 Description: Display a manpage or documentation files from a Debian package.
52 The list of files is displayed in a dialog.
2953 Supported locations for debian packages are: Local .deb-file,
3054 a package in the repository or an installed package.
55 The default for manpages is man - less is used for other files.
56 Default can be overwritten with -k|-g|-x and -m -o.
3157 Syntax1 : debmany [-?|-h|--help]
32 Syntax2 : debmany [-m viewer|-k|-g|-x] [-L limit] [-l lang1[,...]] package[.deb]
58 Syntax2 : debmany [-v[v]] [-k|-g|-x] [-m manviewer] [-o otherviewer] [-L limit] [-l lang1[,...]] package[.deb]
59 Syntax3 : debmany [-v[v]] [-k|-g|-x] [-m manviewer] [-o otherviewer] [-L limit] [-l lang1[,...]] -z [package[.deb]]
3360 Examples: debmany foo.deb show manpages from a local package file foo.deb
3461 debmany foo show manpages from a package, if the package is
3562 not installed it is retrieved from the
3663 configured repositories.
37 debmany -k foo show manpages using your preferred man-viewer (KDE)
38 debmany -g foo show manpages using your preferred man-viewer (GNOME)
39 debmany -x foo show manpages using your preferred man-viewer
64 debmany -k foo show files using your preferred viewer (KDE)
65 man: kfmclient exec man:%s other: kfmclient exec %s
66 debmany -g foo show files using your preferred viewer (GNOME)
67 man: gnome-open man:%s other: gnome-open %s
68 debmany -x foo show files using your preferred viewer
69 man: xdg-open man:%s other: xdg-open %s
4070 using xdg-open from xdg-utils package (Xfce users)
41 debmany -m 'konqueror man:%s' -l de,fr -L 5M foo
71 debmany -m 'konqueror man:%s' -l 'de*,fr*' -L 5M foo
4272 show english, german and french manpages using
4373 konqueror as man-viewer and ask if download size
4474 exceeds 5M
45 alias debmany='debmany -l de -L 5M -k'; debmany -m man -l '*' foo
75 debmany -z -k use zenity (as dialog) to select packages and files
76 TMPDIR=~/tmp debmany -k -o 'foo.sh %s' -l de,fr -L 5M foo
77 use ~/tmp as temporary folder
78 use KDE-defaults but overwrite viewer for other files
79 debmany -v foo show some debugging information (-vv show more)
80 alias debmany='debmany -l de -L 5M -k'; debmany -m man -l 'zh*' foo
4681 set an alias with your preferred options and
4782 overwrite them if needed"
4883 if [ $# -eq 0 ]
5792 do
5893 case $1 in
5994 "-?"|-h|--help) usage ;;
60 -m) # override default manpageviewer or environment variable DEBMANY_MAN_VIEWER
95 -k) mancmdline='kfmclient exec man:%s' # set kde viewers
96 othercmdline='kfmclient exec %s';;
97 -g) mancmdline='gnome-open man:%s' # set gnome viewers
98 othercmdline='gnome-open %s';;
99 -x) mancmdline='xdg-open man:%s' # set independant viewers
100 othercmdline='xdg-open %s';;
101 -m) # override default manpageviewer
61102 shift
62 mancmd=($1) # get first word from manpageviewer
63 if which $mancmd >/dev/null 2>&1 # is the manpageviewer executeable?
64 then
65 echo $1 | grep -q "%s" && mancmdline="$1" || mancmdline="$1 %s"
66 else
67 usage "Manpageviewer '$mancmd' is not available or executable"
68 fi
69 ;;
70 -k) mancmdline='kfmclient exec man:%s';; # set kde viewer
71 -g) mancmdline='gnome-open man:%s';; # set gnome viewer
72 -x) mancmdline='xdg-open man:%s';; # set independant viewer
73 -l) shift; lang=$1;; # remember language
74 -L) shift; asksize=$1;; # remember asksize
103 mancmdline="$1";;
104 -o) # override default viewer for other data
105 shift
106 othercmdline="$1";;
107 -l) shift; lang=$1;; # remember language
108 -L) shift; asksize=$1;; # remember asksize
109 -v) debug=1;;
110 -vv) debug=2;;
111 -z) cmd="zenity"
112 # is zenity executeable?
113 which $cmd >/dev/null 2>&1 || error "$cmd must be installed if you use parameter -z"
114 ;;
75115 -*) usage "Unknown option '$1'.";;
76116 *) package="$1";;
77117 esac
78118 shift
79119 done
80120
81 test -z "$package" && usage "You must specify one package or a Debian package file."
82
83 # determine the size of your terminal
84 declare -i size=(`stty size`)
85 declare -i x=${size[1]}
86 declare -i y=${size[0]}
87
88 # if it is impossible to determine the size
89 if [ $x -eq 0 ]
90 then
91 x=80
92 y=25
93 echo "Unable to determine the size of your terminal - using Console default: $x*$y" >&2
94 sleep 3
95 fi
96
97 # test upon minimum resolution
98 if [ $x -lt 40 -o $y -lt 9 ]
99 then
100 error "Resolution too small ($x*$y). I need a minimum of 40*9 - recommended is more..."
101 fi
102
103 # set the size of the dialog window and menu
104 x=x-1 # width of the dialog
105 y=y-1 # height of the dialog
106 declare -i h=y-7 # height of the menu
107
108 if [ "${package##*.}" = "deb" ]
109 then
110 # mode1: you want to see manpages from a .deb-file
121 mancmd=($mancmdline) # get first word !dash
122 if which $mancmd >/dev/null 2>&1 # is the manpageviewer(first word) executeable?
123 then
124 echo "$mancmdline" | grep -q "%s" || mancmdline="$mancmdline %s"
125 else
126 usage "Manpageviewer '$mancmd' is not available or executable"
127 fi
128 othercmd=($othercmdline) # get first word !dash
129 if which $othercmd >/dev/null 2>&1 # is the manpageviewer executeable?
130 then
131 echo "$othercmdline" | grep -q "%s" || othercmdline="$othercmdline %s"
132 else
133 usage "Viewer for other data '$othercmd' is not available or executable"
134 fi
135
136 # Version of debmany
137 version=1.3
138
139 # choose whiptail or dialog
140 whiptail=/usr/bin/whiptail
141 dialog=/usr/bin/dialog
142
143 if [ "$cmd" ]
144 then
145 # zenity version
146 if [ -z "$package" ]
147 then
148 package=`$cmd --entry --title="Debmany $version" --text="Enter package or package.deb"` || exit 0
149 fi
150 else
151 test -z "$package" && usage "You must specify one package or a Debian package file."
152 test -x $whiptail && cmd=$whiptail || cmd=$dialog
153
154 # determine the size of your terminal
155 read y x <<EOF
156 `stty size`
157 EOF
158
159 # if it is impossible to determine the size
160 if [ "$x" = "" ]
161 then
162 x=80
163 y=25
164 echo "Unable to determine the size of your terminal - using Console default: $x*$y" >&2
165 sleep 3
166 fi
167
168 # test upon minimum resolution
169 if [ $x -lt 40 -o $y -lt 9 ]
170 then
171 error "Resolution too small ($x*$y). I need a minimum of 40*9 - recommended is more..."
172 fi
173
174 debug "Terminalsize: ${x}x$y" # comment
175
176 # set the size of the dialog window and menu
177 x=$(($x-1)) # width of the dialog
178 y=$(($y-1)) # height of the dialog
179 h=$(($y-7)) # height of the menu
180 fi
181 debug "Using '$cmd' for selection" # comment
182
183
184 if [ "${package##*.}" = "deb" ]
185 then
186 debug "Mode1: You want to see manpages from a .deb-file" # comment
111187 if [ -r "$package" ]
112188 then
113189 file=`readlink -f "$package"`
116192 error "The file $package cannot be read."
117193 fi
118194 else
119 # mode 2: test if you have the package already installed
195 debug "Test if the package '$package' is already installed" # comment
120196 if dpkg -l "$package" 2>/dev/null | grep -q ^i
121197 then
198 debug "Package '$package' is already installed" # comment
122199 status=installed
200 # create the list of all mandirs (with -e for grep) (X11R6 is only for sarge - didn't find it in etch anymore)
201 mandirs="-e /usr/share/man/man.*/ -e /usr/share/doc/"
202 # modify lang for grep regular expressions: fr -> fr\.* (-> fr+fr.ISO8859-1+"fr."...)
203 for l in `echo "$lang"|sed -e "s/,/ /" -e "s/*/.*/"`
204 do
205 mandirs="$mandirs -e /usr/share/man/$l/"
206 done
207 debug "Using grep pattern '$mandirs'" # comment
208 # list the manpage dirs
123209 set -f
124 # modify lang for grep regular expressions: fr -> fr\.* (-> fr+fr.ISO8859-1+"fr."...)
125 langgrep=`echo $lang|sed -e s/*/.*/g -e 's/\([a-zA-Z_][a-zA-Z_]*\)/\1,\1\\\\\\.*/'`
126 # create the list of all mandirs (with -e for grep) (X11R6 is only for sarge - didn't find it in etch anymore)
127 mandirs="`eval echo \\"-e \\"/usr/\{share,X11R6\}/man/man.*/ \\"-e \\"/usr/\{share,X11R6\}/man/\{$langgrep,XYZZXY\}/`"
128210 for man in `dpkg -L "$package" 2>/dev/null|grep $mandirs|sort`
129211 do
130212 # mode 2: add the manpages to the list
131213 test -f $man && manpages="$manpages $man ${man##*/}"
132214 done
133215 set +f
134 fi
135 fi
136
137 # choose whiptail or dialog
138 whiptail=/usr/bin/whiptail
139 dialog=/usr/bin/dialog
140 test -x $whiptail && cmd=$whiptail || cmd=$dialog
216 if [ "$debug" = 2 ]
217 then
218 debug "Mode2: Found manpages/docs: $manpages" # comment
219 else
220 debug "Mode2: Found manpages/docs" # comment
221 fi
222 fi
223 fi
141224
142225 if [ "$status" = "installed" ]
143226 then
145228 cd /
146229 else
147230 # mode 1 and 3
148 trap 'test -n "$temp" && rm -rf $temp; exit' 0 2 15 # cleanup
149
150 tmp=/dev/shm # set default tempdir
151 test -d $tmp || tmp=/tmp # if not available use /tmp
152
153 # make a temporary folder for the manpages - $TMPDIR overrides the path of -p
154 temp=`mktemp -d -p $tmp debmany.XXXXXXXXXX` || error "Unable to create a temporary folder."
231 trap 'test -n "$temp" && rm -rf "$temp"; exit' 0 2 15 # cleanup
232
233 # find a directory for temporary files (you can use $TMPDIR to specify the destination)
234 for tmp in "$TMPDIR" /dev/shm /tmp /var/tmp
235 do
236 test -d "$tmp" && break
237 done
238
239 # make a temporary folder for the manpages
240 temp=`mktemp -d -p "$tmp" debmany.XXXXXXXXXX` || error "Unable to create a temporary folder in '$tmp'."
241 debug "Mode1/3: Created temporary folder $temp" # comment
155242
156243 if [ -z "$file" ]
157244 then
158 # mode 3: find the package.deb
245 debug "Mode3: Determining the path of '$package' (you use file:// in sources.list)" # comment
159246 aptdata=`apt-get -q2 --print-uris --reinstall install "$package" 2>/dev/null | tail -1`
160247 if [ -z "$aptdata" ]
161248 then
166253 url=`echo "$aptdata" | sed -e "s/^'\([^']*\)'.*$/\1/"`
167254 test -z "$url" && error "Could not obtain an URL for '$pkgspec'."
168255
256 debug "Mode3: Found package '$package' in the repository" # comment
169257 if [ "${url%%:*}" = "file" ]
170258 then
171 # mode 3: access the local file
172259 file="${url#*:}"
260 debug "Mode3: Access the local file '$file'" # comment
173261 if [ ! -r "$file" ]
174262 then
175263 error "Could not access '$file' from the repository."
176264 fi
177265 status=repos-file
178266 else
179 # mode 3: download the local file
180267 file="$temp/tmp.deb"
268 debug "Mode3: Preparing download of file '$url' to '$file'" # comment
181269 # if i should ask at a specific size
182270 if [ "$asksize" != "" ]
183271 then
272 debug "Mode3: Determine the size of the file to download" # comment
184273 # determine the size of the file to download (*10 for 10,5M)
185 declare -i size=`apt-cache show "$package"|grep ^"Size: "|cut -f2 -d" "|head -1`*10
274 size=`apt-cache show "$package"|grep ^"Size: "|head -1|cut -f2 -d" "`
186275 # determine the value of ask_size
187 templimit=`echo ${asksize//[^0-9]/}`
188 test "$templimit" = "" && error "Parameter -L needs an argument - e.g. '10M'."
189 declare -i limit=`echo ${asksize//[^0-9]/}`*10
276 limit=`echo $asksize|tr -cd "[0-9]"`
277 test "$limit" = "" && error "Parameter -L needs an argument - e.g. '10M'."
190278 # determine the unit of ask_size
191 unit=`echo ${asksize//[0-9]/}`
192 # calculate the limit according to unit from DEBMANY_ASK_SIZE
279 unit=`echo $asksize|tr -d "[0-9]"`
280 debug "Mode3: Determined download limit is '$limit' '$unit'" # comment
281 # calculate the limit !dash integer variables support < 2G
193282 case $unit in
194283 B|"") ;;
195 K) limit=limit*1024;;
196 M) limit=limit*1024*1024;;
197 G) limit=limit*1024*1024*1024;;
198 T) limit=limit*1024*1024*1024*1024;;
199 *) error "Invalid unit '$unit' in variable DEBMANY_ASK_SIZE."
284 K) limit=$(($limit*1024));;
285 M) limit=$(($limit*1024*1024));;
286 G) limit=$(($limit*1024*1024*1024));;
287 T) limit=$(($limit*1024*1024*1024*1024));;
288 *) error "Invalid unit '$unit' in command line."
200289 esac
201290 # calculate the human readable size and ask for download if size exceeds limit
202291 if [ $size -ge $limit ]
203292 then
293 debug "Mode3: Size '$size' exceeds specified limit '$limit'" # comment
204294 unit=B
295 size=$(($size*100)) # !dash 2G limit
205296 # reduce the size and correct the unit until it is human readable
206 while [ $size -gt 1024 ]
297 while [ $size -ge 10240 ]
207298 do
208 size=size/1024
299 size=$(($size/1024))
300 # correct the unit every time /1024
209301 case $unit in
210302 G) unit=T;;
211303 M) unit=G;;
213305 B) unit=K;;
214306 esac
215307 done
216 # set the comma (so if the file has a size of 50M we change 500 to 50,0M
217 commasize=`echo $size|sed "s/\([0-9]*\)\([0-9]\)/\1,\2/"`$unit
308 size=$((($size+5)/10)) # !dash 2G limit
309 # set the comma (so if the file has a size of 5M we change 50 to 5,0M)
310 commasize=`echo $size|sed "s/\(.*\)\(.\)/\1.\2/"`
311 commasize=`printf "%.1f$unit" $commasize`
218312 # ask if the download may start - otherwise debmany exits
219 if ! $cmd --yesno "Would you like to download the package with a size of $commasize?" 9 40
313 if [ "$cmd" = "zenity" ]
220314 then
221 echo "Download undesired - $commasize is too big."
222 exit
315 if ! $cmd --question --text="Would you like to download the package with a size of $commasize?"
316 then
317 echo "Download undesired - $commasize is too big."
318 exit
319 fi
320 else
321 if ! $cmd --yesno "Would you like to download the package with a size of $commasize?" 9 40
322 then
323 echo "Download undesired - $commasize is too big."
324 exit
325 fi
223326 fi
224327 fi
225328 fi
226 curl "$url" >"$file" || error "Could not download '$file' from the repository."
329 # download the package
330 debug "Mode3: Start download using curl" # comment
331 curl "$url" >"$file" || error "Failed to download '$url' to '$file'."
227332 status=repos-curl
228333 fi
229334 fi
230 cd $temp
335 cd "$temp"
231336 # extract the manpages
232 set -f
233 # modify lang for pathname expansion: fr -> fr.* (-> fr+fr.ISO8859-1+"fr."...)
234 lang=`echo $lang|sed -e 's/\([a-zA-Z_][a-zA-Z_]*\)/\1,\1*/'`
235337 # create the list of all mandirs (X11R6 is only for sarge - didn't find it in etch anymore)
236 mandirs="`eval echo \{./,\}usr/\{share,X11R6\}/man/man*/ \{./,\}usr/\{share,X11R6\}/man/\{$lang,XYZZXY\}/`"
338 # and add language specific manpages: fr -> fr.* (-> fr+fr.ISO8859-1+"fr."...)
339 mandirs="./usr/share/man/man*/ /usr/share/man/man*/ ./usr/share/doc/ /usr/share/doc/"
340 for l in `echo "$lang"|tr "," " "`
341 do
342 mandirs="$mandirs ./usr/share/man/$l/ /usr/share/man/$l/"
343 done
344 debug "Using tar pattern '$mandirs'" # comment
345 debug "Mode1/3: Extract the manpage and doc dirs from '$file'" # comment
237346 dpkg --fsys-tarfile "$file" | tar --wildcards -xf - $mandirs 2>/dev/null
238 set +f
239 manpages=`find usr -type f|sort|sed -e 's§\([^/]*\)$§\1 \1§'`
347 # find all manpage files
348 manpages=`find usr -type f 2>/dev/null|sort|sed -e 's§\([^/]*\)$§\1 \1§'`
240349 fi
241350
242351 while true
245354 test -z "$manpages" && error "No manpage exists for package '$package'."
246355
247356 # select your manpages using dialog
248 exec 3>&1
249 return=`$cmd --title "Select a manpage ($status:$package)" --menu '' $y $x $h $manpages 2>&1 1>&3`
250 exec 3>&-
357 if [ "$cmd" = "zenity" ]
358 then
359 return=`$cmd --title="Debmany: $package" --text="Select a file ($status:$package)" --width=800 --height=600 --list --column=Path --column=File $manpages`
360 else
361 exec 3>&1
362 return=`$cmd --title "Select a file ($status:$package)" --menu '' $y $x $h $manpages 2>&1 1>&3`
363 exec 3>&-
364 fi
365
251366 if [ -n "$return" ]
252367 then
253368 # show the manpage
254 `printf "$mancmdline" "$PWD/$return"`
369 if echo $return | grep -q usr/share/man
370 then
371 path=$(dirname `dirname "$return"`)
372 file=`echo "$return"|sed "s§^$path/§§"`
373 if [ "${return##/*}" ] # test relative path
374 then
375 # it is a temporary extracted archive
376 debug "Going to manpage directory: $temp/$path" # comment
377 cd "$temp/$path"
378 else
379 # installed manpage
380 debug "Going to manpage directory: $path" # comment
381 cd "$path"
382 fi
383 debug "Opening manpage file: "`printf "$mancmdline" "$PWD/$file"` # comment
384 eval $(printf "$mancmdline" "$PWD/$file")
385 cd - >/dev/null
386 else
387 # other file (usr/share/doc)
388 debug "Opening other file: "`printf "$othercmdline" "$PWD/$return"` # comment
389 eval $(printf "$othercmdline" "$PWD/$return")
390 fi
255391 else
256 cd $curdir
392 cd "$curdir"
257393 exit
258394 fi
259395 done
260396
261 # This should not be reached
262 cd $curdir
263 exit 0
0 # debmany(1) completion
1 #
2 # Copy this file to ~/.bash_completion.
3 # To activate bash completion for new logins configure ~/.bashrc
4 # or simply source /etc/bash_completion to test it.
5 # After a new login completion is done for
6 # all parameters,
7 # packages or filenames and folders.
8 #
9 have debmany &&
10 _debmany()
11 {
12 local cur prev setf
13
14 COMPREPLY=()
15 cur=${COMP_WORDS[COMP_CWORD]}
16 prev=${COMP_WORDS[COMP_CWORD-1]}
17
18 case "$prev" in
19 -L) if echo "$cur" | grep -q ^"[0-9][0-9]*[KMGT]*"; then
20 COMPREPLY=( $( compgen -W '`echo ${cur/[KMGT]/}{K,M,G,T}`' -- "$cur" ) )
21 else
22 COMPREPLY=("100K" "50M" "5G" "1T")
23 fi
24 ;;
25 -l) # show all possible languages from /usr/share/i18n/SUPPORTED
26 setf=`echo $-` # remember switch f (shell filename completion)
27 set -f
28 COMPREPLY=( $( compgen -W '`sed -e "s/[@_. ].*//g" -e "s/$/*/" /usr/share/i18n/SUPPORTED|sort -u`' -- "$cur" ) )
29 echo "$setf"|grep -q f || set +f # switch back if needed
30 ;;
31 -m) case "${cur:0:1}" in
32 \"|\') local manpageviewer="${cur:1}";;
33 *) local manpageviewer="$cur";;
34 esac
35 COMP_WORDS=(COMP_WORDS[0] "$manpageviewer")
36 COMP_CWORD=1
37 _command
38 ;;
39 -o) case "${cur:0:1}" in
40 \"|\') local otherviewer="${cur:1}";;
41 *) local otherviewer="$cur";;
42 esac
43 COMP_WORDS=(COMP_WORDS[0] "$otherviewer")
44 COMP_CWORD=1
45 _command
46 ;;
47 *) if [[ "$cur" == -* ]]; then
48 COMPREPLY=( $( compgen -W '-? -h --help -k -g -x -m -o -L -l -v -vv -z' -- "$cur" ) )
49 else
50 COMPREPLY=( $( apt-cache pkgnames "$cur" 2> /dev/null; ) )
51 if [ ${#COMPREPLY[@]} -eq 0 ]
52 then
53 _filedir
54 fi
55 fi
56 ;;
57 esac
58
59 return 0
60 } &&
61 complete -F _debmany $filenames debmany
0 # Changes for v1.3
1 ### fixed bugs
2 # includes in manpages (".so") didn't work - example packages: bash: bash-builtins, ax25-tools:netrom-tools
3 # solution: cd to extracted manpages before opening them
4 # fixed detection of tmp-directory /dev/shm
5 # working directory with space -> cd back gave an error
6 # $TMPDIR wasn't implemented (forgotten)
7 # corrected manpage
8 # correct size calculation of file to download
9 ### features
10 # added debugging option (-v and -vv)
11 # added usr/share/doc to view additional files
12 # added option -o to overwrite the viewer for other files (not manpages)
13 # added option -z to use a graphical dialog (zenity) instead of dialog or whiptail
14 # improved bash_completion (maybe it will get in debian-goodies)
15 # added a png-file for debmany (maybe it will get in debian-goodies)
16 # with $TMPDIR you can specify the destination for temporary files
17 # option -l changed: old: -l fr -> fr* new: -l fr -> fr
18 # examples: -l de,fr -l "zh*"
19 # improved manpages
20 # check for parameter -k, -g and -x if kfmclient, gnome-open or xdg-open exists
21 # added rounding for size calculation
22 ### quality
23 # added a checklist (comment in debmany) for new releases of debmany
24 ### technical
25 # removed search in usr/share/X11R6 (last seen in debian sarge)
26 # small parts rewritten for better dash compatibility - remaining is marked "!dash"
27 # less should be a dependency because it is the default viewer for other files
28 # zenity should be a suggested package because it is a graphical alternative for dialog
29 ### remaining but no reason to operate
30 # blanks in filenames do not work - checked in debian etch: no packages found
Binary diff not shown
0 .TH "DEBMANY" "1" "1.2" "Michael Arlt" "User Commands"
0 .TH "DEBMANY" "1" "1.3" "Michael Arlt" "User Commands"
11 .SH "NAME"
2 debmany \- select manpages from installed packages, packages from the repository or .deb\-files for viewing using "man" or an alternative viewer.
2 debmany \- select manpages or documentation files from installed packages, packages from the repository or .deb\-files for viewing using "man" resp. "less" or an alternative viewer.
33 .SH "SYNOPSIS"
44 .B debmany
55 \fI\-\-help
66 .br
77 .B debmany
8 \fI[\-m manpageviewer|\-k|\-g|\-x] [\-L limit] [\-l lang1[,...]] [package|package.deb\fR
8 \fI[\-v[v]] [\-k|\-g|\-x] [\-m manpageviewer] [\-o otherviewer] [\-L limit] [\-l lang1[,...]] package|package.deb\fR
9 .br
10 .B debmany
11 \fI[\-v[v]] [\-k|\-g|\-x] [\-m manpageviewer] [\-o otherviewer] [\-L limit] [\-l lang1[,...]] \-z [package|package.deb]\fR
912 .SH "DESCRIPTION"
1013 .\" Add any additional description here
1114 .PP
12 Select a manpage from a debian package for viewing with man or an alternative viewer. The list of manpages is displayed in a dialog. Supported locations for debian packages are: Local .deb\-file, a package in the repository or a installed package.
15 Select a manpage or files at /usr/share/doc from a debian package for viewing with "man", "less" or an alternative viewer. The list of files is displayed in a dialog. Supported locations for debian packages are: Local .deb\-file, a package in the repository or a installed package.
1316 .TP
1417 \fB\-\-help\fR
1518 display a small help and exit
19 .TP
20 \fB\-k\fR
21 Display the manpage using your preferred viewer (must support .gz files) if you use KDE \- this is the short form of \-m 'kfmclient exec man:%s'. "kfmclient" is a part of the package "konqueror" (at least in Debian Etch).
22 .TP
23 \fB\-g\fR
24 Display the manpage using your preferred viewer (must support .gz files) if you use GNOME \- this is the short form of \-m 'gnome\-open man:%s'. "gnome\-open" is a part of the package "libgnome2\-0" (at least in Debian Etch).
25 .TP
26 \fB\-x\fR
27 Display the manpage using your preferred viewer (must support .gz files) if you use KDE/GNOME/Xfce \- this is the short form of \-m 'xdg\-open man:%s'. "xdg\-open" is a part of the package "xdg\-utils" (at least in Debian Etch).
1628 .TP
1729 \fB\-m manpageviewer\fR
1830 Optionally set a manpage viewer. The viewer must support .gz files. You must define the complete request. "%s" gets replaced with the path to the manpage. If "%s" is missing " %s" is appended to the manpageviewer. The manpageviewer must be enclosed with "" or '' \- see examples.
1931 If you use a graphical viewer you must ensure that you have access to your desktop (if necessary: sux or ssh with x\-forwarding)
2032 .TP
21 \fB\-k\fR
22 Display the manpage using your preferred viewer (must support .gz files) if you use KDE \- this is the short form of \-m 'kfmclient exec man:%s'. "kfmclient" is a part of the package "konqueror".
23 .TP
24 \fB\-g\fR
25 Display the manpage using your preferred viewer (must support .gz files) if you use GNOME \- this is the short form of \-m 'gnome\-open man:%s'. "gnome\-open" is a part of the package "libgnome2\-0".
26 .TP
27 \fB\-x\fR
28 Display the manpage using your preferred viewer (must support .gz files) if you use KDE/GNOME/Xfce \- this is the short form of \-m 'xdg\-open man:%s'. "xdg\-open" is a part of the package "xdg\-utils".
33 \fB\-o otherviewer\fR
34 Optionally set a viewer for other files (/use/share/doc).
2935 .TP
3036 \fB\-L limit\fR
3137 If a file which must be downloaded exceeds the limit, you are asked if the download should start. Without unit the value is in bytes. You can append K, M, G or T to the value to change the unit.
3238 .TP
3339 \fB\-l lang1[,...]\fR
34 English manpages are displayed always. If you want more languages you can specify them here. Provide a comma separated list of the folder names in the manpgage folders (/usr/share/man,/usr/X11R6/man) \- e.g. de,fr or "*" if you want to see all languages. Folders with ".xyz" at the end (e.g. fr.ISO8859\-1) are automatically selected together with your choice (fr in this example).
40 English manpages are displayed always. If you want more languages you can specify them here. Provide a comma separated list of the folder names in the manpgage folders (/usr/share/man) \- e.g. de,fr or "zh*" if you want to see all Chinese manpages (Simplified and Traditional Chinese as well). It is safe always to use "*" at the end of your language.
41 During installation automatic generated character set based versions are not available for selection.
42 .TP
43 \fB\-z\fR
44 Zenity (a graphical dialog) is used to select the files and if necessary to enter the package name. You must have the rights to start X\-programs. This option combined with the parameters \-k, \-g, \-x respectively \-m and \-o make it possible to use debmany without console.
3545 .PP
36 The manpages are temporarily extracted to /dev/shm (if the directory exists) or /tmp . You can override the path if you set and export the environment variable TMPDIR.
46 The manpages are temporarily extracted to /dev/shm (if the directory exists) or /tmp . You can override the path if you set and export the environment variable TMPDIR or set it as a temporary variable.
3747 .PP
3848 You need to have the debian package "whiptail" (preferred) or "dialog" as well as "curl" installed.
3949 .SH "EXAMPLES"
4858 Show all manpages from the local debian package "./test.deb" using man.
4959 .TP
5060 debmany \-k sc
51 Use your preferred man\-viewer (for KDE user)
61 Use your preferred man\-viewer (for KDE user).
5262 .TP
5363 debmany \-g sc
54 Use your preferred man\-viewer (for GNOME user)
64 Use your preferred man\-viewer (for GNOME user).
5565 .TP
5666 debmany \-x sc
57 Use your preferred man\-viewer (for KDE/GNOME/Xfce user)
67 Use your preferred man\-viewer (for KDE/GNOME/Xfce user).
5868 .TP
59 debmany \-m 'konqueror man:%s' sc
60 Use Konqueror as viewer
69 debmany \-z \-k
70 Uses "zenity" to select files and to enter the package name.
6171 .TP
62 alias debmany='debmany \-l de \-L 5M \-k'; debmany \-m man \-l "*" foo
72 TMPDIR=~/tmp debmany \-m 'konqueror man:%s' sc
73 Use ~/tmp as temporary folder and Konqueror as viewer.
74 .TP
75 alias debmany='debmany \-l de \-L 5M \-k'; debmany \-m man \-l "zh*" foo
6376 Set an alias with your preferred options and overwrite them if needed.
77 .TP
78 vi /usr/local/bin/ask # after saving: chmod 755 ask
79 #!/bin/dash
80 .br
81 read \-p "program to use: " pgm
82 .br
83 eval $pgm "$1"
84 .br
85
86 .br
87 debmany \-o ask
88 .br
89 Every time you select other files from a package you will be asked which program to use.
6490 .SH "AUTHOR"
6591 Written by Michael Arlt.
6692 .SH "LICENSE"
0 .TH "DEBMANY" "1" "1.2" "Michael Arlt" "Dienstprogramme für Benutzer"
0 .TH "DEBMANY" "1" "1.3" "Michael Arlt" "Dienstprogramme für Benutzer"
11 .SH "NAME"
2 debmany \- Wählen von manpages aus installierten Paketen, Paketen des Repositories oder .deb\-Dateien zum Betrachten mit "man" oder einem alternativen Viewer.
2 debmany \- Wählen von Manpages oder Dokumentationen aus installierten Paketen, Paketen des Repositories oder .deb\-Dateien zum Betrachten mit "man" bzw. "less" oder einem alternativen Viewer.
33 .SH "SYNTAX"
44 .B debmany
55 \fI\-\-help
66 .br
77 .B debmany
8 \fI[\-m manpageviewer|\-k|\-g|\-x] [\-L Limit] [\-l Sprache1[,...]] Paket|Paket.deb\fR
8 \fI[\-v[v]] [\-k|\-g|\-x] [\-m manpageviewer] [\-o otherviewer] [\-L Limit] [\-l Sprache1[,...]] Paket|Paket.deb\fR
9 .br
10 .B debmany
11 \fI[\-v[v]] [\-k|\-g|\-x] [\-m manpageviewer] [\-o otherviewer] [\-L Limit] [\-l Sprache1[,...]] \-z [Paket|Paket.deb]\fR
912 .SH "BESCHREIBUNG"
1013 .\" Add any additional description here
1114 .PP
12 Wählen Sie eine Manpage von einem Debian Paket um sie mit "man" oder einem alternativen Viewer zu betrachten. Die Liste der Manpages wird in einem Dialog dargestellt. Unterstützte Quellen für Debian Pakete sind: Lokale .deb\-Datei, ein Paket aus dem Repository oder ein installiertes Paket.
15 Wählen Sie eine Manpage oder Dateien aus usr/share/doc von einem Debian Paket um sie mit "man" oder "less" bzw. einem alternativen Viewer zu betrachten. Die Liste der Dateien wird in einem Dialog dargestellt. Unterstützte Quellen für Debian Pakete sind: Lokale .deb\-Datei, ein Paket aus dem Repository oder ein installiertes Paket.
1316 .TP
1417 \fB\-\-help\fR
1518 zeigt eine kurze Hilfe und beendet sich
1619 .TP
20 \fB\-k\fR
21 Zeigt die Manpage im bevorzugten Viewer (muss .gz Dateien unterstützen) an, falls Sie KDE benutzen \- Kurzform von \-m 'kfmclient exec man:%s' bzw. 'kfmclient exec %s' für andere Dateien. "kfmclient" ist Teil des Paketes "konqueror" (zumindest in Debian Etch).
22 .TP
23 \fB\-g\fR
24 Zeigt die Manpage im bevorzugten Viewer (muss .gz Dateien unterstützen) an, falls Sie GNOME benutzen \- Kurzform von \-m 'gnome\-open man:%s'. "gnome\-open" ist Teil des Paketes "libgnome2\-0" (zumindest in Debian Etch).
25 .TP
26 \fB\-x\fR
27 Zeigt die Manpage im bevorzugten Viewer (muss .gz Dateien unterstützen) an, falls Sie KDE/GNOME/Xfce benutzen \- Kurzform von \-m 'xdg\-open man:%s'. "xdg\-open" ist Teil des Paketes "xdg\-utils" (zumindest in Debian Etch).
28 .TP
1729 \fB\-m manpageviewer\fR
18 Setzt optional den Manpageviewer. Der Viewer muss .gz Dateien unterstützen. Es ist zu beachten, dass der komplette Aufruf formuliert werden muss. "%s" wird durch den Pfad zur Manpage ersetzt. Wenn "%s" fehlt wird " %s" an den Manpageviewer angehängt. Der Aufruf muss in "" oder '' gefasst werden \- siehe Beispiele.
30 Überschreibt den Manpageviewer. Der Viewer muss .gz Dateien unterstützen. Es ist zu beachten, dass der komplette Aufruf formuliert werden muss. "%s" wird durch den Pfad zur Manpage ersetzt. Wenn "%s" fehlt wird " %s" an den Manpageviewer angehängt. Der Aufruf muss in "" oder '' gefasst werden \- siehe Beispiele.
1931 Bei der Benutzung eines grafischen Manpageviewers müssen Sie sicherstellen, dass Sie Zugriff auf den Desktop haben (ggf.: sux oder ssh mit x\-forwarding)
2032 .TP
21 \fB\-k\fR
22 Zeigt die Manpage im bevorzugten Viewer (muss .gz Dateien unterstützen) an, falls Sie KDE benutzen \- Kurzform von \-m 'kfmclient exec man:%s'. "kfmclient" ist Teil des Paketes "konqueror".
23 .TP
24 \fB\-g\fR
25 Zeigt die Manpage im bevorzugten Viewer (muss .gz Dateien unterstützen) an, falls Sie GNOME benutzen \- Kurzform von \-m 'gnome\-open man:%s'. "gnome\-open" ist Teil des Paketes "libgnome2\-0".
26 .TP
27 \fB\-x\fR
28 Zeigt die Manpage im bevorzugten Viewer (muss .gz Dateien unterstützen) an, falls Sie KDE/GNOME/Xfce benutzen \- Kurzform von \-m 'xdg\-open man:%s'. "xdg\-open" ist Teil des Paketes "xdg\-utils".
33 \fB\-o otherviewer\fR
34 Überschreibt den Viewer für sonstige Dateien (/usr/share/doc).
2935 .TP
3036 \fB\-L Limit\fR
31 Überschreitet ein File, das per Download heruntergeladen werden muss, das Limit so werden Sie gefragt, ob der Download stattfinden soll. Ohne Angabe einer Einheit ist die Angabe in Bytes. Durch Anhängen der Buchstaben K, M, G der T kann die Einheit geändert werden.
37 Überschreitet ein File, das per Download heruntergeladen werden muss, das Limit so werden Sie gefragt, ob der Download stattfinden soll. Ohne Angabe einer Einheit ist die Angabe in Bytes. Durch Anhängen der Buchstaben K, M, G oder T kann die Einheit geändert werden.
3238 .TP
3339 \fB\-l Sprache1[,...]\fR
34 Englische Manpages werden immer angezeigt. Wenn Sie mehr Sprachen sehen wollen, so können Sie dies hier festlegen. Im Prinzip geben Sie hier eine mit Komma getrennte Liste der Ordner aus den Manpage Ordnern (/usr/share/man,/usr/X11R6/man) an \- z. B. de,fr oder "*" wenn Sie alle Sprachen sehen wollen. Ordner mit ".xyz" am Ende (z. B. fr.ISO8859\-1) werden automatisch durch Ihre Auswahl (fr in diesem Beispiel) selektiert.
40 Englische Manpages werden immer angezeigt. Wenn Sie mehr Sprachen sehen wollen, so können Sie dies hier festlegen. Im Prinzip geben Sie hier eine mit Komma getrennte Liste der Ordner aus den Manpage Ordnern (/usr/share/man) an \- z. B. de,fr oder "zh*" wenn Sie alle chinesischen Manpages (sowohl das einfache "zh_CN" als auch das traditionelle Chinesisch "zh_TW") sehen wollen. Sicherheitshalber kann man auch immer "*" am Ende der Sprache anhängen.
41 Bei der Installation ggf. dynamisch generierte zeichensatzbasierte Abwandlungen stehen nicht zur Auswahl.
42 .TP
43 \fB\-z\fR
44 Zur Auswahl der Dateien und ggf. zur Eingabe des Paketes wird "zenity" (grafischer Dialog) verwendet. Hierzu muss man berechtigt sein, X\-Programme zu starten. Diese Option in Kombination mit den Parametern \-k, \-g, \-x bzw. \-m und \-o ermöglicht es, debmany ohne Console zu verwenden.
3545 .PP
36 Die Manpages werden temporär nach /dev/shm (sofern dieses Verzeichnis existiert) oder /tmp extrahiert. Durch das Setzen und Exportieren der Umgebungsvariable TMPDIR kann der Speicherort überschrieben werden.
46 Die Manpages werden temporär nach /dev/shm (sofern dieses Verzeichnis existiert), /tmp oder /var/tmp extrahiert. Durch das Setzen und Exportieren der Umgebungsvariable TMPDIR bzw. das Setzen als temporären Variable kann der Speicherort überschrieben werden.
3747 .PP
3848 Das Debian Paket "whiptail" (bevorzugt) oder "dialog" sowie "curl" muss installiert sein.
3949 .SH "BEISPIELE"
5666 debmany \-x sc
5767 Benutzt den bevorzugten Manviewer (für KDE/GNOME/Xfce Anwender)
5868 .TP
59 debmany \-m 'konqueror man:%s' sc
60 Benutzt Konqueror als Viewer
69 debmany \-z \-k
70 Benutzt "zenity" um Dateien auszuwählen und Paketnamen einzugeben.
6171 .TP
62 alias debmany='debmany \-l de \-L 5M \-k'; debmany \-m man \-l "*" foo
72 TMPDIR=~/tmp debmany \-m 'konqueror man:%s' sc
73 Benutzt ~/tmp als temporären Ordner und Konqueror als Viewer
74 .TP
75 alias debmany='debmany \-l de \-L 5M \-k'; debmany \-m man \-l "zh*" foo
6376 Setzte einen Alias um die bevorzugten Optionen festzulegen. Diese können, wie man sieht, jederzeit überschrieben werden.
77 .TP
78 vi /usr/local/bin/ask # nach dem Speichern: chmod 755 ask
79 #!/bin/dash
80 .br
81 read \-p "Programm zum Öffnen: " pgm
82 .br
83 eval $pgm "$1"
84 .br
85
86 .br
87 debmany \-o ask
88 .br
89 Beim Öffnen einer Datei aus usr/share/doc wird man nach dem Programm, mit dem man sie öffnen möchte, gefragt.
6490 .SH "AUTOR"
6591 Geschrieben von Michael Arlt.
6692 .SH "LIZENZ"
6666 sys.exit(1)
6767
6868 if outputfile == None:
69 output = tempfile.NamedTemporaryFile(suffix='.html')
70 outputfile = output.name
69 fd, outputfile = tempfile.mkstemp(suffix='.html')
70 output = os.fdopen(fd, 'w')
7171 view = 1
7272 elif outputfile == '-':
7373 output = sys.stdout