Skip to content

Commit

Permalink
[packaging] adapt previous patchset to new .VERSION.mk
Browse files Browse the repository at this point in the history
To recap, the goal is to keep the commit sha1 in the package release
number after the always-incrementing timestamp, and not in logstash's
version number.

Otherwise, we risk having dpkg/rpm believe the package will be
downgraded in the case let's say you have an 1.2.3.dev-abc123 version
which arrives after 1.2.3.dev-def456.
  • Loading branch information
Marc Fournier committed Nov 27, 2013
1 parent 3ccf067 commit 7a4ee6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ TESTS=$(wildcard spec/inputs/gelf.rb spec/support/*.rb spec/filters/*.rb spec/ex
.VERSION.mk:
@REVISION="$$(git rev-parse --short HEAD | tr -d ' ')" ; \
RELEASE=$$(awk -F\" '/LOGSTASH_VERSION/ {print $$2}' lib/logstash/version.rb | tr -d ' ') ; \
echo "RELEASE=$${RELEASE}" > $@ ; \
echo "REVISION=$${REVISION}" >> $@ ; \
if git diff --shortstat --exit-code > /dev/null ; then \
echo "VERSION=$${RELEASE}-$${REVISION}" ; \
else \
echo "VERSION=$${RELEASE}-$${REVISION}-modified"; \
fi > $@
fi >> $@

-include .VERSION.mk

Expand Down
15 changes: 7 additions & 8 deletions pkg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

if ! git show-ref --tags | grep -q "$(git rev-parse HEAD)"; then
# HEAD is not tagged, add the date, time and commit hash to the revision
GIT_COMMIT="$(git rev-parse --short HEAD)"
BUILD_TIME="$(date +%Y%m%d%H%M)"
DEB_REVISION="${BUILD_TIME}~${GIT_COMMIT}"
RPM_REVISION=".${BUILD_TIME}.${GIT_COMMIT}"
DEB_REVISION="${BUILD_TIME}~${REVISION}"
RPM_REVISION=".${BUILD_TIME}.${REVISION}"
fi


Expand Down Expand Up @@ -40,7 +39,7 @@ mkdir -p $destdir/$prefix


# install logstash.jar
jar="$(dirname $0)/../build/logstash-$VERSION-flatjar.jar"
jar="$(dirname $0)/../build/logstash-$VERSION-flatjar.jar"
if [ ! -f "$jar" ] ; then
echo "Unable to find $jar"
exit 1
Expand Down Expand Up @@ -99,7 +98,7 @@ esac
description="logstash is a system for managing and processing events and logs"
case $os in
centos|fedora|redhat)
fpm -s dir -t rpm -n logstash -v "$VERSION" \
fpm -s dir -t rpm -n logstash -v "$RELEASE" \
-a noarch --iteration "1_${os}${RPM_REVISION}" \
--url "$URL" \
--description "$DESCRIPTION" \
Expand All @@ -112,14 +111,14 @@ case $os in
-f -C $destdir .
;;
ubuntu|debian)
if ! echo $VERSION | grep -q '\.(dev\|rc.*)'; then
if ! echo $RELEASE | grep -q '\.(dev\|rc.*)'; then
# This is a dev or RC version... So change the upstream version
# example: 1.2.2.dev => 1.2.2~dev
# This ensures a clean upgrade path.
VERSION="$(echo $VERSION | sed 's/\.\(dev\|rc.*\)/~\1/')"
RELEASE="$(echo $RELEASE | sed 's/\.\(dev\|rc.*\)/~\1/')"
fi

fpm -s dir -t deb -n logstash -v "$VERSION" \
fpm -s dir -t deb -n logstash -v "$RELEASE" \
-a all --iteration "1+${os}${DEB_REVISION}" \
--url "$URL" \
--description "$DESCRIPTION" \
Expand Down

0 comments on commit 7a4ee6a

Please sign in to comment.