Bug#734922: apt-cache showsrc shows duplicate entries

2014-01-15 Thread Michael Vogt
On Tue, Jan 14, 2014 at 06:02:21PM +0530, Faheem Mitha wrote:
 On Tue, 14 Jan 2014, Michael Vogt wrote:
 
 On Sat, Jan 11, 2014 at 01:05:23AM +0530, Faheem Mitha wrote:
 Package: apt
 Version: 0.9.7.9+deb7u1
 Severity: normal
 
 Unlike, for example `apt-cache show` and `apt-cache policy`,
 `apt-cache showsrc` shows duplicate entries. I can't see any good
 reason for this inconsistency.
 
 Attached is a possilbe fix, but there is some cleanup needed before
 this can go in.
 
 In this line, idential should be identical.
 
 +  // avoid showing idential records

Great, thanks! Fixed.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#734922: apt-cache showsrc shows duplicate entries

2014-01-14 Thread Michael Vogt
On Sat, Jan 11, 2014 at 01:05:23AM +0530, Faheem Mitha wrote:
 Package: apt
 Version: 0.9.7.9+deb7u1
 Severity: normal
 
 Unlike, for example `apt-cache show` and `apt-cache policy`,
 `apt-cache showsrc` shows duplicate entries. I can't see any good
 reason for this inconsistency.

Attached is a possilbe fix, but there is some cleanup needed before
this can go in.

Cheers,
 Michael
From 14042cb47e58bb64afefe67a0d83494191c11a7a Mon Sep 17 00:00:00 2001
From: Michael Vogt m...@debian.org
Date: Mon, 13 Jan 2014 17:35:54 +0100
Subject: [PATCH] do not show duplicated apt-cache showsrc entries

---
 cmdline/apt-cache.cc   | 23 +--
 .../test-bug-734922-apt-showsrc-duplicate  | 47 ++
 2 files changed, 67 insertions(+), 3 deletions(-)
 create mode 100755 test/integration/test-bug-734922-apt-showsrc-duplicate

diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index b8892d2..58864b4 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -34,6 +34,7 @@
 #include apt-pkg/pkgsystem.h
 #include apt-pkg/indexfile.h
 #include apt-pkg/metaindex.h
+#include apt-pkg/hashes.h
 
 #include apt-private/private-list.h
 #include apt-private/private-cmndline.h
@@ -1475,6 +1476,15 @@ bool ShowPkgNames(CommandLine CmdL)
return true;
 }
 	/*}}}*/
+
+// FIXME: move to hashes.h: HashString::FromString()
+std::string Sha1FromString(std::string input)
+{
+   SHA1Summation sha1;
+   sha1.Add(input.c_str(), input.length());
+   return sha1.Result().Value();
+}
+
 // ShowSrcPackage - Show source package records/*{{{*/
 // -
 /* */
@@ -1497,10 +1507,17 @@ bool ShowSrcPackage(CommandLine CmdL)
   
   pkgSrcRecords::Parser *Parse;
   unsigned found_this = 0;
+  // avoid showing idential records
+  std::setstd::string seen;
   while ((Parse = SrcRecs.Find(*I,false)) != 0) {
-cout  Parse-AsStr()  endl;;
-found++;
-found_this++;
+ std::string sha1str = Sha1FromString(Parse-AsStr());
+ if (std::find(seen.begin(), seen.end(), sha1str) == seen.end())
+ {
+cout  Parse-AsStr()  endl;;
+found++;
+found_this++;
+seen.insert(sha1str);
+ } 
   }
   if (found_this == 0) {
 _error-Warning(_(Unable to locate package %s),*I);
diff --git a/test/integration/test-bug-734922-apt-showsrc-duplicate b/test/integration/test-bug-734922-apt-showsrc-duplicate
new file mode 100755
index 000..66db534
--- /dev/null
+++ b/test/integration/test-bug-734922-apt-showsrc-duplicate
@@ -0,0 +1,47 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'i386' 
+
+# foo is identical, show it only once in showsrc
+insertpackage unstable foo i386 1.0
+insertpackage testing foo i386 1.0
+insertsource unstable foo i386 1.0
+insertsource testing foo i386 1.0
+
+# bar is different, show twice
+insertsource unstable bar i386 1.0
+insertsource testing bar i386 2.0
+
+setupaptarchive
+
+testequal Package: foo
+Binary: foo
+Version: 1.0
+Maintainer: Joe Sixpack j...@example.org
+Architecture: i386
+Files:
+ d41d8cd98f00b204e9800998ecf8427e 0 foo_1.0.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 foo_1.0.tar.gz
+
+Package: bar
+Binary: bar
+Version: 2.0
+Maintainer: Joe Sixpack j...@example.org
+Architecture: i386
+Files:
+ d41d8cd98f00b204e9800998ecf8427e 0 bar_2.0.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 bar_2.0.tar.gz
+
+Package: bar
+Binary: bar
+Version: 1.0
+Maintainer: Joe Sixpack j...@example.org
+Architecture: i386
+Files:
+ d41d8cd98f00b204e9800998ecf8427e 0 bar_1.0.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 bar_1.0.tar.gz
+ aptcache showsrc foo bar
\ No newline at end of file
-- 
1.8.3.2



Bug#734922: apt-cache showsrc shows duplicate entries

2014-01-14 Thread Faheem Mitha


On Tue, 14 Jan 2014, Michael Vogt wrote:


On Sat, Jan 11, 2014 at 01:05:23AM +0530, Faheem Mitha wrote:

Package: apt
Version: 0.9.7.9+deb7u1
Severity: normal

Unlike, for example `apt-cache show` and `apt-cache policy`,
`apt-cache showsrc` shows duplicate entries. I can't see any good
reason for this inconsistency.



Attached is a possilbe fix, but there is some cleanup needed before
this can go in.


In this line, idential should be identical.

+  // avoid showing idential records

 Regards, Faheem


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#734922: apt-cache showsrc shows duplicate entries

2014-01-10 Thread Faheem Mitha
Package: apt
Version: 0.9.7.9+deb7u1
Severity: normal

Unlike, for example `apt-cache show` and `apt-cache policy`,
`apt-cache showsrc` shows duplicate entries. I can't see any good
reason for this inconsistency.

For example:

#
$ apt-cache policy tla

tla:
  Installed: (none)
  Candidate: 1.3.5+dfsg-18
  Version table:
 1.3.5+dfsg-18 0
500 http://debian.lcs.mit.edu/debian/ wheezy/main amd64 Packages
 50 http://debian.lcs.mit.edu/debian/ testing/main amd64 Packages
 50 http://debian.lcs.mit.edu/debian/ unstable/main amd64 Packages
 1.3.5+dfsg-16 0
500 http://debian.lcs.mit.edu/debian/ squeeze/main amd64 Packages
##

and

##

$ apt-cache show tla

Package: tla
Version: 1.3.5+dfsg-18
Installed-Size: 881
Maintainer: Debian QA Group packa...@qa.debian.org
Architecture: amd64
Depends: libc6 (= 2.11), libexpat1 (= 1.95.8), gawk, patch
Recommends: tla-doc
Suggests: gnupg, ssh
Description-en: GNU Arch revision control system
 Arch is a modern replacement for CVS, specifically designed for the
 distributed development. It supports development on branches,
 distributed repositories, changeset-oriented project management,
 and of course, file and directory renaming.
Description-md5: b1978a310e178291e9aa549e4eefcad2
Tag: devel::rcs, implemented-in::c, interface::commandline, role::program,
 suite::gnu, use::synchronizing
Section: vcs
Priority: optional
Filename: pool/main/t/tla/tla_1.3.5+dfsg-18_amd64.deb
Size: 383026
MD5sum: 2e34fa6e47043991bf968f4ae631ce1c
SHA1: 71447d826cb54a6c53b32b9b418590a8b48a46ff
SHA256: 59e55d5dd9ca5ae6d70d0c6ff9a5d9f838bf196ff559baea1205fb6aa41cd4a3

Package: tla
Priority: optional
Section: vcs
Installed-Size: 932
Maintainer: Debian QA Group packa...@qa.debian.org
Architecture: amd64
Version: 1.3.5+dfsg-16
Depends: libc6 (= 2.3), libexpat1 (= 1.95.8), gawk, patch
Recommends: tla-doc
Suggests: gnupg, ssh
Filename: pool/main/t/tla/tla_1.3.5+dfsg-16_amd64.deb
Size: 383200
MD5sum: 293e07e53cef4f690cfe7e50d1831185
SHA1: 75ab0f97c5fb77aceaafcd5f7b4cf4c97e8c3a0e
SHA256: bf00971e5cbf8163c83c12e6a9aaf243987c22f5852137af3562a8e557f58962
Description-en: GNU Arch revision control system
 Arch is a modern replacement for CVS, specifically designed for the
 distributed development. It supports development on branches,
 distributed repositories, changeset-oriented project management,
 and of course, file and directory renaming.
Tag: devel::rcs, implemented-in::c, interface::commandline, qa::orphaned, 
role::program, suite::gnu, use::synchronizing

##

but

##
$ apt-cache showsrc tla

Package: tla
Binary: tla, tla-doc
Version: 1.3.5+dfsg-18
Maintainer: Debian QA Group packa...@qa.debian.org
Build-Depends: debhelper (= 7), autotools-dev, time, libexpat1-dev
Architecture: any all
Standards-Version: 3.9.2
Format: 3.0 (quilt)
Files:
 5729ed285e021c152b8c8b66ad98407a 1218 tla_1.3.5+dfsg-18.dsc
 985debdf20daea547f3e4ef36a7c17cd 3182003 tla_1.3.5+dfsg.orig.tar.gz
 65462ae1eb1449728914d42a010f06ec 37401 tla_1.3.5+dfsg-18.debian.tar.gz
Checksums-Sha1:
 7006faee7b9fc26f11bc4a7ebff21c311300101b 1218 tla_1.3.5+dfsg-18.dsc
 0d5ee989801d10b4c98ae2e1d1c7a00a88fd7647 3182003 tla_1.3.5+dfsg.orig.tar.gz
 c83c34bcd03e366845ab38bce547708bc53a0645 37401 tla_1.3.5+dfsg-18.debian.tar.gz
Checksums-Sha256:
 9565ea169ad96ab7b413f30e4124d767833662aa6e418483c434bc48d61e07ea 1218 
tla_1.3.5+dfsg-18.dsc
 64b6dc792074ff8bb2ddf3195901baca34ec5477e394cc5109813d06d9f812ee 3182003 
tla_1.3.5+dfsg.orig.tar.gz
 701f705125655ac12017428ed0b2973570908109699118df0d323e9b07ecf38e 37401 
tla_1.3.5+dfsg-18.debian.tar.gz
Package-List:
 tla deb vcs optional
 tla-doc deb doc optional
Directory: pool/main/t/tla
Priority: source
Section: vcs

Package: tla
Binary: tla, tla-doc
Version: 1.3.5+dfsg-18
Maintainer: Debian QA Group packa...@qa.debian.org
Build-Depends: debhelper (= 7), autotools-dev, time, libexpat1-dev
Architecture: any all
Standards-Version: 3.9.2
Format: 3.0 (quilt)
Files:
 5729ed285e021c152b8c8b66ad98407a 1218 tla_1.3.5+dfsg-18.dsc
 985debdf20daea547f3e4ef36a7c17cd 3182003 tla_1.3.5+dfsg.orig.tar.gz
 65462ae1eb1449728914d42a010f06ec 37401 tla_1.3.5+dfsg-18.debian.tar.gz
Checksums-Sha1:
 7006faee7b9fc26f11bc4a7ebff21c311300101b 1218 tla_1.3.5+dfsg-18.dsc
 0d5ee989801d10b4c98ae2e1d1c7a00a88fd7647 3182003 tla_1.3.5+dfsg.orig.tar.gz
 c83c34bcd03e366845ab38bce547708bc53a0645 37401 tla_1.3.5+dfsg-18.debian.tar.gz
Checksums-Sha256:
 9565ea169ad96ab7b413f30e4124d767833662aa6e418483c434bc48d61e07ea 1218 
tla_1.3.5+dfsg-18.dsc
 64b6dc792074ff8bb2ddf3195901baca34ec5477e394cc5109813d06d9f812ee 3182003 
tla_1.3.5+dfsg.orig.tar.gz