chiark / gitweb /
dgit: Enforce a syntax for nominal distros
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Jan 2017 18:45:59 +0000 (18:45 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Jan 2017 22:14:48 +0000 (22:14 +0000)
These appear in various interchange output like tags.  They should be
sane.  They're going to appear in Dgit: too where people will need to
use them.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm
dgit

index 314bd8c712c6159fe031bfe8073a62f902666f84..5a7b59d750e65893212d40c32f5a3a783604c7ad 100644 (file)
@@ -50,6 +50,7 @@ BEGIN {
                      git_get_ref git_for_each_ref
                       git_for_each_tag_referring is_fast_fwd
                       $package_re $component_re $deliberately_re
                      git_get_ref git_for_each_ref
                       git_for_each_tag_referring is_fast_fwd
                       $package_re $component_re $deliberately_re
+                     $distro_re
                       $branchprefix
                       initdebug enabledebug enabledebuglevel
                       printdebug debugcmd
                       $branchprefix
                       initdebug enabledebug enabledebuglevel
                       printdebug debugcmd
@@ -65,6 +66,7 @@ our @EXPORT_OK;
 our $package_re = '[0-9a-z][-+.0-9a-z]*';
 our $component_re = '[0-9a-zA-Z][-+.0-9a-zA-Z]*';
 our $deliberately_re = "(?:TEST-)?$package_re";
 our $package_re = '[0-9a-z][-+.0-9a-z]*';
 our $component_re = '[0-9a-zA-Z][-+.0-9a-zA-Z]*';
 our $deliberately_re = "(?:TEST-)?$package_re";
+our $distro_re = $component_re;
 our $branchprefix = 'dgit';
 
 # policy hook exit status bits
 our $branchprefix = 'dgit';
 
 # policy hook exit status bits
diff --git a/dgit b/dgit
index 54b0e6fc7719237d1d357459edfb6e2a3d360c62..de7b4de625ec4520ff13d552cee200172d76c3b3 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -727,7 +727,10 @@ sub access_basedistro () {
 
 sub access_nomdistro () {
     my $base = access_basedistro();
 
 sub access_nomdistro () {
     my $base = access_basedistro();
-    return cfg("dgit-distro.$base.nominal-distro",'RETURN-UNDEF') // $base;
+    my $r = cfg("dgit-distro.$base.nominal-distro",'RETURN-UNDEF') // $base;
+    $r =~ m/^$distro_re$/ or badcfg
+ "bad syntax for (nominal) distro \`$r' (does not match /^$distro_re$/)";
+    return $r;
 }
 
 sub access_quirk () {
 }
 
 sub access_quirk () {