custom.pm 1.7 KB

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