File: make-tarball.sh

package info (click to toggle)
pax-utils 1.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 728 kB
  • sloc: ansic: 8,752; sh: 671; python: 495; makefile: 303
file content (86 lines) | stat: -rwxr-xr-x 1,516 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash

set -e

if ! . /etc/init.d/functions.sh 2>/dev/null ; then
	einfo() { printf ' * %b\n' "$*"; }
	eerror() { einfo "$@" 1>&2; }
fi
die() { eerror "$@"; exit 1; }

v() { printf '\t%s\n' "$*"; "$@"; }

: ${MAKE:=make}

CHECK=false
if [[ $1 == "--check" ]] ; then
	CHECK=true
	shift
fi

if [[ $# -ne 1 ]] ; then
	die "Usage: $0 <ver>"
fi

case $1 in
snap) ver=$(date -u +%Y%m%d) ;;
git) ver="HEAD" ;;
*)
	ver="v${1#v}"
	if ! git describe --tags "${ver}" >&/dev/null ; then
		die "Please create the tag first: git tag ${ver}"
	fi
	;;
esac
p="pax-utils-${ver#v}"

rm -rf "${p}"
mkdir "${p}"

einfo "Checking out clean git sources ..."
git archive "${ver}" | tar xf - -C "${p}"

pushd "${p}" >/dev/null

einfo "Building docs ..."
echo "<releaseinfo>${ver#v}</releaseinfo>" > man/fragment/version
make -C man

einfo "Building autotools ..."
sed -i "/^AC_INIT/s:git:${ver}:" configure.ac
sed -i "1iPV := ${ver}" Makefile
SKIP_AUTOTOOLS_UPDATE=true LC_ALL=C ${MAKE} -s autotools >/dev/null
rm -rf autom4te.cache

popd >/dev/null

einfo "Generating tarball ..."
tar cf - "${p}" | xz > "${p}".tar.xz
rm -r "${p}"

if ${CHECK} ; then

einfo "Checking tarball (simple) ..."
tar xf "${p}".tar.*
pushd "${p}" >/dev/null
v ${MAKE} -s
v ${MAKE} -s check
popd >/dev/null
rm -rf "${p}"

einfo "Checking tarball (autotools) ..."
tar xf "${p}".tar.*
pushd "${p}" >/dev/null
v ./configure -q
v ${MAKE} -s
v ${MAKE} -s check
popd >/dev/null
rm -rf "${p}"

fi

echo
einfo "All ready for distribution!"
du -b "${p}".tar.*

exit 0