diff options
Diffstat (limited to 'scripts/Dpkg/Source')
-rw-r--r-- | scripts/Dpkg/Source/Archive.pm | 72 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package.pm | 104 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package/V1.pm | 56 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package/V2.pm | 160 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package/V3/bzr.pm | 20 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package/V3/custom.pm | 10 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package/V3/git.pm | 20 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package/V3/native.pm | 18 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package/V3/quilt.pm | 56 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Patch.pm | 158 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Quilt.pm | 58 |
11 files changed, 366 insertions, 366 deletions
diff --git a/scripts/Dpkg/Source/Archive.pm b/scripts/Dpkg/Source/Archive.pm index 5ce625a14..7146d8a97 100644 --- a/scripts/Dpkg/Source/Archive.pm +++ b/scripts/Dpkg/Source/Archive.pm @@ -34,40 +34,40 @@ use base 'Dpkg::Compression::FileHandle'; sub create { my ($self, %opts) = @_; - $opts{"options"} ||= []; + $opts{options} ||= []; my %spawn_opts; # Possibly run tar from another directory - if ($opts{"chdir"}) { - $spawn_opts{"chdir"} = $opts{"chdir"}; - *$self->{"chdir"} = $opts{"chdir"}; + if ($opts{chdir}) { + $spawn_opts{chdir} = $opts{chdir}; + *$self->{chdir} = $opts{chdir}; } # Redirect input/output appropriately $self->ensure_open("w"); - $spawn_opts{"to_handle"} = $self->get_filehandle(); - $spawn_opts{"from_pipe"} = \*$self->{'tar_input'}; + $spawn_opts{to_handle} = $self->get_filehandle(); + $spawn_opts{from_pipe} = \*$self->{tar_input}; # Call tar creation process - $spawn_opts{"delete_env"} = [ "TAR_OPTIONS" ]; - $spawn_opts{'exec'} = [ 'tar', '--null', '-T', '-', '--numeric-owner', + $spawn_opts{delete_env} = [ "TAR_OPTIONS" ]; + $spawn_opts{exec} = [ 'tar', '--null', '-T', '-', '--numeric-owner', '--owner', '0', '--group', '0', - @{$opts{"options"}}, '-cf', '-' ]; - *$self->{"pid"} = spawn(%spawn_opts); - *$self->{"cwd"} = getcwd(); + @{$opts{options}}, '-cf', '-' ]; + *$self->{pid} = spawn(%spawn_opts); + *$self->{cwd} = getcwd(); } sub _add_entry { my ($self, $file) = @_; - my $cwd = *$self->{'cwd'}; - internerr("call create() first") unless *$self->{"tar_input"}; + my $cwd = *$self->{cwd}; + internerr("call create() first") unless *$self->{tar_input}; $file = $2 if ($file =~ /^\Q$cwd\E\/(.+)$/); # Relative names - print({ *$self->{'tar_input'} } "$file\0") || + print({ *$self->{tar_input} } "$file\0") || syserr(_g("write on tar input")); } sub add_file { my ($self, $file) = @_; my $testfile = $file; - if (*$self->{"chdir"}) { - $testfile = File::Spec->catfile(*$self->{"chdir"}, $file); + if (*$self->{chdir}) { + $testfile = File::Spec->catfile(*$self->{chdir}, $file); } internerr("add_file() doesn't handle directories") if not -l $testfile and -d _; $self->_add_entry($file); @@ -76,8 +76,8 @@ sub add_file { sub add_directory { my ($self, $file) = @_; my $testfile = $file; - if (*$self->{"chdir"}) { - $testfile = File::Spec->catdir(*$self->{"chdir"}, $file); + if (*$self->{chdir}) { + $testfile = File::Spec->catdir(*$self->{chdir}, $file); } internerr("add_directory() only handles directories") unless not -l $testfile and -d _; $self->_add_entry($file); @@ -85,26 +85,26 @@ sub add_directory { sub finish { my ($self) = @_; - close(*$self->{'tar_input'}) or syserr(_g("close on tar input")); - wait_child(*$self->{'pid'}, cmdline => 'tar -cf -'); - delete *$self->{'pid'}; - delete *$self->{'tar_input'}; - delete *$self->{'cwd'}; - delete *$self->{'chdir'}; + close(*$self->{tar_input}) or syserr(_g("close on tar input")); + wait_child(*$self->{pid}, cmdline => 'tar -cf -'); + delete *$self->{pid}; + delete *$self->{tar_input}; + delete *$self->{cwd}; + delete *$self->{chdir}; $self->close(); } sub extract { my ($self, $dest, %opts) = @_; - $opts{"options"} ||= []; - $opts{"in_place"} ||= 0; - $opts{"no_fixperms"} ||= 0; + $opts{options} ||= []; + $opts{in_place} ||= 0; + $opts{no_fixperms} ||= 0; my %spawn_opts = (wait_child => 1); # Prepare destination my $tmp; - if ($opts{"in_place"}) { - $spawn_opts{"chdir"} = $dest; + if ($opts{in_place}) { + $spawn_opts{chdir} = $dest; $tmp = $dest; # So that fixperms call works } else { my $template = basename($self->get_filename()) . ".tmp-extract.XXXXX"; @@ -113,17 +113,17 @@ sub extract { mkdir($dest) || syserr(_g("cannot create directory %s"), $dest); } $tmp = tempdir($template, DIR => Cwd::realpath("$dest/.."), CLEANUP => 1); - $spawn_opts{"chdir"} = $tmp; + $spawn_opts{chdir} = $tmp; } # Prepare stuff that handles the input of tar $self->ensure_open("r"); - $spawn_opts{"from_handle"} = $self->get_filehandle(); + $spawn_opts{from_handle} = $self->get_filehandle(); # Call tar extraction process - $spawn_opts{"delete_env"} = [ "TAR_OPTIONS" ]; - $spawn_opts{'exec'} = [ 'tar', '--no-same-owner', '--no-same-permissions', - @{$opts{"options"}}, '-xf', '-' ]; + $spawn_opts{delete_env} = [ "TAR_OPTIONS" ]; + $spawn_opts{exec} = [ 'tar', '--no-same-owner', '--no-same-permissions', + @{$opts{options}}, '-xf', '-' ]; spawn(%spawn_opts); $self->close(); @@ -135,10 +135,10 @@ sub extract { # extracted); we need --no-same-owner because putting the owner # back is tedious - in particular, correct group ownership would # have to be calculated using mount options and other madness. - fixperms($tmp) unless $opts{"no_fixperms"}; + fixperms($tmp) unless $opts{no_fixperms}; # Stop here if we extracted in-place as there's nothing to move around - return if $opts{"in_place"}; + return if $opts{in_place}; # Rename extracted directory opendir(my $dir_dh, $tmp) || syserr(_g("cannot opendir %s"), $tmp); diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 10b29c78d..63f28cfa8 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -153,11 +153,11 @@ sub new { checksums => Dpkg::Checksums->new(), }; bless $self, $class; - if (exists $args{'options'}) { - $self->{'options'} = $args{'options'}; + if (exists $args{options}) { + $self->{options} = $args{options}; } - if (exists $args{"filename"}) { - $self->initialize($args{"filename"}); + if (exists $args{filename}) { + $self->initialize($args{filename}); $self->init_options(); } return $self; @@ -167,41 +167,41 @@ sub init_options { my ($self) = @_; # Use full ignore list by default # note: this function is not called by V1 packages - $self->{'options'}{'diff_ignore_regexp'} ||= $diff_ignore_default_regexp; - $self->{'options'}{'diff_ignore_regexp'} .= '|(?:^|/)debian/source/local-.*$'; - if (defined $self->{'options'}{'tar_ignore'}) { - $self->{'options'}{'tar_ignore'} = [ @tar_ignore_default_pattern ] - unless @{$self->{'options'}{'tar_ignore'}}; + $self->{options}{diff_ignore_regexp} ||= $diff_ignore_default_regexp; + $self->{options}{diff_ignore_regexp} .= '|(?:^|/)debian/source/local-.*$'; + if (defined $self->{options}{tar_ignore}) { + $self->{options}{tar_ignore} = [ @tar_ignore_default_pattern ] + unless @{$self->{options}{tar_ignore}}; } else { - $self->{'options'}{'tar_ignore'} = [ @tar_ignore_default_pattern ]; + $self->{options}{tar_ignore} = [ @tar_ignore_default_pattern ]; } - push @{$self->{'options'}{'tar_ignore'}}, "debian/source/local-options", + push @{$self->{options}{tar_ignore}}, "debian/source/local-options", "debian/source/local-patch-header"; # Skip debianization while specific to some formats has an impact # on code common to all formats - $self->{'options'}{'skip_debianization'} ||= 0; + $self->{options}{skip_debianization} ||= 0; } sub initialize { my ($self, $filename) = @_; my ($fn, $dir) = fileparse($filename); error(_g("%s is not the name of a file"), $filename) unless $fn; - $self->{'basedir'} = $dir || "./"; - $self->{'filename'} = $fn; + $self->{basedir} = $dir || "./"; + $self->{filename} = $fn; # Check if it contains a signature open(my $dsc_fh, "<", $filename) || syserr(_g("cannot open %s"), $filename); - $self->{'is_signed'} = 0; + $self->{is_signed} = 0; while (<$dsc_fh>) { next if /^\s*$/o; - $self->{'is_signed'} = 1 if /^-----BEGIN PGP SIGNED MESSAGE-----\s*$/o; + $self->{is_signed} = 1 if /^-----BEGIN PGP SIGNED MESSAGE-----\s*$/o; last; } close($dsc_fh); # Read the fields my $fields = Dpkg::Control->new(type => CTRL_PKG_SRC); $fields->load($filename); - $self->{'fields'} = $fields; + $self->{fields} = $fields; foreach my $f (qw(Source Version Files)) { unless (defined($fields->{$f})) { @@ -209,7 +209,7 @@ sub initialize { } } - $self->{'checksums'}->add_from_control($fields, use_files_for_md5 => 1); + $self->{checksums}->add_from_control($fields, use_files_for_md5 => 1); $self->upgrade_object_type(0); } @@ -217,9 +217,9 @@ sub initialize { sub upgrade_object_type { my ($self, $update_format) = @_; $update_format //= 1; - $self->{'fields'}{'Format'} = '1.0' - unless exists $self->{'fields'}{'Format'}; - my $format = $self->{'fields'}{'Format'}; + $self->{fields}{'Format'} = '1.0' + unless exists $self->{fields}{'Format'}; + my $format = $self->{fields}{'Format'}; if ($format =~ /^([\d\.]+)(?:\s+\((.*)\))?$/) { my ($version, $variant, $major, $minor) = ($1, $2, $1, undef); @@ -229,8 +229,8 @@ sub upgrade_object_type { eval "require $module; \$minor = \$${module}::CURRENT_MINOR_VERSION;"; $minor //= 0; if ($update_format) { - $self->{'fields'}{'Format'} = "$major.$minor"; - $self->{'fields'}{'Format'} .= " ($variant)" if defined $variant; + $self->{fields}{'Format'} = "$major.$minor"; + $self->{fields}{'Format'} .= " ($variant)" if defined $variant; } if ($@) { error(_g("source package format '%s' is not supported: %s"), @@ -250,7 +250,7 @@ Returns the filename of the DSC file. sub get_filename { my ($self) = @_; - return $self->{'basedir'} . $self->{'filename'}; + return $self->{basedir} . $self->{filename}; } =item $p->get_files() @@ -262,7 +262,7 @@ usually do not have any path information. sub get_files { my ($self) = @_; - return $self->{'checksums'}->get_files(); + return $self->{checksums}->get_files(); } =item $p->check_checksums() @@ -275,16 +275,16 @@ discovered, it immediately errors out. sub check_checksums { my ($self) = @_; - my $checksums = $self->{'checksums'}; + my $checksums = $self->{checksums}; # add_from_file verify the checksums if they are already existing foreach my $file ($checksums->get_files()) { - $checksums->add_from_file($self->{'basedir'} . $file, key => $file); + $checksums->add_from_file($self->{basedir} . $file, key => $file); } } sub get_basename { my ($self, $with_revision) = @_; - my $f = $self->{'fields'}; + my $f = $self->{fields}; unless (exists $f->{'Source'} and exists $f->{'Version'}) { error(_g("source and version are required to compute the source basename")); } @@ -303,7 +303,7 @@ sub find_original_tarballs { $opts{include_supplementary} = 1 unless exists $opts{include_supplementary}; my $basename = $self->get_basename(); my @tar; - foreach my $dir (".", $self->{'basedir'}, $self->{'options'}{'origtardir'}) { + foreach my $dir (".", $self->{basedir}, $self->{options}{origtardir}) { next unless defined($dir) and -d $dir; opendir(my $dir_dh, $dir) || syserr(_g("cannot opendir %s"), $dir); push @tar, map { "$dir/$_" } grep { @@ -326,7 +326,7 @@ Otherwise returns 0. sub is_signed { my $self = shift; - return $self->{'is_signed'}; + return $self->{is_signed}; } =item $p->check_signature() @@ -349,8 +349,8 @@ sub check_signature { push @exec, "gpg", "--no-default-keyring", "-q", "--verify"; } if (scalar(@exec)) { - if (defined $ENV{'HOME'} and -r "$ENV{'HOME'}/.gnupg/trustedkeys.gpg") { - push @exec, "--keyring", "$ENV{'HOME'}/.gnupg/trustedkeys.gpg"; + if (defined $ENV{HOME} and -r "$ENV{HOME}/.gnupg/trustedkeys.gpg") { + push @exec, "--keyring", "$ENV{HOME}/.gnupg/trustedkeys.gpg"; } foreach my $vendor_keyring (run_vendor_hook('keyrings')) { if (-r $vendor_keyring) { @@ -367,7 +367,7 @@ sub check_signature { my $gpg_status = WEXITSTATUS($?); print STDERR "$stdout$stderr" if $gpg_status; if ($gpg_status == 1 or ($gpg_status && - $self->{'options'}{'require_valid_signature'})) + $self->{options}{require_valid_signature})) { error(_g("failed to verify signature on %s"), $dsc); } elsif ($gpg_status) { @@ -377,7 +377,7 @@ sub check_signature { subprocerr("@exec"); } } else { - if ($self->{'options'}{'require_valid_signature'}) { + if ($self->{options}{require_valid_signature}) { error(_g("could not verify signature on %s since gpg isn't installed"), $dsc); } else { warning(_g("could not verify signature on %s since gpg isn't installed"), $dsc); @@ -409,11 +409,11 @@ sub extract { my $self = shift; my $newdirectory = $_[0]; - my ($ok, $error) = version_check($self->{'fields'}{'Version'}); + my ($ok, $error) = version_check($self->{fields}{'Version'}); error($error) unless $ok; # Copy orig tarballs - if ($self->{'options'}{'copy_orig_tarballs'}) { + if ($self->{options}{copy_orig_tarballs}) { my $basename = $self->get_basename(); my ($dirname, $destdir) = fileparse($newdirectory); $destdir ||= "./"; @@ -421,7 +421,7 @@ sub extract { foreach my $orig (grep { /^\Q$basename\E\.orig(-[[:alnum:]-]+)?\.tar\.$ext$/ } $self->get_files()) { - my $src = File::Spec->catfile($self->{'basedir'}, $orig); + my $src = File::Spec->catfile($self->{basedir}, $orig); my $dst = File::Spec->catfile($destdir, $orig); if (not check_files_are_the_same($src, $dst, 1)) { system('cp', '--', $src, $dst); @@ -438,8 +438,8 @@ sub extract { } # Store format if non-standard so that next build keeps the same format - if ($self->{'fields'}{'Format'} ne "1.0" and - not $self->{'options'}{'skip_debianization'}) + if ($self->{fields}{'Format'} ne "1.0" and + not $self->{options}{skip_debianization}) { my $srcdir = File::Spec->catdir($newdirectory, "debian", "source"); my $format_file = File::Spec->catfile($srcdir, "format"); @@ -447,7 +447,7 @@ sub extract { mkdir($srcdir) unless -e $srcdir; open(my $format_fh, ">", $format_file) || syserr(_g("cannot write %s"), $format_file); - print $format_fh $self->{'fields'}{'Format'} . "\n"; + print $format_fh $self->{fields}{'Format'} . "\n"; close($format_fh); } } @@ -460,7 +460,7 @@ sub extract { syserr(_g("cannot stat %s"), $rules); } warning(_g("%s does not exist"), $rules) - unless $self->{'options'}{'skip_debianization'}; + unless $self->{options}{skip_debianization}; } elsif (-f _) { chmod($s[2] | 0111, $rules) || syserr(_g("cannot make %s executable"), $rules); @@ -506,11 +506,11 @@ sub can_build { sub add_file { my ($self, $filename) = @_; my ($fn, $dir) = fileparse($filename); - if ($self->{'checksums'}->has_file($fn)) { + if ($self->{checksums}->has_file($fn)) { internerr("tried to add file '%s' twice", $fn); } - $self->{'checksums'}->add_from_file($filename, key => $fn); - $self->{'checksums'}->export_to_control($self->{'fields'}, + $self->{checksums}->add_from_file($filename, key => $fn); + $self->{checksums}->export_to_control($self->{fields}, use_files_for_md5 => 1); } @@ -526,18 +526,18 @@ sub commit { sub do_commit { my ($self, $dir) = @_; info(_g("'%s' is not supported by the source format '%s'"), - "dpkg-source --commit", $self->{'fields'}{'Format'}); + "dpkg-source --commit", $self->{fields}{'Format'}); } sub write_dsc { my ($self, %opts) = @_; - my $fields = $self->{'fields'}; + my $fields = $self->{fields}; - foreach my $f (keys %{$opts{'override'}}) { - $fields->{$f} = $opts{'override'}{$f}; + foreach my $f (keys %{$opts{override}}) { + $fields->{$f} = $opts{override}{$f}; } - unless($opts{'nocheck'}) { + unless($opts{nocheck}) { foreach my $f (qw(Source Version)) { unless (defined($fields->{$f})) { error(_g("missing information for critical output field %s"), $f); @@ -550,16 +550,16 @@ sub write_dsc { } } - foreach my $f (keys %{$opts{'remove'}}) { + foreach my $f (keys %{$opts{remove}}) { delete $fields->{$f}; } - my $filename = $opts{'filename'}; + my $filename = $opts{filename}; unless (defined $filename) { $filename = $self->get_basename(1) . ".dsc"; } open(my $dsc_fh, ">", $filename) || syserr(_g("cannot write %s"), $filename); - $fields->apply_substvars($opts{'substvars'}); + $fields->apply_substvars($opts{substvars}); $fields->output($dsc_fh); close($dsc_fh); } diff --git a/scripts/Dpkg/Source/Package/V1.pm b/scripts/Dpkg/Source/Package/V1.pm index f278c5c46..314ae0f16 100644 --- a/scripts/Dpkg/Source/Package/V1.pm +++ b/scripts/Dpkg/Source/Package/V1.pm @@ -44,32 +44,32 @@ sub init_options { my ($self) = @_; # Don't call $self->SUPER::init_options() on purpose, V1.0 has no # ignore by default - if ($self->{'options'}{'diff_ignore_regexp'}) { - $self->{'options'}{'diff_ignore_regexp'} .= '|(?:^|/)debian/source/local-.*$'; + if ($self->{options}{diff_ignore_regexp}) { + $self->{options}{diff_ignore_regexp} .= '|(?:^|/)debian/source/local-.*$'; } else { - $self->{'options'}{'diff_ignore_regexp'} = '(?:^|/)debian/source/local-.*$'; + $self->{options}{diff_ignore_regexp} = '(?:^|/)debian/source/local-.*$'; } - push @{$self->{'options'}{'tar_ignore'}}, "debian/source/local-options", + push @{$self->{options}{tar_ignore}}, "debian/source/local-options", "debian/source/local-patch-header"; - $self->{'options'}{'sourcestyle'} ||= 'X'; - $self->{'options'}{'skip_debianization'} ||= 0; - $self->{'options'}{'abort_on_upstream_changes'} ||= 0; + $self->{options}{sourcestyle} ||= 'X'; + $self->{options}{skip_debianization} ||= 0; + $self->{options}{abort_on_upstream_changes} ||= 0; } sub parse_cmdline_option { my ($self, $opt) = @_; - my $o = $self->{'options'}; + my $o = $self->{options}; if ($opt =~ m/^-s([akpursnAKPUR])$/) { warning(_g("-s%s option overrides earlier -s%s option"), $1, - $o->{'sourcestyle'}) if $o->{'sourcestyle'} ne 'X'; - $o->{'sourcestyle'} = $1; - $o->{'copy_orig_tarballs'} = 0 if $1 eq 'n'; # Extract option -sn + $o->{sourcestyle}) if $o->{sourcestyle} ne 'X'; + $o->{sourcestyle} = $1; + $o->{copy_orig_tarballs} = 0 if $1 eq 'n'; # Extract option -sn return 1; } elsif ($opt =~ m/^--skip-debianization$/) { - $o->{'skip_debianization'} = 1; + $o->{skip_debianization} = 1; return 1; } elsif ($opt =~ m/^--abort-on-upstream-changes$/) { - $o->{'abort_on_upstream_changes'} = 1; + $o->{abort_on_upstream_changes} = 1; return 1; } return 0; @@ -77,15 +77,15 @@ sub parse_cmdline_option { sub do_extract { my ($self, $newdirectory) = @_; - my $sourcestyle = $self->{'options'}{'sourcestyle'}; - my $fields = $self->{'fields'}; + my $sourcestyle = $self->{options}{sourcestyle}; + my $fields = $self->{fields}; $sourcestyle =~ y/X/p/; $sourcestyle =~ m/[pun]/ || usageerr(_g("source handling style -s%s not allowed with -x"), $sourcestyle); - my $dscdir = $self->{'basedir'}; + my $dscdir = $self->{basedir}; my $basename = $self->get_basename(); my $basenamerev = $self->get_basename(1); @@ -149,13 +149,13 @@ sub do_extract { } } - if ($difffile and not $self->{'options'}{'skip_debianization'}) { + if ($difffile and not $self->{options}{skip_debianization}) { my $patch = "$dscdir$difffile"; info(_g("applying %s"), $difffile); my $patch_obj = Dpkg::Source::Patch->new(filename => $patch); my $analysis = $patch_obj->apply($newdirectory, force_timestamp => 1); my @files = grep { ! m{^\Q$newdirectory\E/debian/} } - sort keys %{$analysis->{'filepatched'}}; + sort keys %{$analysis->{filepatched}}; info(_g("upstream files that have been modified: %s"), "\n " . join("\n ", @files)) if scalar @files; } @@ -165,16 +165,16 @@ sub can_build { my ($self, $dir) = @_; # As long as we can use gzip, we can do it as we have # native packages as fallback - return ($self->{'options'}{'compression'} eq "gzip", + return ($self->{options}{compression} eq "gzip", _g("only supports gzip compression")); } sub do_build { my ($self, $dir) = @_; - my $sourcestyle = $self->{'options'}{'sourcestyle'}; - my @argv = @{$self->{'options'}{'ARGV'}}; - my @tar_ignore = map { "--exclude=$_" } @{$self->{'options'}{'tar_ignore'}}; - my $diff_ignore_regexp = $self->{'options'}{'diff_ignore_regexp'}; + my $sourcestyle = $self->{options}{sourcestyle}; + my @argv = @{$self->{options}{ARGV}}; + my @tar_ignore = map { "--exclude=$_" } @{$self->{options}{tar_ignore}}; + my $diff_ignore_regexp = $self->{options}{diff_ignore_regexp}; if (scalar(@argv) > 1) { usageerr(_g("-b takes at most a directory and an orig source ". @@ -187,7 +187,7 @@ sub do_build { $sourcestyle); } - my $sourcepackage = $self->{'fields'}{'Source'}; + my $sourcepackage = $self->{fields}{'Source'}; my $basenamerev = $self->get_basename(1); my $basename = $self->get_basename(); my $basedirname = $basename; @@ -287,7 +287,7 @@ sub do_build { } if ($sourcestyle eq "n") { - $self->{'options'}{'ARGV'} = []; # ensure we have no error + $self->{options}{ARGV} = []; # ensure we have no error Dpkg::Source::Package::V3::native::do_build($self, $dir); } elsif ($sourcestyle =~ m/[nurUR]/) { if (stat($tarname)) { @@ -306,7 +306,7 @@ sub do_build { DIR => getcwd(), UNLINK => 0); my $tar = Dpkg::Source::Archive->new(filename => $newtar, compression => compression_guess_from_filename($tarname), - compression_level => $self->{'options'}{'comp_level'}); + compression_level => $self->{options}{comp_level}); $tar->create(options => \@tar_ignore, chdir => $tardirbase); $tar->add_directory($tardirname); $tar->finish(); @@ -362,14 +362,14 @@ sub do_build { my $analysis = $diff->analyze($origdir); my @files = grep { ! m{^debian/} } map { s{^[^/]+/+}{}; $_ } - sort keys %{$analysis->{'filepatched'}}; + sort keys %{$analysis->{filepatched}}; if (scalar @files) { warning(_g("the diff modifies the following upstream files: %s"), "\n " . join("\n ", @files)); info(_g("use the '3.0 (quilt)' format to have separate and " . "documented changes to upstream files, see dpkg-source(1)")); error(_g("aborting due to --abort-on-upstream-changes")) - if $self->{'options'}{'abort_on_upstream_changes'}; + if $self->{options}{abort_on_upstream_changes}; } rename($newdiffgz, $diffname) || diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index ee9687386..4da8bdae2 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -48,60 +48,60 @@ our $CURRENT_MINOR_VERSION = "0"; sub init_options { my ($self) = @_; $self->SUPER::init_options(); - $self->{'options'}{'include_removal'} = 0 - unless exists $self->{'options'}{'include_removal'}; - $self->{'options'}{'include_timestamp'} = 0 - unless exists $self->{'options'}{'include_timestamp'}; - $self->{'options'}{'include_binaries'} = 0 - unless exists $self->{'options'}{'include_binaries'}; - $self->{'options'}{'preparation'} = 1 - unless exists $self->{'options'}{'preparation'}; - $self->{'options'}{'skip_patches'} = 0 - unless exists $self->{'options'}{'skip_patches'}; - $self->{'options'}{'unapply_patches'} = 'auto' - unless exists $self->{'options'}{'unapply_patches'}; - $self->{'options'}{'skip_debianization'} = 0 - unless exists $self->{'options'}{'skip_debianization'}; - $self->{'options'}{'create_empty_orig'} = 0 - unless exists $self->{'options'}{'create_empty_orig'}; - $self->{'options'}{'auto_commit'} = 0 - unless exists $self->{'options'}{'auto_commit'}; + $self->{options}{include_removal} = 0 + unless exists $self->{options}{include_removal}; + $self->{options}{include_timestamp} = 0 + unless exists $self->{options}{include_timestamp}; + $self->{options}{include_binaries} = 0 + unless exists $self->{options}{include_binaries}; + $self->{options}{preparation} = 1 + unless exists $self->{options}{preparation}; + $self->{options}{skip_patches} = 0 + unless exists $self->{options}{skip_patches}; + $self->{options}{unapply_patches} = 'auto' + unless exists $self->{options}{unapply_patches}; + $self->{options}{skip_debianization} = 0 + unless exists $self->{options}{skip_debianization}; + $self->{options}{create_empty_orig} = 0 + unless exists $self->{options}{create_empty_orig}; + $self->{options}{auto_commit} = 0 + unless exists $self->{options}{auto_commit}; } sub parse_cmdline_option { my ($self, $opt) = @_; if ($opt =~ /^--include-removal$/) { - $self->{'options'}{'include_removal'} = 1; + $self->{options}{include_removal} = 1; return 1; } elsif ($opt =~ /^--include-timestamp$/) { - $self->{'options'}{'include_timestamp'} = 1; + $self->{options}{include_timestamp} = 1; return 1; } elsif ($opt =~ /^--include-binaries$/) { - $self->{'options'}{'include_binaries'} = 1; + $self->{options}{include_binaries} = 1; return 1; } elsif ($opt =~ /^--no-preparation$/) { - $self->{'options'}{'preparation'} = 0; + $self->{options}{preparation} = 0; return 1; } elsif ($opt =~ /^--skip-patches$/) { - $self->{'options'}{'skip_patches'} = 1; + $self->{options}{skip_patches} = 1; return 1; } elsif ($opt =~ /^--unapply-patches$/) { - $self->{'options'}{'unapply_patches'} = 'yes'; + $self->{options}{unapply_patches} = 'yes'; return 1; } elsif ($opt =~ /^--no-unapply-patches$/) { - $self->{'options'}{'unapply_patches'} = 'no'; + $self->{options}{unapply_patches} = 'no'; return 1; } elsif ($opt =~ /^--skip-debianization$/) { - $self->{'options'}{'skip_debianization'} = 1; + $self->{options}{skip_debianization} = 1; return 1; } elsif ($opt =~ /^--create-empty-orig$/) { - $self->{'options'}{'create_empty_orig'} = 1; + $self->{options}{create_empty_orig} = 1; return 1; } elsif ($opt =~ /^--abort-on-upstream-changes$/) { - $self->{'options'}{'auto_commit'} = 0; + $self->{options}{auto_commit} = 0; return 1; } elsif ($opt =~ /^--auto-commit$/) { - $self->{'options'}{'auto_commit'} = 1; + $self->{options}{auto_commit} = 1; return 1; } return 0; @@ -109,9 +109,9 @@ sub parse_cmdline_option { sub do_extract { my ($self, $newdirectory) = @_; - my $fields = $self->{'fields'}; + my $fields = $self->{fields}; - my $dscdir = $self->{'basedir'}; + my $dscdir = $self->{basedir}; my $basename = $self->get_basename(); my $basenamerev = $self->get_basename(1); @@ -164,7 +164,7 @@ sub do_extract { } # Stop here if debianization is not wanted - return if $self->{'options'}{'skip_debianization'}; + return if $self->{options}{skip_debianization}; # Extract debian tarball after removing the debian directory info(_g("unpacking %s"), $debianfile); @@ -186,7 +186,7 @@ sub do_extract { # Apply patches (in a separate method as it might be overriden) $self->apply_patches($newdirectory, usage => 'unpack') - unless $self->{'options'}{'skip_patches'}; + unless $self->{options}{skip_patches}; } sub get_autopatch_name { @@ -195,7 +195,7 @@ sub get_autopatch_name { sub get_patches { my ($self, $dir, %opts) = @_; - $opts{"skip_auto"} //= 0; + $opts{skip_auto} //= 0; my @patches; my $pd = "$dir/debian/patches"; my $auto_patch = $self->get_autopatch_name(); @@ -204,7 +204,7 @@ sub get_patches { foreach my $patch (sort readdir($dir_dh)) { # patches match same rules as run-parts next unless $patch =~ /^[\w-]+$/ and -f "$pd/$patch"; - next if $opts{"skip_auto"} and $patch eq $auto_patch; + next if $opts{skip_auto} and $patch eq $auto_patch; push @patches, $patch; } closedir($dir_dh); @@ -214,17 +214,17 @@ sub get_patches { sub apply_patches { my ($self, $dir, %opts) = @_; - $opts{"skip_auto"} //= 0; + $opts{skip_auto} //= 0; my @patches = $self->get_patches($dir, %opts); return unless scalar(@patches); my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied"); open(my $applied_fh, '>', $applied) || syserr(_g("cannot write %s"), $applied); - print $applied_fh "# During $opts{'usage'}\n"; + print $applied_fh "# During $opts{usage}\n"; my $timestamp = fs_time($applied); foreach my $patch ($self->get_patches($dir, %opts)) { my $path = File::Spec->catfile($dir, "debian", "patches", $patch); - info(_g("applying %s"), $patch) unless $opts{"skip_auto"}; + info(_g("applying %s"), $patch) unless $opts{skip_auto}; my $patch_obj = Dpkg::Source::Patch->new(filename => $path); $patch_obj->apply($dir, force_timestamp => 1, timestamp => $timestamp, @@ -242,7 +242,7 @@ sub unapply_patches { my $timestamp = fs_time($applied); foreach my $patch (@patches) { my $path = File::Spec->catfile($dir, "debian", "patches", $patch); - info(_g("unapplying %s"), $patch) unless $opts{"quiet"}; + info(_g("unapplying %s"), $patch) unless $opts{quiet}; my $patch_obj = Dpkg::Source::Patch->new(filename => $path); $patch_obj->apply($dir, force_timestamp => 1, verbose => 0, timestamp => $timestamp, @@ -263,7 +263,7 @@ sub upstream_tarball_template { sub can_build { my ($self, $dir) = @_; return 1 if $self->find_original_tarballs(include_supplementary => 0); - return 1 if $self->{'options'}{'create_empty_orig'} and + return 1 if $self->{options}{create_empty_orig} and $self->find_original_tarballs(include_main => 0); return (0, sprintf(_g("no upstream tarball found at %s"), $self->upstream_tarball_template())); @@ -271,7 +271,7 @@ sub can_build { sub before_build { my ($self, $dir) = @_; - $self->check_patches_applied($dir) if $self->{'options'}{'preparation'}; + $self->check_patches_applied($dir) if $self->{options}{preparation}; } sub after_build { @@ -284,7 +284,7 @@ sub after_build { $reason = <$applied_fh>; close($applied_fh); } - my $opt_unapply = $self->{'options'}{'unapply_patches'}; + my $opt_unapply = $self->{options}{unapply_patches}; if (($opt_unapply eq "auto" and $reason =~ /^# During preparation/) or $opt_unapply eq "yes") { $self->unapply_patches($dir); @@ -293,21 +293,21 @@ sub after_build { sub prepare_build { my ($self, $dir) = @_; - $self->{'diff_options'} = { - diff_ignore_regexp => $self->{'options'}{'diff_ignore_regexp'} . + $self->{diff_options} = { + diff_ignore_regexp => $self->{options}{diff_ignore_regexp} . '|(^|/)debian/patches/.dpkg-source-applied$', - include_removal => $self->{'options'}{'include_removal'}, - include_timestamp => $self->{'options'}{'include_timestamp'}, + include_removal => $self->{options}{include_removal}, + include_timestamp => $self->{options}{include_timestamp}, use_dev_null => 1, }; - push @{$self->{'options'}{'tar_ignore'}}, "debian/patches/.dpkg-source-applied"; - $self->check_patches_applied($dir) if $self->{'options'}{'preparation'}; - if ($self->{'options'}{'create_empty_orig'} and + push @{$self->{options}{tar_ignore}}, "debian/patches/.dpkg-source-applied"; + $self->check_patches_applied($dir) if $self->{options}{preparation}; + if ($self->{options}{create_empty_orig} and not $self->find_original_tarballs(include_supplementary => 0)) { # No main orig.tar, create a dummy one my $filename = $self->get_basename() . ".orig.tar." . - $self->{'options'}{'comp_ext'}; + $self->{options}{comp_ext}; my $tar = Dpkg::Source::Archive->new(filename => $filename); $tar->create(); $tar->finish(); @@ -351,9 +351,9 @@ sub generate_patch { error(_g("no upstream tarball found at %s"), $self->upstream_tarball_template()) unless $tarfile; - if ($opts{'usage'} eq "build") { + if ($opts{usage} eq "build") { info(_g("building %s using existing %s"), - $self->{'fields'}{'Source'}, "@origtarballs"); + $self->{fields}{'Source'}, "@origtarballs"); } # Unpack a second copy for comparison @@ -377,8 +377,8 @@ sub generate_patch { subprocerr(_g("copy of the debian directory")) if $?; # Apply all patches except the last automatic one - $opts{'skip_auto'} //= 0; - $self->apply_patches($tmp, skip_auto => $opts{'skip_auto'}, usage => 'build'); + $opts{skip_auto} //= 0; + $self->apply_patches($tmp, skip_auto => $opts{skip_auto}, usage => 'build'); # Create a patch my ($difffh, $tmpdiff) = tempfile($self->get_basename(1) . ".diff.XXXXXX", @@ -387,24 +387,24 @@ sub generate_patch { my $diff = Dpkg::Source::Patch->new(filename => $tmpdiff, compression => "none"); $diff->create(); - if ($opts{'header_from'} and -e $opts{'header_from'}) { + if ($opts{header_from} and -e $opts{header_from}) { my $header_from = Dpkg::Source::Patch->new( - filename => $opts{'header_from'}); + filename => $opts{header_from}); my $analysis = $header_from->analyze($dir, verbose => 0); - $diff->set_header($analysis->{'patchheader'}); + $diff->set_header($analysis->{patchheader}); } else { $diff->set_header($self->get_patch_header($dir)); } $diff->add_diff_directory($tmp, $dir, basedirname => $basedirname, - %{$self->{'diff_options'}}, - handle_binary_func => $opts{'handle_binary'}, - order_from => $opts{'order_from'}); + %{$self->{diff_options}}, + handle_binary_func => $opts{handle_binary}, + order_from => $opts{order_from}); error(_g("unrepresentable changes to source")) if not $diff->finish(); if (-s $tmpdiff) { info(_g("local changes detected, the modified files are:")); my $analysis = $diff->analyze($dir, verbose => 0); - foreach my $fn (sort keys %{$analysis->{'filepatched'}}) { + foreach my $fn (sort keys %{$analysis->{filepatched}}) { print " $fn\n"; } } @@ -419,17 +419,17 @@ sub generate_patch { sub do_build { my ($self, $dir) = @_; - my @argv = @{$self->{'options'}{'ARGV'}}; + my @argv = @{$self->{options}{ARGV}}; if (scalar(@argv)) { usageerr(_g("-b takes only one parameter with format `%s'"), - $self->{'fields'}{'Format'}); + $self->{fields}{'Format'}); } $self->prepare_build($dir); - my $include_binaries = $self->{'options'}{'include_binaries'}; - my @tar_ignore = map { "--exclude=$_" } @{$self->{'options'}{'tar_ignore'}}; + my $include_binaries = $self->{options}{include_binaries}; + my @tar_ignore = map { "--exclude=$_" } @{$self->{options}{tar_ignore}}; - my $sourcepackage = $self->{'fields'}{'Source'}; + my $sourcepackage = $self->{fields}{'Source'}; my $basenamerev = $self->get_basename(1); # Check if the debian directory contains unwanted binary files @@ -450,7 +450,7 @@ sub do_build { my $copy = $_; $copy =~ s/,/\\,/g; $copy; - } @{$self->{'options'}{'tar_ignore'}}) . "}"; + } @{$self->{options}{tar_ignore}}) . "}"; my $filter_ignore = sub { # Filter out files that are not going to be included in the debian # tarball due to ignores. @@ -503,9 +503,9 @@ sub do_build { my $tmpdiff = $self->generate_patch($dir, order_from => $autopatch, header_from => $autopatch, handle_binary => $handle_binary, - skip_auto => $self->{'options'}{'auto_commit'}, + skip_auto => $self->{options}{auto_commit}, usage => 'build'); - unless (-z $tmpdiff or $self->{'options'}{'auto_commit'}) { + unless (-z $tmpdiff or $self->{options}{auto_commit}) { info(_g("you can integrate the local changes with %s"), "dpkg-source --commit"); error(_g("aborting due to unexpected upstream changes, see %s"), @@ -515,7 +515,7 @@ sub do_build { $binaryfiles->update_debian_source_include_binaries() if $include_binaries; # Install the diff as the new autopatch - if ($self->{'options'}{'auto_commit'}) { + if ($self->{options}{auto_commit}) { mkpath(File::Spec->catdir($dir, "debian", "patches")); $autopatch = $self->register_patch($dir, $tmpdiff, $self->get_autopatch_name()); @@ -527,7 +527,7 @@ sub do_build { pop @Dpkg::Exit::handlers; # Create the debian.tar - my $debianfile = "$basenamerev.debian.tar." . $self->{'options'}{'comp_ext'}; + my $debianfile = "$basenamerev.debian.tar." . $self->{options}{comp_ext}; info(_g("building %s in %s"), $sourcepackage, $debianfile); my $tar = Dpkg::Source::Archive->new(filename => $debianfile); $tar->create(options => \@tar_ignore, chdir => $dir); @@ -619,7 +619,7 @@ sub _is_bad_patch_name { sub do_commit { my ($self, $dir) = @_; - my ($patch_name, $tmpdiff) = @{$self->{'options'}{'ARGV'}}; + my ($patch_name, $tmpdiff) = @{$self->{options}{ARGV}}; $self->prepare_build($dir); @@ -689,19 +689,19 @@ sub new { sub new_binary_found { my ($self, $path) = @_; - $self->{'seen_binaries'}{$path} = 1; + $self->{seen_binaries}{$path} = 1; } sub load_allowed_binaries { my ($self) = @_; - my $incbin_file = $self->{'include_binaries_path'}; + my $incbin_file = $self->{include_binaries_path}; if (-f $incbin_file) { open(my $incbin_fh, "<", $incbin_file) || syserr(_g("cannot read %s"), $incbin_file); while (defined($_ = <$incbin_fh>)) { chomp; s/^\s*//; s/\s*$//; next if /^#/ or /^$/; - $self->{'allowed_binaries'}{$_} = 1; + $self->{allowed_binaries}{$_} = 1; } close($incbin_fh); } @@ -709,7 +709,7 @@ sub load_allowed_binaries { sub binary_is_allowed { my ($self, $path) = @_; - return 1 if exists $self->{'allowed_binaries'}{$path}; + return 1 if exists $self->{allowed_binaries}{$path}; return 0; } @@ -719,14 +719,14 @@ sub update_debian_source_include_binaries { my @unknown_binaries = $self->get_unknown_binaries(); return unless scalar(@unknown_binaries); - my $incbin_file = $self->{'include_binaries_path'}; - mkpath(File::Spec->catdir($self->{'dir'}, "debian", "source")); + my $incbin_file = $self->{include_binaries_path}; + mkpath(File::Spec->catdir($self->{dir}, "debian", "source")); open(my $incbin_fh, ">>", $incbin_file) || syserr(_g("cannot write %s"), $incbin_file); foreach my $binary (@unknown_binaries) { print $incbin_fh "$binary\n"; info(_g("adding %s to %s"), $binary, "debian/source/include-binaries"); - $self->{'allowed_binaries'}{$binary} = 1; + $self->{allowed_binaries}{$binary} = 1; } close($incbin_fh); } @@ -738,7 +738,7 @@ sub get_unknown_binaries { sub get_seen_binaries { my ($self) = @_; - my @seen = sort keys %{$self->{'seen_binaries'}}; + my @seen = sort keys %{$self->{seen_binaries}}; return @seen; } diff --git a/scripts/Dpkg/Source/Package/V3/bzr.pm b/scripts/Dpkg/Source/Package/V3/bzr.pm index bba97fb21..28c9935a8 100644 --- a/scripts/Dpkg/Source/Package/V3/bzr.pm +++ b/scripts/Dpkg/Source/Package/V3/bzr.pm @@ -86,20 +86,20 @@ sub can_build { sub do_build { my ($self, $dir) = @_; - my @argv = @{$self->{'options'}{'ARGV'}}; + my @argv = @{$self->{options}{ARGV}}; # TODO: warn here? - #my @tar_ignore = map { "--exclude=$_" } @{$self->{'options'}{'tar_ignore'}}; - my $diff_ignore_regexp = $self->{'options'}{'diff_ignore_regexp'}; + #my @tar_ignore = map { "--exclude=$_" } @{$self->{options}{tar_ignore}}; + my $diff_ignore_regexp = $self->{options}{diff_ignore_regexp}; $dir =~ s{/+$}{}; # Strip trailing / my ($dirname, $updir) = fileparse($dir); if (scalar(@argv)) { usageerr(_g("-b takes only one parameter with format `%s'"), - $self->{'fields'}{'Format'}); + $self->{fields}{'Format'}); } - my $sourcepackage = $self->{'fields'}{'Source'}; + my $sourcepackage = $self->{fields}{'Source'}; my $basenamerev = $self->get_basename(1); my $basename = $self->get_basename(); my $basedirname = $basename; @@ -149,12 +149,12 @@ sub do_build { "$tardir/.bzr/branch/parent"); # Create the tar file - my $debianfile = "$basenamerev.bzr.tar." . $self->{'options'}{'comp_ext'}; + my $debianfile = "$basenamerev.bzr.tar." . $self->{options}{comp_ext}; info(_g("building %s in %s"), $sourcepackage, $debianfile); my $tar = Dpkg::Source::Archive->new(filename => $debianfile, - compression => $self->{'options'}{'compression'}, - compression_level => $self->{'options'}{'comp_level'}); + compression => $self->{options}{compression}, + compression_level => $self->{options}{comp_level}); $tar->create(chdir => $tmp); $tar->add_directory($dirname); $tar->finish(); @@ -168,9 +168,9 @@ sub do_build { # Called after a tarball is unpacked, to check out the working copy. sub do_extract { my ($self, $newdirectory) = @_; - my $fields = $self->{'fields'}; + my $fields = $self->{fields}; - my $dscdir = $self->{'basedir'}; + my $dscdir = $self->{basedir}; my $basename = $self->get_basename(); my $basenamerev = $self->get_basename(1); diff --git a/scripts/Dpkg/Source/Package/V3/custom.pm b/scripts/Dpkg/Source/Package/V3/custom.pm index e27cdc68a..9ba8d5874 100644 --- a/scripts/Dpkg/Source/Package/V3/custom.pm +++ b/scripts/Dpkg/Source/Package/V3/custom.pm @@ -31,7 +31,7 @@ our $CURRENT_MINOR_VERSION = "0"; sub parse_cmdline_option { my ($self, $opt) = @_; if ($opt =~ /^--target-format=(.*)$/) { - $self->{'options'}{'target_format'} = $1; + $self->{options}{target_format} = $1; return 1; } return 0; @@ -42,18 +42,18 @@ sub do_extract { sub can_build { my ($self, $dir) = @_; - return (scalar(@{$self->{'options'}{'ARGV'}}), + return (scalar(@{$self->{options}{ARGV}}), _g("no files indicated on command line")); } sub do_build { my ($self, $dir) = @_; # Update real target format - my $format = $self->{'options'}{'target_format'}; + my $format = $self->{options}{target_format}; error(_g("--target-format option is missing")) unless $format; - $self->{'fields'}{'Format'} = $format; + $self->{fields}{'Format'} = $format; # Add all files - foreach my $file (@{$self->{'options'}{'ARGV'}}) { + foreach my $file (@{$self->{options}{ARGV}}) { $self->add_file($file); } } diff --git a/scripts/Dpkg/Source/Package/V3/git.pm b/scripts/Dpkg/Source/Package/V3/git.pm index b1e4a0dbc..863576f86 100644 --- a/scripts/Dpkg/Source/Package/V3/git.pm +++ b/scripts/Dpkg/Source/Package/V3/git.pm @@ -76,10 +76,10 @@ sub parse_cmdline_option { my ($self, $opt) = @_; return 1 if $self->SUPER::parse_cmdline_option($opt); if ($opt =~ /^--git-ref=(.*)$/) { - push @{$self->{'options'}{'git_ref'}}, $1; + push @{$self->{options}{git_ref}}, $1; return 1; } elsif ($opt =~ /^--git-depth=(\d+)$/) { - $self->{'options'}{'git_depth'} = $1; + $self->{options}{git_depth} = $1; return 1; } return 0; @@ -92,7 +92,7 @@ sub can_build { sub do_build { my ($self, $dir) = @_; - my $diff_ignore_regexp = $self->{'options'}{'diff_ignore_regexp'}; + my $diff_ignore_regexp = $self->{options}{diff_ignore_regexp}; $dir =~ s{/+$}{}; # Strip trailing / my ($dirname, $updir) = fileparse($dir); @@ -138,7 +138,7 @@ sub do_build { # bundle that. my $tmp; my $shallowfile; - if ($self->{'options'}{'git_depth'}) { + if ($self->{options}{git_depth}) { chdir($old_cwd) || syserr(_g("unable to chdir to `%s'"), $old_cwd); $tmp = tempdir("$dirname.git.XXXXXX", DIR => $updir); @@ -147,8 +147,8 @@ sub do_build { # file:// is needed to avoid local cloning, which does not # create a shallow clone. info(_g("creating shallow clone with depth %s"), - $self->{'options'}{'git_depth'}); - system("git", "clone", "--depth=" . $self->{'options'}{'git_depth'}, + $self->{options}{git_depth}); + system("git", "clone", "--depth=" . $self->{options}{git_depth}, "--quiet", "--bare", "file://" . abs_path($dir), $clone_dir); $? && subprocerr("git clone"); chdir($clone_dir) || @@ -160,8 +160,8 @@ sub do_build { # Create the git bundle. my $bundlefile = "$basenamerev.git"; - my @bundle_arg = $self->{'options'}{'git_ref'} ? - (@{$self->{'options'}{'git_ref'}}) : "--all"; + my @bundle_arg = $self->{options}{git_ref} ? + (@{$self->{options}{git_ref}}) : "--all"; info(_g("bundling: %s"), join(" ", @bundle_arg)); system("git", "bundle", "create", "$old_cwd/$bundlefile", @bundle_arg, @@ -186,9 +186,9 @@ sub do_build { sub do_extract { my ($self, $newdirectory) = @_; - my $fields = $self->{'fields'}; + my $fields = $self->{fields}; - my $dscdir = $self->{'basedir'}; + my $dscdir = $self->{basedir}; my $basenamerev = $self->get_basename(1); my @files = $self->get_files(); diff --git a/scripts/Dpkg/Source/Package/V3/native.pm b/scripts/Dpkg/Source/Package/V3/native.pm index de0b43c5f..726bc3905 100644 --- a/scripts/Dpkg/Source/Package/V3/native.pm +++ b/scripts/Dpkg/Source/Package/V3/native.pm @@ -38,10 +38,10 @@ our $CURRENT_MINOR_VERSION = "0"; sub do_extract { my ($self, $newdirectory) = @_; - my $sourcestyle = $self->{'options'}{'sourcestyle'}; - my $fields = $self->{'fields'}; + my $sourcestyle = $self->{options}{sourcestyle}; + my $fields = $self->{fields}; - my $dscdir = $self->{'basedir'}; + my $dscdir = $self->{basedir}; my $basename = $self->get_basename(); my $basenamerev = $self->get_basename(1); @@ -69,17 +69,17 @@ sub can_build { sub do_build { my ($self, $dir) = @_; - my @tar_ignore = map { "--exclude=$_" } @{$self->{'options'}{'tar_ignore'}}; - my @argv = @{$self->{'options'}{'ARGV'}}; + my @tar_ignore = map { "--exclude=$_" } @{$self->{options}{tar_ignore}}; + my @argv = @{$self->{options}{ARGV}}; if (scalar(@argv)) { usageerr(_g("-b takes only one parameter with format `%s'"), - $self->{'fields'}{'Format'}); + $self->{fields}{'Format'}); } - my $sourcepackage = $self->{'fields'}{'Source'}; + my $sourcepackage = $self->{fields}{'Source'}; my $basenamerev = $self->get_basename(1); - my $tarname = "$basenamerev.tar." . $self->{'options'}{'comp_ext'}; + my $tarname = "$basenamerev.tar." . $self->{options}{comp_ext}; info(_g("building %s in %s"), $sourcepackage, $tarname); @@ -90,7 +90,7 @@ sub do_build { my ($dirname, $dirbase) = fileparse($dir); my $tar = Dpkg::Source::Archive->new(filename => $newtar, compression => compression_guess_from_filename($tarname), - compression_level => $self->{'options'}{'comp_level'}); + compression_level => $self->{options}{comp_level}); $tar->create(options => \@tar_ignore, chdir => $dirbase); $tar->add_directory($dirname); $tar->finish(); diff --git a/scripts/Dpkg/Source/Package/V3/quilt.pm b/scripts/Dpkg/Source/Package/V3/quilt.pm index dee4c1760..7ebee244f 100644 --- a/scripts/Dpkg/Source/Package/V3/quilt.pm +++ b/scripts/Dpkg/Source/Package/V3/quilt.pm @@ -38,10 +38,10 @@ our $CURRENT_MINOR_VERSION = "0"; sub init_options { my ($self) = @_; - $self->{'options'}{'single_debian_patch'} = 0 - unless exists $self->{'options'}{'single_debian_patch'}; - $self->{'options'}{'allow_version_of_quilt_db'} = [] - unless exists $self->{'options'}{'allow_version_of_quilt_db'}; + $self->{options}{single_debian_patch} = 0 + unless exists $self->{options}{single_debian_patch}; + $self->{options}{allow_version_of_quilt_db} = [] + unless exists $self->{options}{allow_version_of_quilt_db}; $self->SUPER::init_options(); } @@ -50,12 +50,12 @@ sub parse_cmdline_option { my ($self, $opt) = @_; return 1 if $self->SUPER::parse_cmdline_option($opt); if ($opt =~ /^--single-debian-patch$/) { - $self->{'options'}{'single_debian_patch'} = 1; + $self->{options}{single_debian_patch} = 1; # For backwards compatibility. - $self->{'options'}{'auto_commit'} = 1; + $self->{options}{auto_commit} = 1; return 1; } elsif ($opt =~ /^--allow-version-of-quilt-db=(.*)$/) { - push @{$self->{'options'}{'allow_version_of_quilt_db'}}, $1; + push @{$self->{options}{allow_version_of_quilt_db}}, $1; return 1; } return 0; @@ -63,9 +63,9 @@ sub parse_cmdline_option { sub build_quilt_object { my ($self, $dir) = @_; - return $self->{'quilt'}{$dir} if exists $self->{'quilt'}{$dir}; - $self->{'quilt'}{$dir} = Dpkg::Source::Quilt->new($dir); - return $self->{'quilt'}{$dir}; + return $self->{quilt}{$dir} if exists $self->{quilt}{$dir}; + $self->{quilt}{$dir} = Dpkg::Source::Quilt->new($dir); + return $self->{quilt}{$dir}; } sub can_build { @@ -80,25 +80,25 @@ sub can_build { sub get_autopatch_name { my ($self) = @_; - if ($self->{'options'}{'single_debian_patch'}) { + if ($self->{options}{single_debian_patch}) { return "debian-changes"; } else { - return "debian-changes-" . $self->{'fields'}{'Version'}; + return "debian-changes-" . $self->{fields}{'Version'}; } } sub apply_patches { my ($self, $dir, %opts) = @_; - if ($opts{'usage'} eq 'unpack') { - $opts{'verbose'} = 1; - } elsif ($opts{'usage'} eq 'build') { - $opts{'warn_options'} = 1; - $opts{'verbose'} = 0; + if ($opts{usage} eq 'unpack') { + $opts{verbose} = 1; + } elsif ($opts{usage} eq 'build') { + $opts{warn_options} = 1; + $opts{verbose} = 0; } my $quilt = $self->build_quilt_object($dir); - $quilt->load_series(%opts) if $opts{'warn_options'}; # Trigger warnings + $quilt->load_series(%opts) if $opts{warn_options}; # Trigger warnings # Always create the quilt db so that if the maintainer calls quilt to # create a patch, it's stored in the right directory @@ -118,8 +118,8 @@ sub apply_patches { return unless scalar($quilt->series()); - if ($opts{'usage'} eq "preparation" and - $self->{'options'}{'unapply_patches'} eq 'auto') { + if ($opts{usage} eq "preparation" and + $self->{options}{unapply_patches} eq 'auto') { # We're applying the patches in --before-build, remember to unapply # them afterwards in --after-build my $pc_unapply = $quilt->get_db_file(".dpkg-source-unapply"); @@ -130,8 +130,8 @@ sub apply_patches { # Apply patches my $pc_applied = $quilt->get_db_file("applied-patches"); - $opts{"timestamp"} = fs_time($pc_applied); - if ($opts{"skip_auto"}) { + $opts{timestamp} = fs_time($pc_applied); + if ($opts{skip_auto}) { my $auto_patch = $self->get_autopatch_name(); $quilt->push(%opts) while ($quilt->next() and $quilt->next() ne $auto_patch); } else { @@ -144,11 +144,11 @@ sub unapply_patches { my $quilt = $self->build_quilt_object($dir); - $opts{'verbose'} //= 1; + $opts{verbose} //= 1; my $pc_applied = $quilt->get_db_file("applied-patches"); my @applied = $quilt->applied(); - $opts{"timestamp"} = fs_time($pc_applied) if @applied; + $opts{timestamp} = fs_time($pc_applied) if @applied; $quilt->pop(%opts) while $quilt->top(); @@ -164,10 +164,10 @@ sub prepare_build { my $func = sub { return 1 if $_[0] =~ m{^debian/patches/series$} and -l $_[0]; return 1 if $_[0] =~ /^\.pc(\/|$)/; - return 1 if $_[0] =~ /$self->{'options'}{'diff_ignore_regexp'}/; + 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 do_build { @@ -178,7 +178,7 @@ sub do_build { if (defined($version) and $version != 2) { if (scalar grep { $version eq $_ } - @{$self->{'options'}{'allow_version_of_quilt_db'}}) + @{$self->{options}{allow_version_of_quilt_db}}) { warning(_g("unsupported version of the quilt metadata: %s"), $version); } else { @@ -193,7 +193,7 @@ sub after_build { my ($self, $dir) = @_; my $quilt = $self->build_quilt_object($dir); my $pc_unapply = $quilt->get_db_file(".dpkg-source-unapply"); - my $opt_unapply = $self->{'options'}{'unapply_patches'}; + my $opt_unapply = $self->{options}{unapply_patches}; if (($opt_unapply eq "auto" and -e $pc_unapply) or $opt_unapply eq "yes") { unlink($pc_unapply); $self->unapply_patches($dir); diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm index a43983bb5..97bdc788b 100644 --- a/scripts/Dpkg/Source/Patch.pm +++ b/scripts/Dpkg/Source/Patch.pm @@ -41,31 +41,31 @@ use base 'Dpkg::Compression::FileHandle'; sub create { my ($self, %opts) = @_; $self->ensure_open("w"); # Creates the file - *$self->{'errors'} = 0; - *$self->{'empty'} = 1; - if ($opts{'old'} and $opts{'new'}) { - $opts{'old'} = "/dev/null" unless -e $opts{'old'}; - $opts{'new'} = "/dev/null" unless -e $opts{'new'}; - if (-d $opts{'old'} and -d $opts{'new'}) { - $self->add_diff_directory($opts{'old'}, $opts{'new'}, %opts); - } elsif (-f $opts{'old'} and -f $opts{'new'}) { - $self->add_diff_file($opts{'old'}, $opts{'new'}, %opts); + *$self->{errors} = 0; + *$self->{empty} = 1; + if ($opts{old} and $opts{new}) { + $opts{old} = "/dev/null" unless -e $opts{old}; + $opts{new} = "/dev/null" unless -e $opts{new}; + if (-d $opts{old} and -d $opts{new}) { + $self->add_diff_directory($opts{old}, $opts{new}, %opts); + } elsif (-f $opts{old} and -f $opts{new}) { + $self->add_diff_file($opts{old}, $opts{new}, %opts); } else { - $self->_fail_not_same_type($opts{'old'}, $opts{'new'}); + $self->_fail_not_same_type($opts{old}, $opts{new}); } - $self->finish() unless $opts{"nofinish"}; + $self->finish() unless $opts{nofinish}; } } sub set_header { my ($self, $header) = @_; - *$self->{'header'} = $header; + *$self->{header} = $header; } sub add_diff_file { my ($self, $old, $new, %opts) = @_; - $opts{"include_timestamp"} = 0 unless exists $opts{"include_timestamp"}; - my $handle_binary = $opts{"handle_binary_func"} || sub { + $opts{include_timestamp} = 0 unless exists $opts{include_timestamp}; + my $handle_binary = $opts{handle_binary_func} || sub { my ($self, $old, $new) = @_; $self->_fail_with_msg($new, _g("binary file contents changed")); }; @@ -73,29 +73,29 @@ sub add_diff_file { return 1 if compare($old, $new, 4096) == 0; # Default diff options my @options; - if ($opts{"options"}) { - push @options, @{$opts{"options"}}; + if ($opts{options}) { + push @options, @{$opts{options}}; } else { push @options, '-p'; } # Add labels - if ($opts{"label_old"} and $opts{"label_new"}) { - if ($opts{"include_timestamp"}) { + if ($opts{label_old} and $opts{label_new}) { + if ($opts{include_timestamp}) { my $ts = (stat($old))[9]; my $t = POSIX::strftime("%Y-%m-%d %H:%M:%S", gmtime($ts)); - $opts{"label_old"} .= sprintf("\t%s.%09d +0000", $t, + $opts{label_old} .= sprintf("\t%s.%09d +0000", $t, ($ts-int($ts))*1000000000); $ts = (stat($new))[9]; $t = POSIX::strftime("%Y-%m-%d %H:%M:%S", gmtime($ts)); - $opts{"label_new"} .= sprintf("\t%s.%09d +0000", $t, + $opts{label_new} .= sprintf("\t%s.%09d +0000", $t, ($ts-int($ts))*1000000000); } else { # Space in filenames need special treatment - $opts{"label_old"} .= "\t" if $opts{"label_old"} =~ / /; - $opts{"label_new"} .= "\t" if $opts{"label_new"} =~ / /; + $opts{label_old} .= "\t" if $opts{label_old} =~ / /; + $opts{label_new} .= "\t" if $opts{label_new} =~ / /; } - push @options, "-L", $opts{"label_old"}, - "-L", $opts{"label_new"}; + push @options, "-L", $opts{label_old}, + "-L", $opts{label_new}; } # Generate diff my $diffgen; @@ -121,9 +121,9 @@ sub add_diff_file { chomp; error(_g("unknown line from diff -u on %s: `%s'"), $new, $_); } - if (*$self->{'empty'} and defined(*$self->{'header'})) { - $self->print(*$self->{'header'}) or syserr(_g("failed to write")); - *$self->{'empty'} = 0; + if (*$self->{empty} and defined(*$self->{header})) { + $self->print(*$self->{header}) or syserr(_g("failed to write")); + *$self->{empty} = 0; } print $self $_ || syserr(_g("failed to write")); } @@ -144,13 +144,13 @@ sub add_diff_directory { my ($self, $old, $new, %opts) = @_; # TODO: make this function more configurable # - offer to disable some checks - my $basedir = $opts{"basedirname"} || basename($new); - my $inc_removal = $opts{"include_removal"} || 0; + my $basedir = $opts{basedirname} || basename($new); + my $inc_removal = $opts{include_removal} || 0; my $diff_ignore; - if ($opts{"diff_ignore_func"}) { - $diff_ignore = $opts{"diff_ignore_func"}; - } elsif ($opts{"diff_ignore_regexp"}) { - $diff_ignore = sub { return $_[0] =~ /$opts{"diff_ignore_regexp"}/o }; + if ($opts{diff_ignore_func}) { + $diff_ignore = $opts{diff_ignore_func}; + } elsif ($opts{diff_ignore_regexp}) { + $diff_ignore = sub { return $_[0] =~ /$opts{diff_ignore_regexp}/o }; } else { $diff_ignore = sub { return 0 }; } @@ -188,7 +188,7 @@ sub add_diff_directory { } my $label_old = "$basedir.orig/$fn"; - if ($opts{'use_dev_null'}) { + if ($opts{use_dev_null}) { $label_old = $old_file if $old_file eq '/dev/null'; } push @diff_files, [$fn, $mode, $size, $old_file, "$new/$fn", @@ -235,13 +235,13 @@ sub add_diff_directory { find({ wanted => $scan_new, no_chdir => 1 }, $new); find({ wanted => $scan_old, no_chdir => 1 }, $old); - if ($opts{"order_from"} and -e $opts{"order_from"}) { + if ($opts{order_from} and -e $opts{order_from}) { my $order_from = Dpkg::Source::Patch->new( - filename => $opts{"order_from"}); + filename => $opts{order_from}); my $analysis = $order_from->analyze($basedir, verbose => 0); my %patchorder; my $i = 0; - foreach my $fn (@{$analysis->{"patchorder"}}) { + foreach my $fn (@{$analysis->{patchorder}}) { $fn =~ s{^[^/]+/}{}; $patchorder{$fn} = $i++; } @@ -288,12 +288,12 @@ sub add_diff_directory { sub finish { my ($self) = @_; close($self) || syserr(_g("cannot close %s"), $self->get_filename()); - return not *$self->{'errors'}; + return not *$self->{errors}; } sub register_error { my ($self) = @_; - *$self->{'errors'}++; + *$self->{errors}++; } sub _fail_with_msg { my ($self, $file, $msg) = @_; @@ -371,7 +371,7 @@ sub _intuit_file_patched { sub analyze { my ($self, $destdir, %opts) = @_; - $opts{"verbose"} //= 1; + $opts{verbose} //= 1; my $diff = $self->get_filename(); my %filepatched; my %dirtocreate; @@ -398,8 +398,8 @@ sub analyze { unless(s/^--- //) { error(_g("expected ^--- in line %d of diff `%s'"), $., $diff); } - $path{'old'} = $_ = _strip_ts($_); - $fn{'old'} = $_ if $_ ne '/dev/null' and s{^[^/]*/+}{$destdir/}; + $path{old} = $_ = _strip_ts($_); + $fn{old} = $_ if $_ ne '/dev/null' and s{^[^/]*/+}{$destdir/}; if (/\.dpkg-orig$/) { error(_g("diff `%s' patches file with name ending .dpkg-orig"), $diff); } @@ -410,10 +410,10 @@ sub analyze { unless (s/^\+\+\+ //) { error(_g("line after --- isn't as expected in diff `%s' (line %d)"), $diff, $.); } - $path{'new'} = $_ = _strip_ts($_); - $fn{'new'} = $_ if $_ ne '/dev/null' and s{^[^/]*/+}{$destdir/}; + $path{new} = $_ = _strip_ts($_); + $fn{new} = $_ if $_ ne '/dev/null' and s{^[^/]*/+}{$destdir/}; - unless (defined $fn{'old'} or defined $fn{'new'}) { + unless (defined $fn{old} or defined $fn{new}) { error(_g("none of the filenames in ---/+++ are valid in diff '%s' (line %d)"), $diff, $.); } @@ -435,18 +435,18 @@ sub analyze { } } - if ($path{'old'} eq '/dev/null' and $path{'new'} eq '/dev/null') { + if ($path{old} eq '/dev/null' and $path{new} eq '/dev/null') { error(_g("original and modified files are /dev/null in diff `%s' (line %d)"), $diff, $.); - } elsif ($path{'new'} eq '/dev/null') { + } elsif ($path{new} eq '/dev/null') { error(_g("file removal without proper filename in diff `%s' (line %d)"), - $diff, $. - 1) unless defined $fn{'old'}; - if ($opts{"verbose"}) { + $diff, $. - 1) unless defined $fn{old}; + if ($opts{verbose}) { warning(_g("diff %s removes a non-existing file %s (line %d)"), - $diff, $fn{'old'}, $.) unless -e $fn{'old'}; + $diff, $fn{old}, $.) unless -e $fn{old}; } } - my $fn = _intuit_file_patched($fn{'old'}, $fn{'new'}); + my $fn = _intuit_file_patched($fn{old}, $fn{new}); my $dirname = $fn; if ($dirname =~ s{/[^/]+$}{} && not -d $dirname) { @@ -459,7 +459,7 @@ sub analyze { if ($filepatched{$fn}) { warning(_g("diff `%s' patches file %s twice"), $diff, $fn) - if $opts{"verbose"}; + if $opts{verbose}; } else { $filepatched{$fn} = 1; push @patchorder, $fn; @@ -477,7 +477,7 @@ sub analyze { unless (defined($_ = _getline($self))) { if (($olines == $nlines) and ($olines < 3)) { warning(_g("unexpected end of diff `%s'"), $diff) - if $opts{"verbose"}; + if $opts{verbose}; last; } else { error(_g("unexpected end of diff `%s'"), $diff); @@ -502,19 +502,19 @@ sub analyze { close($self); unless ($diff_count) { warning(_g("diff `%s' doesn't contain any patch"), $diff) - if $opts{"verbose"}; + if $opts{verbose}; } - *$self->{'analysis'}{$destdir}{"dirtocreate"} = \%dirtocreate; - *$self->{'analysis'}{$destdir}{"filepatched"} = \%filepatched; - *$self->{'analysis'}{$destdir}{"patchorder"} = \@patchorder; - *$self->{'analysis'}{$destdir}{"patchheader"} = $patch_header; - return *$self->{'analysis'}{$destdir}; + *$self->{analysis}{$destdir}{dirtocreate} = \%dirtocreate; + *$self->{analysis}{$destdir}{filepatched} = \%filepatched; + *$self->{analysis}{$destdir}{patchorder} = \@patchorder; + *$self->{analysis}{$destdir}{patchheader} = $patch_header; + return *$self->{analysis}{$destdir}; } sub prepare_apply { my ($self, $analysis, %opts) = @_; - if ($opts{"create_dirs"}) { - foreach my $dir (keys %{$analysis->{'dirtocreate'}}) { + if ($opts{create_dirs}) { + foreach my $dir (keys %{$analysis->{dirtocreate}}) { eval { mkpath($dir, 0, 0777); }; syserr(_g("cannot create directory %s"), $dir) if $@; } @@ -524,13 +524,13 @@ sub prepare_apply { sub apply { my ($self, $destdir, %opts) = @_; # Set default values to options - $opts{"force_timestamp"} = 1 unless exists $opts{"force_timestamp"}; - $opts{"remove_backup"} = 1 unless exists $opts{"remove_backup"}; - $opts{"create_dirs"} = 1 unless exists $opts{"create_dirs"}; - $opts{"options"} ||= [ '-t', '-F', '0', '-N', '-p1', '-u', + $opts{force_timestamp} = 1 unless exists $opts{force_timestamp}; + $opts{remove_backup} = 1 unless exists $opts{remove_backup}; + $opts{create_dirs} = 1 unless exists $opts{create_dirs}; + $opts{options} ||= [ '-t', '-F', '0', '-N', '-p1', '-u', '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig']; - $opts{"add_options"} ||= []; - push @{$opts{"options"}}, @{$opts{"add_options"}}; + $opts{add_options} ||= []; + push @{$opts{options}}, @{$opts{add_options}}; # Check the diff and create missing directories my $analysis = $self->analyze($destdir, %opts); $self->prepare_apply($analysis, %opts); @@ -538,7 +538,7 @@ sub apply { $self->ensure_open("r"); my ($stdout, $stderr) = ('', ''); spawn( - exec => [ 'patch', @{$opts{"options"}} ], + exec => [ 'patch', @{$opts{options}} ], chdir => $destdir, env => { LC_ALL => 'C', LANG => 'C' }, delete_env => [ 'POSIXLY_CORRECT' ], # ensure expected patch behaviour @@ -551,21 +551,21 @@ sub apply { if ($?) { print STDOUT $stdout; print STDERR $stderr; - subprocerr("LC_ALL=C patch " . join(" ", @{$opts{"options"}}) . + subprocerr("LC_ALL=C patch " . join(" ", @{$opts{options}}) . " < " . $self->get_filename()); } $self->close(); # Reset the timestamp of all the patched files # and remove .dpkg-orig files - my @files = keys %{$analysis->{'filepatched'}}; - my $now = $opts{"timestamp"}; - $now ||= fs_time($files[0]) if $opts{"force_timestamp"} and scalar @files; + my @files = keys %{$analysis->{filepatched}}; + my $now = $opts{timestamp}; + $now ||= fs_time($files[0]) if $opts{force_timestamp} and scalar @files; foreach my $fn (@files) { - if ($opts{"force_timestamp"}) { + if ($opts{force_timestamp}) { utime($now, $now, $fn) || $! == ENOENT || syserr(_g("cannot change timestamp for %s"), $fn); } - if ($opts{"remove_backup"}) { + if ($opts{remove_backup}) { $fn .= ".dpkg-orig"; unlink($fn) || syserr(_g("remove patch backup file %s"), $fn); } @@ -577,11 +577,11 @@ sub apply { sub check_apply { my ($self, $destdir, %opts) = @_; # Set default values to options - $opts{"create_dirs"} = 1 unless exists $opts{"create_dirs"}; - $opts{"options"} ||= [ '--dry-run', '-s', '-t', '-F', '0', '-N', '-p1', '-u', + $opts{create_dirs} = 1 unless exists $opts{create_dirs}; + $opts{options} ||= [ '--dry-run', '-s', '-t', '-F', '0', '-N', '-p1', '-u', '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig']; - $opts{"add_options"} ||= []; - push @{$opts{"options"}}, @{$opts{"add_options"}}; + $opts{add_options} ||= []; + push @{$opts{options}}, @{$opts{add_options}}; # Check the diff and create missing directories my $analysis = $self->analyze($destdir, %opts); $self->prepare_apply($analysis, %opts); @@ -589,7 +589,7 @@ sub check_apply { $self->ensure_open("r"); my $error; my $patch_pid = spawn( - exec => [ 'patch', @{$opts{"options"}} ], + exec => [ 'patch', @{$opts{options}} ], chdir => $destdir, env => { LC_ALL => 'C', LANG => 'C' }, delete_env => [ 'POSIXLY_CORRECT' ], # ensure expected patch behaviour diff --git a/scripts/Dpkg/Source/Quilt.pm b/scripts/Dpkg/Source/Quilt.pm index 2edb14824..9c7c949ea 100644 --- a/scripts/Dpkg/Source/Quilt.pm +++ b/scripts/Dpkg/Source/Quilt.pm @@ -82,7 +82,7 @@ sub load_db { my ($self) = @_; my $pc_applied = $self->get_db_file("applied-patches"); - $self->{'applied_patches'} = [ $self->read_patch_list($pc_applied) ]; + $self->{applied_patches} = [ $self->read_patch_list($pc_applied) ]; } sub write_db { @@ -92,7 +92,7 @@ sub write_db { my $pc_applied = $self->get_db_file("applied-patches"); open(my $applied_fh, ">", $pc_applied) or syserr(_g("cannot write %s"), $pc_applied); - foreach my $patch (@{$self->{'applied_patches'}}) { + foreach my $patch (@{$self->{applied_patches}}) { print $applied_fh "$patch\n"; } close($applied_fh); @@ -102,38 +102,38 @@ sub load_series { my ($self, %opts) = @_; my $series = $self->get_series_file(); - $self->{'series'} = [ $self->read_patch_list($series, %opts) ]; + $self->{series} = [ $self->read_patch_list($series, %opts) ]; } sub series { my ($self) = @_; - return @{$self->{'series'}}; + return @{$self->{series}}; } sub applied { my ($self) = @_; - return @{$self->{'applied_patches'}}; + return @{$self->{applied_patches}}; } sub top { my ($self) = @_; - my $count = scalar @{$self->{'applied_patches'}}; - return $self->{'applied_patches'}[$count - 1] if $count; + my $count = scalar @{$self->{applied_patches}}; + return $self->{applied_patches}[$count - 1] if $count; return; } sub next { my ($self) = @_; - my $count_applied = scalar @{$self->{'applied_patches'}}; - my $count_series = scalar @{$self->{'series'}}; - return $self->{'series'}[$count_applied] if ($count_series > $count_applied); + my $count_applied = scalar @{$self->{applied_patches}}; + my $count_series = scalar @{$self->{series}}; + return $self->{series}[$count_applied] if ($count_series > $count_applied); return; } sub push { my ($self, %opts) = @_; - $opts{"verbose"} //= 0; - $opts{"timestamp"} //= fs_time($self->{'dir'}); + $opts{verbose} //= 0; + $opts{timestamp} //= fs_time($self->{dir}); my $patch = $self->next(); return unless defined $patch; @@ -141,10 +141,10 @@ sub push { my $path = $self->get_patch_file($patch); my $obj = Dpkg::Source::Patch->new(filename => $path); - info(_g("applying %s"), $patch) if $opts{"verbose"}; + info(_g("applying %s"), $patch) if $opts{verbose}; eval { - $obj->apply($self->{'dir'}, timestamp => $opts{"timestamp"}, - verbose => $opts{"verbose"}, + $obj->apply($self->{dir}, timestamp => $opts{timestamp}, + verbose => $opts{verbose}, force_timestamp => 1, create_dirs => 1, remove_backup => 0, options => [ '-t', '-F', '0', '-N', '-p1', '-u', '-V', 'never', '-g0', '-E', '-b', @@ -158,22 +158,22 @@ sub push { erasedir($self->get_db_file($patch)); die $@; } - CORE::push @{$self->{'applied_patches'}}, $patch; + CORE::push @{$self->{applied_patches}}, $patch; $self->write_db(); } sub pop { my ($self, %opts) = @_; - $opts{"verbose"} //= 0; - $opts{"timestamp"} //= fs_time($self->{'dir'}); - $opts{"reverse_apply"} //= 0; + $opts{verbose} //= 0; + $opts{timestamp} //= fs_time($self->{dir}); + $opts{reverse_apply} //= 0; my $patch = $self->top(); return unless defined $patch; - info(_g("unapplying %s"), $patch) if $opts{"verbose"}; + info(_g("unapplying %s"), $patch) if $opts{verbose}; my $backup_dir = $self->get_db_file($patch); - if (-d $backup_dir and not $opts{"reverse_apply"}) { + if (-d $backup_dir and not $opts{reverse_apply}) { # Use the backup copies to restore $self->restore_quilt_backup_files($patch); } else { @@ -181,7 +181,7 @@ sub pop { my $path = $self->get_patch_file($patch); my $obj = Dpkg::Source::Patch->new(filename => $path); - $obj->apply($self->{'dir'}, timestamp => $opts{"timestamp"}, + $obj->apply($self->{dir}, timestamp => $opts{timestamp}, verbose => 0, force_timestamp => 1, remove_backup => 0, options => [ '-R', '-t', '-N', '-p1', '-u', '-V', 'never', '-g0', '-E', @@ -189,7 +189,7 @@ sub pop { } erasedir($backup_dir); - pop @{$self->{'applied_patches'}}; + pop @{$self->{applied_patches}}; $self->write_db(); } @@ -231,7 +231,7 @@ sub get_series_file { sub get_db_file { my $self = shift; - return File::Spec->catfile($self->{'dir'}, ".pc", @_); + return File::Spec->catfile($self->{dir}, ".pc", @_); } sub get_db_dir { @@ -241,7 +241,7 @@ sub get_db_dir { sub get_patch_file { my $self = shift; - return File::Spec->catfile($self->{'dir'}, "debian", "patches", @_); + return File::Spec->catfile($self->{dir}, "debian", "patches", @_); } sub get_patch_dir { @@ -254,7 +254,7 @@ sub get_patch_dir { sub read_patch_list { my ($self, $file, %opts) = @_; return () if not defined $file or not -f $file; - $opts{"warn_options"} //= 0; + $opts{warn_options} //= 0; my @patches; open(my $series_fh, "<" , $file) || syserr(_g("cannot read %s"), $file); while (defined($_ = <$series_fh>)) { @@ -267,7 +267,7 @@ sub read_patch_list { warning(_g("the series file (%s) contains unsupported " . "options ('%s', line %s); dpkg-source might " . "fail when applying patches"), - $file, $2, $.) if $opts{"warn_options"}; + $file, $2, $.) if $opts{warn_options}; } } error(_g("%s contains an insecure path: %s"), $file, $_) if m{(^|/)\.\./}; @@ -281,13 +281,13 @@ sub restore_quilt_backup_files { my ($self, $patch, %opts) = @_; my $patch_dir = $self->get_db_file($patch); return unless -d $patch_dir; - info(_g("restoring quilt backup files for %s"), $patch) if $opts{'verbose'}; + info(_g("restoring quilt backup files for %s"), $patch) if $opts{verbose}; find({ no_chdir => 1, wanted => sub { return if -d $_; my $relpath_in_srcpkg = File::Spec->abs2rel($_, $patch_dir); - my $target = File::Spec->catfile($self->{'dir'}, $relpath_in_srcpkg); + my $target = File::Spec->catfile($self->{dir}, $relpath_in_srcpkg); if (-s $_) { unlink($target); make_path(dirname($target)); |