aboutsummaryrefslogtreecommitdiff
path: root/tools/mk-release-source
blob: 7964665b3e471d2623ba0efd4c1856e57695260f (plain)
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
#!/bin/sh
REVISION="${1}"
COMPRESS="gzip"
WORKDIR="xbmc-${REVISION}"

if [[ -z "${REVISION}" ]]; then echo "Usage: ${0} tag|branch|commit [gzip|xz|...]" && exit 1; fi
if [[ -d "${WORKDIR}" ]]; then echo "${WORKDIR} dir exists, refusing to overwrite" && exit 1; fi
if [[ -n "${2}" ]]; then COMPRESS="${2}"; fi

which git >/dev/null || exit 1
git rev-list -1 ${REVISION} >/dev/null || exit 1

mkdir -p "${WORKDIR}"
GIT_WORK_TREE="${WORKDIR}" git checkout "${REVISION}" -- . || exit 1

pushd "${WORKDIR}" >/dev/null
./bootstrap || ( rm -rf "${WORKDIR}" && exit 1 )
popd >/dev/null

pushd "${WORKDIR}/tools/android/depends" >/dev/null
./bootstrap || ( rm -rf "${WORKDIR}" && exit 1 )
popd >/dev/null

echo "${REVISION}" > "${WORKDIR}"/VERSION
echo "`git rev-list -1 ${REVISION}`" >> "${WORKDIR}"/VERSION

tar cf "${WORKDIR}.tar" "${WORKDIR}" || ( rm -f "${WORKDIR}.tar" && rm -rf "${WORKDIR}" exit 1 )
${COMPRESS} ${WORKDIR}.tar || ( rm -f "${WORKDIR}.tar" && rm -rf "${WORKDIR}" && exit 1 )

rm -rf ${WORKDIR}
exit 0