[omd-commits] OMD Git: omd: added new test checking if package contains any unusual files

git version control git at mathias-kettner.de
Sat Sep 14 18:34:47 CEST 2013


Module:   omd
Branch:   master
Commit:   9dc85294c6a0138adf20d12accd4f8c4e017d016
URL:      http://omdistro.org/projects/omd/repository/revisions/9dc85294c6a0138adf20d12accd4f8c4e017d016

Author:   Sven Nierlein <Sven.Nierlein at consol.de>
Date:     Sun Sep  8 18:51:50 2013 +0200
Commiter: Sven Nierlein <sven at consol.de>
Date:     Fri Sep 13 10:41:12 2013 +0200

added new test checking if package contains any unusual files

python seems to create /usr/local folders which should not be part
of the package. This test ensures this won't happen again.

---

 t/04-package_files.t |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/t/04-package_files.t b/t/04-package_files.t
new file mode 100644
index 0000000..5611574
--- /dev/null
+++ b/t/04-package_files.t
@@ -0,0 +1,56 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+use Test::More;
+
+plan skip_all => 'you need to specify OMD_PACKAGE for this test' unless defined $ENV{'OMD_PACKAGE'};
+
+my $file = $ENV{'OMD_PACKAGE'};
+ok(-f $file, "file: $file exists");
+
+# debian packages
+if($file =~ m/\.deb/gmx) {
+    my $content = `dpkg -c $file 2>&1`;
+    is($?, 0, 'got package content');
+    my @files = split("\n", $content);
+    ok(scalar @files > 0, 'got package '.(scalar @files).' files');
+    for my $e (@files) {
+        my($mode, $usr, $ref, $date, $time, $path) = split(/\s+/mx, $e);
+        next if file_ok($path);
+        fail("pkg contains unusual file: $e");
+    }
+}
+elsif($file =~ m/\.rpm/gmx) {
+    my $content = `rpm -qpl $file 2>&1`;
+    is($?, 0, 'got package content');
+    my @files = split("\n", $content);
+    ok(scalar @files > 0, 'got package '.(scalar @files).' files');
+    for my $e (@files) {
+        next if file_ok($e);
+        fail("pkg contains unusual file: $e");
+    }
+}
+else {
+    fail("unsupported pkg: $file");
+}
+
+done_testing();
+
+#################################################
+sub file_ok {
+    my($file) = @_;
+    $file =~ s/^\.//gmx;
+    return 1 if $file =~ m|/opt/|;
+    return 1 if $file =~ m|/usr/share/doc/omd|;
+    return 1 if $file =~ m|/etc/init.d/omd|;
+    return 1 if $file =~ m|/usr/share/man/|;
+    return 1 if $file eq '/';
+    return 1 if $file eq '/etc/';
+    return 1 if $file eq '/etc/init.d/';
+    return 1 if $file eq '/usr/';
+    return 1 if $file eq '/usr/share/';
+    return 1 if $file eq '/usr/share/doc/';
+    return;
+}
+



More information about the omd-commits mailing list