Debian Codegraph @

pybuild-autopkgtest

raw
1 #! /usr/bin/env perl
2 # vim: et ts=4 sw=4
3 # Copyright © 2021 Antonio Terceiro <[email protected]>
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 # THE SOFTWARE.
22
23 use strict;
24 use warnings;
25 use File::Basename;
26 use File::Temp qw( tempdir );
27 use Debian::Debhelper::Buildsystem::pybuild;
28 use Debian::Debhelper::Dh_Lib qw(doit);
29
30 sub main {
31 my $tmpdir = tempdir( CLEANUP => 1);
32 my $run = "${tmpdir}/run";
33 open(RUN, ">", $run) or die($!);
34 print(RUN "#!/usr/bin/make -f\n");
35 print(RUN "include debian/rules\n");
36 print(RUN "pybuild-autopkgtest:\n");
37 printf(RUN "\tpybuild-autopkgtest\n");
38 close(RUN);
39 chmod(0755, $run);
40 $ENV{PYBUILD_AUTOPKGTEST} = "1";
41 if (system("grep -q ^before-pybuild-autopkgtest: debian/rules") == 0) {
42 doit($run, "before-pybuild-autopkgtest");
43 }
44 doit($run, "pybuild-autopkgtest");
45 if (system("grep -q ^after-pybuild-autopkgtest: debian/rules") == 0) {
46 doit($run, "after-pybuild-autopkgtest");
47 }
48 }
49
50 sub child {
51 # The child inherits the environment defined in debian/rules
52 my $dh = Debian::Debhelper::Buildsystem::pybuild->new();
53 foreach my $command ($dh->pybuild_commands('autopkgtest')) {
54 doit(@$command);
55 }
56 }
57
58 if (scalar(@ARGV) > 0) {
59 my $prog = basename($0);
60 print STDERR "usage: ${prog}\n";
61 exit(1);
62 }
63
64 if (defined $ENV{PYBUILD_AUTOPKGTEST}) {
65 child;
66 } else {
67 main;
68 }