summaryrefslogtreecommitdiffstats
path: root/scripts/dpkg-buildtree.pl
blob: f2505981339655d939597e65802cc6da6292a2e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/perl
#
# dpkg-buildtree
#
# Copyright © 2023 Guillem Jover <guillem@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

use strict;
use warnings;

use Dpkg ();
use Dpkg::Gettext;
use Dpkg::ErrorHandling;
use Dpkg::BuildTree;

textdomain('dpkg-dev');

sub version {
    printf g_("Debian %s version %s.\n"), $Dpkg::PROGNAME, $Dpkg::PROGVERSION;

    printf g_('
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
');
}

sub usage {
    printf g_(
'Usage: %s [<command>]')
    . "\n\n" . g_(
'Commands:
  clean              clean dpkg generated artifacts from the build tree.
  --help             show this help message.
  --version          show the version.
'), $Dpkg::PROGNAME;
}

my $action;

while (@ARGV) {
    my $arg = shift @ARGV;
    if ($arg eq 'clean') {
        usageerr(g_('two commands specified: %s and %s'), $1, $action)
            if defined $action;
        $action = $arg;
    } elsif ($arg eq '-?' or $arg eq '--help') {
        usage();
        exit 0;
    } elsif ($arg eq '--version') {
        version();
        exit 0;
    } else {
        usageerr(g_("unknown option '%s'"), $arg);
    }
}

usageerr(g_('missing action')) unless $action;

my $bt = Dpkg::BuildTree->new();

if ($action eq 'clean') {
    $bt->clean();
}