use File::Path;
use File::Spec;
+sub init_options {
+ my ($self) = @_;
+ $self->{'options'}{'include_removal'} = 0
+ unless exists $self->{'options'}{'include_removal'};
+ $self->{'options'}{'include_timestamp'} = 0
+ unless exists $self->{'options'}{'include_timestamp'};
+}
+
+sub parse_cmdline_option {
+ my ($self, $opt) = @_;
+ if ($opt =~ /^--include-removal$/) {
+ $self->{'options'}{'include_removal'} = 1;
+ return 1;
+ } elsif ($opt =~ /^--include-timestamp$/) {
+ $self->{'options'}{'include_timestamp'} = 1;
+ return 1;
+ }
+ return 0;
+}
+
sub do_extract {
my ($self, $newdirectory) = @_;
my $fields = $self->{'fields'};
sub prepare_build {
my ($self, $dir) = @_;
$self->{'diff_options'} = {
- diff_ignore_regexp => $self->{'options'}{'diff_ignore_regexp'}
+ diff_ignore_regexp => $self->{'options'}{'diff_ignore_regexp'},
+ include_removal => $self->{'options'}{'include_removal'},
+ include_timestamp => $self->{'options'}{'include_timestamp'},
};
}
use Dpkg::Source::Patch;
use Dpkg::IPC;
+use POSIX;
use File::Basename;
use File::Spec;
+sub init_options {
+ my ($self) = @_;
+ $self->SUPER::init_options();
+ $self->{'options'}{'without_quilt'} = 0
+ unless exists $self->{'options'}{'without_quilt'};
+}
+
+sub parse_cmdline_option {
+ my ($self, $opt) = @_;
+ return 1 if $self->SUPER::parse_cmdline_option($opt);
+ if ($opt =~ /^--without-quilt$/) {
+ $self->{'options'}{'without_quilt'} = 1;
+ return 1;
+ }
+ return 0;
+}
+
sub get_autopatch_name {
my ($self) = @_;
return "debian-changes-" . $self->{'fields'}{'Version'} . ".diff";
foreach my $patch ($self->get_patches($dir, $skip_auto)) {
my $path = File::Spec->catfile($dir, "debian", "patches", $patch);
my $patch_obj = Dpkg::Source::Patch->new(filename => $path);
- if ($have_quilt) {
+ if ($have_quilt and not $self->{'options'}{'without_quilt'}) {
info(_g("applying %s with quilt"), $patch) unless $skip_auto;
my $analysis = $patch_obj->analyze($dir);
foreach my $dir (keys %{$analysis->{'dirtocreate'}}) {
);
fork_and_exec(%opts);
foreach my $fn (keys %{$analysis->{'filepatched'}}) {
- utime($now, $now, $fn) ||
+ utime($now, $now, $fn) || $! == ENOENT ||
syserr(_g("cannot change timestamp for %s"), $fn);
}
} else {
sub prepare_build {
my ($self, $dir) = @_;
+ $self->SUPER::prepare_build($dir);
# Skip .pc directories of quilt by default and ignore difference
# on debian/patches/series symlinks
my $func = sub {
return 1 if $_[0] =~ /$self->{'options'}{'diff_ignore_regexp'}/;
return 0;
};
- $self->{'diff_options'} = {
- diff_ignore_func => $func
- };
+ $self->{'diff_options'}{'diff_ignore_func'} = $func;
}
sub register_autopatch {
# Ignore files
tar_ignore => [],
diff_ignore_regexp => '',
- # Sourcestyle
- sourcestyle => 'X',
);
# Fields to remove/override
my $opmode;
my $tar_ignore_default_pattern_done;
+my @cmdline_options;
while (@ARGV && $ARGV[0] =~ m/^-/) {
$_ = shift(@ARGV);
if (m/^-b$/) {
usageerr(_g("%s is not a compression level"), $comp_level)
unless $comp_level =~ /^([1-9]|fast|best)$/;
Dpkg::Source::Compressor->set_default_compression_level($comp_level);
- } elsif (m/^-s([akpursnAKPUR])$/) {
- warning(_g("-s%s option overrides earlier -s%s option"), $1,
- $options{'sourcestyle'}) if $options{'sourcestyle'} ne 'X';
- $options{'sourcestyle'} = $1;
} elsif (m/^-c/) {
$controlfile = $POSTMATCH;
} elsif (m/^-l/) {
}
} elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:]/) {
$substvars->set($1, $POSTMATCH);
+ warning(_g("substvars support is deprecated (see README.feature-removal-schedule)"));
} elsif (m/^-T/) {
- $varlistfile = $POSTMATCH;
- warning(_g("substvars support is deprecated (see README.feature-removal-schedule)"));
+ $varlistfile = $POSTMATCH;
+ warning(_g("substvars support is deprecated (see README.feature-removal-schedule)"));
} elsif (m/^-(h|-help)$/) {
usage();
exit(0);
} elsif (m/^--$/) {
last;
} else {
- usageerr(_g("unknown option \`%s'"), $_);
+ push @cmdline_options, $_;
}
}
}
info(_g("using source format `%s'"), $fields->{'Format'});
+ # Parse command line options
+ $srcpkg->init_options();
+ $srcpkg->parse_cmdline_options(@cmdline_options);
+
# Build the files (.tar.gz, .diff.gz, etc)
$srcpkg->build($dir);
my $srcpkg = Dpkg::Source::Package->new(filename => $dsc,
options => \%options);
+ # Parse command line options
+ $srcpkg->parse_cmdline_options(@cmdline_options);
+
# Decide where to unpack
my $newdirectory = $srcpkg->get_basename();
$newdirectory =~ s/_/-/g;
Commands:
-x <filename>.dsc [<output-dir>]
extract source package.
- -b <dir> [<orig-dir>|<orig-targz>|\'\']
+ -b <dir>
build source package.
Build options:
(defaults to: '%s').
-I[<pattern>] filter out files when building tarballs
(defaults to: %s).
- -sa auto select orig source (-sA is default).
- -sk use packed orig source (unpack & keep).
- -sp use packed orig source (unpack & remove).
- -su use unpacked orig source (pack & keep).
- -sr use unpacked orig source (pack & remove).
- -ss trust packed & unpacked orig src are same.
- -sn there is no diff, do main tarfile only.
- -sA,-sK,-sP,-sU,-sR like -sa,-sk,-sp,-su,-sr but may overwrite.
-Z<compression> select compression to use (defaults to 'gzip',
supported are: %s).
-z<level> compression level to use (defaults to '9',
supported are: '1'-'9', 'best', 'fast')
-Extract options:
- -sp (default) leave orig source packed in current dir.
- -sn do not copy original source to current dir.
- -su unpack original source tree too.
-
General options:
-h, --help show this help message.
--version show the version.
+
+More options are available but they depend on the source package format.
+See dpkg-source(1) for more info.
"), $progname,
$diff_ignore_default_regexp,
join('', map { " -I$_" } @tar_ignore_default_pattern),