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

Re: Modifying /etc/apt/sources.list in postinst ; determining the suite in postinst

On Tue, 2007-04-03 at 21:14 +0100, Neil Williams wrote:
> 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

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 Hutchings
I'm not a reverse psychological virus.  Please don't copy me into your sig.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply to: