# Don't set -e here as egrep (used a few times) returns 1 if no matches
# were found.
-version=`git describe --tags --abbrev=0 | sed -e "s/v//"`
+# Use a tag if what we've built is exactly on one
+version=$(git describe --tags --abbrev=0 --match=v2.*.* --exact-match $1 2> /dev/null)
+if [ "$?" != "0" ]; then
+ # Otherwise use <branch>-<commit>
+ version="$(git name-rev --name-only HEAD)-$(git rev-parse --short HEAD)"
+fi
# DMG size in megabytes
DMG_SIZE=256
for arch in $arch1_name $arch2_name; do
for obj in "${linkers[@]}"; do
- deps=`otool -arch $arch -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu|libssh)"`
+ deps=`otool -arch $arch -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|@rpath|boost|libicu|libssh)"`
changes=""
for dep in $deps; do
base=`basename $dep`