ソースを参照

dpkg-scansources: implement --extra-override

Raphaël Hertzog 17 年 前
コミット
b636de1a3e
共有3 個のファイルを変更した36 個の追加0 個の削除を含む
  1. 1 0
      debian/changelog
  2. 4 0
      man/dpkg-scansources.1
  3. 31 0
      scripts/dpkg-scansources.pl

+ 1 - 0
debian/changelog

@@ -51,6 +51,7 @@ dpkg (1.15.4) UNRELEASED; urgency=low
     be installed due to a conflicting file instead of quoting the master link.
     be installed due to a conflicting file instead of quoting the master link.
   * Add support for extra override file in dpkg-scanpackages. Thanks to Robert
   * Add support for extra override file in dpkg-scanpackages. Thanks to Robert
     Millan for the patch. Closes: #537559
     Millan for the patch. Closes: #537559
+  * Add support for extra override file in dpkg-scansources.
   * Update sample in dpkg-gensymbols(1) to give an accurate listing of
   * Update sample in dpkg-gensymbols(1) to give an accurate listing of
     64 bit arches. Thanks to Julien Cristau for the patch. Closes: #540382
     64 bit arches. Thanks to Julien Cristau for the patch. Closes: #540382
   * Create /etc/cron.daily/dpkg to handle the backup of
   * Create /etc/cron.daily/dpkg to handle the backup of

+ 4 - 0
man/dpkg-scansources.1

@@ -46,6 +46,10 @@ sources).
 .IP "\fB\-n\fR, \fB\-\-no\-sort\fR" 4
 .IP "\fB\-n\fR, \fB\-\-no\-sort\fR" 4
 Don't sort the index records. Normally they are sorted by source package
 Don't sort the index records. Normally they are sorted by source package
 name.
 name.
+.TP
+.IP "\fB\-e\fR, \fB\-\-extra\-override\fR \fIfile\fP" 4
+Scan \fIfile\fP to find supplementary overrides. Each line contains 3
+space separated fields: package name, field name to override, new field value.
 .IP "\fB\-s\fR, \fB\-\-source\-override\fR \fIfile\fR" 4
 .IP "\fB\-s\fR, \fB\-\-source\-override\fR \fIfile\fR" 4
 Use \fIfile\fR as the source override file. The default is the name of the
 Use \fIfile\fR as the source override file. The default is the name of the
 override file you specified with \fI.src\fR appended.
 override file you specified with \fI.src\fR appended.

+ 31 - 0
scripts/dpkg-scansources.pl

@@ -48,6 +48,7 @@ sub O_PRIORITY		() { 0 }
 sub O_SECTION		() { 1 }
 sub O_SECTION		() { 1 }
 sub O_MAINT_FROM	() { 2 } # undef for non-specific, else listref
 sub O_MAINT_FROM	() { 2 } # undef for non-specific, else listref
 sub O_MAINT_TO		() { 3 } # undef if there's no maint override
 sub O_MAINT_TO		() { 3 } # undef if there's no maint override
+my %Extra_Override;
 
 
 my %Priority = (
 my %Priority = (
      'extra'		=> 1,
      'extra'		=> 1,
@@ -62,12 +63,14 @@ my %Priority = (
 my $Debug	= 0;
 my $Debug	= 0;
 my $No_sort	= 0;
 my $No_sort	= 0;
 my $Src_override = undef;
 my $Src_override = undef;
+my $Extra_override_file = undef;
 
 
 my @Option_spec = (
 my @Option_spec = (
     'debug!'		=> \$Debug,
     'debug!'		=> \$Debug,
     'help!'		=> \&usage,
     'help!'		=> \&usage,
     'no-sort|n'		=> \$No_sort,
     'no-sort|n'		=> \$No_sort,
     'source-override|s=s' => \$Src_override,
     'source-override|s=s' => \$Src_override,
+    'extra-override|e=s' => \$Extra_override_file,
     'version'		=> \&version,
     'version'		=> \&version,
 );
 );
 
 
@@ -86,6 +89,8 @@ sub usage {
 
 
 Options:
 Options:
   -n, --no-sort            don't sort by package before outputting.
   -n, --no-sort            don't sort by package before outputting.
+  -e, --extra-override <file>
+                           use extra override file.
   -s, --source-override <file>
   -s, --source-override <file>
                            use file for additional source overrides, default
                            use file for additional source overrides, default
                            is regular override file with .src appended.
                            is regular override file with .src appended.
@@ -221,6 +226,23 @@ sub load_src_override {
     close SRC_OVERRIDE or syserr(_g("error closing source override file"));
     close SRC_OVERRIDE or syserr(_g("error closing source override file"));
 }
 }
 
 
+sub load_override_extra
+{
+    my $extra_override = shift;
+    open(OVERRIDE, "<", $extra_override) or
+        syserr(_g("Couldn't open override file %s"), $extra_override);
+
+    while (<OVERRIDE>) {
+	s/\#.*//;
+	s/\s+$//;
+	next unless $_;
+
+	my ($p, $field, $value) = split(/\s+/, $_, 3);
+        $Extra_Override{$p}{$field} = $value;
+    }
+    close(OVERRIDE);
+}
+
 # Given PREFIX and DSC-FILE, process the file and returns the fields.
 # Given PREFIX and DSC-FILE, process the file and returns the fields.
 
 
 sub process_dsc {
 sub process_dsc {
@@ -280,6 +302,14 @@ sub process_dsc {
         }
         }
     }
     }
 
 
+    # Process extra override
+    if (exists $Extra_Override{$source}) {
+        my ($field, $value);
+        while(($field, $value) = each %{$Extra_Override{$source}}) {
+            $fields->{$field} = $value;
+        }
+    }
+
     # A directory field will be inserted just before the files field.
     # A directory field will be inserted just before the files field.
     my $dir;
     my $dir;
     $dir = ($file =~ s-(.*)/--) ? $1 : '';
     $dir = ($file =~ s-(.*)/--) ? $1 : '';
@@ -323,6 +353,7 @@ sub main {
 
 
     load_override $override if defined $override;
     load_override $override if defined $override;
     load_src_override $Src_override, $override;
     load_src_override $Src_override, $override;
+    load_extra_override $Extra_override_file if defined $Extra_override_file;
 
 
     open FIND, "find \Q$dir\E -follow -name '*.dsc' -print |"
     open FIND, "find \Q$dir\E -follow -name '*.dsc' -print |"
 	or syserr(_g("can't fork"));
 	or syserr(_g("can't fork"));