Skip to content

Commit 8c8208a

Browse files
committed
Fix version for tarballs (release & git archive)
1 parent 0508898 commit 8c8208a

File tree

4 files changed

+59
-48
lines changed

4 files changed

+59
-48
lines changed

.gitattributes

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
/tools/create_version_h.sh export-subst
2-
/CMakeList.txt export-subst
1+
/CMakeLists.txt export-subst

CMakeLists.txt

+30-24
Original file line numberDiff line numberDiff line change
@@ -86,37 +86,43 @@ endif(WIN32)
8686

8787
# Check if this is source package build
8888
if(NOT IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
89-
set(SOURCE_PACKAGE 1)
89+
set(SOURCE_PACKAGE 1)
90+
else()
91+
set(SOURCE_PACKAGE 0)
9092
endif()
9193

9294
#
9395
# Set package version
9496
#
95-
97+
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/src/") # the src/ subdirectory won't exist yet
9698
if(DEFINED PROJECT_VERSION)
97-
#project version is defined by -D on the cmake command line
98-
# only use that value, do not upate it at make time
99-
EXECUTE_PROCESS( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h ${PROJECT_VERSION}
100-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
101-
)
99+
#project version is defined by -D on the cmake command line
100+
# only use that value, do not upate it at make time
101+
execute_process(
102+
COMMAND ${CMAKE_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h ${PROJECT_VERSION}
103+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
104+
)
102105
else(DEFINED PROJECT_VERSION)
103-
if(NOT SOURCE_PACKAGE)
104-
# this part is setting the corresponding CMake variable which gets used for example when creating a source package
105-
EXECUTE_PROCESS(COMMAND git describe --tags --dirty
106-
COMMAND sed "s,^release-,,;s,-,+,;s,-,~,;" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PROJECT_VERSION
107-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
108-
add_custom_target(
109-
generate_version ALL
110-
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h
111-
COMMENT "Updating version string"
112-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
113-
)
114-
else(NOT SOURCE_PACKAGE)
115-
set(PROJECT_VERSION "archive-$Format:%H$")
116-
execute_process( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h ${PROJECT_VERSION}
117-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
118-
)
119-
endif(NOT SOURCE_PACKAGE)
106+
if(NOT SOURCE_PACKAGE) # i.e., a git checkout
107+
# this part is setting the corresponding CMake variable which gets used for example when creating a source package
108+
execute_process(
109+
COMMAND git describe --tags --dirty
110+
COMMAND sed "s,^release-,,;s,-,+,;s,-,~,;" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PROJECT_VERSION
111+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
112+
add_custom_target(generate_version ALL
113+
COMMAND ${CMAKE_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h
114+
COMMENT "Updating version string"
115+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
116+
)
117+
elseif(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/version_gen.h)
118+
# no need to create version_gen.h if it's already shipped. that is for example the case with our release tarballs
119+
# else(NOT SOURCE_PACKAGE)
120+
set(PROJECT_VERSION "archive-$Format:%H$")
121+
execute_process(
122+
COMMAND ${CMAKE_SOURCE_DIR}/tools/create_version_h.sh ${CMAKE_CURRENT_BINARY_DIR}/src/version_gen.h ${PROJECT_VERSION}
123+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
124+
)
125+
endif(NOT SOURCE_PACKAGE)
120126
endif(DEFINED PROJECT_VERSION)
121127

122128

tools/create_release.sh

+24-17
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,40 @@ echo "are you sure these guys received proper credit in the about dialog?"
66
read answer
77

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

12-
mkdir -p tmp
13-
cd tmp
14-
tar xvf ../darktable-$dt_decoration.tar
13+
SRCDIR=`pwd`
14+
TMPDIR=`mktemp -d -t darktable-XXXXXX`
15+
cd "$TMPDIR"
16+
tar xf "$SRCDIR/darktable-$dt_decoration.tar"
1517

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

19-
# remove docs, that's > 45 MB
20-
rm -rf darktable-$dt_decoration/doc/htdocs
22+
# remove usermanual, that's > 80 MB and released separately
23+
echo "* removing usermanual"
2124
rm -rf darktable-$dt_decoration/doc/usermanual
22-
tar cvzf darktable-$dt_decoration.tar.gz darktable-$dt_decoration/
23-
tar cvJf darktable-$dt_decoration.tar.xz darktable-$dt_decoration/
24-
rm ../darktable-$dt_decoration.tar
25-
mv darktable-$dt_decoration.tar.gz ..
26-
mv darktable-$dt_decoration.tar.xz ..
2725

28-
# now test the build:
29-
rm -rf darktable-*
30-
tar xvzf ../darktable-$dt_decoration.tar.gz
31-
cd darktable-*
32-
./build.sh
26+
echo "* creating final tarball"
27+
tar cJf darktable-$dt_decoration.tar.xz darktable-$dt_decoration/
28+
rm "$SRCDIR/darktable-$dt_decoration.tar"
29+
cp darktable-$dt_decoration.tar.xz "$SRCDIR"
3330

34-
echo "actually to test this build you should do:"
35-
echo "cd tmp/darktable-$dt_decoration/build && sudo make install"
31+
# now test the build:
32+
echo "* test compiling"
33+
rm -rf darktable-$dt_decoration/
34+
tar xf darktable-$dt_decoration.tar.xz
35+
cd darktable-$dt_decoration/
36+
./build.sh --prefix "$TMPDIR/darktable/"
37+
38+
echo
39+
echo "to actually test this build you should do:"
40+
echo "cd $TMPDIR/darktable-$dt_decoration/build && make install"
41+
echo "then run darktable from:"
42+
echo "$TMPDIR/darktable/bin/darktable"
3643

3744

3845

tools/create_version_h.sh

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
set -e
44

55
H_FILE=$1
6+
NEW_VERSION=$2
67

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

1413
if [ -n "`echo -e $NEW_VERSION | grep Format`" ]; then
15-
NEW_VERSION="unknown-version"
14+
NEW_VERSION="unknown-version"
1615
fi
1716

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

0 commit comments

Comments
 (0)