2 # dgit repos policy hook script for Debian
5 # dgit-repos-policy-debian DISTRO DGIT-REPOS-DIR ACTION...
7 # dgit-repos-policy-debian ... check-list
8 # dgit-repos-policy-debian ... check-package PACKAGE
9 # dgit-repos-policy-debian ... push PACKAGE \
10 # VERSION SUITE TAGNAME DELIBERATELIES [...]
12 # cwd for push is a temporary repo where the to-be-pushed objects have
13 # been received; TAGNAME is the version-based tag
15 # policy hook for a particular package will be invoked only once at
22 use Debian::Dgit qw(:DEFAULT :policyflags);
24 our $distro = shift @ARGV // die "need DISTRO";
25 our $repos = shift @ARGV // die "need DGIT-REPOS-DIR";
26 our $action = shift @ARGV // die "need ACTION";
27 our $pkg = shift @ARGV;
29 # We assume that it is not possible for NEW to have a version older
32 # Whenever pushing, we check for
33 # source-package-local tainted history
34 # global tainted history
35 # can be overridden by --deliberately except for an admin prohib taint
37 # ALL of the following apply only if history is secret:
39 # if NEW has no version, or a version which is not in our history[1]
42 # if any suite's version is in our history[1], publish our history
43 # otherwise discard our history,
44 # tainting --deliberately-include-questionable-history
46 # if NEW has a version which is in our history[1]
48 # require explicit specification of one of
49 # --deliberately-include-questionable-history
50 # --deliberately-not-fast-forward
51 # (latter will taint old NEW version --d-i-q-h)
55 # [1] looking for the relevant git tag for the version number and not
56 # caring what that tag refers to.
61 $!=0; $?=0; my $json = `dgit -d $distro archive-api-query $subpath`;
62 defined $json or die "$subpath $! $?";
63 return decode_json $json;
66 sub new_has_vsn_in_our_history () {
67 my $in_new = apiquery "/dsc_in_suite/new/$pkg";
68 foreach my $entry (@$in_new) {
69 my $vsn = $entry->{version};
70 die "$pkg ?" unless defined $vsn;
71 my $tag = debiantag $vsn;
72 $?=0; my $r = system qw(git show-ref --verify --quiet), $tag;
75 die "$pkg tag $tag $? $!";
80 sub selectpackage () {
82 die if $pkg =~ m#[^-+.0-9a-z]#;
84 if (!chdir "$repos/$pkg") {
85 die "$pkg $!" unless $!==ENOENT;
89 if (~(stat _)[2] & 05) {
103 my $fn = ${*::}{"action_$cmd"};
104 $fn or die "unknown ACTION";