Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Add a message to explain no property violation is found
[simgrid.git] / tools / check_dist_archive
index ca1f75e..963a4a3 100755 (executable)
@@ -1,5 +1,11 @@
 #!/bin/bash
 
+# Copyright (c) 2013-2014. The SimGrid Team.
+# All rights reserved.
+
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the license (GNU LGPL) which comes with this package.
+
 set -e
 
 if [ "$1" = "-batch" ]; then
@@ -12,24 +18,24 @@ else
 fi
 
 if [ $# -lt 1 -o $# -gt 3 ]; then
-    cat <<EOF
-Usage: $0 [-batch] archive.tar.gz [git_url [git_branch]]
+    cat >&2 <<EOF
+Usage: $0 [-batch] archive.tar.gz [git_url [git_reference]]
 EOF
     exit 1
 fi
 
 archive=$1
 if [ ! -r "$archive" ]; then
-    printf 'File not found: %s\n' "$archive"
+    printf 'File not found: %s\n' "$archive" >&2
     exit 1
 fi
 
 if [ $# -ge 2 ]; then
     giturl=$2
-    gitbranch=${3:-master}
+    gitref=${3:-master}
 else
     giturl=$(git rev-parse --show-toplevel)
-    gitbranch=$(git branch | sed -n '/^\*/{s/^..//;p;}')
+    gitref=HEAD
 fi
 
 tmpdir=$(mktemp -d)
@@ -49,7 +55,7 @@ case "$myname" in
 esac
 
 if [ ! -r "$exclude" ]; then
-    printf 'File not found: %s\n' "$exclude"
+    printf 'File not found: %s\n' "$exclude" >&2
     exit 1
 fi
 
@@ -60,8 +66,8 @@ tar --directory "$tmpdir" \
     --transform 's!^[^/]*!a!' \
     --extract --gunzip --file "$archive"
 
-echo "Copying git repository: $giturl/$gitbranch -> $git_dir"
-git archive --format=tar --prefix="b/" --remote="$giturl" "$gitbranch" \
+echo "Copying git repository: $giturl/$gitref -> $git_dir"
+git archive --format=tar --prefix="b/" --remote="$giturl" "$gitref" \
     | tar --directory "$tmpdir" --extract --file -
 
 fa=from_tgz
@@ -81,15 +87,28 @@ find b -type f \
     | sort > "$fb"
 
 diffcmd() {
-    diff -u "$fa" "$fb"
+    if cmp -s "$fa" "$fb"; then
+        status=0
+        echo "The archive looks good."
+    else
+        status=1
+        cat <<EOF
+ERROR: Some files are missing and/or unexpected in the archive.
+* lines beginning with '-' give files that are unexpected in the archive
+* lines beginning with '+' give files that are missing from the archive
+Please fix CMake files (e.g. "buildtools/Cmake/DefinePackages.cmake"),
+and/or "tools/check_dist_archive.exclude".
+EOF
+        diff -u "$fa" "$fb"
+    fi
 }
 
-colordiff=$(type -p colordiff)
+colordiff=$(type -p colordiff || true) 
 colorless() {
     if [ -x "$colordiff" ]; then
-        "$colordiff" | less -R -F
+        "$colordiff" | less -R -F -X
     else
-        less -F
+        less -F -X
     fi
 }
 
@@ -97,4 +116,6 @@ if [ "$interactive" = "1" ]; then
     diffcmd | colorless
 else
     diffcmd
-fi
+fi || true
+
+exit $status