-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_ind_os.sh
87 lines (67 loc) · 2.29 KB
/
build_ind_os.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
lodev=""
mntdir=""
cleanup() {
if [ -n "${lodev}" ]; then
sudo losetup -d "${lodev}"
fi
if [ -n "${mntdir}" ]; then
mountpoint "${mntdir}" >/dev/null && sudo umount "${mntdir}"
rmdir "${mntdir}"
fi
}
# ---------------------------------------------------------------------------------------------------------------------
# Clean previous build
# ---------------------------------------------------------------------------------------------------------------------
get_build_mounts() {
mount|awk '{print $3;}'|grep ^${PWD}/ || true
}
rm_build_mounts() {
local tries=0
while :
do
mounts=$(get_build_mounts)
[ -z "${mounts}" ] && break
for m in ${mounts}
do
sudo umount ${m} 2>/dev/null || true
done
# Abort if some mounts remain after multiple attempts
tries=$((${tries} + 1))
if [ ${tries} -ge 3 ]
then
echo "# error: mounts within 'tmp' are busy!" >&2
exit 1
fi
sleep 1
done
}
trap cleanup EXIT
mounts=$(get_build_mounts)
if [ -n "${mounts}" ]; then
echo "# trying to remove mounts from previous build(s)..."
rm_build_mounts
fi
MACHINE=$1
BUILD_DIRECTORY=$2
echo "$(pwd)"
echo "Printed current working directory"
sudo rm -rf build
. industrial-core/setup-environment ipc
bitbake development-image
bitbake service-stick-image
echo "Create a loopback device for the current service stick image"
sudo losetup -d /dev/loop0 2>/dev/null || true
sudo losetup /dev/loop0 tmp/deploy/images/ipc/service-stick-image-industrial-os-ipc.wic.img
echo "Probe partitions from the service stick (image)"
sudo partprobe /dev/loop0
echo "Mount the ipc partition"
sudo mkdir -p /mnt/ipc_mnt
sudo mount -o loop /dev/loop0p3 /mnt/ipc_mnt
sudo mkdir -p /mnt/ipc_mnt/images
echo "Copy images to be included"
mv tmp/deploy/images/ipc/development-image-industrial-os-ipc.wic.img tmp/deploy/images/ipc/development-image-industrial-os-ipc.wic
gzip -c tmp/deploy/images/ipc/development-image-industrial-os-ipc.wic | sudo tee /mnt/ipc_mnt/images/image-industrial-os-ipc.wic.gz >/dev/null
echo "Copy the packages you need from the mel-apt folder to the apt folder on the service stick to install offline packages"
sudo umount /mnt/ipc_mnt
sudo losetup -d /dev/loop0
sync