Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / packaging / source / git-export-release.sh.in
blob454d17bcefbabe184000cbe1b560178dc3cc4529
1 #!/bin/bash
3 # Creates a release tarball directly from git
5 # Note that the tarball contents might not exactly match
6 # a particular git commit, particularly for untagged
7 # commits.
9 # An alternative approach would be to generate source tarballs
10 # using CPack. That would remove our dependency on git, but if
11 # Autotools is any indication it would require continuous
12 # maintenance.
14 # Copyright 2011 Balint Reczey <balint@balintreczey.hu>
16 # Wireshark - Network traffic analyzer
17 # By Gerald Combs <gerald@wireshark.org>
18 # Copyright 1998 Gerald Combs
20 # SPDX-License-Identifier: GPL-2.0-or-later
22 set -e -u -o pipefail
24 DESTDIR=.
26 while getopts "d:" OPTCHAR ; do
27 case $OPTCHAR in
28 d) DESTDIR=$OPTARG ;;
29 *) printf "Unknown option %s\n" "$OPTCHAR" ;;
30 esac
31 done
32 shift $(( OPTIND - 1 ))
34 # The remaining parameter, if set, is a package version such as 3.4.5
35 # or 3.4.5-67-gabcd4321
36 # By default the version from make-version.py + CMake is used.
37 PROJECT_VERSION=@PROJECT_VERSION@
38 if test -n "${1-}"; then
39 PROJECT_VERSION="$1"
42 TARBALL="${DESTDIR}/wireshark-${PROJECT_VERSION}.tar.zst"
44 # A tarball produced by 'git archive' will have the $Format string
45 # substituted due to the use of 'export-subst' in .gitattributes.
46 # shellcheck disable=SC2016
47 COMMIT='$Format:%H$'
49 if [[ $COMMIT != \$F* ]] ; then
50 # This file was extracted from a tarball produced by git archive
51 # and so we are not in a git repository.
52 if [[ -f "$TARBALL" ]] ; then
53 # git get-tar-commit-id works outside a git repo, as it
54 # only reads the first 1024 bytes of the tar extended header.
55 if [[ $(git get-tar-commit-id < <(zstdcat "$TARBALL")) == "$COMMIT" ]] ; then
56 echo "$TARBALL commit ID matches $COMMIT."
57 else
58 # Allow people to make changes to a downloaded source tarball
59 # and re-tar it?
60 echo "WARNING: $TARBALL is not the original git archive."
62 exit 0
65 echo ""
66 echo "The build system cannot produce a source tarball outside of a git repository."
67 echo "If you are trying to build an RPM package from source extracted from a tarball,"
68 echo "copy it (i.e., wireshark-${PROJECT_VERSION}.tar.zst) to"
69 echo "$DESTDIR"
70 echo "and run the build command again."
72 exit 1
75 STASH_ID=$(git stash create || echo "")
77 if [[ -n "$STASH_ID" ]] ; then
78 echo "Setting commit from stash $STASH_ID"
79 COMMIT="$STASH_ID"
80 else
81 echo "Setting commit from HEAD"
82 COMMIT="HEAD"
85 if [ -f "$TARBALL" ] ; then
86 printf "Found %s\\n" "$TARBALL"
87 if TARBALL_ID=$(git get-tar-commit-id < <(zstdcat "$TARBALL")) && COMMIT_ID=$(git rev-parse --verify "$COMMIT") ; then
88 if [[ $TARBALL_ID == "$COMMIT_ID" ]] ; then
89 echo "$TARBALL commit ID matches $COMMIT."
90 exit 0
95 echo "Creating $TARBALL from $COMMIT"
97 git archive --prefix="wireshark-${PROJECT_VERSION}/" "$COMMIT" | zstd --threads=0 --long --ultra -22 > "$TARBALL"