aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2019-01-11 22:34:03 +0000
committerGerald Combs <gerald@wireshark.org>2019-01-14 17:41:43 +0000
commit290214adc986cc5f8bbbf87df023c290f32d982d (patch)
tree40d237c5aa4f59d18d0293d705d145ba803e7260
parentc3d198c401d5ec17289159cc88e2f891070e7779 (diff)
tarball+RPM: Fetch our version from CMake.
Move git-export-release.sh to packaging/source. Have the source and RPM packaging derive version information from CMake's VERSION variable. This brings them in line with the rest of our packaging and avoids having to read chicken entrails^W^Wgit output. Make sure we always generate wireshark.spec. Bug: 15359 Change-Id: I188efda489c94449a10a612abebf9c2872c305cb Reviewed-on: https://code.wireshark.org/review/31504 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--CMakeLists.txt37
-rw-r--r--packaging/rpm/wireshark.spec.in3
-rwxr-xr-xpackaging/source/git-export-release.sh.in60
-rwxr-xr-xtools/git-export-release.sh85
4 files changed, 69 insertions, 116 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f74e5f957..62a920d3a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1165,7 +1165,7 @@ endforeach()
# dist target that prepares source dir
# XXX Duplicated in the RPM section below.
add_custom_target(dist
- COMMAND ./tools/git-export-release.sh -d "${CMAKE_BINARY_DIR}"
+ COMMAND ${CMAKE_BINARY_DIR}/packaging/source/git-export-release.sh -d "${CMAKE_BINARY_DIR}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
@@ -1546,6 +1546,7 @@ set(CFG_OUT_FILES
packaging/macosx/osx-dmg.sh
packaging/macosx/Read_me_first.rtf
packaging/macosx/Wireshark_package.pmdoc/index.xml
+ packaging/source/git-export-release.sh
wireshark.pc
)
foreach( _cfg_file ${CFG_OUT_FILES} )
@@ -2773,18 +2774,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_program(APPIMAGETOOL_EXECUTABLE appimagetool)
endif()
-function(_SET_GITVERSION_CMAKE_VARIABLE OUTPUT_VARIABLE)
- # Load version string and write it to a cmake variable so it can be accessed from cmake.
- FILE(READ "${CMAKE_CURRENT_BINARY_DIR}/version.h" VERSION_H_FILE_CONTENT)
- string(REPLACE "\n" "" VERSION_H_FILE_CONTENT ${VERSION_H_FILE_CONTENT})
- #define VCSVERSION "v2.9.0rc0-305-gb8e8aa87"
- string(SUBSTRING "${VERSION_H_FILE_CONTENT}" 21 -1 VERSION_STRING)
- STRING(REGEX REPLACE "\"" "" VERSION_STRING "${VERSION_STRING}")
- MESSAGE(STATUS "Version string created from version.h: ${VERSION_STRING}")
- SET(${OUTPUT_VARIABLE} "${VERSION_STRING}" CACHE INTERNAL "${OUTPUT_VARIABLE}")
-endfunction(_SET_GITVERSION_CMAKE_VARIABLE)
-
+string(REPLACE "-" "_" RPM_VERSION "${VERSION}")
+configure_file(packaging/rpm/wireshark.spec.in ${CMAKE_BINARY_DIR}/packaging/rpm/SPECS/wireshark.spec)
if(RPMBUILD_EXECUTABLE)
foreach(_rpm_dir BUILD RPMS SOURCES SPECS SRPMS)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm/${_rpm_dir}")
@@ -2834,26 +2826,13 @@ if(RPMBUILD_EXECUTABLE)
${CMAKE_SOURCE_DIR}
)
- _SET_GITVERSION_CMAKE_VARIABLE(_git_description)
-
- if (NOT _git_description)
- # We're building the rpm outside the source. Guess the version from the dirname.
- get_filename_component(CMAKE_SOURCE_DIR_NAME ${CMAKE_SOURCE_DIR} NAME)
- # XXX this assumes the directory to start with "wireshark-"
- string(SUBSTRING "${CMAKE_SOURCE_DIR_NAME}" 10 -1 _git_description)
- endif()
- string(REPLACE "-" "_" RPM_VERSION "${_git_description}")
- configure_file(packaging/rpm/wireshark.spec.in ${CMAKE_BINARY_DIR}/packaging/rpm/SPECS/wireshark.spec)
-
# XXX Replace with the "dist" target?
- set(_export_tarball "${CPACK_PACKAGE_NAME}-${_git_description}.tar.xz")
+ set(_export_tarball "${CPACK_PACKAGE_NAME}-${VERSION}.tar.xz")
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/packaging/rpm/SOURCES/${_export_tarball}"
- COMMAND ./tools/git-export-release.sh
+ COMMAND ${CMAKE_BINARY_DIR}/packaging/source/git-export-release.sh
-d "${CMAKE_BINARY_DIR}/packaging/rpm/SOURCES"
- "${_git_description}"
- # XXX Add an option to git-export-release.sh to write to a
- # specific directory so that we can get rid of `ln` below.
+ "${VERSION}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_custom_target(rpm-package
@@ -3249,9 +3228,9 @@ if(SHELLCHECK_EXECUTABLE)
packaging/appimage/AppRun
packaging/macosx/osx-app.sh.in
packaging/macosx/osx-dmg.sh.in
+ packaging/source/git-export-release.sh.in
tools/compress-pngs.sh
tools/debian-setup.sh
- tools/git-export-release.sh
tools/fuzz-test.sh
tools/gen-bugnote
tools/pre-commit
diff --git a/packaging/rpm/wireshark.spec.in b/packaging/rpm/wireshark.spec.in
index 066437ce7f..a9c391fb4d 100644
--- a/packaging/rpm/wireshark.spec.in
+++ b/packaging/rpm/wireshark.spec.in
@@ -3,7 +3,6 @@
# says that recent CMake versions take care of rpathification.
# To do:
-# - Find a better way to sync with git-export-release.sh.
# - Set version in version.h
# - Add bcond_with clang
@@ -32,7 +31,7 @@
# are set.
%global use_wireshark_group 1
-%global package_version @_git_description@
+%global package_version @VERSION@
Summary: Wireshark is the world's foremost protocol analyzer
diff --git a/packaging/source/git-export-release.sh.in b/packaging/source/git-export-release.sh.in
new file mode 100755
index 0000000000..ce1b0ca897
--- /dev/null
+++ b/packaging/source/git-export-release.sh.in
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# Creates a release tarball directly from git
+
+# Note that the tarball contents might not exactly match
+# a particular git commit, particularly for untagged
+# commits.
+#
+# An alternative approach would be to generate source tarballs
+# using CPack. That would remove our dependency on git, but if
+# Autotools is any indication it would require continuous
+# maintenance.
+#
+# Copyright 2011 Balint Reczey <balint@balintreczey.hu>
+#
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+set -e
+
+DESTDIR=.
+
+while getopts "d:" OPTCHAR ; do
+ case $OPTCHAR in
+ d) DESTDIR=$OPTARG ;;
+ *) printf "Unknown option %s\n" "$OPTCHAR" ;;
+ esac
+done
+shift $(( OPTIND - 1 ))
+
+# The remaining parameter, if set, is a package version such as 3.4.5
+# or 3.4.5-67-gabcd4321
+# By default the version from make-version.pl + CMake is used.
+VERSION=@VERSION@
+if test -n "$1"; then
+ VERSION="$1"
+fi
+
+STASH_POP=false
+XZ_OPTS=
+
+COMMIT="HEAD"
+if ! git diff-index --quiet HEAD ; then
+ git stash --keep-index
+ COMMIT="stash@{0}"
+ STASH_POP=true
+fi
+
+echo "Creating wireshark-$VERSION.tar.xz"
+
+echo . | xz --threads=0 > /dev/null 2>&1 && XZ_OPTS=--threads=0
+
+git archive --prefix="wireshark-${VERSION}/" ${COMMIT} | xz $XZ_OPTS > "${DESTDIR}/wireshark-${VERSION}.tar.xz"
+
+if $STASH_POP ; then
+ git stash pop
+fi
diff --git a/tools/git-export-release.sh b/tools/git-export-release.sh
deleted file mode 100755
index c66e4d7272..0000000000
--- a/tools/git-export-release.sh
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/bash
-#
-# creates a release tarball directly from git
-#
-# Copyright 2011 Balint Reczey <balint@balintreczey.hu>
-#
-# Wireshark - Network traffic analyzer
-# By Gerald Combs <gerald@wireshark.org>
-# Copyright 1998 Gerald Combs
-#
-# SPDX-License-Identifier: GPL-2.0-or-later
-
-set -e
-
-DESTDIR=.
-
-while getopts "d:" OPTCHAR ; do
- case $OPTCHAR in
- d) DESTDIR=$OPTARG ;;
- *) printf "Unknown option %s" "$OPTCHAR"
- esac
-done
-shift $(( OPTIND - 1 ))
-
-# The remaining parameter, if set, is a git commit, like v1.12.0-rc1 or 54819e5699f
-# By default HEAD is used.
-# Note, that filtering takes place base on the _exported_ version's
-# .gitattributes files thus archives generated from older commits will contain
-# the whole tree.
-COMMIT="HEAD"
-if test -n "$1"; then
- COMMIT="$1"
-fi
-
-if [ ! -e "${GIT_DIR:-.git}" ] ; then
- echo "Must be run from the top-level repository directory."
- exit 1
-fi
-
-# --abbrev=<n> and --match should match tools/make-version.pl.
-DESCRIPTION=$(git describe --abbrev=8 --match "v[1-9]*" "${COMMIT}")
-VERSION=${DESCRIPTION#v}
-STASH_POP=False
-XZ_OPTS=
-
-# We might be able to avoid stashing by doing one of the following:
-#
-# For official releases, update our build process such that we don't
-# need to modify version.conf.
-#
-# Use tar to append a new or updated version.conf to the archive.
-# This would require detecting our local tar flavor (GNU or BSD) and
-# constructing a compatible command. BSD tar appears to support inline
-# inline filtering via `-a @- -s /^/wireshark-${VERSION} version.conf`
-# or something similar. GNU tar appears to require that we write to
-# a file and append to it. I'm not sure if we can add a path prefix.
-#
-# Use the 'export-subst' gitattribute along with
-# 'git_description=$Format:...$' in version.conf. export-subst uses
-# 'git log' formatting. I'm not sure if we can build $DESCRIPTION
-# from that.
-#
-# Rewrite this script in Python and use the built-in tarfile module
-# to replace version.conf.
-
-if [ "$COMMIT" == "HEAD" ] ; then
- echo "Adding description $DESCRIPTION"
- echo "git_description=$DESCRIPTION" >> version.conf
- git add version.conf
- git stash --keep-index
- COMMIT="stash@{0}"
- STASH_POP=True
-else
- echo "Not archiving HEAD. Skipping description."
-fi
-
-echo "Creating wireshark-$VERSION.tar.xz"
-
-echo . | xz --threads=0 > /dev/null 2>&1 && XZ_OPTS=--threads=0
-
-git archive --prefix="wireshark-${VERSION}/" ${COMMIT} | xz $XZ_OPTS > "${DESTDIR}/wireshark-${VERSION}.tar.xz"
-
-if [ "$STASH_POP" == "True" ] ; then
- git stash pop
-fi