Author: adsb
Date: 2008-11-24 19:51:47 +0000 (Mon, 24 Nov 2008)
New Revision: 1744
Modified:
trunk/debian/changelog
trunk/scripts/debi.1
trunk/scripts/debi.pl
Log:
debi: Add an "upgrade" option indicating that only those packages
already installed on the system should be installed, rather than
all packages listed in the .changes file. Thanks, Colin Watson.
(Closes: #506663)
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-11-20 16:29:19 UTC (rev 1743)
+++ trunk/debian/changelog 2008-11-24 19:51:47 UTC (rev 1744)
@@ -1,7 +1,10 @@
devscripts (2.10.42) UNRELEASED; urgency=low
[ Adam D. Barratt ]
- * NOT RELEASED YET
+ * debi: Add an "upgrade" option indicating that only those packages
+ already installed on the system should be installed, rather than
+ all packages listed in the .changes file. Thanks, Colin Watson.
+ (Closes: #506663)
[ Christoph Berg ]
* rmadison: Add debug.debian.net.
Modified: trunk/scripts/debi.1
===================================================================
--- trunk/scripts/debi.1 2008-11-20 16:29:19 UTC (rev 1743)
+++ trunk/scripts/debi.1 2008-11-24 19:51:47 UTC (rev 1744)
@@ -76,6 +76,12 @@
either be an absolute path or relative to the top of the source
directory.
.TP
+\fB\-\-upgrade\fR
+Only upgrade packages already installed on the system, rather than
+installing all packages listed in the \fI.changes\fR file.
+Useful for multi-binary packages when you don't want to have all the
+binaries installed at once.
+.TP
\fB\-\-check-dirname-level\fR \fIN\fR
See the above section "Directory name checking" for an explanation of
this option.
Modified: trunk/scripts/debi.pl
===================================================================
--- trunk/scripts/debi.pl 2008-11-20 16:29:19 UTC (rev 1743)
+++ trunk/scripts/debi.pl 2008-11-24 19:51:47 UTC (rev 1744)
@@ -30,6 +30,9 @@
use File::Basename;
use filetest 'access';
use Cwd;
+use File::Spec;
+use IPC::Open3;
+use Symbol 'gensym';
my $progname = basename($0,'.pl'); # the '.pl' is for when we're debugging
my $modified_conf_msg;
@@ -48,6 +51,7 @@
--debs-dir DIR Look for the changes and debs files in DIR instead of
the parent of the current package directory
--multi Search for multiarch .changes file made by dpkg-cross
+ --upgrade Only upgrade packages; don't install new ones.
--check-dirname-level N
How much to check directory names:
N=0 never
@@ -171,6 +175,7 @@
# Command line options next
my ($opt_help, $opt_version, $opt_a, $opt_t, $opt_debsdir, $opt_multi);
+my $opt_upgrade;
my ($opt_ignore, $opt_level, $opt_regex, $opt_noconf);
GetOptions("help" => \$opt_help,
"version" => \$opt_version,
@@ -178,6 +183,7 @@
"t=s" => \$opt_t,
"debs-dir=s" => \$opt_debsdir,
"multi" => \$opt_multi,
+ "upgrade" => \$opt_upgrade,
"ignore-dirname" => \$opt_ignore,
"check-dirname-level=s" => \$opt_level,
"check-dirname-regex=s" => \$opt_regex,
@@ -379,6 +385,42 @@
}
close CHANGES;
+if ($progname eq 'debi' and $opt_upgrade and @debs) {
+ my %installed;
+ my @cmd = ('dpkg-query', '-W', '-f', '${Package} ${Status}\n');
+ for my $deb (@debs) {
+ (my $pkg = $deb) =~ s/_.*//;
+ push @cmd, $pkg;
+ }
+ local (*NULL, *QUERY);
+ open NULL, '>', File::Spec->devnull;
+ my $pid = open3(gensym, \*QUERY, '>&NULL', @cmd)
+ or die "$progname: dpkg-query failed\n";
+ while (<QUERY>) {
+ my ($pkg, $want, $eflag, $status) = split;
+ if ($status and $status ne 'not-installed' and
+ $status ne 'config-files') {
+ $installed{$pkg} = 1;
+ }
+ }
+ close QUERY;
+ waitpid $pid, 0;
+ my @new_debs;
+ for my $deb (@debs) {
+ (my $pkg = $deb) =~ s/_.*//;
+ if ($installed{$pkg}) {
+ push @new_debs, $deb;
+ } elsif (@ARGV) {
+ if (exists $pkgs{$pkg}) {
+ $pkgs{$pkg}--;
+ } elsif (exists $pkgs{$deb}) {
+ $pkgs{$deb}--;
+ }
+ }
+ }
+ @debs = @new_debs;
+}
+
if (! @debs) {
die "$progname: no appropriate .debs found in the changes file
$changes!\n";
}
--
To unsubscribe, send mail to [EMAIL PROTECTED]