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

26 lines
721 B
Bash
Executable File

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