#!/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 # # Wireshark - Network traffic analyzer # By Gerald Combs # Copyright 1998 Gerald Combs # # SPDX-License-Identifier: GPL-2.0-or-later set -e -u -o pipefail 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 TARBALL="${DESTDIR}/wireshark-${VERSION}.tar.xz" COMMIT="${CI_COMMIT_SHA:-HEAD}" STASH_ID=$(git stash create) if [[ -n "$STASH_ID" ]] ; then COMMIT="$STASH_ID" fi if [ -f "$TARBALL" ] ; then if TARBALL_ID=$(git get-tar-commit-id < <(xzcat "$TARBALL")) && COMMIT_ID=$(git rev-parse --verify "$COMMIT") ; then if [[ $TARBALL_ID == "$COMMIT_ID" ]] ; then echo "$TARBALL commit ID matches $COMMIT." exit 0 fi fi fi echo "Creating $TARBALL from $COMMIT" XZ_OPTS= echo . | xz --threads=0 > /dev/null 2>&1 && XZ_OPTS=--threads=0 git archive --prefix="wireshark-${VERSION}/" "$COMMIT" | xz $XZ_OPTS > "$TARBALL"