From c00456f208d26767246b28e6f06f4462a76d9ac2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 21 Mar 2015 10:53:10 +0000 Subject: [PATCH] Export policy hook exist status flags from Dgit.pm --- Debian/Dgit.pm | 14 +++++++++++++- infra/dgit-repos-policy-debian | 8 +------- infra/dgit-repos-server | 10 +++++----- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index 3fe03093..a124930b 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -13,7 +13,7 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw(debiantag $package_re); - %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + %EXPORT_TAGS = ( policyflags => qw() ); @EXPORT_OK = qw(); } @@ -21,6 +21,18 @@ our @EXPORT_OK; our $package_re = '[0-9a-z][-+.0-9a-z]*'; + +# policy hook exit status bits +# any unexpected bits mean failure, and then known set bits are ignored + +sub NOFFCHECK () { return 2; } +# suppress dgit-repos-server's ff check ("push" only) + +sub FRESHREPO () { return 4; } +# blow away repo right away (ie, as if before push or fetch) +# ("check-package" only) + + sub debiantag ($) { my ($v) = @_; $v =~ y/~:/_%/; diff --git a/infra/dgit-repos-policy-debian b/infra/dgit-repos-policy-debian index db153103..46f10395 100755 --- a/infra/dgit-repos-policy-debian +++ b/infra/dgit-repos-policy-debian @@ -9,12 +9,6 @@ # dgit-repos-policy-debian ... push PACKAGE \ # VERSION SUITE TAGNAME DELIBERATELIES [...] # -# exit status is bitmap; bit weights (values) as follows -# 1 failure; operation must be rejected; other bits will be ignored -# 2 suppress dgit-repos-server's ff check ("push" only) -# 4 blow away repo away right away (ie before push or fetch) -# ("check-package" only) -# # cwd for push is a temporary repo where the to-be-pushed objects have # been received; TAGNAME is the version-based tag # @@ -25,7 +19,7 @@ use strict; use POSIX; use JSON; -use Debian::Dgit; +use Debian::Dgit qw(:DEFAULT :policyflags); our $distro = shift @ARGV // die "need DISTRO"; our $repos = shift @ARGV // die "need DGIT-REPOS-DIR"; diff --git a/infra/dgit-repos-server b/infra/dgit-repos-server index 6d7fb631..3f41a0bb 100755 --- a/infra/dgit-repos-server +++ b/infra/dgit-repos-server @@ -87,7 +87,7 @@ use POSIX; use Fcntl qw(:flock); use File::Path qw(rmtree); -use Debian::Dgit; +use Debian::Dgit qw(:DEFAULT :policyflags); open DEBUG, ">/dev/null" or die $!; @@ -504,7 +504,7 @@ sub checks () { debug "translated version $v"; $tagname eq "debian/$v" or die; - my ($policy) = policyhook(2,'push',$package, + my ($policy) = policyhook(NOFFCHECK, 'push',$package, $version,$suite,$tagname, join(",",@delberatelies)); @@ -512,7 +512,7 @@ sub checks () { # check that our ref is being fast-forwarded debug "oldcommit $oldcommit"; - if (!($policy & 2) && $oldcommit =~ m/[^0]/) { + if (!($policy & NOFFCHECK) && $oldcommit =~ m/[^0]/) { $?=0; $!=0; my $mb = `git merge-base $commit $oldcommit`; chomp $mb; $mb eq $oldcommit or reject "not fast forward on dgit branch"; @@ -631,8 +631,8 @@ sub parseargsdispatch () { reject "unknown method" unless $mainfunc; - my ($policy, $pollock) = policyhook(4, 'check-package',$package); - if ($policy & 4) { + my ($policy, $pollock) = policyhook(FRESHREPO,'check-package',$package); + if ($policy & FRESHREPO) { my $garbagerepo = "$dgitrepos/_tmp/${package}_garbage"; acquiretree($garbagerepo,1); rmtree $garbagerepo; -- 2.30.2