Skip to content

Commit

Permalink
check *_source.changes if they are valid debian source change files
Browse files Browse the repository at this point in the history
Without this commit all *.changes files are checked like changelog files

With this commit 40-sequence-changes checks if the file is a valid debian
source changes file when the filename matches *_source.changes, by searching
for all mandatory keywords in the file. If it is a valid debian source
changes file, further changelog checks are ommitted

Fixes #42
  • Loading branch information
M0ses committed Jul 26, 2017
1 parent d4384e5 commit 2641256
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 40-sequence-changes
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ FIRST_CHANGES=""
RETURN=0
for i in $DIR_TO_CHECK/*.changes ; do
test -f $i || continue
if [ $i != ${i%_source.changes} ];then
/usr/lib/obs/service/source_validators/helpers/check_debian_source_changes $i && continue
echo "(W) File ends with '_source.changes' but is not a valid debian source changes file"
fi
RETURN=0
test -n "$FIRST_CHANGES" || FIRST_CHANGES=$i
if test -n "$FIRST_CHANGES" -a "$FIRST_CHANGES" != "$i" ; then
Expand Down
21 changes: 21 additions & 0 deletions helpers/DebianSourceChangesValidator.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package DebianSourceChangesValidator;

use strict;
use warnings;

sub validate {
my ($fname) = @_;
my @mandatory = qw/Format Date Source Binary Architecture Version Distribution Maintainer Description Changes Checksums-Sha1 Checksums-Sha256 Files/;
my $re = '^('.join('|',@mandatory).'):.*';
my $result = {};

open(my $fh,$fname) || die "Could not open '$fname': $!\n";
while (my $line = <$fh>) { $line =~ m/$re/ && $result->{$1}++ }
close $fh;

for my $key (@mandatory) { return 1 if (! $result->{$key} ) }

return 0
}

1;
12 changes: 12 additions & 0 deletions helpers/check_debian_source_changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/perl

use strict;
use warnings;

BEGIN { unshift(@::INC,'/usr/lib/obs/service/source_validators/helpers/') }

use DebianSourceChangesValidator;

my $ev = DebianSourceChangesValidator::validate($ARGV[0]);

exit $ev;
Empty file modified source_validator
100644 → 100755
Empty file.

0 comments on commit 2641256

Please sign in to comment.