]> granicus.if.org Git - ejabberd/commitdiff
Add check for files missing in hex packaging
authorPaweł Chmielowski <pchmielowski@process-one.net>
Fri, 29 Jun 2018 10:51:20 +0000 (12:51 +0200)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Fri, 29 Jun 2018 10:51:20 +0000 (12:51 +0200)
tools/update-deps-releases.pl

index e22cef424ddfbb40ca5512ee9ee32adc08472151..9458c9da26895bf2b4a7d2b8d950e000bf0dbc55 100755 (executable)
@@ -7,6 +7,8 @@ use warnings;
 use File::Slurp qw(slurp write_file);
 use File::stat;
 use File::Touch;
+use File::chdir;
+use File::Spec;
 use Data::Dumper qw(Dumper);
 use Carp;
 use Term::ANSIColor;
@@ -323,6 +325,44 @@ sub git_push {
     system("git", "-C", ".deps-update/$dep", "push", "--tags");
 }
 
+sub check_hex_files {
+    my ($dep) = @_;
+    my $app = ".deps-update/$dep/src/$dep.app.src";
+    return if not -f $app;
+    my $content = slurp($app);
+    my @paths;
+    if ($content =~ /{\s*files\s*,\s*\[([^\]]+)\]/) {
+        my $list = $1;
+        push @paths, $1 while $list =~ /"([^"]*?)"/g;
+    } else {
+        @paths = (
+            "src", "c_src", "include", "rebar.config.script", "priv",
+            "rebar.config", "rebar.lock", "README*", "readme*", "LICENSE*",
+            "license*", "NOTICE");
+    }
+    local $CWD = ".deps-update/$dep";
+    my @interesting_files = map {File::Spec->canonpath($_)} glob("rebar.config* src/*.erl src/*.app.src c_src/*.c c_src/*.cpp \
+        c_src/*.h c_src/*.hpp include/*.hrl");
+
+    my @matching_files;
+    for my $path (@paths) {
+        if (-d $path) {
+            push @matching_files, map {File::Spec->canonpath($_)} glob("$path/*");
+        } else {
+            push @matching_files, map {File::Spec->canonpath($_)} glob($path);
+        }
+    }
+    my %diff;
+    @diff{ @interesting_files } = undef;
+    delete @diff{ @matching_files };
+    my @diff = keys %diff;
+    if (@diff) {
+        print color("red"), "Dependency ", color("bold red"), $dep, color("reset"), color("red"), " files section doesn't match: ",
+            join(" ", @diff), color("reset"), "\n";
+
+    }
+}
+
 update_deps_repos();
 
 MAIN:
@@ -350,6 +390,10 @@ while (1) {
     say "(none)" if not $changed_deps;
     say "";
 
+    for my $dep (sort keys %$top_deps) {
+        check_hex_files($dep);
+    }
+
     my $cmd = show_commands($old_deps ? (U => "Update dependency") : (),
         $changed_deps ? (T => "Tag new release") : (),
         @operations ? (A => "Apply changes") : (),