summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdgit52
1 files changed, 41 insertions, 11 deletions
diff --git a/dgit b/dgit
index 59f7a73..3c31140 100755
--- a/dgit
+++ b/dgit
@@ -574,7 +574,7 @@ sub access_basedistro () {
}
sub access_quirk () {
- # returns (quirk name, distro to use instead, quirk-specific info)
+ # returns (quirk name, distro to use instead or undef, quirk-specific info)
my $basedistro = access_basedistro();
my $backports_quirk = cfg("dgit-distro.$basedistro.backports-quirk",
'RETURN-UNDEF');
@@ -588,22 +588,52 @@ sub access_quirk () {
return ('backports',"$basedistro-backports",$1);
}
}
- return ('none',$basedistro);
+ return ('none',undef);
}
-sub access_distro () {
- return (access_quirk())[1];
+sub access_distros () {
+ # Returns list of distros to try, in order
+ #
+ # We want to try:
+ # 1. the access_quirk distro, if any
+ # 2a. the user's specified distro, or failing that } basedistro
+ # 2b. the distro calculated from the suite }
+ my @l = access_basedistro();
+
+ my (undef,$quirkdistro) = access_quirk();
+ unshift @l, $quirkdistro if defined $quirkdistro;
+
+ return @l;
}
sub access_cfg (@) {
my (@keys) = @_;
- my $basedistro = access_basedistro();
- my $distro = $idistro || access_distro();
- my $value = cfg(map {
- ("dgit-distro.$distro.$_",
- "dgit-distro.$basedistro.$_",
- "dgit.default.$_")
- } @keys);
+ my @cfgs;
+ # The nesting of these loops determines the search order. We put
+ # the key loop on the outside so that we search all the distros
+ # for each key, before going on to the next key. That means that
+ # if access_cfg is called with a more specific, and then a less
+ # specific, key, an earlier distro can override the less specific
+ # without necessarily overriding any more specific keys. (If the
+ # distro wants to override the more specific keys it can simply do
+ # so; whereas if we did the loop the other way around, it would be
+ # impossible to for an earlier distro to override a less specific
+ # key but not the more specific ones without restating the unknown
+ # values of the more specific keys.
+ my @realkeys;
+ my @rundef;
+ # We have to deal with RETURN-UNDEF specially, so that we don't
+ # terminate the search prematurely.
+ foreach (@keys) {
+ if (m/RETURN-UNDEF/) { push @rundef, $_; last; }
+ push @realkeys, $_
+ }
+ foreach my $d (access_distros()) {
+ push @cfgs, map { "dgit-distro.$d.$_" } @realkeys;
+ }
+ push @cfgs, map { "dgit.default.$_" } @realkeys;
+ push @cfgs, @rundef;
+ my $value = cfg(@cfgs);
return $value;
}