-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall3_2PrepareChroot.sh
More file actions
103 lines (87 loc) · 2.77 KB
/
Install3_2PrepareChroot.sh
File metadata and controls
103 lines (87 loc) · 2.77 KB
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
#! /bin/zsh
source Utils.sh
UserName=ArchUser;
# =====================================||===================================== #
# #
# Functions #
# #
# ===============ft_linux==============||==============©Othello=============== #
ChangeOwnershipForChroot()
{
# Chaning ownership
EchoInfo "Changing ownership from $UserName to root"
chown --from $UserName -R root:root $LFS/{usr,lib,var,etc,bin,sbin,tools}
case $(uname -m) in
x86_64) chown --from $UserName -R root:root $LFS/lib64 ;;
esac
}
MountFileSystems()
{
# Preparing Virtual Kernel File Systems
EchoInfo "Creating $LFS directories"
mkdir -pv $LFS/{dev,proc,sys,run}
EchoInfo "Mounting $LFS directories"
! mountpoint -q $LFS/dev && mount -v --bind /dev $LFS/dev
! mountpoint -q $LFS/dev/pts && mount -vt devpts devpts -o gid=5,mode=0620 $LFS/dev/pts
! mountpoint -q $LFS/proc && mount -vt proc proc $LFS/proc
! mountpoint -q $LFS/sys && mount -vt sysfs sysfs $LFS/sys
! mountpoint -q $LFS/run && mount -vt tmpfs tmpfs $LFS/run
EchoInfo "Populating $LFS/dev"
if [ -h $LFS/dev/shm ]; then
install -v -d -m 1777 $LFS$(realpath /dev/shm)
else
mountpoint -q $LFS/dev/shm || mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm;
fi
}
DisplayDirectoryList()
{
ls -l $LFS;
printf '%*s\n' "$Width" '' | tr ' ' '-';
}
DisplayMountStructure()
{
findmnt --target $LFS --submounts;
printf '%*s\n' "$Width" '' | tr ' ' '-';
}
# =====================================||===================================== #
# #
# Execution #
# #
# ===============ft_linux==============||==============©Othello=============== #
if [ $# -gt 0 ]; then
case "$1" in
RunAll) PrepareChrootForTemporaryTools;;
*) echo "Bad flag: '$1'";;
esac
exit;
fi
while true; do
Width=$(tput cols);
clear;
printf '%*s\n' "$Width" '' | tr ' ' '-';
echo "${C_ORANGE}${C_BOLD}5. Compiling a Cross-Toolchain${C_RESET}";
echo "Option:\t${-}";
printf '%*s\n' "$Width" '' | tr ' ' '-';
echo "0)\t Prepare Chroot";
echo "7)\t Change Ownership for Chroot";
echo "8)\t Mount Virtual Kernel File Systems";
echo " \t - This needs to repeated if rebooting (!)";
printf '%*s\n' "$Width" '' | tr ' ' '-';
echo "l)\t Display $LFS directory list";
echo "m)\t Display $LFS mount structure";
echo "q)\t Return to main menu";
printf '%*s\n' "$Width" '' | tr ' ' '-';
$LocalCommand;
unset LocalCommand;
echo -n "Input> ";
GetKeyPress;
case $input in
0) ChangeOwnershipForChroot;
MountFileSystems;;
7) ChangeOwnershipForChroot || PressAnyKeyToContinue;;
8) MountFileSystems || { echo $?; PressAnyKeyToContinue; } ;;
l) local LocalCommand="DisplayDirectoryList";;
m) local LocalCommand="DisplayMountStructure";;
q) exit;;
esac
done