summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2013-11-06 06:02:09 +0100
committerGuillem Jover <guillem@debian.org>2013-11-24 05:48:18 +0100
commit1919e88f193dfd98be05cd25acfe86e617cb2228 (patch)
treea5306d56ef9d837bd1241aa7f52778ca59b0ee00 /scripts
parent1cccaf0d0c509f9ac77f5448a0573e2d1c9c1ae4 (diff)
downloaddpkg-1919e88f193dfd98be05cd25acfe86e617cb2228.tar.gz
Dpkg::Source::Package: Deprecate public package variables
Replace direct usage of $diff_ignore_default_regexp and @tar_ignore_default_pattern with accessor functions. Addresses Variables::ProhibitPackageVars. Warned-by: perlcritic
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Dpkg/Source/Package.pm36
-rwxr-xr-xscripts/dpkg-source.pl11
2 files changed, 41 insertions, 6 deletions
diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm
index f2fef8bdf..266ec4ded 100644
--- a/scripts/Dpkg/Source/Package.pm
+++ b/scripts/Dpkg/Source/Package.pm
@@ -35,7 +35,7 @@ is the one that supports the extraction of the source package.
use strict;
use warnings;
-our $VERSION = '1.0';
+our $VERSION = '1.01';
use Dpkg::Gettext;
use Dpkg::ErrorHandling;
@@ -51,6 +51,10 @@ use Dpkg::Vendor qw(run_vendor_hook);
use POSIX qw(:errno_h :sys_wait_h);
use File::Basename;
+use Exporter qw(import);
+our @EXPORT_OK = qw(get_default_diff_ignore_regex
+ get_default_tar_ignore_pattern);
+
my $diff_ignore_default_regex = '
# Ignore general backup files
(?:^|/).*~$|
@@ -72,6 +76,8 @@ $diff_ignore_default_regex =~ s/^#.*$//mg;
$diff_ignore_default_regex =~ s/\n//sg;
# Public variables
+# XXX: Backwards compatibility, stop exporting on VERSION 2.00.
+## no critic (Variables::ProhibitPackageVars)
our $diff_ignore_default_regexp = $diff_ignore_default_regex;
no warnings 'qw'; ## no critic (TestingAndDebugging::ProhibitNoWarnings)
@@ -110,9 +116,30 @@ _MTN
_darcs
{arch}
);
+## use critic
=over 4
+=item my $string = get_default_diff_ignore_regex()
+
+Returns the default diff ignore regex.
+
+=cut
+
+sub get_default_diff_ignore_regex {
+ return $diff_ignore_default_regex;
+}
+
+=item my @array = get_default_tar_ignore_pattern()
+
+Returns the default tar ignore pattern, as an array.
+
+=cut
+
+sub get_default_tar_ignore_pattern {
+ return @tar_ignore_default_pattern;
+}
+
=item $p = Dpkg::Source::Package->new(filename => $dscfile, options => {})
Creates a new object corresponding to the source package described
@@ -565,6 +592,13 @@ sub write_dsc {
=back
+=head1 CHANGES
+
+=head2 Version 1.01
+
+New functions: get_default_diff_ignore_regex(), get_default_tar_ignore_pattern()
+Deprecated variables: $diff_ignore_default_regexp, @tar_ignore_default_pattern
+
=head1 AUTHOR
Raphaƫl Hertzog, E<lt>hertzog@debian.orgE<gt>
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index a2045eac8..7e2d0fa39 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -42,7 +42,8 @@ use Dpkg::Substvars;
use Dpkg::Version;
use Dpkg::Vars;
use Dpkg::Changelog::Parse;
-use Dpkg::Source::Package;
+use Dpkg::Source::Package qw(get_default_diff_ignore_regex
+ get_default_tar_ignore_pattern);
use Dpkg::Vendor qw(run_vendor_hook);
use Cwd;
@@ -76,7 +77,7 @@ my %override;
my $substvars = Dpkg::Substvars->new();
my $tar_ignore_default_pattern_done;
-my $diff_ignore_regex = $Dpkg::Source::Package::diff_ignore_default_regexp;
+my $diff_ignore_regex = get_default_diff_ignore_regex();
my @options;
my @cmdline_options;
@@ -178,7 +179,7 @@ while (@options) {
push @{$options{tar_ignore}}, $1;
} elsif (m/^-(?:I|-tar-ignore)$/) {
unless ($tar_ignore_default_pattern_done) {
- push @{$options{tar_ignore}}, @Dpkg::Source::Package::tar_ignore_default_pattern;
+ push @{$options{tar_ignore}}, get_default_tar_ignore_pattern();
# Prevent adding multiple times
$tar_ignore_default_pattern_done = 1;
}
@@ -517,8 +518,8 @@ sub usage {
'More options are available but they depend on the source package format.
See dpkg-source(1) for more info.') . "\n",
$Dpkg::PROGNAME,
- $Dpkg::Source::Package::diff_ignore_default_regexp,
- join(' ', map { "-I$_" } @Dpkg::Source::Package::tar_ignore_default_pattern),
+ get_default_diff_ignore_regex(),
+ join(' ', map { "-I$_" } get_default_tar_ignore_pattern()),
compression_get_default(),
join(' ', compression_get_list()),
compression_get_default_level();