aboutsummaryrefslogtreecommitdiffstats
path: root/preparechroot.sh
blob: df673eaa21df94dbd28f778651a116f7d3399145 (plain)
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
#!/bin/bash

source colors.sh

export LFS="$1"

if [[ -z "${LFS}" ]]; then
	printf "%b" "  ${IGRN}preparechroot.sh${RST}: ${IRED}Require first argument as path to LFS build!${RST}\n"
	exit 1
fi

if [[ -f chrootprepared ]]; then
	printf "%b" "  ${IRED}CHROOT ${IGRN}already prepared\n${RST}"
else
	printf "%b" "${GRN}Changing ownership to root...${RST}\n"
	{
	sudo chown -v  root:root "${LFS}"
	sudo chown -Rv root:root "${LFS}"/bin
	sudo chown -Rv root:root "${LFS}"/etc
	sudo chown -Rv root:root "${LFS}"/lib
	sudo chown -Rv root:root "${LFS}"/sbin
	sudo chown -Rv root:root "${LFS}"/tools
	sudo chown -Rv root:root "${LFS}"/usr
	sudo chown -Rv root:root "${LFS}"/var

	case $(uname -m) in
		x86_64) sudo chown -Rv root:root "${LFS}"/lib64 ;;
	esac
	} >"${LFS}"/sources/log/preparechroot.log 2>&1

	printf "%b" "${GRN}Creating virtual kernel filesystem mountpoints...${RST}\n"
	{
	sudo mkdir -pv "${LFS}"/dev
	sudo mkdir -pv "${LFS}"/proc
	sudo mkdir -pv "${LFS}"/run
	sudo mkdir -pv "${LFS}"/sys
	} >>"${LFS}"/sources/log/preparechroot.log 2>&1

	printf "%b" "${GRN}Creating initial device nodes...${RST}\n"
	{
	sudo mknod -m 600 "${LFS}"/dev/console c 5 1
	sudo mknod -m 666 "${LFS}"/dev/null c 1 3
	} >>"${LFS}"/sources/log/preparechroot.log 2>&1
	
	source mountvirtfs.sh

	touch chrootprepared
fi