Tamarin/hooks/prebuild/debian/add-package-version-suffix

26 lines
721 B
Plaintext
Raw Normal View History

2015-11-18 10:45:20 +01:00
#!/usr/bin/env bash
2017-02-09 21:53:24 +01:00
cd src
2015-11-18 10:45:20 +01:00
if [ ! -f debian/changelog ]; then
2017-02-09 21:53:24 +01:00
tamarin_info "No changelog. Skipping..."
2015-11-18 10:45:20 +01:00
exit
fi
2017-02-09 21:53:24 +01:00
if [ $(tamarin_db get no_version_suffix 'no') == 'yes' ]; then
tamarin_info "Not adding version suffix."
exit
fi
2015-11-18 10:45:20 +01:00
if [ -d .git ]; then
2017-02-09 21:53:24 +01:00
tamarin_info "It seems to be a Git repository. Generating version suffix based on Git history..."
2015-11-18 10:45:20 +01:00
commit_count=$(git rev-list --count HEAD)
current_commit=$(git log -n 1 --pretty=format:"%h")
version_suffix=tamarin${commit_count}~${current_commit}
else
2017-02-09 21:53:24 +01:00
tamarin_info "Not a Git project. Fallback to timestamp for suffix generation..."
2015-11-18 10:45:20 +01:00
version_suffix=tamarin$(date +%Y%m%d%H%M)
fi
sed -i "0,/(\(.*\))/s/(\(.*\))/(\1${version_suffix})/" debian/changelog