2019-01-11 22:34:03 +00:00
|
|
|
#!/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
|
|
|
|
|
2021-01-08 19:04:00 +00:00
|
|
|
set -e -u -o pipefail
|
2019-01-11 22:34:03 +00:00
|
|
|
|
|
|
|
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@
|
2021-01-08 19:04:00 +00:00
|
|
|
if test -n "${1-}"; then
|
2019-01-11 22:34:03 +00:00
|
|
|
VERSION="$1"
|
|
|
|
fi
|
|
|
|
|
2021-01-08 19:04:00 +00:00
|
|
|
if [ -f "${DESTDIR}/wireshark-$VERSION.tar.xz" ] ; then
|
|
|
|
echo "${DESTDIR}/wireshark-$VERSION.tar.xz exists."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-01-11 22:34:03 +00:00
|
|
|
COMMIT="HEAD"
|
2022-01-04 14:36:50 +00:00
|
|
|
if [ -n "${CI_COMMIT_SHA-}" ] ; then
|
2021-08-27 17:55:30 +00:00
|
|
|
COMMIT=$CI_COMMIT_SHA
|
|
|
|
fi
|
|
|
|
|
|
|
|
STASH_POP=false
|
|
|
|
if ! git diff-index "$COMMIT" ; then
|
2019-01-11 22:34:03 +00:00
|
|
|
git stash --keep-index
|
|
|
|
COMMIT="stash@{0}"
|
|
|
|
STASH_POP=true
|
|
|
|
fi
|
|
|
|
|
2021-08-27 17:55:30 +00:00
|
|
|
echo "Creating ${DESTDIR}/wireshark-$VERSION.tar.xz from $COMMIT"
|
2019-01-11 22:34:03 +00:00
|
|
|
|
2021-08-27 17:55:30 +00:00
|
|
|
XZ_OPTS=
|
2019-01-11 22:34:03 +00:00
|
|
|
echo . | xz --threads=0 > /dev/null 2>&1 && XZ_OPTS=--threads=0
|
|
|
|
|
2021-08-27 17:55:30 +00:00
|
|
|
git archive --prefix="wireshark-${VERSION}/" "$COMMIT" | xz $XZ_OPTS > "${DESTDIR}/wireshark-${VERSION}.tar.xz"
|
2019-01-11 22:34:03 +00:00
|
|
|
|
|
|
|
if $STASH_POP ; then
|
|
|
|
git stash pop
|
|
|
|
fi
|