Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 54 lines (46 sloc) 1.517 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#!/bin/sh

CONFIGURE_AC=configure.ac
RPM_SPEC=vzctl.spec

# Try to figure out version from git
GIT_DESC=$(git describe --tags | sed s'/^[^0-9]*-\([0-9].*\)$/\1/')
GIT_V=$(echo $GIT_DESC | sed 's/-.*$//')
# 3.0.28-1-gf784152
GIT_R=$(echo $GIT_DESC | sed 's/^[^-]*-\([1-9][0-9]*\)-g/\1.git./')
test "$GIT_V" = "$GIT_R" && GIT_R="1"
GIT_VR="${GIT_V}-${GIT_R}"

CONF_V=$(grep AC_INIT $CONFIGURE_AC | \
sed 's/^[^,]*,[ ]\([^,]*\),.*$/\1/')

read_spec() {
SPEC_V=$(awk '($1 == "Version:") {print $2}' $RPM_SPEC)
SPEC_R=$(awk '($1 " " $2 == "%define rel") {print $3}' $RPM_SPEC)
SPEC_VR="${SPEC_V}-${SPEC_R}"
}
read_spec

# Set version/release in spec from git
if test "$GIT_VR" != "$SPEC_VR"; then
# echo "Changing $RPM_SPEC:"
# Version: 3.0.28
# Release: 1%{?dist}
sed -i -e "s/^\(Version:[[:space:]]*\).*\$/\1$GIT_V/" \
-e "s/^\(%define rel[[:space:]]*\).*\$/\1$GIT_R/" \
$RPM_SPEC
if test "$GIT_R" != "1"; then
NVR='%{name}-%{version}-%{rel}'
sed -i -e "s/^\(Source:[[:space:]]*\).*\$/\1${NVR}.tar.bz2/" \
-e "s/^%setup[[:space:]]*.*\$/%setup -n ${NVR}/" \
$RPM_SPEC
fi
fi
#grep -E -H '^Version:|^%define rel|^Source:|^%setup' $RPM_SPEC

# Set version in configure.ac from spec
read_spec
SPEC_VR=$(echo $SPEC_VR | sed 's/-1$//')
if test "$CONF_V" != "$SPEC_VR"; then
# echo "Changing $CONFIGURE_AC:"
# AC_INIT(vzctl, 3.0.28, devel@openvz.org)
sed -i "s/^\(AC_INIT(vzctl,[ ]\)[^,]*\(,.*\$\)/\1$SPEC_VR\2/" \
$CONFIGURE_AC
autoconf
fi
#grep -H '^AC_INIT' $CONFIGURE_AC

exit 0
Something went wrong with that request. Please try again.