2018-11-07 23:24:49 +03:00
|
|
|
#!/bin/bash
|
2010-05-25 08:40:08 +04:00
|
|
|
# Usage: sh update.sh <upstream_src_directory>
|
2018-11-07 23:24:49 +03:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
[[ -n "$1" ]] || ( echo "syntax: $0 update_src_directory"; exit 1 )
|
|
|
|
[[ -e "$1/src/nestegg.c" ]] || ( echo "$1: nestegg not found"; exit 1 )
|
|
|
|
|
2010-05-25 08:40:08 +04:00
|
|
|
cp $1/include/nestegg/nestegg.h include
|
|
|
|
cp $1/src/nestegg.c src
|
|
|
|
cp $1/LICENSE .
|
2014-09-29 04:13:10 +04:00
|
|
|
cp $1/README.md .
|
2010-05-25 08:40:08 +04:00
|
|
|
cp $1/AUTHORS .
|
2018-11-07 23:24:49 +03:00
|
|
|
|
2010-09-07 08:54:17 +04:00
|
|
|
if [ -d $1/.git ]; then
|
|
|
|
rev=$(cd $1 && git rev-parse --verify HEAD)
|
2018-08-26 11:30:18 +03:00
|
|
|
date=$(cd $1 && git show -s --format=%ci HEAD)
|
2010-09-07 08:54:17 +04:00
|
|
|
dirty=$(cd $1 && git diff-index --name-only HEAD)
|
2018-11-07 23:24:49 +03:00
|
|
|
set +e
|
|
|
|
pre_rev=$(grep -o '[[:xdigit:]]\{40\}' moz.yaml)
|
|
|
|
commits=$(cd $1 && git log --pretty=format:'%h - %s' $pre_rev..$rev)
|
|
|
|
set -e
|
2010-09-07 08:54:17 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$rev" ]; then
|
|
|
|
version=$rev
|
|
|
|
if [ -n "$dirty" ]; then
|
|
|
|
version=$version-dirty
|
|
|
|
echo "WARNING: updating from a dirty git repository."
|
|
|
|
fi
|
2018-11-07 23:24:49 +03:00
|
|
|
sed -i.bak -e "s/^ *release:.*/ release: \"$version ($date)\"/" moz.yaml
|
|
|
|
if [[ ! "$( grep "$version" moz.yaml )" ]]; then
|
|
|
|
echo "Updating moz.yaml failed."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
rm moz.yaml.bak
|
|
|
|
[[ -n "$commits" ]] && echo -e "Pick commits:\n$commits"
|
2010-09-07 08:54:17 +04:00
|
|
|
else
|
2018-11-07 23:24:49 +03:00
|
|
|
echo "Remember to update moz.yaml with the version details."
|
2010-09-07 08:54:17 +04:00
|
|
|
fi
|