custom.pm 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. our $VERSION = "0.01";
  19. use base 'Dpkg::Source::Package';
  20. use Dpkg;
  21. use Dpkg::Gettext;
  22. use Dpkg::ErrorHandling;
  23. our $CURRENT_MINOR_VERSION = "0";
  24. sub parse_cmdline_option {
  25. my ($self, $opt) = @_;
  26. if ($opt =~ /^--target-format=(.*)$/) {
  27. $self->{'options'}{'target_format'} = $1;
  28. return 1;
  29. }
  30. return 0;
  31. }
  32. sub do_extract {
  33. error(_g("Format `3.0 (custom)' is only used to create source packages"));
  34. }
  35. sub can_build {
  36. my ($self, $dir) = @_;
  37. return (scalar(@{$self->{'options'}{'ARGV'}}),
  38. _g("no files indicated on command line"));
  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;