Skip to content

Commit

Permalink
Fix version for tarballs (release & git archive)
Browse files Browse the repository at this point in the history
  • Loading branch information
houz committed Nov 10, 2015
1 parent 0508898 commit 8c8208a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 48 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/tools/create_version_h.sh export-subst
/CMakeList.txt export-subst
/CMakeLists.txt export-subst
54 changes: 30 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,37 +86,43 @@ endif(WIN32)

# Check if this is source package build
if(NOT IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
set(SOURCE_PACKAGE 1)
set(SOURCE_PACKAGE 1)
else()
set(SOURCE_PACKAGE 0)
endif()

#
# Set package version
#

file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/src/") # the src/ subdirectory won't exist yet
if(DEFINED PROJECT_VERSION)
#project version is defined by -D on the cmake command line
# only use that value, do not upate it at make time
EXECUTE_PROCESS( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h ${PROJECT_VERSION}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
#project version is defined by -D on the cmake command line
# only use that value, do not upate it at make time
execute_process(
COMMAND ${CMAKE_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h ${PROJECT_VERSION}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
else(DEFINED PROJECT_VERSION)
if(NOT SOURCE_PACKAGE)
# this part is setting the corresponding CMake variable which gets used for example when creating a source package
EXECUTE_PROCESS(COMMAND git describe --tags --dirty
COMMAND sed "s,^release-,,;s,-,+,;s,-,~,;" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PROJECT_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_custom_target(
generate_version ALL
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h
COMMENT "Updating version string"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
else(NOT SOURCE_PACKAGE)
set(PROJECT_VERSION "archive-$Format:%H$")
execute_process( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h ${PROJECT_VERSION}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif(NOT SOURCE_PACKAGE)
if(NOT SOURCE_PACKAGE) # i.e., a git checkout
# this part is setting the corresponding CMake variable which gets used for example when creating a source package
execute_process(
COMMAND git describe --tags --dirty
COMMAND sed "s,^release-,,;s,-,+,;s,-,~,;" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PROJECT_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_custom_target(generate_version ALL
COMMAND ${CMAKE_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h
COMMENT "Updating version string"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
elseif(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/version_gen.h)
# no need to create version_gen.h if it's already shipped. that is for example the case with our release tarballs
# else(NOT SOURCE_PACKAGE)
set(PROJECT_VERSION "archive-$Format:%H$")
execute_process(
COMMAND ${CMAKE_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h ${PROJECT_VERSION}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif(NOT SOURCE_PACKAGE)
endif(DEFINED PROJECT_VERSION)


Expand Down
41 changes: 24 additions & 17 deletions tools/create_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,40 @@ echo "are you sure these guys received proper credit in the about dialog?"
read answer

# prefix rc with ~, so debian thinks its less than
echo "* archiving git tree"
dt_decoration=$(git describe --tags $branch | sed 's,^release-,,;s,-,+,;s,-,~,;' | sed 's/rc/~rc/')
git archive HEAD --prefix=darktable-$dt_decoration/ -o darktable-$dt_decoration.tar

mkdir -p tmp
cd tmp
tar xvf ../darktable-$dt_decoration.tar
SRCDIR=`pwd`
TMPDIR=`mktemp -d -t darktable-XXXXXX`
cd "$TMPDIR"
tar xf "$SRCDIR/darktable-$dt_decoration.tar"

# create version header for non-git tarball:
echo "* creating version header"
echo "#define PACKAGE_VERSION \"$dt_decoration\"" > darktable-$dt_decoration/src/version_gen.h

# remove docs, that's > 45 MB
rm -rf darktable-$dt_decoration/doc/htdocs
# remove usermanual, that's > 80 MB and released separately
echo "* removing usermanual"
rm -rf darktable-$dt_decoration/doc/usermanual
tar cvzf darktable-$dt_decoration.tar.gz darktable-$dt_decoration/
tar cvJf darktable-$dt_decoration.tar.xz darktable-$dt_decoration/
rm ../darktable-$dt_decoration.tar
mv darktable-$dt_decoration.tar.gz ..
mv darktable-$dt_decoration.tar.xz ..

# now test the build:
rm -rf darktable-*
tar xvzf ../darktable-$dt_decoration.tar.gz
cd darktable-*
./build.sh
echo "* creating final tarball"
tar cJf darktable-$dt_decoration.tar.xz darktable-$dt_decoration/
rm "$SRCDIR/darktable-$dt_decoration.tar"
cp darktable-$dt_decoration.tar.xz "$SRCDIR"

echo "actually to test this build you should do:"
echo "cd tmp/darktable-$dt_decoration/build && sudo make install"
# now test the build:
echo "* test compiling"
rm -rf darktable-$dt_decoration/
tar xf darktable-$dt_decoration.tar.xz
cd darktable-$dt_decoration/
./build.sh --prefix "$TMPDIR/darktable/"

echo
echo "to actually test this build you should do:"
echo "cd $TMPDIR/darktable-$dt_decoration/build && make install"
echo "then run darktable from:"
echo "$TMPDIR/darktable/bin/darktable"



9 changes: 4 additions & 5 deletions tools/create_version_h.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
set -e

H_FILE=$1
NEW_VERSION=$2

VERSION_H_NEEDS_UPDATE=1
if [ -z "$2" ]; then
NEW_VERSION=`git describe --tags --dirty | sed 's,^release-,,;s,-,+,;s,-,~,;'`
else
NEW_VERSION=$2
if [ -z "$NEW_VERSION" ]; then
NEW_VERSION=`git describe --tags --dirty | sed 's,^release-,,;s,-,+,;s,-,~,;'`
fi

if [ -n "`echo -e $NEW_VERSION | grep Format`" ]; then
NEW_VERSION="unknown-version"
NEW_VERSION="unknown-version"
fi

# version.h exists => check if it containts the up-to-date version
Expand Down

0 comments on commit 8c8208a

Please sign in to comment.