Package list debian-goodies / b0ddff8
Imported Debian version 0.54 Javier Fernandez-Sanguino 9 years ago
7 changed file(s) with 1290 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
00 #!/usr/bin/python
11
22 # Copyright (C) 2001 Matt Zimmerman <mdz@debian.org>
3 # Copyright (C) 2007,2008 Javier Fernandez-Sanguino <jfs@debian.org>
3 # Copyright (C) 2007,2010 Javier Fernandez-Sanguino <jfs@debian.org>
44 # - included patch from Justin Pryzby <justinpryzby_AT_users.sourceforge.net>
55 # to work with the latest Lsof - modify to reduce false positives by not
66 # complaining about deleted inodes/files under /tmp/, /var/log/,
4848 sys.stderr.write('about all open file descriptors in the system.\n')
4949 sys.exit(1)
5050
51
5251 def find_cmd(cmd):
5352 dirs = [ '/', '/usr/', '/usr/local/', sys.prefix ]
5453 for d in dirs:
5655 location = os.path.join(d, sd, cmd)
5756 if os.path.exists(location):
5857 return location
59 return 0
58 return 1
6059
6160 def usage():
6261 sys.stderr.write('usage: checkrestart [-vhpa]\n')
9796 assert False, "unhandled option"
9897
9998 # Start checking
100 toRestart = lsofcheck()
101 # Check if we have lsof, if not, use psdel
99
100 if find_cmd('lsof') == 1:
101 sys.stderr.write('ERROR: This program needs lsof in order to run.\n')
102 sys.stderr.write('Please install the lsof package in your system.\n')
103 sys.exit(1)
104 # Check if we have lsof, if not, use psdel
102105 # if find_cmd('lsof'):
103106 # toRestart = lsofcheck()
104107 # else:
105108 # TODO - This does not work yet:
106109 # toRestart = psdelcheck()
110
111 toRestart = lsofcheck()
107112
108113 print "Found %d processes using old versions of upgraded files" % len(toRestart)
109114
266271 return 0
267272 # Or about files under /tmp
268273 if f.startswith('/tmp/'):
274 return 0
275 # Or about files under /drm
276 if f.startswith('/drm'):
269277 return 0
270278 # Or about files under /var/tmp
271279 if f.startswith('/var/tmp/'):
0 debian-goodies (0.54) unstable; urgency=low
1
2 * debian/control: Turn the lsof Depends: into Recommends for the benefit
3 of the kfreebsd architectures (i.e. to make it possible for it to be
4 installed in these as lsof is not available there). Unfortunately,
5 we cannot use a Depends based on architecture as we are Arch: all
6 (Closes: #594431)
7 * [checkrestart]: Complain if lsof is not installed (could happen since
8 it is now in Recommends) and abort as we do not currently have
9 an alternative (psdel still unfinished...)
10 * [checkrestart]: Fix false positive with Xorg in some specific Xorg
11 servers due to the use of /drm. Thanks to Tarek Soliman for the patch.
12 (Closes: 548380)
13 * [dglob, dglob.pod]: Use grep-aptavail when the user requests all packages
14 listed. Also use apt-file if available since if the package is not
15 installed then the list of files is not available in the system
16 (Closes: #594426)
17 * Include a new 'debpaste' which is borrowed from http://paste.debian.net
18 (more specifically http://ankh-morp.org/~vetinari/tools/paste-dn.pl).
19 Adjust debian/copyright accordingly to acknowledge the author and
20 its copyright. This script is not yet distributed as Recommends/Depends
21 have to be adjusted to accommodate it, and a manpage needs to be written,
22 but it will be used as a basis to coses bug #476099.
23
24 -- Javier Fernandez-Sanguino Pen~a <jfs@debian.org> Sat, 02 Oct 2010 18:54:36 +0200
25
026 debian-goodies (0.53) unstable; urgency=low
127
228 * [checkrestart] Fix numerical use of errno. Thanks Jakub Wilk! See
234260
235261 * Exclude /var/run contents from the deleted files check which means
236262 that apache2, when using mod_ssl should now not be reported
237 as needing a restart (Closes: 432569)
263 as needing a restart (Closes: 432569, 482136)
238264
239265 -- Javier Fernandez-Sanguino Pen~a <jfs@debian.org> Thu, 06 Sep 2007 23:37:03 +0200
240266
99
1010 Package: debian-goodies
1111 Architecture: all
12 Depends: dctrl-tools | grep-dctrl, perl, curl, python (>= 2.4), lsof, whiptail | dialog, less, ${misc:Depends}
12 Depends: dctrl-tools | grep-dctrl, perl, curl, python (>= 2.4), whiptail | dialog, less, ${misc:Depends}
13 Recommends: lsof
1314 Suggests: popularity-contest, xdg-utils, zenity
1415 Conflicts: debget
1516 Replaces: debget
1111
1212 - checkrestart:
1313 Copyright (C) 2001 Matt Zimmerman <mdz@debian.org>
14 Copyright (C) 2007,2008 Javier Fernandez-Sanguino <jfs@debian.org>
14 Copyright (C) 2007,2010 Javier Fernandez-Sanguino <jfs@debian.org>
1515
1616 - debget, dgrep, dglob, dpigs, popbugs
1717
1818 Copyright (C) 2001-2004 Matt Zimmerman <mdz@debian.org>
1919
2020 - debman
21
2122 Copyright (C) 2003 Colin Watson <cjwatson@debian.org>
2223
2324 - which-pkg-broke
2930
3031 Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
3132
33 - debpaste
34
35 Copyright (C) 2009 Hanno Hecker <vetinari@ankh-morp.org>
36
3237 - debian/ contents
3338
3439 Copyright (C) 2001-2004 Matt Zimmerman <mdz@debian.org>
35 Copyright (C) 2006-2009 Javier Fernandez-Sanguino <jfs@debian.org>
40 Copyright (C) 2006-2010 Javier Fernandez-Sanguino <jfs@debian.org>
3641
3742
3843 The license of all programs in this package, excluding 'which-pkg-broke' which
39 is in the public domain, is:
44 is in the public domain, and debpaste, is:
4045
4146 # This program is free software; you can redistribute it and/or modify
4247 # it under the terms of the GNU General Public License as published by
5661
5762 On Debian systems, a copy of the GNU General Public License may be
5863 found in /usr/share/common-licenses/GPL.
64
65 The program 'debpaste' has been retrieved (2010-10-02) from
66 http://paste.debian.net/paste.pl?show_template=clients
67 and is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE (AGPL 3.0)
68 license:
69
70 GNU AFFERO GENERAL PUBLIC LICENSE
71 Version 3, 19 November 2007
72
73 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
74 Everyone is permitted to copy and distribute verbatim copies
75 of this license document, but changing it is not allowed.
76
77 Preamble
78
79 The GNU Affero General Public License is a free, copyleft license for
80 software and other kinds of works, specifically designed to ensure
81 cooperation with the community in the case of network server software.
82
83 The licenses for most software and other practical works are designed
84 to take away your freedom to share and change the works. By contrast,
85 our General Public Licenses are intended to guarantee your freedom to
86 share and change all versions of a program--to make sure it remains free
87 software for all its users.
88
89 When we speak of free software, we are referring to freedom, not
90 price. Our General Public Licenses are designed to make sure that you
91 have the freedom to distribute copies of free software (and charge for
92 them if you wish), that you receive source code or can get it if you
93 want it, that you can change the software or use pieces of it in new
94 free programs, and that you know you can do these things.
95
96 Developers that use our General Public Licenses protect your rights
97 with two steps: (1) assert copyright on the software, and (2) offer
98 you this License which gives you legal permission to copy, distribute
99 and/or modify the software.
100
101 A secondary benefit of defending all users' freedom is that
102 improvements made in alternate versions of the program, if they
103 receive widespread use, become available for other developers to
104 incorporate. Many developers of free software are heartened and
105 encouraged by the resulting cooperation. However, in the case of
106 software used on network servers, this result may fail to come about.
107 The GNU General Public License permits making a modified version and
108 letting the public access it on a server without ever releasing its
109 source code to the public.
110
111 The GNU Affero General Public License is designed specifically to
112 ensure that, in such cases, the modified source code becomes available
113 to the community. It requires the operator of a network server to
114 provide the source code of the modified version running there to the
115 users of that server. Therefore, public use of a modified version, on
116 a publicly accessible server, gives the public access to the source
117 code of the modified version.
118
119 An older license, called the Affero General Public License and
120 published by Affero, was designed to accomplish similar goals. This is
121 a different license, not a version of the Affero GPL, but Affero has
122 released a new version of the Affero GPL which permits relicensing under
123 this license.
124
125 The precise terms and conditions for copying, distribution and
126 modification follow.
127
128 TERMS AND CONDITIONS
129
130 0. Definitions.
131
132 "This License" refers to version 3 of the GNU Affero General Public License.
133
134 "Copyright" also means copyright-like laws that apply to other kinds of
135 works, such as semiconductor masks.
136
137 "The Program" refers to any copyrightable work licensed under this
138 License. Each licensee is addressed as "you". "Licensees" and
139 "recipients" may be individuals or organizations.
140
141 To "modify" a work means to copy from or adapt all or part of the work
142 in a fashion requiring copyright permission, other than the making of an
143 exact copy. The resulting work is called a "modified version" of the
144 earlier work or a work "based on" the earlier work.
145
146 A "covered work" means either the unmodified Program or a work based
147 on the Program.
148
149 To "propagate" a work means to do anything with it that, without
150 permission, would make you directly or secondarily liable for
151 infringement under applicable copyright law, except executing it on a
152 computer or modifying a private copy. Propagation includes copying,
153 distribution (with or without modification), making available to the
154 public, and in some countries other activities as well.
155
156 To "convey" a work means any kind of propagation that enables other
157 parties to make or receive copies. Mere interaction with a user through
158 a computer network, with no transfer of a copy, is not conveying.
159
160 An interactive user interface displays "Appropriate Legal Notices"
161 to the extent that it includes a convenient and prominently visible
162 feature that (1) displays an appropriate copyright notice, and (2)
163 tells the user that there is no warranty for the work (except to the
164 extent that warranties are provided), that licensees may convey the
165 work under this License, and how to view a copy of this License. If
166 the interface presents a list of user commands or options, such as a
167 menu, a prominent item in the list meets this criterion.
168
169 1. Source Code.
170
171 The "source code" for a work means the preferred form of the work
172 for making modifications to it. "Object code" means any non-source
173 form of a work.
174
175 A "Standard Interface" means an interface that either is an official
176 standard defined by a recognized standards body, or, in the case of
177 interfaces specified for a particular programming language, one that
178 is widely used among developers working in that language.
179
180 The "System Libraries" of an executable work include anything, other
181 than the work as a whole, that (a) is included in the normal form of
182 packaging a Major Component, but which is not part of that Major
183 Component, and (b) serves only to enable use of the work with that
184 Major Component, or to implement a Standard Interface for which an
185 implementation is available to the public in source code form. A
186 "Major Component", in this context, means a major essential component
187 (kernel, window system, and so on) of the specific operating system
188 (if any) on which the executable work runs, or a compiler used to
189 produce the work, or an object code interpreter used to run it.
190
191 The "Corresponding Source" for a work in object code form means all
192 the source code needed to generate, install, and (for an executable
193 work) run the object code and to modify the work, including scripts to
194 control those activities. However, it does not include the work's
195 System Libraries, or general-purpose tools or generally available free
196 programs which are used unmodified in performing those activities but
197 which are not part of the work. For example, Corresponding Source
198 includes interface definition files associated with source files for
199 the work, and the source code for shared libraries and dynamically
200 linked subprograms that the work is specifically designed to require,
201 such as by intimate data communication or control flow between those
202 subprograms and other parts of the work.
203
204 The Corresponding Source need not include anything that users
205 can regenerate automatically from other parts of the Corresponding
206 Source.
207
208 The Corresponding Source for a work in source code form is that
209 same work.
210
211 2. Basic Permissions.
212
213 All rights granted under this License are granted for the term of
214 copyright on the Program, and are irrevocable provided the stated
215 conditions are met. This License explicitly affirms your unlimited
216 permission to run the unmodified Program. The output from running a
217 covered work is covered by this License only if the output, given its
218 content, constitutes a covered work. This License acknowledges your
219 rights of fair use or other equivalent, as provided by copyright law.
220
221 You may make, run and propagate covered works that you do not
222 convey, without conditions so long as your license otherwise remains
223 in force. You may convey covered works to others for the sole purpose
224 of having them make modifications exclusively for you, or provide you
225 with facilities for running those works, provided that you comply with
226 the terms of this License in conveying all material for which you do
227 not control copyright. Those thus making or running the covered works
228 for you must do so exclusively on your behalf, under your direction
229 and control, on terms that prohibit them from making any copies of
230 your copyrighted material outside their relationship with you.
231
232 Conveying under any other circumstances is permitted solely under
233 the conditions stated below. Sublicensing is not allowed; section 10
234 makes it unnecessary.
235
236 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
237
238 No covered work shall be deemed part of an effective technological
239 measure under any applicable law fulfilling obligations under article
240 11 of the WIPO copyright treaty adopted on 20 December 1996, or
241 similar laws prohibiting or restricting circumvention of such
242 measures.
243
244 When you convey a covered work, you waive any legal power to forbid
245 circumvention of technological measures to the extent such circumvention
246 is effected by exercising rights under this License with respect to
247 the covered work, and you disclaim any intention to limit operation or
248 modification of the work as a means of enforcing, against the work's
249 users, your or third parties' legal rights to forbid circumvention of
250 technological measures.
251
252 4. Conveying Verbatim Copies.
253
254 You may convey verbatim copies of the Program's source code as you
255 receive it, in any medium, provided that you conspicuously and
256 appropriately publish on each copy an appropriate copyright notice;
257 keep intact all notices stating that this License and any
258 non-permissive terms added in accord with section 7 apply to the code;
259 keep intact all notices of the absence of any warranty; and give all
260 recipients a copy of this License along with the Program.
261
262 You may charge any price or no price for each copy that you convey,
263 and you may offer support or warranty protection for a fee.
264
265 5. Conveying Modified Source Versions.
266
267 You may convey a work based on the Program, or the modifications to
268 produce it from the Program, in the form of source code under the
269 terms of section 4, provided that you also meet all of these conditions:
270
271 a) The work must carry prominent notices stating that you modified
272 it, and giving a relevant date.
273
274 b) The work must carry prominent notices stating that it is
275 released under this License and any conditions added under section
276 7. This requirement modifies the requirement in section 4 to
277 "keep intact all notices".
278
279 c) You must license the entire work, as a whole, under this
280 License to anyone who comes into possession of a copy. This
281 License will therefore apply, along with any applicable section 7
282 additional terms, to the whole of the work, and all its parts,
283 regardless of how they are packaged. This License gives no
284 permission to license the work in any other way, but it does not
285 invalidate such permission if you have separately received it.
286
287 d) If the work has interactive user interfaces, each must display
288 Appropriate Legal Notices; however, if the Program has interactive
289 interfaces that do not display Appropriate Legal Notices, your
290 work need not make them do so.
291
292 A compilation of a covered work with other separate and independent
293 works, which are not by their nature extensions of the covered work,
294 and which are not combined with it such as to form a larger program,
295 in or on a volume of a storage or distribution medium, is called an
296 "aggregate" if the compilation and its resulting copyright are not
297 used to limit the access or legal rights of the compilation's users
298 beyond what the individual works permit. Inclusion of a covered work
299 in an aggregate does not cause this License to apply to the other
300 parts of the aggregate.
301
302 6. Conveying Non-Source Forms.
303
304 You may convey a covered work in object code form under the terms
305 of sections 4 and 5, provided that you also convey the
306 machine-readable Corresponding Source under the terms of this License,
307 in one of these ways:
308
309 a) Convey the object code in, or embodied in, a physical product
310 (including a physical distribution medium), accompanied by the
311 Corresponding Source fixed on a durable physical medium
312 customarily used for software interchange.
313
314 b) Convey the object code in, or embodied in, a physical product
315 (including a physical distribution medium), accompanied by a
316 written offer, valid for at least three years and valid for as
317 long as you offer spare parts or customer support for that product
318 model, to give anyone who possesses the object code either (1) a
319 copy of the Corresponding Source for all the software in the
320 product that is covered by this License, on a durable physical
321 medium customarily used for software interchange, for a price no
322 more than your reasonable cost of physically performing this
323 conveying of source, or (2) access to copy the
324 Corresponding Source from a network server at no charge.
325
326 c) Convey individual copies of the object code with a copy of the
327 written offer to provide the Corresponding Source. This
328 alternative is allowed only occasionally and noncommercially, and
329 only if you received the object code with such an offer, in accord
330 with subsection 6b.
331
332 d) Convey the object code by offering access from a designated
333 place (gratis or for a charge), and offer equivalent access to the
334 Corresponding Source in the same way through the same place at no
335 further charge. You need not require recipients to copy the
336 Corresponding Source along with the object code. If the place to
337 copy the object code is a network server, the Corresponding Source
338 may be on a different server (operated by you or a third party)
339 that supports equivalent copying facilities, provided you maintain
340 clear directions next to the object code saying where to find the
341 Corresponding Source. Regardless of what server hosts the
342 Corresponding Source, you remain obligated to ensure that it is
343 available for as long as needed to satisfy these requirements.
344
345 e) Convey the object code using peer-to-peer transmission, provided
346 you inform other peers where the object code and Corresponding
347 Source of the work are being offered to the general public at no
348 charge under subsection 6d.
349
350 A separable portion of the object code, whose source code is excluded
351 from the Corresponding Source as a System Library, need not be
352 included in conveying the object code work.
353
354 A "User Product" is either (1) a "consumer product", which means any
355 tangible personal property which is normally used for personal, family,
356 or household purposes, or (2) anything designed or sold for incorporation
357 into a dwelling. In determining whether a product is a consumer product,
358 doubtful cases shall be resolved in favor of coverage. For a particular
359 product received by a particular user, "normally used" refers to a
360 typical or common use of that class of product, regardless of the status
361 of the particular user or of the way in which the particular user
362 actually uses, or expects or is expected to use, the product. A product
363 is a consumer product regardless of whether the product has substantial
364 commercial, industrial or non-consumer uses, unless such uses represent
365 the only significant mode of use of the product.
366
367 "Installation Information" for a User Product means any methods,
368 procedures, authorization keys, or other information required to install
369 and execute modified versions of a covered work in that User Product from
370 a modified version of its Corresponding Source. The information must
371 suffice to ensure that the continued functioning of the modified object
372 code is in no case prevented or interfered with solely because
373 modification has been made.
374
375 If you convey an object code work under this section in, or with, or
376 specifically for use in, a User Product, and the conveying occurs as
377 part of a transaction in which the right of possession and use of the
378 User Product is transferred to the recipient in perpetuity or for a
379 fixed term (regardless of how the transaction is characterized), the
380 Corresponding Source conveyed under this section must be accompanied
381 by the Installation Information. But this requirement does not apply
382 if neither you nor any third party retains the ability to install
383 modified object code on the User Product (for example, the work has
384 been installed in ROM).
385
386 The requirement to provide Installation Information does not include a
387 requirement to continue to provide support service, warranty, or updates
388 for a work that has been modified or installed by the recipient, or for
389 the User Product in which it has been modified or installed. Access to a
390 network may be denied when the modification itself materially and
391 adversely affects the operation of the network or violates the rules and
392 protocols for communication across the network.
393
394 Corresponding Source conveyed, and Installation Information provided,
395 in accord with this section must be in a format that is publicly
396 documented (and with an implementation available to the public in
397 source code form), and must require no special password or key for
398 unpacking, reading or copying.
399
400 7. Additional Terms.
401
402 "Additional permissions" are terms that supplement the terms of this
403 License by making exceptions from one or more of its conditions.
404 Additional permissions that are applicable to the entire Program shall
405 be treated as though they were included in this License, to the extent
406 that they are valid under applicable law. If additional permissions
407 apply only to part of the Program, that part may be used separately
408 under those permissions, but the entire Program remains governed by
409 this License without regard to the additional permissions.
410
411 When you convey a copy of a covered work, you may at your option
412 remove any additional permissions from that copy, or from any part of
413 it. (Additional permissions may be written to require their own
414 removal in certain cases when you modify the work.) You may place
415 additional permissions on material, added by you to a covered work,
416 for which you have or can give appropriate copyright permission.
417
418 Notwithstanding any other provision of this License, for material you
419 add to a covered work, you may (if authorized by the copyright holders of
420 that material) supplement the terms of this License with terms:
421
422 a) Disclaiming warranty or limiting liability differently from the
423 terms of sections 15 and 16 of this License; or
424
425 b) Requiring preservation of specified reasonable legal notices or
426 author attributions in that material or in the Appropriate Legal
427 Notices displayed by works containing it; or
428
429 c) Prohibiting misrepresentation of the origin of that material, or
430 requiring that modified versions of such material be marked in
431 reasonable ways as different from the original version; or
432
433 d) Limiting the use for publicity purposes of names of licensors or
434 authors of the material; or
435
436 e) Declining to grant rights under trademark law for use of some
437 trade names, trademarks, or service marks; or
438
439 f) Requiring indemnification of licensors and authors of that
440 material by anyone who conveys the material (or modified versions of
441 it) with contractual assumptions of liability to the recipient, for
442 any liability that these contractual assumptions directly impose on
443 those licensors and authors.
444
445 All other non-permissive additional terms are considered "further
446 restrictions" within the meaning of section 10. If the Program as you
447 received it, or any part of it, contains a notice stating that it is
448 governed by this License along with a term that is a further
449 restriction, you may remove that term. If a license document contains
450 a further restriction but permits relicensing or conveying under this
451 License, you may add to a covered work material governed by the terms
452 of that license document, provided that the further restriction does
453 not survive such relicensing or conveying.
454
455 If you add terms to a covered work in accord with this section, you
456 must place, in the relevant source files, a statement of the
457 additional terms that apply to those files, or a notice indicating
458 where to find the applicable terms.
459
460 Additional terms, permissive or non-permissive, may be stated in the
461 form of a separately written license, or stated as exceptions;
462 the above requirements apply either way.
463
464 8. Termination.
465
466 You may not propagate or modify a covered work except as expressly
467 provided under this License. Any attempt otherwise to propagate or
468 modify it is void, and will automatically terminate your rights under
469 this License (including any patent licenses granted under the third
470 paragraph of section 11).
471
472 However, if you cease all violation of this License, then your
473 license from a particular copyright holder is reinstated (a)
474 provisionally, unless and until the copyright holder explicitly and
475 finally terminates your license, and (b) permanently, if the copyright
476 holder fails to notify you of the violation by some reasonable means
477 prior to 60 days after the cessation.
478
479 Moreover, your license from a particular copyright holder is
480 reinstated permanently if the copyright holder notifies you of the
481 violation by some reasonable means, this is the first time you have
482 received notice of violation of this License (for any work) from that
483 copyright holder, and you cure the violation prior to 30 days after
484 your receipt of the notice.
485
486 Termination of your rights under this section does not terminate the
487 licenses of parties who have received copies or rights from you under
488 this License. If your rights have been terminated and not permanently
489 reinstated, you do not qualify to receive new licenses for the same
490 material under section 10.
491
492 9. Acceptance Not Required for Having Copies.
493
494 You are not required to accept this License in order to receive or
495 run a copy of the Program. Ancillary propagation of a covered work
496 occurring solely as a consequence of using peer-to-peer transmission
497 to receive a copy likewise does not require acceptance. However,
498 nothing other than this License grants you permission to propagate or
499 modify any covered work. These actions infringe copyright if you do
500 not accept this License. Therefore, by modifying or propagating a
501 covered work, you indicate your acceptance of this License to do so.
502
503 10. Automatic Licensing of Downstream Recipients.
504
505 Each time you convey a covered work, the recipient automatically
506 receives a license from the original licensors, to run, modify and
507 propagate that work, subject to this License. You are not responsible
508 for enforcing compliance by third parties with this License.
509
510 An "entity transaction" is a transaction transferring control of an
511 organization, or substantially all assets of one, or subdividing an
512 organization, or merging organizations. If propagation of a covered
513 work results from an entity transaction, each party to that
514 transaction who receives a copy of the work also receives whatever
515 licenses to the work the party's predecessor in interest had or could
516 give under the previous paragraph, plus a right to possession of the
517 Corresponding Source of the work from the predecessor in interest, if
518 the predecessor has it or can get it with reasonable efforts.
519
520 You may not impose any further restrictions on the exercise of the
521 rights granted or affirmed under this License. For example, you may
522 not impose a license fee, royalty, or other charge for exercise of
523 rights granted under this License, and you may not initiate litigation
524 (including a cross-claim or counterclaim in a lawsuit) alleging that
525 any patent claim is infringed by making, using, selling, offering for
526 sale, or importing the Program or any portion of it.
527
528 11. Patents.
529
530 A "contributor" is a copyright holder who authorizes use under this
531 License of the Program or a work on which the Program is based. The
532 work thus licensed is called the contributor's "contributor version".
533
534 A contributor's "essential patent claims" are all patent claims
535 owned or controlled by the contributor, whether already acquired or
536 hereafter acquired, that would be infringed by some manner, permitted
537 by this License, of making, using, or selling its contributor version,
538 but do not include claims that would be infringed only as a
539 consequence of further modification of the contributor version. For
540 purposes of this definition, "control" includes the right to grant
541 patent sublicenses in a manner consistent with the requirements of
542 this License.
543
544 Each contributor grants you a non-exclusive, worldwide, royalty-free
545 patent license under the contributor's essential patent claims, to
546 make, use, sell, offer for sale, import and otherwise run, modify and
547 propagate the contents of its contributor version.
548
549 In the following three paragraphs, a "patent license" is any express
550 agreement or commitment, however denominated, not to enforce a patent
551 (such as an express permission to practice a patent or covenant not to
552 sue for patent infringement). To "grant" such a patent license to a
553 party means to make such an agreement or commitment not to enforce a
554 patent against the party.
555
556 If you convey a covered work, knowingly relying on a patent license,
557 and the Corresponding Source of the work is not available for anyone
558 to copy, free of charge and under the terms of this License, through a
559 publicly available network server or other readily accessible means,
560 then you must either (1) cause the Corresponding Source to be so
561 available, or (2) arrange to deprive yourself of the benefit of the
562 patent license for this particular work, or (3) arrange, in a manner
563 consistent with the requirements of this License, to extend the patent
564 license to downstream recipients. "Knowingly relying" means you have
565 actual knowledge that, but for the patent license, your conveying the
566 covered work in a country, or your recipient's use of the covered work
567 in a country, would infringe one or more identifiable patents in that
568 country that you have reason to believe are valid.
569
570 If, pursuant to or in connection with a single transaction or
571 arrangement, you convey, or propagate by procuring conveyance of, a
572 covered work, and grant a patent license to some of the parties
573 receiving the covered work authorizing them to use, propagate, modify
574 or convey a specific copy of the covered work, then the patent license
575 you grant is automatically extended to all recipients of the covered
576 work and works based on it.
577
578 A patent license is "discriminatory" if it does not include within
579 the scope of its coverage, prohibits the exercise of, or is
580 conditioned on the non-exercise of one or more of the rights that are
581 specifically granted under this License. You may not convey a covered
582 work if you are a party to an arrangement with a third party that is
583 in the business of distributing software, under which you make payment
584 to the third party based on the extent of your activity of conveying
585 the work, and under which the third party grants, to any of the
586 parties who would receive the covered work from you, a discriminatory
587 patent license (a) in connection with copies of the covered work
588 conveyed by you (or copies made from those copies), or (b) primarily
589 for and in connection with specific products or compilations that
590 contain the covered work, unless you entered into that arrangement,
591 or that patent license was granted, prior to 28 March 2007.
592
593 Nothing in this License shall be construed as excluding or limiting
594 any implied license or other defenses to infringement that may
595 otherwise be available to you under applicable patent law.
596
597 12. No Surrender of Others' Freedom.
598
599 If conditions are imposed on you (whether by court order, agreement or
600 otherwise) that contradict the conditions of this License, they do not
601 excuse you from the conditions of this License. If you cannot convey a
602 covered work so as to satisfy simultaneously your obligations under this
603 License and any other pertinent obligations, then as a consequence you may
604 not convey it at all. For example, if you agree to terms that obligate you
605 to collect a royalty for further conveying from those to whom you convey
606 the Program, the only way you could satisfy both those terms and this
607 License would be to refrain entirely from conveying the Program.
608
609 13. Remote Network Interaction; Use with the GNU General Public License.
610
611 Notwithstanding any other provision of this License, if you modify the
612 Program, your modified version must prominently offer all users
613 interacting with it remotely through a computer network (if your version
614 supports such interaction) an opportunity to receive the Corresponding
615 Source of your version by providing access to the Corresponding Source
616 from a network server at no charge, through some standard or customary
617 means of facilitating copying of software. This Corresponding Source
618 shall include the Corresponding Source for any work covered by version 3
619 of the GNU General Public License that is incorporated pursuant to the
620 following paragraph.
621
622 Notwithstanding any other provision of this License, you have
623 permission to link or combine any covered work with a work licensed
624 under version 3 of the GNU General Public License into a single
625 combined work, and to convey the resulting work. The terms of this
626 License will continue to apply to the part which is the covered work,
627 but the work with which it is combined will remain governed by version
628 3 of the GNU General Public License.
629
630 14. Revised Versions of this License.
631
632 The Free Software Foundation may publish revised and/or new versions of
633 the GNU Affero General Public License from time to time. Such new versions
634 will be similar in spirit to the present version, but may differ in detail to
635 address new problems or concerns.
636
637 Each version is given a distinguishing version number. If the
638 Program specifies that a certain numbered version of the GNU Affero General
639 Public License "or any later version" applies to it, you have the
640 option of following the terms and conditions either of that numbered
641 version or of any later version published by the Free Software
642 Foundation. If the Program does not specify a version number of the
643 GNU Affero General Public License, you may choose any version ever published
644 by the Free Software Foundation.
645
646 If the Program specifies that a proxy can decide which future
647 versions of the GNU Affero General Public License can be used, that proxy's
648 public statement of acceptance of a version permanently authorizes you
649 to choose that version for the Program.
650
651 Later license versions may give you additional or different
652 permissions. However, no additional obligations are imposed on any
653 author or copyright holder as a result of your choosing to follow a
654 later version.
655
656 15. Disclaimer of Warranty.
657
658 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
659 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
660 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
661 OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
662 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
663 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
664 IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
665 ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
666
667 16. Limitation of Liability.
668
669 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
670 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
671 THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
672 GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
673 USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
674 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
675 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
676 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
677 SUCH DAMAGES.
678
679 17. Interpretation of Sections 15 and 16.
680
681 If the disclaimer of warranty and limitation of liability provided
682 above cannot be given local legal effect according to their terms,
683 reviewing courts shall apply local law that most closely approximates
684 an absolute waiver of all civil liability in connection with the
685 Program, unless a warranty or assumption of liability accompanies a
686 copy of the Program in return for a fee.
687
688 END OF TERMS AND CONDITIONS
689
690 How to Apply These Terms to Your New Programs
691
692 If you develop a new program, and you want it to be of the greatest
693 possible use to the public, the best way to achieve this is to make it
694 free software which everyone can redistribute and change under these terms.
695
696 To do so, attach the following notices to the program. It is safest
697 to attach them to the start of each source file to most effectively
698 state the exclusion of warranty; and each file should have at least
699 the "copyright" line and a pointer to where the full notice is found.
700
701 <one line to give the program's name and a brief idea of what it does.>
702 Copyright (C) <year> <name of author>
703
704 This program is free software: you can redistribute it and/or modify
705 it under the terms of the GNU Affero General Public License as published by
706 the Free Software Foundation, either version 3 of the License, or
707 (at your option) any later version.
708
709 This program is distributed in the hope that it will be useful,
710 but WITHOUT ANY WARRANTY; without even the implied warranty of
711 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
712 GNU Affero General Public License for more details.
713
714 You should have received a copy of the GNU Affero General Public License
715 along with this program. If not, see <http://www.gnu.org/licenses/>.
716
717 Also add information on how to contact you by electronic and paper mail.
718
719 If your software can interact with users remotely through a computer
720 network, you should also make sure that it provides a way for users to
721 get its source. For example, if your program is a web application, its
722 interface could display a "Source" link that leads users to an archive
723 of the code. There are many ways you could offer source, and different
724 solutions will be better for different programs; see section 13 for the
725 specific requirements.
726
727 You should also get your employer (if you work as a programmer) or school,
728 if any, to sign a "copyright disclaimer" for the program, if necessary.
729 For more information on this, and how to apply and follow the GNU AGPL, see
730 <http://www.gnu.org/licenses/>.
0 #!/usr/bin/perl -w
1 #
2
3 =head1 NAME
4
5 debpaste - http://paste.debian.net/ XML-RPC client
6
7 =cut
8
9 # Author: Hanno Hecker <vetinari@ankh-morp.org>
10 # Licence: AGPL 3.0 (http://www.fsf.org/licensing/licenses/agpl-3.0.html)
11 # Version: $Id: debpaste 22 2009-11-19 17:23:47Z vetinari $
12 # SVN: http://svn.ankh-morp.org:8080/tools/paste-dn/
13 #
14 # Required:
15 # deb: perl-base perl-modules
16 # libtimedate-perl libfrontier-rpc-perl libtext-iconv-perl
17 #
18 # ToDo:
19 # * "get" formatting?
20 # * wishlist :)
21 #
22 use strict;
23 use Getopt::Long;
24 use Pod::Usage;
25 my %config;
26 my $VERSION = '1.1 ($Rev: 22 $)';
27
28 =head1 SYNOPSIS
29
30 B<debpaste> ACTION [OPTIONS] [CODE|ID]
31
32 =head1 ACTIONS
33
34 =over 4
35
36 =item add
37
38 Usage: debpaste add [OPTIONS] [CODE]
39
40 Adds a new paste to L<http://paste.debian.net/>. If no code is given on the
41 command line, it will read from stdin.
42
43 Your paste infos are saved to I<~/.debpaste.history>
44
45 =item del
46
47 Usage: debpaste del [OPTIONS] ID
48
49 Deletes paste with id ID. This must be an ID which you have pasted before
50 (and is in your history file)
51
52 =item get
53
54 Usage: debpaste get [OPTIONS] ID
55
56 Fetches the paste with id ID from L<http://paste.debian.net>. To C<download>
57 a paste use something like
58
59 debpaste get --noheader ID > OUTFILE
60
61 =item lang
62
63 Usage: debpaste lang [OPTIONS]
64
65 Dumps the list of available languages for syntax highlighting, use the
66 B<--lang=LANG> option when B<add>ing a paste.
67
68 =item edit
69
70 Usage: debpaste edit [OPTIONS] ID
71
72 Downloads the paste with id ID, spawns an editor, and sends the edited file
73 as new paste.
74
75 =item expire
76
77 Usage: debpaste expire [OPTIONS] [ID]
78
79 Removes the entry ID from history file. If no ID is given it removes all
80 entries which are expired.
81
82 =back
83
84 =head1 OPTIONS
85
86 =over 4
87
88 =item --user=USERNAME
89
90 paste as USERNAME instead of C<anonymous>
91
92 =item --server=URL
93
94 use URL instead of http://paste.debian.net/server.pl
95
96 =item --noproxy
97
98 do not use the http proxy given in the environment variable C<http_proxy>
99
100 =item --lang=LANG
101
102 use LANG for syntax highlight ('debpaste lang' for available languages)
103
104 =item --expires=SEC
105
106 expires in SEC seconds (default: 259200 = 72h)
107
108 =item --encoding=ENC
109
110 when adding new paste, use ENC as encoding of file, default: UTF-8
111
112 =item --noheader
113
114 when B<get>ting entries, don't print header, just dump the paste to stdout.
115
116 =item --version
117
118 print version and exit
119
120 =back
121
122 =cut
123
124 binmode(STDOUT, ":utf8");
125 binmode(STDERR, ":utf8");
126
127 $0 =~ s#.*/##;
128
129 =head1 FILES
130
131 =over 4
132
133 =item ~/.debpaste.rc
134
135 The right place for setting default options like the username or expire values.
136 Format is C<KeyInAnYCase: value>, example:
137
138 User: Vetinari
139 Expires: 86400
140
141 =item ~/.debpaste.history
142
143 All info about pastes done with B<debpaste> are recorded here. This file
144 is used to keep a record for B<del>eting entries after pasting. Use
145 B<debpaste expire> to remove old entries.
146
147 =back
148
149 =cut
150
151 my $settings = $ENV{HOME}."/.debpaste.rc";
152
153 ## Don't change, edit $settings file:
154 ## KeYInAnyCaSE: value
155 ## AnoThErKey: other-value
156 my $history = $ENV{HOME}."/.debpaste.history";
157 %config = (
158 server => "http://paste.debian.net/server.pl",
159 user => "anonymous",
160 lang => "",
161 expires => 86400 * 3, #
162 history_file => $history,
163 no_get_header => 0,
164 );
165 my $action = "help";
166 my %help = (
167 'add' => "\n"
168 ."Usage: $0 add [OPTIONS] [CODE]\n"
169 ." Adds a new paste to http://paste.debian.net/\n"
170 ." If no code is given on the command line, it will read from\n"
171 ." stdin.\n"
172 ." Your paste infos are saved to $history\n",
173 'get' => "\n"
174 ."Usage: $0 get [OPTIONS] ID\n"
175 ." Fetches the paste with id ID from paste.debian.net\n"
176 ." To 'download' a paste use something like\n"
177 ." $0 get --noheader ID > OUTFILE\n",
178 'del' => "\n"
179 ."Usage: $0 del [OPTIONS] ID\n"
180 ." Deletes paste with id ID. This must be an ID which you have\n"
181 ." pasted before (and is in your history file)\n",
182 'lang' => "\n"
183 ."Usage: $0 lang [OPTIONS]\n"
184 ." Dumps the list of available languages for syntax highlighting\n",
185 'edit' => "\n"
186 ."Usage: $0 edit [OPTIONS] ID\n"
187 ." Downloads the paste with id ID, spawns an editor (\$EDITOR)\n"
188 ." and sends the edited file as new paste\n",
189 'expire' => "\n"
190 ."Usage: $0 expire [OPTIONS] [ID]\n"
191 ." Removes the entry ID from history file. If no ID is given,\n"
192 ." it removes all entries which are expired.\n",
193 # 'help' => "FIXME: help",
194 );
195
196 if (@ARGV and $ARGV[0] !~ /^-/) {
197 $action = shift @ARGV;
198 }
199
200 &read_settings();
201
202 GetOptions(
203 "user=s" => \$config{user},
204 "server=s" => \$config{server},
205 "expires=s" => \$config{expires},
206 "lang=s" => \$config{lang},
207 "encoding=s"=> \$config{encoding},
208 "noheader" => \$config{no_get_header},
209 "help" => sub { pod2usage(-exitval => 0, -verbose => 2) },
210 "version" => sub { print "debpaste v$VERSION\n"; exit 0; },
211 )
212 or pod2usage(-exitval => 1, -verbose => 2);
213
214 if ($action and $action eq "help") {
215 $action = shift @ARGV
216 if (@ARGV and $ARGV[0] !~ /^-/);
217 &help($action);
218 exit 0;
219 }
220
221 my $paste = PasteDN->new(%config);
222 if ($paste->can($action) and $action ne "new" and $action !~ /^_/) {
223 $paste->$action();
224 }
225 else {
226 die "$0: err... unknown action $action...\n";
227 }
228
229 sub read_settings {
230 open SET, $settings
231 or return;
232 while (defined (my $line = <SET>)) {
233 next unless $line =~ /^(\w+):\s+(.*)$/;
234 my ($key, $value) = (lc $1, $2);
235 unless (exists $config{$key}) {
236 warn "$0: unknown config key '$key' found\n";
237 next;
238 }
239 ($config{$key} = $value) =~ s/^\s*(.*?)\s*$/$1/;
240 }
241 close SET;
242 }
243
244 sub help {
245 my $msg = "";
246 ($msg = $help{$_[0]}."\n") if (exists $help{$_[0]});
247 pod2usage(-exitval => 0, -verbose => 2, -message => $msg);
248 }
249
250 ###################################################################
251
252 package PasteDN;
253 use Frontier::Client;
254 use Date::Parse;
255 use POSIX qw(strftime);
256 use File::Temp qw(tempfile);
257 use Text::Iconv;
258
259 sub new {
260 my $me = shift;
261 my %args = @_;
262 my $type = ref($me) || $me;
263 my $self = {};
264 bless $self, $type;
265 foreach (keys %args) {
266 $self->{$_} = $args{$_};
267 }
268 unless (exists $self->{editor}) {
269 $self->{editor} = $ENV{EDITOR} ?
270 $ENV{EDITOR} : ($ENV{VISUAL} ?
271 $ENV{VISUAL} : "/usr/bin/editor");
272 }
273 $self->{encoding} = "UTF-8" unless $self->{encoding};
274 $self->{expires} += time;
275 my %fc = ( url => $self->{server} );
276 unless ($self->{noproxy}) {
277 $fc{proxy} = $ENV{http_proxy} if $ENV{http_proxy};
278 }
279 $self->{_service} = Frontier::Client->new(%fc);
280 $self;
281 }
282
283 sub _to_utf8 {
284 my ($self,$txt) = @_;
285 my $enc = $self->{encoding};
286 return $txt if $enc eq "UTF-8";
287
288 my $i = eval { Text::Iconv->new($enc, "UTF-8"); };
289 die "$0: unsupported encoding $enc\n" if $@;
290
291 my $new = $i->convert($txt);
292 return $txt unless $new;
293 return $new;
294 }
295
296 sub _error {
297 my ($self, $msg) = @_;
298 unlink $self->{_tempfile} if $self->{_tempfile};
299 die "$0: $msg\n";
300 }
301
302 sub lang {
303 my $self = shift;
304 my $rc = $self->{_service}->call("paste.getLanguages");
305 die $rc->{statusmessage},"\n" if $rc->{rc};
306 ## print $rc->{statusmessage},"\n";
307 print "Available syntax highlights:\n";
308 foreach (@{$rc->{langs}}) {
309 print " $_\n";
310 }
311 }
312
313 sub get {
314 my $self = shift;
315 my $id = shift @ARGV;
316 die "$0: no id given\n" unless $id;
317 my $rc = $self->{_service}->call("paste.getPaste", $id);
318 die $rc->{statusmessage},"\n" if $rc->{rc};
319 # ugly, but dates are ok then...
320 # FIXME: probably only works with paste.d.n's timezone:
321 my $stime = str2time($rc->{submitdate}, "CET") - 3600;
322 my $sub_date = strftime('%Y-%m-%d %H:%M:%S', localtime $stime);
323 my $exp_date = strftime('%Y-%m-%d %H:%M:%S',
324 localtime($stime + $rc->{expiredate}));
325 unless ($self->{no_get_header}) {
326 print "User: ", $rc->{submitter}, "\n",
327 "Date: $sub_date\n",
328 "Expires: $exp_date\n",
329 "---------------------------------\n";
330 }
331 print $rc->{code},"\n";
332 }
333
334 sub edit {
335 my $self = shift;
336 my $id = shift @ARGV;
337 die "$0: no id given\n" unless $id;
338
339 my $rc = $self->{_service}->call("paste.getPaste", $id);
340 die $rc->{statusmessage},"\n" if $rc->{rc};
341 my $new = $self->_spawn_editor($rc->{code});
342 if (!$new or ($new eq $rc->{code})) {
343 print "$0: not changed, aborting...\n";
344 exit 0;
345 }
346 ## FIXME: text from paste.debian.net is probably UTF-8
347 ## $new = $self->_to_utf8($new);
348 $rc = $self->{_service}->call("paste.addPaste", $new,
349 $self->{user},
350 $self->{expires} - time,
351 $self->{lang});
352 die $rc->{statusmessage},"\n"
353 if $rc->{rc};
354 print $rc->{statusmessage},"\n";
355 print "To delete this entry, use: $0 del $rc->{id}\n";
356 $self->_save_entry($rc);
357 }
358
359 sub _spawn_editor {
360 my ($self, $txt) = @_;
361 my $fh;
362
363 ($fh, $self->{_tempfile}) = tempfile("debpaste.XXXXXX", DIR => "/tmp");
364
365 $self->_error("Could not create temp file: $!")
366 unless ($fh and $self->{_tempfile});
367 print $fh $txt or $self->_error("Could not print to tempfile: $!");
368 close $fh or $self->_error("Failed to close tempfile: $!");
369
370 if (system($self->{editor}, $self->{_tempfile}) != 0) {
371 $self->_error("failed to execute: $!")
372 if $? == -1;
373
374 $self->_error(sprintf('child died with signal %d, %s coredump',
375 ($? & 127), ($? & 128) ? 'with' : 'without'))
376 if $? & 127;
377
378 $self->error(sprintf('editor exited with value %d', $? >> 8));
379 }
380
381 open FH, $self->{_tempfile}
382 or $self->_error("Failed to open temp file: $!");
383 {
384 local $/ = undef;
385 $txt = <FH>;
386 };
387 close FH;
388 unlink $self->{_tempfile};
389 return $txt;
390 }
391
392 sub delete { $_[0]->del(); }
393 sub del {
394 my $self = shift;
395 my %entry = ();
396 my $id = shift @ARGV;
397 die "$0: no id given\n" unless $id;
398 open FILE, $self->{history_file}
399 or die "$0: failed to open history file: $!\n";
400 {
401 local $/ = "\n\n";
402 while (<FILE>) {
403 s#^[\n\s]+##ms;
404 s#[\n\s]+$##ms;
405 next unless $_;
406 %entry = map { /^(\S+):\s*(.*?)\s*$/;
407 ($1, $2 ? $2 : "") } split /\n/, $_;
408 last if ($entry{Entry} and $entry{Entry} eq $id);
409 %entry = ();
410 }
411 }
412 die "$0: Entry for $id not found...\n" unless $entry{Entry};
413 die "$0: No Digest for $id\n" unless $entry{Digest};
414 die "$0: Entry $id expired at ", scalar(localtime($entry{Expires})),"\n"
415 if ($entry{Expires} and $entry{Expires} < time);
416
417 my $rc = $self->{_service}->call("paste.deletePaste", $entry{Digest});
418 die $rc->{statusmessage},"\n" if $rc->{rc};
419 print $rc->{statusmessage},"\n",
420 "$0: deleted paste id ",$rc->{id},"\n";
421 $self->_expire($rc->{id});
422 }
423
424 sub expire {
425 my $self = shift;
426 my $id = shift @ARGV;
427 $self->_expire($id);
428 }
429
430 sub _expire {
431 my ($self, $id) = @_;
432 my @history = ();
433 my %entry;
434 my @ids = ();
435 open FILE, $self->{history_file}
436 or return;
437 {
438 local $/ = "\n\n";
439 while (<FILE>) {
440 s#^[\n\s]+##ms;
441 s#[\n\s]+$##ms;
442 next unless $_;
443 %entry = map { /^(\S+):\s*(.*?)\s*$/;
444 ($1, $2 ? $2 : "") } split /\n/, $_;
445
446 ## print "ID: $entry{Entry}\n";
447 if ($id) {
448 if ($entry{Entry} and $entry{Entry} eq $id) {
449 push @ids, $entry{Entry};
450 next;
451 }
452 }
453 elsif ($entry{Expires} and $entry{Expires} < time) {
454 push @ids, $entry{Entry};
455 next;
456 }
457 push @history, { %entry };
458 }
459 }
460 close FILE;
461 open FILE, ">", $self->{history_file}
462 or die "$0: Failed to open history file: $!\n";
463 foreach my $h (@history) {
464 foreach (keys %{$h}) {
465 next unless $_;
466 print FILE "$_: $h->{$_}\n";
467 }
468 print FILE "\n";
469 }
470 close FILE or die "$0: failed to write: $!\n";
471 print "$0: expired ", scalar(@ids), " entries from history",
472 (@ids ? ": ".join(", ", @ids) : ""), "\n";
473 }
474
475 sub add {
476 my $self = shift;
477
478 my $code = undef;
479 if (@ARGV) {
480 $code = join("\n", @ARGV);
481 }
482 else {
483 { local $/ = undef; $code = <STDIN>; }
484 }
485 die "$0: no code given\n"
486 unless $code;
487
488 $code = $self->_to_utf8($code);
489 my $rc = $self->{_service}->call("paste.addPaste", $code,
490 $self->{user},
491 $self->{expires} - time,
492 $self->{lang});
493 die $rc->{statusmessage},"\n"
494 if $rc->{rc};
495 print $rc->{statusmessage},"\n";
496 print "To delete this entry, use: $0 del $rc->{id}\n";
497 $self->_save_entry($rc);
498 }
499
500 sub _save_entry {
501 my ($self, $rc) = @_;
502 # return unless $self->{save_pastes};
503 my $file = $self->{history_file}
504 or return;
505 open FILE, ">>", $file or die "$0: failed to open $file: $!\n";
506 seek FILE, 0, 2 or die "$0: Failed to seek: $!\n";
507 print FILE "Server: ", $self->{server}, "\n",
508 "Entry: ", $rc->{id}, "\n",
509 "Lang: ", $self->{lang}, "\n",
510 "Expires: ", $self->{expires},"\n",
511 "Digest: ", $rc->{digest}, "\n\n"
512 or die "$0: Failed to save paste: $!\n";
513 close FILE or die "$0: Failed to save paste: $!\n";
514 }
515
516 =head1 DOWNLOAD
517
518 L<http://ankh-morp.org/code/paste-dn/debpaste> or
519 L<SVN|http://svn.ankh-morp.org:8080/tools/paste-dn/>
520
521 =head1 NOTES
522
523 Renamed to C<debpaste> at Rev. 20
524
525 =head1 AUTHOR
526
527 Hanno Hecker <vetinari@ankh-morp.org>
528
529 =cut
530
531
532 # vim: ts=4 sw=4 expandtab syn=perl
2626 filter="grep-dctrl -FStatus ' installed'"
2727 expand="cat"
2828 grep_dctrl_options=""
29 all="no"
30
2931 while true; do
3032 case "$1" in
31 -a) filter="cat" ; shift ;;
33 -a) filter="cat" ; all="yes" ; shift ;;
3234 -0) SEP=0 ; shift ;;
3335 -r|-e|-i|-X|-v) grep_dctrl_options="$grep_dctrl_options $1"; shift ;;
3436 -f) expand="xargs dpkg --listfiles | perl -nl${SEP}e 'print if -f'"
37 if [ "$all" == "yes" ] ; then
38 if [ -n "`which apt-file`" ] ; then
39 # if we have apt-file use it instead
40 expand="while read pack; do apt-file show \$pack; done | perl -ple 's/^.*?: //'"
41 else
42 echo -e "WARN: You requested information on files of all packages,\nWARN: however, since the 'apt-file' package is not available, this\nWARN: information can only be provided for those packages currently installed." >&2
43 fi
44 fi
3545 shift
3646 ;;
3747
4050 done
4151
4252 # Does the package exist?
43 packages=`eval $filter /var/lib/dpkg/status | grep-dctrl -PnsPackage $grep_dctrl_options "$1"`
44 if [ -z "$packages" ] ; then
45 exit 1
53 if [ "$all" == "no" ] ; then
54 packages=`eval $filter /var/lib/dpkg/status | grep-dctrl -PnsPackage $grep_dctrl_options "$1"`
55 if [ -z "$packages" ] ; then
56 exit 1
57 fi
58 eval $filter /var/lib/dpkg/status | grep-dctrl -PnsPackage $grep_dctrl_options "$1" |
59 (eval $expand)
60 else
61 # Use grep-available as the status file does not include all available
62 # packages
63 grep-aptavail -PnsPackage $grep_dctrl_options "$1" |
64 (eval $expand)
4665 fi
47
48 eval $filter /var/lib/dpkg/status | grep-dctrl -PnsPackage $grep_dctrl_options "$1" |
49 (eval $expand)
1414 installed packages; the B<-a> switch widens the search (see L<"OPTIONS">). The
1515 list is written to stdout, one name per line.
1616
17 grep-dctrl(1) is used to search the list of packages, so you should
18 refer to its documentation for information on how patterns are
17 grep-dctrl(1) and grep-aptavail(1) are used to search the list of packages, so
18 you should refer to its documentation for information on how patterns are
1919 matched. By default, all packages whose name contains the given
2020 string will be matched, but several options are available to modify
2121 this behavior (see L<"OPTIONS">).
2222
2323 If you use dglob with the B<-f> option, all files in the matched packages
24 are listed instead of their names. Only existing, plain (i.e. no symlinks,
25 directories or other special ones) files are listed. The filenames are
24 are listed instead of their names. If you do not use de B<-a> switch,
25 only existing, plain (i.e. no symlinks, directories or other special ones)
26 files are listed. If the B<-a> switch is use then all files will
27 be listed both for installed and non-installed packages. The filenames are
2628 written to stdout, one file per line. You can use the B<-0> option to
2729 get the filenames separated by '\0' instead of a newline.
2830
3537 =item B<-a>
3638
3739 Search through all available packages, not just installed ones.
40 If set, grep-aptavail(1) is used.
3841
3942 =item B<-f>
4043
41 List all files in the matched packages. This list only installed (i.e.
42 locally existing) files from installed packages, so using it together
43 with B<-a> is rather pointless.
44 List all files in the matched packages. By default, this lists only installed
45 (i.e. locally existing) files from installed packages. If used
46 together with B<-a> then it will list all files both of installed and
47 non-installed packages by mean of apt-file(1). If apt-file is not
48 installed, using B<-f> together with B<-a> is rather pointless.
4449
4550 =item B<-0>
4651
4954
5055 =item B<-r>, B<-e>, B<-i>, B<-X>, B<-v>
5156
52 These options are passed directly to grep-dctrl(1) to modify how the
53 pattern is matched. See grep-dctrl(1).
57 These options are passed directly to grep-dctrl(1) or to grep-aptavail(1) to
58 modify how the pattern is matched. See grep-dctrl(1).
5459
5560 =back
5661
6974
7075 Matt Zimmerman <mdz@debian.org>
7176
72 This manpage was written by Frank Lichtenheld <frank@lichtenheld.de>.
77 This manpage was written by Frank Lichtenheld <frank@lichtenheld.de>,
78 and further enhanced by Javier Fernandez-Sanguino <jfs@debian.org>.
7379
7480 =head1 COPYRIGHT AND LICENCE
7581
8591
8692 =head1 SEE ALSO
8793
88 grep-dctrl(1), dpkg(8)
94 grep-dctrl(1), grep-available(1), apt-file(1), dpkg(8)