#!/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 shift interactive=0 elif [ -t 1 ]; then interactive=1 else interactive=0 fi if [ $# -lt 1 -o $# -gt 3 ]; then cat >&2 <&2 exit 1 fi if [ $# -ge 2 ]; then giturl=$2 gitref=${3:-master} else giturl=$(git rev-parse --show-toplevel) gitref=HEAD fi tmpdir=$(mktemp -d) trap "rm -fr \"$tmpdir\"" EXIT arch_dir="$tmpdir/a" git_dir="$tmpdir/b" myname=$(type -p "$0") case "$myname" in /*) exclude="$myname.exclude" ;; *) exclude="$PWD/$myname.exclude" ;; esac if [ ! -r "$exclude" ]; then printf 'File not found: %s\n' "$exclude" >&2 exit 1 fi echo "Exclude patterns extracted from file: $exclude" echo "Extracting archive: $archive -> $arch_dir" tar --directory "$tmpdir" \ --transform 's!^[^/]*!a!' \ --extract --gunzip --file "$archive" 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 fb=from_git cd "$tmpdir" sed -n '/^-/{s/^- //;p;}' "$exclude" > ea sed -n '/^+/{s/^+ //;p;}' "$exclude" > eb find a -type f \ | sed 's!^a/!!' \ | grep -E -v -x -f ea \ | sort > "$fa" find b -type f \ | sed 's!^b/!!' \ | grep -E -v -x -f eb \ | sort > "$fb" diffcmd() { if cmp -s "$fa" "$fb"; then status=0 echo "The archive looks good." else status=1 cat <