| 1 |
operz |
1 |
#!/bin/env perl -w |
| 2 |
|
|
# |
| 3 |
|
|
# $Id: qdepend 830 2006-09-19 18:23:08Z comand $ |
| 4 |
|
|
# |
| 5 |
|
|
# Copyright 2006 Cory Omand <comand@blastwave.org> |
| 6 |
|
|
# All rights reserved. Use is subject to license terms. |
| 7 |
|
|
# |
| 8 |
|
|
# Redistribution and/or use, with or without modification, is |
| 9 |
|
|
# permitted. This software is without warranty of any kind. The |
| 10 |
|
|
# author(s) shall not be liable in the event that use of the |
| 11 |
|
|
# software causes damage. |
| 12 |
|
|
# |
| 13 |
|
|
# qdepend - Quick depend formatter for use with installed packages. |
| 14 |
|
|
# |
| 15 |
|
|
|
| 16 |
|
|
use strict; |
| 17 |
|
|
|
| 18 |
|
|
@ARGV or die "Usage: $0 [P|I|R] <pkg> ... <pkgN>\n"; |
| 19 |
|
|
|
| 20 |
|
|
my $DEPTYPE = "P"; |
| 21 |
|
|
$DEPTYPE = shift @ARGV if $ARGV[0] =~ /P|I|R/; |
| 22 |
|
|
|
| 23 |
|
|
foreach my $pkg (@ARGV) { |
| 24 |
|
|
my ($pinfo) = `pkginfo -x $pkg 2>&1`; |
| 25 |
|
|
if (($? >> 8) != 0) { |
| 26 |
|
|
print STDERR $pinfo; |
| 27 |
|
|
next; |
| 28 |
|
|
} |
| 29 |
|
|
$pinfo =~ s/\s{2,}/ /g; |
| 30 |
|
|
chomp($pinfo); |
| 31 |
|
|
print "$DEPTYPE $pinfo\n"; |
| 32 |
|
|
} |
| 33 |
|
|
|