summaryrefslogtreecommitdiffstats
path: root/bootstrap-main.sh
blob: 26e3555966ee1f0940a0295f918df7ae85277fb0 (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
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh

set -e

SCRIPT_DIR=
ARCH=
PLAT=

main()
{
	SCRIPT_DIR="$(cd "${0%/*}" && pwd)"
	setup_arch_plat
	"${SCRIPT_DIR}/bootstrap-prepare.sh"
	"${SCRIPT_DIR}/bootstrap-stage1-build.sh"
	"${SCRIPT_DIR}/bootstrap-stage1-install.sh"
	stage1
}

setup_arch_plat()
{
	ARCH="$(cat /etc/proteanos_arch)"
	PLAT="$(cat /etc/proteanos_plat)"
}

stage1()
{
	local zlib_upstream_ver

	sudo chroot . true
	sudo chroot . readelf -hl /usr/bin/readelf

	zlib_upstream_ver="$(printf '%s' ../pkg/zlib/zlib-*.orig.tar* | sed \
		's|^.*/zlib-\([a-z0-9.~]*\).*\.orig\.tar.*$|\1|')"
	tar -xjOf ../pkg/zlib/zlib-*.orig.tar* \
		"zlib-${zlib_upstream_ver}/examples/fitblk.c" >fitblk.c
	sudo chroot . "${ARCH}-gcc" -lz -o /fitblk /fitblk.c
	sudo chroot . /fitblk | grep -F 'fitblk abort' >/dev/null

	cd ..
}

main "${@}"