dpkg (1.18.25) stretch; urgency=medium
[dpkg] / scripts / Dpkg / Source / Package / V3 / Custom.pm
CommitLineData
1479465f
GJ
1# Copyright © 2008 Raphaël Hertzog <hertzog@debian.org>
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16package Dpkg::Source::Package::V3::Custom;
17
18use strict;
19use warnings;
20
21our $VERSION = '0.01';
22
23use Dpkg::Gettext;
24use Dpkg::ErrorHandling;
25
26use parent qw(Dpkg::Source::Package);
27
28our $CURRENT_MINOR_VERSION = '0';
29
30my @module_cmdline = (
31 {
32 name => '--target-format=<value>',
33 help => N_('define the format of the generated source package'),
34 when => 'build',
35 }
36);
37
38sub describe_cmdline_options {
39 return @module_cmdline;
40}
41
42sub parse_cmdline_option {
43 my ($self, $opt) = @_;
44 if ($opt =~ /^--target-format=(.*)$/) {
45 $self->{options}{target_format} = $1;
46 return 1;
47 }
48 return 0;
49}
50sub do_extract {
51 error(g_("Format '3.0 (custom)' is only used to create source packages"));
52}
53
54sub can_build {
55 my ($self, $dir) = @_;
56
57 return (0, g_('no files indicated on command line'))
58 unless scalar(@{$self->{options}{ARGV}});
59 return 1;
60}
61
62sub do_build {
63 my ($self, $dir) = @_;
64 # Update real target format
65 my $format = $self->{options}{target_format};
66 error(g_('--target-format option is missing')) unless $format;
67 $self->{fields}{'Format'} = $format;
68 # Add all files
69 foreach my $file (@{$self->{options}{ARGV}}) {
70 $self->add_file($file);
71 }
72}
73
741;