-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
71 lines (59 loc) · 2.4 KB
/
build.sh
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
#!/bin/sh
ARCH=amd64
FBSD_RELEASES="11.2-STABLE 12.0-STABLE"
OWNER=fubarnetes
REPO=mfsbsd-testing
git submodule init
git submodule update
cp conf/* mfsbsd/conf/
cat keys/*.pub >> mfsbsd/conf/authorized_keys
if [ -z $GITHUB_TOKEN ]; then
echo "GITHUB_TOKEN not set. Only building"
fi
if [ -z $TAG ]; then
echo "attempting to guess current tag."
TAG=$(git describe --tags --exact-match 2>/dev/null)
echo Tag: $TAG
fi
if [ -z $TAG ]; then
echo "TAG not set. Only building"
fi
echo downloading distfiles...
for FBSD_RELEASE in ${FBSD_RELEASES}; do
mkdir -p ${FBSD_RELEASE}
curl --progress-bar -C - \
-o ${FBSD_RELEASE}/kernel.txz \
http://ftp.freebsd.org/pub/FreeBSD/snapshots/${ARCH}/${FBSD_RELEASE}/kernel.txz
curl --progress-bar -C - \
-o ${FBSD_RELEASE}/base.txz \
http://ftp.freebsd.org/pub/FreeBSD/snapshots/${ARCH}/${FBSD_RELEASE}/base.txz
done
for FBSD_RELEASE in ${FBSD_RELEASES}; do
rm -rf mfsbsd/work
make -C mfsbsd iso \
RELEASE=${FBSD_RELEASE} \
MFSROOT_MAXSIZE=4g \
MFSROOT_FREE_BLOCKS="90%" \
MFSROOT_FREE_INODES="90%" \
ROOTHACK=1 \
PRUNELIST=../prunelist \
BASE=../${FBSD_RELEASE}
done
if [ ! -z $TAG ] && [ !-z $GITHUB_TOKEN ]; then
AUTHHDR="Authorization: token $GITHUB_TOKEN"
# FIXME: check the auth hdr
RELEASE_ID=$(curl -s -H "${AUTHHDR}" https://api.github.com/repos/${OWNER}/${REPO}/releases | jq -r '.[]|select(.tag_name=="'${TAG}'")|.id')
# FIXME: check if there is no release, and create one if necessary.
UPLOAD_URL=$(curl -s -H "${AUTHHDR}" https://api.github.com/repos/${OWNER}/${REPO}/releases/${RELEASE_ID} | jq -r '.upload_url' | cut -d'{' -f1 )
echo "uploading images..."
for FBSD_RELEASE in ${FBSD_RELEASES}; do
ISOFILE=mfsbsd-${FBSD_RELEASE}-${ARCH}.iso
UPLOAD=$(curl \
--progress-bar \
-H "${AUTHHDR}" \
-H "Content-Type: $(file -b --mime-type mfsbsd/${ISOFILE})" \
-H "Accept: application/vnd.github.manifold-preview" \
--data-binary @mfsbsd/${ISOFILE} \
"${UPLOAD_URL}?name=${ISOFILE},label=${FBSD_RELEASE}")
done
fi