summaryrefslogtreecommitdiff
path: root/ci/make-git-snapshot.sh
blob: ee67a5b3b6840f0b9ed48f99312a204179486d10 (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
#!/bin/bash
set -xeuo pipefail

TOP=$(git rev-parse --show-toplevel)
GITREV=$(git rev-parse HEAD)
gitdescribe=$(git describe --always --tags $GITREV)
version=$(echo "$gitdescribe" | sed -e 's,-,\.,g' -e 's,^v,,')
name=libostree
PKG_VER="${name}-${version}"

TARFILE=${PKG_VER}.tar
TARFILE_TMP=${TARFILE}.tmp

git submodule update --init

echo "Archiving ${PKG_VER} at ${GITREV} to ${TARFILE_TMP}"
(cd ${TOP}; git archive --format=tar --prefix=${PKG_VER}/ ${GITREV}) > ${TARFILE_TMP}
ls -al ${TARFILE_TMP}
(cd ${TOP}; git submodule status) | while read line; do
    rev=$(echo ${line} | cut -f 1 -d ' '); path=$(echo ${line} | cut -f 2 -d ' ')
    echo "Archiving ${path} at ${rev}"
    (cd ${TOP}/${path}; git archive --format=tar --prefix=${PKG_VER}/${path}/ ${rev}) > submodule.tar
    tar -A -f ${TARFILE_TMP} submodule.tar
    rm submodule.tar
done
mv ${TARFILE_TMP} ${TARFILE}
xz "${TARFILE}"