| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Copyright © 2012-2021 Jakub Wilk <[email protected]> |
| 4 |
# |
| 5 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
# of this software and associated documentation files (the “Software”), to deal |
| 7 |
# in the Software without restriction, including without limitation the rights |
| 8 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
# copies of the Software, and to permit persons to whom the Software is |
| 10 |
# furnished to do so, subject to the following conditions: |
| 11 |
# |
| 12 |
# The above copyright notice and this permission notice shall be included in |
| 13 |
# all copies or substantial portions of the Software. |
| 14 |
# |
| 15 |
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 |
# SOFTWARE. |
| 22 |
|
| 23 |
set -e |
| 24 |
cd "${0%/*}/.." |
| 25 |
if [ $# -ge 2 ] |
| 26 |
then |
| 27 |
printf '%s [commit]\n' "$0" >&2 |
| 28 |
exit 1 |
| 29 |
fi |
| 30 |
if ! [ -d .git ] |
| 31 |
then |
| 32 |
printf '%s requires git checkout\n' "$0" >&2 |
| 33 |
exit 1 |
| 34 |
fi |
| 35 |
pwd="$PWD" |
| 36 |
commit=${1:-HEAD} |
| 37 |
commit=$(git describe "$commit") |
| 38 |
name=$(git cat-file blob "$commit:doc/changelog" | head -n1 | cut -d ' ' -f 1) |
| 39 |
date=$(git rev-list -1 --format=%cI "$commit" | grep -o '^....-..-..' | tr -d -) |
| 40 |
version=$(git cat-file blob "$commit:doc/changelog" | head -n1 | cut -d ' ' -f2 | tr -d '()') |
| 41 |
released=$(git cat-file blob "$commit:doc/changelog" | head -n1 | grep -v -w UNRELEASED || true) |
| 42 |
[ -n "$released" ] || version="${version}rc${date}" |
| 43 |
printf 'Commit: %s\nVersion: %s\n' "$commit" "$version" >&2 |
| 44 |
set -x |
| 45 |
sourceroot=$(mktemp -d -t "$name-source-XXXXXX") |
| 46 |
tar_opts='--owner root --group root --mode u=rwX,go=rX --format ustar --sort name' |
| 47 |
gzip='gzip -9 -n' |
| 48 |
git archive "$commit" --prefix="$name-$version/" | tar -C "$sourceroot" -xf - |
| 49 |
cd "$sourceroot"/* |
| 50 |
rm -r .git* |
| 51 |
rm private/build-source-tarball |
| 52 |
rm README.rst # shipped as doc/README |
| 53 |
mv LICENSE doc/ |
| 54 |
make -C doc/ |
| 55 |
find . '(' -name '__pycache__' -o -name '*.py[co]' ')' -delete |
| 56 |
rm -r doc/rtd/ |
| 57 |
cd .. |
| 58 |
mkdir -p "$pwd/dist" |
| 59 |
tar $tar_opts -I "$gzip" -cf "$pwd/dist/$name-$version.tar.gz" */ |
| 60 |
rm -r "$sourceroot" |
| 61 |
set +x |
| 62 |
cd "$pwd" |
| 63 |
ls -d "dist/$name-$version.tar.gz" |
| 64 |
|
| 65 |
# vim:ts=4 sts=4 sw=4 et |