Package: devscripts Version: 2.9.7 Severity: wishlist Tags: patch Hi,
attached is a patch for a new script "dget" which I use to download source packages. It is a very nice improvement over "wget URL.dsc" since it downloads the all 3 files (similar for .changes). (And I don't have to modify my sources.list just to download the one package I want to sponsor.) It also downloads binary packages from the mirror configured in sources.list. (apt-get install -d needs root, which dget does not.) [1] Please consider applying the patch for the next devscripts version. Christoph [1] debian-goodies includes a "debget" which is a front-end to apt-get install and hence does require root. -- [EMAIL PROTECTED] | http://www.df7cb.de/
diff -Nru /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/Makefile
/srv/tmp/W3ChAhok1q/devscripts-2.9.8/Makefile
--- /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/Makefile 2005-07-31
16:30:08.000000000 +0200
+++ /srv/tmp/W3ChAhok1q/devscripts-2.9.8/Makefile 2005-10-05
18:46:08.000000000 +0200
@@ -3,7 +3,7 @@
PL_FILES = bts.pl checkbashisms.pl cvs-debuild.pl debchange.pl \
debdiff.pl debi.pl debpkg.pl debuild.pl dpkg-depcheck.pl \
dscverify.pl grep-excuses.pl plotchangelog.pl rc-alert.pl \
- debcommit.pl svnpath.pl dd-list.pl
+ debcommit.pl svnpath.pl dd-list.pl dget.pl
SH_FILES = cvs-debi.sh cvs-debrelease.sh debclean.sh debrelease.sh \
debrsign.sh debsign.sh dpkg-genbuilddeps.sh mergechanges.sh \
@@ -20,7 +20,7 @@
EXAMPLES = conf.default
MAN1S = $(SCRIPTS:=.1) debc.1 cvs-debc.1 devscripts.1
-GEN_MAN1S = bts.1 svnpath.1 debcommit.1 deb-reversion.1
+GEN_MAN1S = bts.1 svnpath.1 debcommit.1 deb-reversion.1 dget.1
MAN5S = devscripts.conf.5
MANS_fr_DIR = po4a/fr
MAN1S_fr = $(subst $(MANS_fr_DIR)/,,$(wildcard $(MANS_fr_DIR)/*.1))
diff -Nru /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/README
/srv/tmp/W3ChAhok1q/devscripts-2.9.8/README
--- /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/README 2005-07-31 15:51:54.000000000
+0200
+++ /srv/tmp/W3ChAhok1q/devscripts-2.9.8/README 2005-10-05 18:49:42.000000000
+0200
@@ -116,6 +116,9 @@
- deb-reversion: Increases a binary package version number and repacks
the package, useful for porters and the like.
+- dget: Downloads source packages from the web and provides a non-root
+ variant of "apt-get install -d" for binary packages.
+
- dpkg-depcheck, dpkg-genbuilddeps [build-essential, strace]: Runs a
specified command (such as debian/rules build) or dpkg-buildpackage,
respectively, to determine the packages used during the build
diff -Nru /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/debian/changelog
/srv/tmp/W3ChAhok1q/devscripts-2.9.8/debian/changelog
--- /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/debian/changelog 2005-09-04
02:53:03.000000000 +0200
+++ /srv/tmp/W3ChAhok1q/devscripts-2.9.8/debian/changelog 2005-10-05
18:51:32.000000000 +0200
@@ -1,3 +1,10 @@
+devscripts (2.9.8) unstable; urgency=low
+
+ * dget: new script: downloads source packages from the web and provides a
+ non-root variant of "apt-get install -d" for binary packages.
+
+ -- Christoph Berg <[EMAIL PROTECTED]> Wed, 5 Oct 2005 18:50:47 +0200
+
devscripts (2.9.7) unstable; urgency=low
* bts: oops, left out a space in usertags command
diff -Nru /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/debian/control
/srv/tmp/W3ChAhok1q/devscripts-2.9.8/debian/control
--- /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/debian/control 2005-07-31
16:41:39.000000000 +0200
+++ /srv/tmp/W3ChAhok1q/devscripts-2.9.8/debian/control 2005-10-05
18:49:42.000000000 +0200
@@ -51,6 +51,8 @@
lintian | linda, gnupg]
- deb-reversion: increases a binary package version number and repacks the
archive
+ - dget: downloads source packages from the web and provides a non-root
+ variant of "apt-get install -d" for binary packages [wget]
- dpkg-depcheck, dpkg-genbuilddeps: determine the packages used during
the build of a Debian package; useful for determining the Build-Depends
control field needed [build-essential, strace]
diff -Nru /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/dget.pl
/srv/tmp/W3ChAhok1q/devscripts-2.9.8/dget.pl
--- /srv/tmp/1Pgr2khYyt/devscripts-2.9.7/dget.pl 1970-01-01
01:00:00.000000000 +0100
+++ /srv/tmp/W3ChAhok1q/devscripts-2.9.8/dget.pl 2005-10-05
18:44:43.000000000 +0200
@@ -0,0 +1,229 @@
+#!/usr/bin/perl -w
+
+# dget (c) 2005 Christoph Berg <[EMAIL PROTECTED]>
+# This program is licensed under the terms of the GNU GPL.
+
+# 2005-10-04 cb: initial release
+
+use strict;
+use IO::File;
+use Digest::MD5;
+
+# some files are in the .dsc and .changes
+my %seen;
+
+# check if we have found sources to unpack
+my $dsc;
+
+# use curl if installed, wget otherwise
+my $wget = "wget -q -O";
+$wget = "curl -s -f -o" if -e "/usr/bin/curl";
+
+sub get_file {
+ my ($dir, $file, $md5sum) = @_;
+
+ return if $seen{$file};
+ $seen{$file} = 1;
+
+ if ($md5sum eq "unlink") {
+ unlink $file;
+ }
+
+ if (-e $file) {
+ my $md5 = Digest::MD5->new;
+ my $fh5 = new IO::File($file) or die "$file: $!";
+ my $md5sum_new = Digest::MD5->new->addfile($fh5)->hexdigest();
+ close $fh5;
+ if (not $md5sum or ($md5sum_new eq $md5sum)) {
+ print "$0: using existing $file\n";
+ } else {
+ print "$0: md5sum for $file does not match\n";
+ unlink $file;
+ }
+ }
+
+ unless (-e $file) {
+ print "$0: retrieving $dir/$file\n";
+ system "$wget $file $dir/$file";
+ unless (-e $file and -s $file) {
+ die "$0: $wget $file $dir/$file failed\n";
+ unlink $file;
+ }
+ }
+
+ if ($file =~ /\.(?:changes|dsc)$/) {
+ parse_file($dir, $file);
+ }
+ if ($file =~ /\.dsc$/) {
+ $dsc = $file;
+ }
+}
+
+sub parse_file {
+ my ($dir, $file) = @_;
+
+ my $fh = IO::File::new($file);
+ open $fh, $file or die "$file: $!";
+ while (<$fh>) {
+ if (/^ ([0-9a-f]{32}) (?:\S+ )*(\S+)$/) {
+ get_file($dir, $2, $1);
+ }
+ }
+ close $fh;
+}
+
+sub apt_get {
+ my ($package, $version) = @_;
+
+ my $apt = new IO::File("apt-cache show $package |") or die "$!";
+ my ($v, $p, $filename, $md5sum);
+ while (<$apt>) {
+ if (/^Package: $package$/) {
+ $p = $package;
+ }
+ if (/^Version: $version$/) {
+ $v = $version;
+ }
+ if (/^Filename: (.*)/) {
+ $filename = $1;
+ }
+ if (/^MD5sum: (.*)/) {
+ $md5sum = $1;
+ }
+ if (/^Description:/) { # we assume this is the last field
+ if ($p and $v and $filename) {
+ last;
+ }
+ undef $p;
+ undef $v;
+ undef $filename;
+ undef $md5sum;
+ }
+ }
+ close $apt;
+
+ unless ($filename) {
+ die "$0: no filename for $package ($version) found\n";
+ }
+
+ $apt = new IO::File("/etc/apt/sources.list") or die
"/etc/apt/sources.list: $!";
+ my $repository;
+ while (<$apt>) {
+ if (/^\s*deb\s*(\S+)/) {
+ $repository = $1;
+ last;
+ }
+ }
+ close $apt;
+ unless ($repository) {
+ die "no repository found in /etc/apt/sources.list";
+ }
+
+ my ($dir, $file) = ($repository, $filename);
+ if ($filename =~ /(.*)\/([^\/]*)$/) {
+ ($dir, $file) = ("$repository/$1", $2);
+ }
+
+ get_file($dir, $file, $md5sum);
+
+ exit 0;
+}
+
+# main program
+
+my $arg = shift || die "usage: $0 package-url.dsc/changes\n";
+
+if ($arg =~ /^((?:http|www).*)\/([^\/]+\.\w+)$/) {
+ my ($dir, $file) = ($1, $2);
+
+ get_file($dir, $file, "unlink");
+
+ if ($dsc) {
+ system "dpkg-source -x $dsc";
+ }
+
+ exit 0;
+}
+
+if ($arg =~ /^[a-z0-9.+-]{2,}$/) {
+ # we reinvent "apt-get -d install" here, without requiring root
+ # (and we do not download dependencies)
+
+ $ENV{LC_ALL} = 'C';
+ my $apt = new IO::File("apt-cache policy $arg |") or die "$!";
+ my $candidate;
+ while (<$apt>) {
+ if (/^ Candidate: (.+)/) {
+ $candidate = $1;
+ last;
+ }
+ }
+ close $apt;
+ unless ($candidate) {
+ die "$0: $arg has no installation candidate\n";
+ }
+
+ apt_get($arg, $candidate);
+
+ exit 0;
+}
+
+if ($arg =~ /^([a-z0-9.+-]{2,})=([a-zA-Z0-9.:+-]+)$/) {
+ apt_get($1, $2);
+
+ exit 0;
+}
+
+die "usage: $0 package-url.dsc/changes\n";
+
+=pod
+
+=head1 NAME
+
+dget -- Download Debian source and binary packages
+
+=head1 SYNOPSIS
+
+=over
+
+=item B<dget> I<URL>
+
+=item B<dget> I<package>
+
+=item B<dget> I<package>=I<version>
+
+=back
+
+=head1 DESCRIPTION
+
+B<dget> downloads Debian packages. In the first form, B<dget> acts as an source
+package-aware form of wget; it fetches the given URL and recursively any files
+referenced, if the URL points to a .dsc or .changes file. The downloaded source
+is unpacked by B<dpkg-source>.
+
+In the second and third form, B<dget> downloads a binary package from the
+Debian mirror configured in /etc/apt/sources.list. Unlike B<apt-get install
+-d>, it does not require root privileges, writes to the current directory, and
+does not download dependencies.
+
+B<dget> was written to make it easier to retrieve source packages from the web
+for sponsor uploads. For checking the package with B<debdiff>, the last binary
+version is available via "B<dget> package", the last source version via
+"B<apt-get> source package".
+
+=head1 OPTIONS
+
+B<dget> does not have options.
+
+=head1 AUTHOR
+
+=over
+
+=item Christoph Berg <[EMAIL PROTECTED]>
+
+=back
+
+=head1 SEE ALSO
+
+debdiff(1), apt-get(1).
+
signature.asc
Description: Digital signature

