custom.pm 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright 2008 Raphaël Hertzog <hertzog@debian.org>
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 2 of the License, or
  5. # (at your option) any later version.
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. # GNU General Public License for more details.
  10. # You should have received a copy of the GNU General Public License along
  11. # with this program; if not, write to the Free Software Foundation, Inc.,
  12. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  13. package Dpkg::Source::Package::V3_0::custom;
  14. use strict;
  15. use warnings;
  16. use base 'Dpkg::Source::Package';
  17. use Dpkg;
  18. use Dpkg::Gettext;
  19. use Dpkg::ErrorHandling qw(error);
  20. sub parse_cmdline_option {
  21. my ($self, $opt) = @_;
  22. if ($opt =~ /^--target-format=(.*)$/) {
  23. $self->{'options'}{'target_format'} = $1;
  24. return 1;
  25. }
  26. return 0;
  27. }
  28. sub do_extract {
  29. error(_g("Format `3.0 (custom)' is only used to create source packages"));
  30. }
  31. sub can_build {
  32. my ($self, $dir) = @_;
  33. return (scalar(@{$self->{'options'}{'ARGV'}}),
  34. _g("no files indicated on command line"));
  35. }
  36. sub do_build {
  37. my ($self, $dir) = @_;
  38. # Update real target format
  39. my $format = $self->{'options'}{'target_format'};
  40. error(_g("--target-format option is missing")) unless $format;
  41. $self->{'fields'}{'Format'} = $format;
  42. # Add all files
  43. foreach my $file (@{$self->{'options'}{'ARGV'}}) {
  44. $self->add_file($file);
  45. }
  46. }
  47. # vim:et:sw=4:ts=8
  48. 1;