-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild-debian-remote-installer
executable file
·56 lines (46 loc) · 1.32 KB
/
build-debian-remote-installer
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
#!/bin/bash
# build-remote-debian-installer
#
# Grabs the stable installer source from apt
# and configures it to allow installation via
# SSH remotely.
if [[ $_ != $0 ]]; then
mode='sourced'
else
mode='script'
fi
source common.sh
function check_privilege() {
if [[ $UID != 0 ]]; then
info 'This script needs root privileges to run, trying sudo'
sudo echo || exit 1
fi
}
function install_apt_dependencies() {
info 'Installing dependencies for chroot'
sudo aptitude install -y binutils debootstrap
}
function create_chroot() {
info 'Creating chroot for build'
sudo /usr/sbin/debootstrap --arch "$ARCH" "$RELEASE" di-chroot http://cdn.debian.net/debian
sudo mkdir -p di-chroot/opt/di-build
sudo cp common.sh chroot-payload preseed.cfg di-chroot/opt/di-build/
}
function run_chroot_build() {
info 'Entering chroot...'
sudo /usr/sbin/chroot di-chroot /opt/di-build/chroot-payload
}
function copy_build_artifacts() {
cp "di-chroot/debian-installer/debian-installer-$DI_VERSION/build/dest/netboot/debian-installer/amd64/linux" '.'
cp "di-chroot/debian-installer/debian-installer-$DI_VERSION/build/dest/netboot/debian-installer/amd64/initrd.gz" '.'
}
function main() {
check_privilege
install_apt_dependencies
create_chroot
run_chroot_build
copy_build_artifacts
}
if [[ $mode == 'script' ]]; then
main
fi