Permalink
Browse files

Set correct version number in copr and OBS builds

Use fallback-version-number option to set correct version number string
in copr and OBS builds.

Resolves: #570
  • Loading branch information...
siteshwar committed Jun 3, 2018
1 parent ca656e9 commit 0194f5fe7bd54c386a48bd9d1cf26061bdcf3cc8
Showing with 24 additions and 4 deletions.
  1. +6 −1 .copr/prep.sh
  2. +1 −1 packaging/debian/rules
  3. +2 −1 packaging/fedora/ksh.spec.in
  4. +2 −1 packaging/opensuse/ksh.spec.in
  5. +13 −0 scripts/build-on-obs.sh
@@ -8,15 +8,20 @@ set -x
# repo, so ignore if it fails.
git fetch --unshallow || :
# Fetch tags to determine version number
git fetch --tags
COMMIT=$(git rev-parse HEAD)
COMMIT_SHORT=$(git rev-parse --short HEAD)
COMMIT_NUM=$(git rev-list HEAD --count)
COMMIT_DATE=$(date --date="@$(git show -s --format=%ct HEAD)" +%Y%m%d)
VCS_VERSION=$(git describe --always --dirty --tags)
sed "s,#COMMIT#,${COMMIT},;
s,#SHORTCOMMIT#,${COMMIT_SHORT},;
s,#COMMITNUM#,${COMMIT_NUM},;
s,#COMMITDATE#,${COMMIT_DATE}," \
s,#COMMITDATE#,${COMMIT_DATE},;
s,#VCS_VERSION#,${VCS_VERSION}," \
packaging/fedora/ksh.spec.in > packaging/fedora/ksh.spec
git archive --prefix "ast-${COMMIT}/" --format "tar.gz" HEAD -o "packaging/fedora/ksh-${COMMIT_SHORT}.tar.gz"
@@ -9,7 +9,7 @@ export DH_VERBOSE=1
override_dh_auto_configure:
# Note: Meson is only available for debhelper >= 10.3
dh_auto_configure --buildsystem=meson --parallel
dh_auto_configure --buildsystem=meson --parallel -- -Dfallback-version-number=#VCS_VERSION#
override_dh_installdocs:
dh_installdocs --link-doc=ksh
@@ -2,6 +2,7 @@
%global shortcommit #SHORTCOMMIT#
%global commitnum #COMMITNUM#
%global commitdate #COMMITDATE#
%global vcs_version #VCS_VERSION#
Name: ksh
Summary: The Original ATT Korn Shell
@@ -37,7 +38,7 @@ with "sh" (the Bourne Shell).
%autosetup -n ast-%{commit}
%build
%meson -Dbuild-pty=false
%meson -Dbuild-pty=false -Dfallback-version-number=%{vcs_version}
%meson_build
%install
@@ -1,4 +1,5 @@
%global commit #COMMIT#
%global vcs_version #VCS_VERSION#
Name: ksh
Summary: The Original ATT Korn Shell
@@ -28,7 +29,7 @@ with "sh" (the Bourne Shell).
%autosetup -n ast-%{commit}
%build
%meson -Dbuild-pty=false
%meson -Dbuild-pty=false -Dfallback-version-number=%{vcs_version}
%meson_build
%install
@@ -12,6 +12,9 @@ git checkout master 2> /dev/null
last_commit=$(git rev-parse HEAD)
git pull origin master
# Fetch tags to determine version number
git fetch --tags
# Check if new commits were added since last build
if [[ $last_commit == $(git rev-parse HEAD) ]]; then
echo "No new changes since last build. Exiting..."
@@ -29,16 +32,26 @@ COMMIT_SHORT=$(git rev-parse --short HEAD)
COMMIT_NUM=$(git rev-list HEAD --count)
COMMIT_DATE=$(date --date="@$(git show -s --format=%ct HEAD)" +%Y%m%d)
CHANGELOG_DATE=$(date +"%a\, %d %b %Y %R:%S %z")
# This is version number of rpm and debian packages
VERSION=${COMMIT_DATE}.0.0+git.${COMMIT_NUM}.${COMMIT_SHORT}
# This is the ksh version number seen inside scripts
# For e.g. with ksh --version
VCS_VERSION=$(git describe --always --dirty --tags)
sed "s,#VERSION#,${VERSION},;
s,#VCS_VERSION#,${VCS_VERSION},;
s,#COMMIT#,${COMMIT},;" \
packaging/opensuse/ksh.spec.in > "${OBS_REPO}/ksh.spec"
# Make all debian related changes in a temporary branch
git branch -D debian_build
git checkout -b debian_build
sed -i "s,#VCS_VERSION#,${VCS_VERSION},;" \
packaging/debian/rules
sed -i "s,#COMMIT#,${COMMIT},;
s,#VERSION#,${VERSION},;
s,#CHANGELOG_DATE#,${CHANGELOG_DATE},;" \

0 comments on commit 0194f5f

Please sign in to comment.