-
Notifications
You must be signed in to change notification settings - Fork 3
/
install_dracut_and_ostree.sh
executable file
·118 lines (90 loc) · 3.19 KB
/
install_dracut_and_ostree.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
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
echo "Installing dracut and ostree..."
# From https://github.com/beagleboard/image-builder/blob/master/scripts/chroot.sh
chroot_mount () {
if [ "$(mount | grep ${BUILDDIR}/sys | awk '{print $3}')" != "${BUILDDIR}/sys" ] ; then
sudo mount -t sysfs sysfs "${BUILDDIR}/sys"
fi
if [ "$(mount | grep ${BUILDDIR}/proc | awk '{print $3}')" != "${BUILDDIR}/proc" ] ; then
sudo mount -t proc proc "${BUILDDIR}/proc"
fi
if [ ! -d "${BUILDDIR}/dev/pts" ] ; then
sudo mkdir -p ${BUILDDIR}/dev/pts || true
fi
if [ "$(mount | grep ${BUILDDIR}/dev/pts | awk '{print $3}')" != "${BUILDDIR}/dev/pts" ] ; then
sudo mount -t devpts devpts "${BUILDDIR}/dev/pts"
fi
}
chroot_umount () {
if [ "$(mount | grep ${BUILDDIR}/dev/pts | awk '{print $3}')" = "${BUILDDIR}/dev/pts" ] ; then
echo "Log: umount: [${BUILDDIR}/dev/pts]"
sync
sudo umount -fl "${BUILDDIR}/dev/pts"
if [ "$(mount | grep ${BUILDDIR}/dev/pts | awk '{print $3}')" = "${BUILDDIR}/dev/pts" ] ; then
echo "Log: ERROR: umount [${BUILDDIR}/dev/pts] failed..."
exit 1
fi
fi
if [ "$(mount | grep ${BUILDDIR}/proc | awk '{print $3}')" = "${BUILDDIR}/proc" ] ; then
echo "Log: umount: [${BUILDDIR}/proc]"
sync
sudo umount -fl "${BUILDDIR}/proc"
if [ "$(mount | grep ${BUILDDIR}/proc | awk '{print $3}')" = "${BUILDDIR}/proc" ] ; then
echo "Log: ERROR: umount [${BUILDDIR}/proc] failed..."
exit 1
fi
fi
if [ "$(mount | grep ${BUILDDIR}/sys | awk '{print $3}')" = "${BUILDDIR}/sys" ] ; then
echo "Log: umount: [${BUILDDIR}/sys]"
sync
sudo umount -fl "${BUILDDIR}/sys"
if [ "$(mount | grep ${BUILDDIR}/sys | awk '{print $3}')" = "${BUILDDIR}/sys" ] ; then
echo "Log: ERROR: umount [${BUILDDIR}/sys] failed..."
exit 1
fi
fi
if [ "$(mount | grep ${BUILDDIR}/run | awk '{print $3}')" = "${BUILDDIR}/run" ] ; then
echo "Log: umount: [${BUILDDIR}/run]"
sync
sudo umount -fl "${BUILDDIR}/run"
if [ "$(mount | grep ${BUILDDIR}/run | awk '{print $3}')" = "${BUILDDIR}/run" ] ; then
echo "Log: ERROR: umount [${BUILDDIR}/run] failed..."
exit 1
fi
fi
}
cat > "${BUILDDIR}/chroot_script.sh" <<-__EOF__
apt-get update
apt-get install -y dracut git
# install ostree and it's dependencies
# CAREFUL - we're building from source
# so dependencies may have changed since
# current debian version of ostree
apt-get install -y ostree
# remove ostree so only dependencies are left
apt-get purge -y ostree libostree-1-1
cd /tmp
wget https://github.com/PocketNC/ostree/releases/download/test5/ostree.tar.gz
tar xzf ostree.tar.gz
cd ostree_install
cp -r * /
cd ..
rm -r ostree_install
rm ostree.tar.gz
dracut --force --add ostree /boot/initrd.img-$KERNEL_VERSION $KERNEL_VERSION
rm -rf /usr/etc
rm /usr/bin/qemu-arm-static
rm /etc/resolv.conf
ln -s /run/connman/resolv.conf /etc/resolv.conf
apt-get clean
rm /chroot_script.sh
__EOF__
QEMU=$(which qemu-arm-static)
if [ ! -n "${QEMU}" ]; then
echo "qemu-user-static package must be installed"
fi
cp $QEMU ${BUILDDIR}/usr/bin
cp --remove-destination /etc/resolv.conf ${BUILDDIR}/etc/resolv.conf
chroot_mount
chroot ${BUILDDIR} qemu-arm-static /bin/bash -e /chroot_script.sh
chroot_umount