From: Raphael Hertzog Date: Sun, 16 Mar 2008 14:29:13 +0000 (+0100) Subject: Use default ignore rules for source package with format >> 1.0 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddf788627634080a39931061af354d8d8e15c433;p=dpkg Use default ignore rules for source package with format >> 1.0 * scripts/dpkg-source.pl: Remove default ignore patterns and move them... * scripts/Dpkg/Source/Package.pm: ...here. The init_options() method now will give default values to the corresponding options. * scripts/Dpkg/Source/Package/V2_0.pm (init_options): Call the parent init_options() to get the default ignore rules. * scripts/Dpkg/Source/Package/V1_0.pm: Don't call the parent init_options() as we don't want default values for format 1.0. --- diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 68c3a453..f43bd709 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -33,6 +33,57 @@ use Dpkg::Path qw(check_files_are_the_same); use POSIX; use File::Basename; +# Public variables +our $diff_ignore_default_regexp = ' +# Ignore general backup files +(?:^|/).*~$| +# Ignore emacs recovery files +(?:^|/)\.#.*$| +# Ignore vi swap files +(?:^|/)\..*\.swp$| +# Ignore baz-style junk files or directories +(?:^|/),,.*(?:$|/.*$)| +# File-names that should be ignored (never directories) +(?:^|/)(?:DEADJOE|\.cvsignore|\.arch-inventory|\.bzrignore|\.gitignore)$| +# File or directory names that should be ignored +(?:^|/)(?:CVS|RCS|\.deps|\{arch\}|\.arch-ids|\.svn|\.hg|_darcs|\.git| +\.shelf|_MTN|\.bzr(?:\.backup|tags)?)(?:$|/.*$) +'; +# Take out comments and newlines +$diff_ignore_default_regexp =~ s/^#.*$//mg; +$diff_ignore_default_regexp =~ s/\n//sg; +no warnings 'qw'; +our @tar_ignore_default_pattern = qw( +*.a +*.la +*.o +*.so +*.swp +*~ +,,* +.[#~]* +.arch-ids +.arch-inventory +.bzr +.bzr.backup +.bzr.tags +.bzrignore +.cvsignore +.deps +.git +.gitignore +.hg +.shelf +.svn +CVS +DEADJOE +RCS +_MTN +_darcs +{arch} +); + +# Private stuff my @dsc_fields = (qw(Format Source Binary Architecture Version Origin Maintainer Uploaders Dm-Upload-Allowed Homepage Standards-Version Vcs-Browser Vcs-Arch Vcs-Bzr @@ -61,6 +112,10 @@ sub new { sub init_options { my ($self) = @_; + # Use full ignore list by default + $self->{'options'}{'diff_ignore_regexp'} ||= $diff_ignore_default_regexp; + $self->{'options'}{'tar_ignore'} = [ @tar_ignore_default_pattern ] + unless @{$self->{'options'}{'tar_ignore'}}; } sub initialize { diff --git a/scripts/Dpkg/Source/Package/V1_0.pm b/scripts/Dpkg/Source/Package/V1_0.pm index 9c316877..3a4706cb 100644 --- a/scripts/Dpkg/Source/Package/V1_0.pm +++ b/scripts/Dpkg/Source/Package/V1_0.pm @@ -40,6 +40,8 @@ use File::Spec; sub init_options { my ($self) = @_; + # Don't call $self->SUPER::init_options() on purpose, V1.0 has no + # ignore by default $self->{'options'}{'sourcestyle'} ||= 'X'; } diff --git a/scripts/Dpkg/Source/Package/V2_0.pm b/scripts/Dpkg/Source/Package/V2_0.pm index cc4ced56..8a3d1e3f 100644 --- a/scripts/Dpkg/Source/Package/V2_0.pm +++ b/scripts/Dpkg/Source/Package/V2_0.pm @@ -39,6 +39,7 @@ use File::Spec; 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 diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 78030b39..eba1fbe0 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -30,56 +30,6 @@ my $controlfile; my $changelogfile; my $changelogformat; -my $diff_ignore_default_regexp = ' -# Ignore general backup files -(?:^|/).*~$| -# Ignore emacs recovery files -(?:^|/)\.#.*$| -# Ignore vi swap files -(?:^|/)\..*\.swp$| -# Ignore baz-style junk files or directories -(?:^|/),,.*(?:$|/.*$)| -# File-names that should be ignored (never directories) -(?:^|/)(?:DEADJOE|\.cvsignore|\.arch-inventory|\.bzrignore|\.gitignore)$| -# File or directory names that should be ignored -(?:^|/)(?:CVS|RCS|\.deps|\{arch\}|\.arch-ids|\.svn|\.hg|_darcs|\.git| -\.shelf|_MTN|\.bzr(?:\.backup|tags)?)(?:$|/.*$) -'; -# Take out comments and newlines -$diff_ignore_default_regexp =~ s/^#.*$//mg; -$diff_ignore_default_regexp =~ s/\n//sg; - -no warnings 'qw'; -my @tar_ignore_default_pattern = qw( -*.a -*.la -*.o -*.so -*.swp -*~ -,,* -.[#~]* -.arch-ids -.arch-inventory -.bzr -.bzr.backup -.bzr.tags -.bzrignore -.cvsignore -.deps -.git -.gitignore -.hg -.shelf -.svn -CVS -DEADJOE -RCS -_MTN -_darcs -{arch} -); - my @build_formats = ("1.0", "3.0 (native)"); my %options = ( # Compression related @@ -134,12 +84,12 @@ while (@ARGV && $ARGV[0] =~ m/^-/) { } elsif (m/^-U([^\=:]+)$/) { $remove{$1} = 1; } elsif (m/^-i(.*)$/) { - $options{'diff_ignore_regexp'} = $1 ? $1 : $diff_ignore_default_regexp; + $options{'diff_ignore_regexp'} = $1 ? $1 : $Dpkg::Source::Package::diff_ignore_default_regexp; } elsif (m/^-I(.+)$/) { push @{$options{'tar_ignore'}}, $1; } elsif (m/^-I$/) { unless ($tar_ignore_default_pattern_done) { - push @{$options{'tar_ignore'}}, @tar_ignore_default_pattern; + push @{$options{'tar_ignore'}}, @Dpkg::Source::Package::tar_ignore_default_pattern; # Prevent adding multiple times $tar_ignore_default_pattern_done = 1; } @@ -433,8 +383,8 @@ General options: 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), + $Dpkg::Source::Package::diff_ignore_default_regexp, + join(' ', map { "-I$_" } @Dpkg::Source::Package::tar_ignore_default_pattern), "@comp_supported"; }