Custom.pm 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. package Dpkg::Source::Package::V3::Custom;
  16. use strict;
  17. use warnings;
  18. our $VERSION = '0.01';
  19. use parent qw(Dpkg::Source::Package);
  20. use Dpkg::Gettext;
  21. use Dpkg::ErrorHandling;
  22. our $CURRENT_MINOR_VERSION = '0';
  23. sub parse_cmdline_option {
  24. my ($self, $opt) = @_;
  25. if ($opt =~ /^--target-format=(.*)$/) {
  26. $self->{options}{target_format} = $1;
  27. return 1;
  28. }
  29. return 0;
  30. }
  31. sub do_extract {
  32. error(g_("Format `3.0 (custom)' is only used to create source packages"));
  33. }
  34. sub can_build {
  35. my ($self, $dir) = @_;
  36. return (0, g_('no files indicated on command line'))
  37. unless scalar(@{$self->{options}{ARGV}});
  38. return 1;
  39. }
  40. sub do_build {
  41. my ($self, $dir) = @_;
  42. # Update real target format
  43. my $format = $self->{options}{target_format};
  44. error(g_('--target-format option is missing')) unless $format;
  45. $self->{fields}{'Format'} = $format;
  46. # Add all files
  47. foreach my $file (@{$self->{options}{ARGV}}) {
  48. $self->add_file($file);
  49. }
  50. }
  51. 1;