Permalink
Browse files

Use semantic version numbers in Linux packages

Related: #335
  • Loading branch information...
siteshwar committed Aug 24, 2018
1 parent d3d98ff commit 0dfc0318e4e7d9d69acc2b382921874f71dd682d
Showing with 39 additions and 23 deletions.
  1. +18 −10 .copr/prep.sh
  2. +6 −5 packaging/fedora/ksh.spec.in
  3. +1 −0 packaging/opensuse/ksh.spec.in
  4. +14 −8 scripts/build-on-obs.sh
View
@@ -11,17 +11,25 @@ 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)
# 2017.0.0-devel-1535-g7c33a1cd-dirty
VCS_VERSION=$(git describe --always --dirty --tags)
sed "s,#COMMIT#,${COMMIT},;
s,#SHORTCOMMIT#,${COMMIT_SHORT},;
s,#COMMITNUM#,${COMMIT_NUM},;
s,#COMMITDATE#,${COMMIT_DATE},;
s,#VCS_VERSION#,${VCS_VERSION}," \
# Extract development version number i.e. 2017.0.0
DEVEL_VERSION_NUM=$(echo $VCS_VERSION | cut -d'-' -f1)
# 1535
COMMIT_NUM=$(echo $VCS_VERSION | cut -d'-' -f3)
# g7c33a1cd
SHORT_COMMIT=$(echo $VCS_VERSION | cut -d'-' -f4)
COMMIT=$(git rev-parse HEAD)
sed "s,#VCS_VERSION#,${VCS_VERSION},;
s,#DEVEL_VERSION_NUM#,${DEVEL_VERSION_NUM},;
s,#COMMIT_NUM#,${COMMIT_NUM},;
s,#SHORT_COMMIT#,${SHORT_COMMIT},;
s,#COMMIT#,${COMMIT}," \
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"
git archive --prefix "ast-${COMMIT}/" --format "tar.gz" HEAD -o "packaging/fedora/ksh-${SHORT_COMMIT}.tar.gz"
@@ -1,16 +1,17 @@
%global commit #COMMIT#
%global shortcommit #SHORTCOMMIT#
%global commitnum #COMMITNUM#
%global commitdate #COMMITDATE#
%global devel_version_num #DEVEL_VERSION_NUM#
%global commit_num #COMMIT_NUM#
%global short_commit #SHORT_COMMIT#
%global vcs_version #VCS_VERSION#
Name: ksh
Summary: The Original ATT Korn Shell
URL: http://www.kornshell.com/
License: EPL
Version: %{commitdate}+git.%{commitnum}.%{shortcommit}
Version: %{devel_version_num}+git.%{commit_num}.%{short_commit}
Epoch: 1
Release: 0%{?dist}
Source0: https://github.com/att/ast/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
Source0: https://github.com/att/ast/archive/%{commit}/%{name}-%{short_commit}.tar.gz
Source1: kshcomp.conf
Source2: kshrc.rhs
Source3: dotkshrc
@@ -6,6 +6,7 @@ Summary: The Original ATT Korn Shell
URL: http://www.kornshell.com/
License: EPL
Version: #VERSION#
Epoch: 1
Release: 0%{?dist}
Source0: %{name}_%{version}.orig.tar.gz
View
@@ -26,19 +26,25 @@ pushd "${OBS_REPO}"
osc rm -f *
popd
# This is the ksh version number seen inside scripts
# For e.g. with ksh --version
# 2017.0.0-devel-1535-g7c33a1cd-dirty
VCS_VERSION=$(git describe --always --dirty --tags)
# Extract development version number i.e. 2017.0.0
DEVEL_VERSION_NUM=$(echo $VCS_VERSION | cut -d'-' -f1)
# 1535
COMMIT_NUM=$(echo $VCS_VERSION | cut -d'-' -f3)
# g7c33a1cd
SHORT_COMMIT=$(echo $VCS_VERSION | cut -d'-' -f4)
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)
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)
VERSION=${DEVEL_VERSION_NUM}+git.${COMMIT_NUM}.${SHORT_COMMIT}
sed "s,#VERSION#,${VERSION},;
s,#VCS_VERSION#,${VCS_VERSION},;

0 comments on commit 0dfc031

Please sign in to comment.