mk-snapshot.sh 1.52 KB
Newer Older
Ben Gamari's avatar
Ben Gamari committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash -e

# Create a snapshot of the libffi repository from github, as a workaround for
# the lack of recent releases of libffi (see https://github.com/libffi/libffi/issues/296)

GVERS=3.99999 # see configure.ac / AC_INIT

# make a temporary directory and perform operations in there.
TMPD=$(mktemp -d)
TDIR=$(pwd)

# clone the repository (shallow is sufficient)
git -C ${TMPD} clone --depth 1 https://github.com/libffi/libffi.git
REPO="${TMPD}/libffi"

# record the revision and create a copy of only the files
# contained in the repository at libffi-<revision>
GHASH=$(git -C ${REPO} rev-parse --short HEAD)
GDATE=$(git -C ${REPO} log -1 --pretty=format:%cd --date=format:%Y%m%d)
SUFFIX="${GVERS}+git${GDATE}+${GHASH}"

22
23
# run autogen and generate distribution tarball.
(cd "$REPO" && ./autogen.sh && ./configure && make dist)
Ben Gamari's avatar
Ben Gamari committed
24
25

# package it up
26
27
28
DISTLIB="libffi-${GVERS}.tar.gz"
FINALLIB="libffi-${SUFFIX}.tar.gz"
mv "$REPO/$DISTLIB" ./$FINALLIB
Ben Gamari's avatar
Ben Gamari committed
29

30
# create orphan libffi-tarballs branch
Ben Gamari's avatar
Ben Gamari committed
31
git checkout --orphan "libffi-${SUFFIX}"
32
git add $FINALLIB
Ben Gamari's avatar
Ben Gamari committed
33
34
35
36
37
38
39
40
41
42
43
44
cat >README.md <<EOF
# libffi snapshot tarball for GHC

This source snapshot was produced from
[libffi](https://github.com/libffi/libffi) commit
[${GHASH}](https://github.com/libffi/libffi/commit/${GHASH}) for GHC. See the
\`master\` branch of this repository for more information about the rationale
and tools for producing these snapshots.
EOF
git add README.md
git rm --cached mk-snapshot.sh
git commit -m "Snapshot of libffi ${GHASH}"
45
git checkout -f master
Ben Gamari's avatar
Ben Gamari committed
46
47

echo "Created branch libffi-${SUFFIX}"