forked from kirei/flashboot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-release.sh
executable file
·107 lines (84 loc) · 2.39 KB
/
build-release.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
CWD=`pwd`
WORKDIR=sandbox
export CWD WORKDIR
# Update for each new release
SHORTREL="58"
LONGREL="5.8"
# No need to change anything below this line for new OS releases!
# Change if ftp.su.se is not the best place to get your files from!
URLBASE="http://ftp.su.se/pub/OpenBSD/${LONGREL}"
PATCHURL="ftp://ftp.openbsd.org/pub/OpenBSD/patches/${LONGREL}/common/*"
echo "Cleaning up previous build.."
rm -rf ${WORKDIR}
echo "Creating sandbox and diststuff.."
mkdir -p ${WORKDIR}
mkdir -p diststuff
echo "Getting current patches.."
mkdir ${WORKDIR}/patches
cd ${WORKDIR}/patches
ftp ${PATCHURL}
cd ${CWD}
binfiles="base${SHORTREL}.tgz
etc${SHORTREL}.tgz
comp${SHORTREL}.tgz
man${SHORTREL}.tgz"
srcfiles="src.tar.gz
sys.tar.gz"
cd diststuff
echo "Downloading binary release.."
for file in ${binfiles}; do
if [ ! -f ${file} ] ; then
echo "Needed ${file}, didn't find it in current dir so downloading.."
ftp ${URLBASE}/`machine`/${file}
fi
done
echo "Downloading source.."
for file in ${srcfiles}; do
if [ ! -f ${file} ] ; then
echo "Needed ${file}, didn't find it in current dir so downloading.."
ftp ${URLBASE}/${file}
fi
done
for file in ${binfiles}; do
echo "checking ${file} file integrity"
gunzip -t ${file}
if [ $? != 0 ] ; then
echo "${file} is corrupt! Exiting"
exit
fi
echo "file integrity OK, extracting ${file} to ${WORKDIR}"
tar zxpf ${file} -C ../${WORKDIR}
done
for file in ${srcfiles}; do
echo "checking ${file} file integrity"
gunzip -t ${file}
if [ $? != 0 ] ; then
echo "${file} is corrupt! Exiting"
exit
fi
echo "file integrity OK, extracting ${file} to ${WORKDIR}"
tar zxpf ${file} -C ../${WORKDIR}/usr/src
done
cd ..
echo "Setting up environment.."
umount ${CWD}/${WORKDIR}/dev
rm -rf ${CWD}/${WORKDIR}/dev-orig
mv ${CWD}/${WORKDIR}/dev ${CWD}/${WORKDIR}/dev-orig
mkdir ${CWD}/${WORKDIR}/dev
mount_mfs -o nosuid -s 32768 swap ${CWD}/${WORKDIR}/dev
cp -p ${CWD}/${WORKDIR}/dev-orig/MAKEDEV ${CWD}/${WORKDIR}/dev/MAKEDEV
cd ${CWD}/${WORKDIR}/dev
./MAKEDEV std
cp -p ${CWD}/mk-mini.conf ${CWD}/${WORKDIR}/mk-mini.conf
cp -p ${CWD}/build-release-injail.sh ${CWD}/${WORKDIR}/
# Don't want anything mounted to /mnt when we starts
umount /mnt
echo "Going into chroot to build.."
/usr/sbin/chroot ${CWD}/${WORKDIR} ./build-release-injail.sh
sleep 4
cd
rm -rf ${CWD}/${WORKDIR}/dev/*
umount ${CWD}/${WORKDIR}/dev
echo "DONE! Now build kernel."
exit