forked from ading2210/shimboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_rootfs.sh
executable file
·47 lines (38 loc) · 944 Bytes
/
build_rootfs.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
#!/bin/bash
#build the debian rootfs
set -e
if [ "$DEBUG" ]; then
set -x
fi
print_help() {
echo "Usage: ./build_rootfs.sh rootfs_path release_name"
}
check_deps() {
local needed_commands="realpath debootstrap"
for command in $needed_commands; do
if ! command -v $command &> /dev/null; then
echo $command
fi
done
}
if [ "$EUID" -ne 0 ]; then
echo "this needs to be run as root."
exit 1
fi
if [ -z "$2" ]; then
print_help
exit 1
fi
missing_commands=$(check_deps)
if [ "${missing_commands}" ]; then
echo "You are missing dependencies needed for this script."
echo "Commands needed:"
echo "${missing_commands}"
exit 1
fi
rootfs_dir=$(realpath "${1}")
release_name="${2}"
debootstrap $release_name $rootfs_dir http://deb.debian.org/debian/
cp -r rootfs/* $rootfs_dir
chroot_command="DEBUG=${DEBUG} release_name=${release_name} /opt/setup_rootfs.sh"
chroot $rootfs_dir /bin/bash -c "${chroot_command}"