[prev in list] [next in list] [prev in thread] [next in thread] 

List:       debian-devel
Subject:    Re: Modifying /etc/apt/sources.list in postinst ; determining the
From:       Ben Hutchings <ben () decadent ! org ! uk>
Date:       2007-04-03 21:17:05
Message-ID: 1175635025.11297.7.camel () deadeye ! i ! decadent ! org ! uk
[Download RAW message or body]

On Tue, 2007-04-03 at 21:14 +0100, Neil Williams wrote:
<snip>
> What about determining the suite?

You should probably use debconf to ask, though.  I wouldn't be surprised
to find that some Emdebian users want a stable host and an unstable
target.

If you still want to find the default suite, you should be able to do it
by parsing apt-cache policy output, though I'm not sure how stable that
format is.  Here's some Perl code that worked for me:

my ($cur_pri, $max_pri, $max_pri_suite);

open POLICY, "apt-cache policy |" or die "open: $!";
for (<POLICY>) {
    if (/^\s*(\d+)/) {
	$cur_pri = $1;
    } elsif (defined($cur_pri)
	     && (!defined($max_pri) || $cur_pri > $max_pri)
	     && /^\s+release o=Debian,a=(\w+),l=Debian,c=main\s*$/) {
	$max_pri = $cur_pri;
	$max_pri_suite = $1;
    }
}
close POLICY;

if (defined($max_pri_suite)) {
    print "Default suite is $max_pri_suite\n";
} else {
    print "No sources for Debian main\n";
}
### END ###

Ben.

-- 
Ben Hutchings
I'm not a reverse psychological virus.  Please don't copy me into your sig.

["signature.asc" (application/pgp-signature)]
-- 
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic