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

33 lines
936 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_tag=$(git describe --match "pkg/*")
pkg_tag=$(git describe --match "pkg/*" --abbrev=0)
commit_count=$(git rev-list --count ${pkg_tag}..HEAD)
current_commit=$(git log -n1 --pretty=format:%h)
tamarin_info $pkg_tag
tamarin_info $commit_count
tamarin_info $current_commit
version_suffix=~${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
tamarin_info $version_suffix
sed -i "0,/(\(.*\))/s/(\(.*\))/(\1${version_suffix})/" debian/changelog