| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# |
| 4 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 5 |
# or more contributor license agreements. See the NOTICE file |
| 6 |
# distributed with this work for additional information |
| 7 |
# regarding copyright ownership. The ASF licenses this file |
| 8 |
# to you under the Apache License, Version 2.0 (the |
| 9 |
# "License"); you may not use this file except in compliance |
| 10 |
# with the License. You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, |
| 15 |
# software distributed under the License is distributed on an |
| 16 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 |
# KIND, either express or implied. See the License for the |
| 18 |
# specific language governing permissions and limitations |
| 19 |
# under the License. |
| 20 |
# |
| 21 |
|
| 22 |
# export.sh - Create a release archive. |
| 23 |
set -e |
| 24 |
trap "cleanup" 0 1 2 3 9 11 13 15 |
| 25 |
|
| 26 |
ME=$(basename ${0}) |
| 27 |
SRC=$(dirname $(dirname $(readlink -f $0))) |
| 28 |
|
| 29 |
usage() |
| 30 |
{ |
| 31 |
echo |
| 32 |
echo "Usage: ${ME} [DIR] [TAG]" |
| 33 |
exit 1 |
| 34 |
} |
| 35 |
|
| 36 |
cleanup() |
| 37 |
{ |
| 38 |
trap - 0 1 2 3 9 11 13 15 |
| 39 |
echo |
| 40 |
[ ${WORKDIR} ] && [ -d ${WORKDIR} ] && rm -rf ${WORKDIR} |
| 41 |
} |
| 42 |
|
| 43 |
DIR=$PWD |
| 44 |
TAG=$(git describe --tags --always) |
| 45 |
|
| 46 |
## |
| 47 |
## Allow overrides to be passed on the cmdline |
| 48 |
## |
| 49 |
if [ $# -gt 2 ]; then |
| 50 |
usage |
| 51 |
elif [ $# -ge 1 ]; then |
| 52 |
DIR=$1 |
| 53 |
if [ $# -eq 2 ]; then |
| 54 |
TAG=$2 |
| 55 |
fi |
| 56 |
fi |
| 57 |
|
| 58 |
# verify the tag exists |
| 59 |
git rev-list -1 tags/${TAG} -- >/dev/null || usage |
| 60 |
|
| 61 |
WORKDIR=$(mktemp -d) |
| 62 |
|
| 63 |
## |
| 64 |
## Create the archive |
| 65 |
## |
| 66 |
( |
| 67 |
cd ${SRC} |
| 68 |
MTIME=$(date -d @`git log -1 --pretty=format:%ct tags/${TAG}` '+%Y-%m-%d %H:%M:%S') |
| 69 |
VERSION=$(git show tags/${TAG}:VERSION.txt) |
| 70 |
ARCHIVE=$DIR/qpid-proton-${VERSION}.tar.gz |
| 71 |
PREFIX=qpid-proton-${VERSION} |
| 72 |
[ -d ${WORKDIR} ] || mkdir -p ${WORKDIR} |
| 73 |
git archive --format=tar --prefix=${PREFIX}/ tags/${TAG} \ |
| 74 |
| tar -x -C ${WORKDIR} |
| 75 |
cd ${WORKDIR} |
| 76 |
tar -c -z \ |
| 77 |
--owner=root --group=root --numeric-owner \ |
| 78 |
--mtime="${MTIME}" \ |
| 79 |
-f ${ARCHIVE} ${PREFIX} |
| 80 |
echo "${ARCHIVE}" |
| 81 |
) |