forked from aarch64-laptops/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquick-start.sh
executable file
·116 lines (96 loc) · 3.82 KB
/
quick-start.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
#!/bin/bash
SCRIPTDIR=scripts
source $SCRIPTDIR/laptops-common.inc
OUTDIR=output
# Exit on any error (saves checking the return value of everything)
set -e
print_blue()
{
echo -e "\e[01;34m$@ \e[0m"
}
function usage()
{
print_blue "USAGE: $0 [[asus-tp370ql|hp-envy-x2]lenovo-miix-630|lenovo-yoga-c630|generic]|kernel|grub|help][-f]"
return 1
}
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
usage
fi
while [ $# -gt 0 ]; do
case $1 in
asus-tp370ql|hp-envy-x2|lenovo-miix-630|lenovo-yoga-c630|generic)
DEVICE=$1
;;
kernel)
BUILD_KERNEL=true
;;
grub)
BUILD_GRUB=true
;;
createclean)
BUILD_CLEAN_IMAGE=true
;;
-f|--force)
EXTRAARGS="$EXTRAARGS -f"
;;
help|--help|-h|?)
usage
;;
*)
print_blue "Unrecognised parameter $1"
usage
;;
esac
shift
done
startup_checks()
{
VMNAME=aarch64-laptops-$DISTRO_VERSION
if [ ! -d isos ] || [ ! -d output ] || [ ! -d scripts ]; then
print_blue "$0 should be executed from this project's root directory"
fi
if [ ! $BUILD_KERNEL ] && [ ! $BUILD_GRUB ]; then
if ls $OUTDIR/$VMNAME.img > /dev/null 2>&1; then
print_blue "The output directory already contains a VM image - either relocate or delete it to continue"
return 1
fi
fi
}
startup_checks
print_blue "Create the containerised build environment (~5 mins)"
print_blue " Containerised Ubuntu to be fully updated with all prerequisite packages installed"
docker build -t aarch64-laptops-build-env:0.1 .
if [ $BUILD_KERNEL ]; then
print_blue "Building the Linux kernel (~35 mins)"
docker run -ti --rm --name aarch64-laptops-kernel \
-v $PWD/isos:/isos -v $PWD/output:/output -v $PWD/scripts:/scripts -v $PWD/src:/src \
aarch64-laptops-build-env:0.1 /scripts/make-image.sh --build-kernel ${EXTRAARGS}
exit 0
fi
if [ $BUILD_GRUB ]; then
print_blue "Building Grub (~5 mins)"
docker run -ti --rm --name aarch64-laptops-grub \
-v $PWD/isos:/isos -v $PWD/output:/output -v $PWD/scripts:/scripts -v $PWD/src:/src \
aarch64-laptops-build-env:0.1 /scripts/make-image.sh --build-grub ${EXTRAARGS}
exit 0
fi
if [ $BUILD_CLEAN_IMAGE ]; then
print_blue "Building a clean pre-built image for faster future runs"
print_blue " Ubuntu installed in a VM (using LibVirt)"
docker run -ti --privileged --name aarch64-laptops-ubuntu-vm \
-v $PWD/isos:/isos -v $PWD/output:/output -v $PWD/scripts:/scripts -v $PWD/src:/src \
aarch64-laptops-build-env:0.1 /scripts/make-image.sh --make-clean-prebuilt-ubuntu --install-ubuntu ${EXTRAARGS}
fi
print_blue "Build the basic SD card image - requires user input (~2 hours manual : ~5 mins prebuilt)"
print_blue " Ubuntu installed in a VM (using LibVirt)"
docker run -ti --privileged --name aarch64-laptops-ubuntu-vm \
-v $PWD/isos:/isos -v $PWD/output:/output -v $PWD/scripts:/scripts -v $PWD/src:/src \
aarch64-laptops-build-env:0.1 /scripts/make-image.sh --install-ubuntu-from-prebuilt ${EXTRAARGS}
print_blue "Saving the aarch64-laptops-ubuntu-vm container as an image"
docker commit aarch64-laptops-ubuntu-vm aarch64-laptops-ubuntu-vm:0.1
print_blue "Cleaning up the no longer required aarch64-laptops-ubuntu-vm container"
docker rm aarch64-laptops-ubuntu-vm
print_blue "Setting up VM (~2.5 hours - manual : 30 mins - prebuilt)"
docker run -ti --rm --privileged --name aarch64-laptops-ubuntu-vm-setup \
-v $PWD/isos:/isos -v $PWD/output:/output -v $PWD/scripts:/scripts -v $PWD/src:/src \
aarch64-laptops-ubuntu-vm:0.1 /scripts/make-image.sh --setup-vm-from-prebuilt ${DEVICE} ${EXTRAARGS}