custom.pm 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 <http://www.gnu.org/licenses/>.
  15. package Dpkg::Source::Package::V3::custom;
  16. use strict;
  17. use warnings;
  18. use base 'Dpkg::Source::Package';
  19. use Dpkg;
  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 (scalar(@{$self->{'options'}{'ARGV'}}),
  37. _g("no files indicated on command line"));
  38. }
  39. sub do_build {
  40. my ($self, $dir) = @_;
  41. # Update real target format
  42. my $format = $self->{'options'}{'target_format'};
  43. error(_g("--target-format option is missing")) unless $format;
  44. $self->{'fields'}{'Format'} = $format;
  45. # Add all files
  46. foreach my $file (@{$self->{'options'}{'ARGV'}}) {
  47. $self->add_file($file);
  48. }
  49. }
  50. # vim:et:sw=4:ts=8
  51. 1;