xref: /openssl/util/mktar.sh (revision 3eb99601)
1#! /bin/sh
2# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the Apache License 2.0 (the "License").  You may not use
5# this file except in compliance with the License.  You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9HERE=`dirname $0`
10
11# Get all version data as shell variables
12. $HERE/../VERSION.dat
13
14if [ -n "$PRE_RELEASE_TAG" ]; then PRE_RELEASE_TAG=-$PRE_RELEASE_TAG; fi
15version=$MAJOR.$MINOR.$PATCH$PRE_RELEASE_TAG$BUILD_METADATA
16basename=openssl
17
18NAME="$basename-$version"
19
20while [ $# -gt 0 ]; do
21    case "$1" in
22        --name=* ) NAME=`echo "$1" | sed -e 's|[^=]*=||'`       ;;
23        --name ) shift; NAME="$1"                               ;;
24        --tarfile=* ) TARFILE=`echo "$1" | sed -e 's|[^=]*=||'` ;;
25        --tarfile ) shift; TARFILE="$1"                         ;;
26        * ) echo >&2 "Could not parse '$1'"; exit 1             ;;
27    esac
28    shift
29done
30
31if [ -z "$TARFILE" ]; then TARFILE="$NAME.tar"; fi
32
33# This counts on .gitattributes to specify what files should be ignored
34git archive --worktree-attributes -9 --prefix="$NAME/" -o $TARFILE.gz -v HEAD
35
36# Good old way to ensure we display an absolute path
37td=`dirname $TARFILE`
38tf=`basename $TARFILE`
39ls -l "`cd $td; pwd`/$tf.gz"
40