[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [APT] A way to produce a by-repository listing of packages



Sebastian Kapfer wrote:
On Fri, 04 Mar 2005 00:30:15 +0100, Tong wrote:


On Thu, 03 Mar 2005 23:11:51 +0100, Sebastian Kapfer wrote:


I'm looking for a way to determine which packages from non-debian APT
repositories I've installed.  How could I produce a list (sorted by repo)
of these packages?  I know I can call apt-cache policy for a single
package, but I'm looking for a more automated approach :-)

I want to know that too. Moreover, I also have packages that are
home-made (compiled myself using checkinstall), or manually downloaded
(not from any repository). Hope this can be covered too.


You can see those in Aptitude (in the main window, section "Obsolete and
locally created".  Still doesn't solve the main question, and both are
connected.


You can easily hack apt-show-versions to do this, example patch[for apt-show-versions] attached[just do 'apt-show-versions | grep -v Debian' to get all non-(official)-Debian packages].

Travis
# licensed under same license as apt-show-versions[GPL v2 or greater]
# Travis Crump 2005

--- /usr/bin/apt-show-versions	2006-02-24 10:06:24.000000000 -0500
+++ apt-show-versions	2005-03-04 12:31:51.000000000 -0500
@@ -34,9 +34,14 @@
 use Getopt::Long;
 use Storable qw(store retrieve);
 
-my $apackagescachefile="/var/cache/apt-show-versions/apackages";
-my $ipackagescachefile="/var/cache/apt-show-versions/ipackages";
-my $filescachefile="/var/cache/apt-show-versions/files";
+my $cachedir = "/var/cache/apt-show-versions";
+unless ( -w "$cachedir") {
+	$cachedir="$ENV{HOME}/.apt-show-versions";
+	mkdir $cachedir unless -e $cachedir;
+}
+my $apackagescachefile="${cachedir}/apackages";
+my $ipackagescachefile="${cachedir}/ipackages";
+my $filescachefile="${cachedir}/files";
 
 use AptPkg::Config '$_config';
 use AptPkg::System '$_system';
@@ -127,7 +132,7 @@
 if (!-e $filescachefile or -M $list_dir < -M $filescachefile or !ref($filesref)) {
     opendir(DIR, $list_dir) or die "Can't opendir $list_dir: $!";
     @files = map { $list_dir . $_} grep /Packages$/, readdir(DIR);
-    ($< == 0) and (store(\@files, $filescachefile) or
+    (store(\@files, $filescachefile) or
 		   warn "Can't write $filescachefile");
 }
 unless (scalar @files > 0) {die "Error: No information about packages! (Maybe no deb entries?)\n"};
@@ -142,7 +147,7 @@
 }
 if (!-e $ipackagescachefile or -M $status_file < -M $ipackagescachefile or !ref($ipackages)) {
     $ipackages = parse_file ($status_file, 1);
-    ($< == 0) and (store($ipackages, $ipackagescachefile) or
+    (store($ipackages, $ipackagescachefile) or
 		   warn "Can't write $ipackagescachefile");
 }
 
@@ -161,16 +166,19 @@
 # Get available package information out of all Packages files
 foreach (@files) {
     my $release = $_;
+    $release =~ s/[-a-z]*_binary-i386_Packages/Release/;
     $release =~ s/Packages/Release/;
     $release = quotemeta $release;
     my $archiv;
-    $archiv = `fgrep -s Archive $release` or
+    $archiv = `fgrep -s Origin $release` or
+	$archiv = `fgrep -s Archive $release` or
 	$archiv = `fgrep -s Suite $release` or
 	($release =~ /(potato|woody|sarge|sid|stable|testing|unstable)/ and $archiv = $1) or
 	$archiv = "unknown";
 #	next;
     $archiv =~ s/Archive: //;
     $archiv =~ s/Suite: //;
+    $archiv =~ s/Origin: //;
     $archiv =~ s/\n//;
     $releases{$archiv} = 1;
 
@@ -210,10 +218,10 @@
     }
 }
 # Store if we are root
-($< == 0) and (store($apackages, $apackagescachefile) or
+(store($apackages, $apackagescachefile) or
 	       die "Warning: Can't write to $apackagescachefile!\n");
 # Exit if we are root and using the -i option
-($< == 0) and (exists $opts{'initialize'}) and exit;
+(exists $opts{'initialize'}) and exit;
 
 # print info for selected package
 if (exists $opts{'package'} &&

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: