blob: fedf71a35acfb347abd4f1c3c7bcecb9fb8d5667 (
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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#!/bin/bash
clear
printf "%b" "Sourcing colors...\n"
# Colors defined for text
source colors.sh
printf "%b" "Sourcing environment variables...\n"
# LFS build environment settings
source env.sh
printf "%b" "Sourcing functions...\n"
# Functions used during build
source functions.sh
# Version check script
#source versioncheck.sh
printf "%b" "\n\n\n${CYN}BUILDING ${YLW}${LFS_VER} $(uname -m)${CYN} at \
${IWHT}${LFS}${CYN} on ${IWHT}${LFS_DISK}${LFS_PART}${RST}\n\n\n"
# Continue or Abort
printf "%b" "${IGRN}CONTINUE ${IWHTB}(C)${RST} / ${IRED}ABORT ${IWHTB}(OTHER)${RST}\n"
if read -r -n 1 contabort; then
if [ "$contabort" == "C" ] || [ "$contabort" == "c" ]; then
printf "%b" "\b${IWHT}Build is ${IGRN}CONTINUING${RST}\n"
else
printf "%b" "\b${IWHT}Build ${IRED}ABORTED!\n"
exit 0
fi
else
printf "%b" "\b${IWHT}Selection ${IRED}FAILURE!${RST}\n"
exit 1
fi
printf "%b" "${GRN}Creating LFS directory at ${YLW}${LFS}${GRN} if it does not exist...${RST}\n"
# Create LFS directory if it doesn't exist
[[ -d /mnt/lfs ]] || sudo mkdir "${LFS}"
# Setup partition, filesystem, format and mount if
# LFS filesystem is not previously mounted
if ! grep -q "${LFS}" /proc/mounts; then
printf "%b" "${GRN}Setting up partition on ${YLW}${LFS_DISK} ${GRN}\
with ${YLW}ext4${GRN} filesystem at ${YLW}${LFS_DISK}${LFS_ROOT} ${GRN}\
and mounting at ${YLW}${LFS}${RST}...\n"
source setupdisk.sh "${LFS_DISK}" "${LFS_PART}"
sudo mount "${LFS_DISK}${LFS_PART}" "${LFS}"
sudo chown -v "${USER}" "${LFS}"
fi
# Create limited directory layout
mkdir -p "${LFS}"/sources
mkdir -p "${LFS}"/tools
mkdir -p "${LFS}"/bin
mkdir -p "${LFS}"/etc
mkdir -p "${LFS}"/lib
mkdir -p "${LFS}"/sbin
mkdir -p "${LFS}"/usr
mkdir -p "${LFS}"/var
case $(uname -m) in
x86_64) mkdir -p "${LFS}"/lib64 ;;
esac
# Will use normal user and not special lfs user
#sudo groupadd lfs
#sudo useradd -s /bin/bash -g lfs -m -k /dev/null lfs
#printf "%b" "${LFS_PWD}\n${LFS_PWD}\n" | sudo passwd lfs
# Copy scripts and csv files to LFS sources target
cp -rf ./*.sh chapter* ./*.csv "${LFS}/sources"
cd "${LFS}/sources" || exit 1
# Download packages and patches
source download.sh
retval=$?
if [ "$retval" -ne 0 ]; then
exit 1
fi
# Chapter 5
for package in binutils gcc linux-api-headers glibc libstdc++; do
source packageinstall.sh 5 $package
retval=$?
if [ "$retval" -ne 0 ]; then
exit 1
fi
done
# Chapter 6
for package in m4 ncurses bash coreutils diffutils file findutils gawk grep gzip make patch sed tar xz binutils gcc; do
source packageinstall.sh 6 $package
retval=$?
if [ "$retval" -ne 0 ]; then
exit 1
fi
done
source chapter6/cleanup.sh
source chapter6/backup.sh
chmod ugo+x preparechroot.sh
chmod ugo+x insidechroot.sh
printf "%b" "${CYN}PREPARING ${RED}CHROOT${RST} ENVIRONMENT...${RST}\n"
sudo ./preparechroot.sh "${LFS}"
printf "%b" "${CYN}ENTERING ${RED}CHROOT${RST} ENVIRONMENT...${RST}\n"
sleep 3
sudo chroot "${LFS}" /usr/bin/env \
HOME=/root \
TERM="${TERM}" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
NUMPROCS="${NUMPROCS}" \
MAKEFLAGS="${MAKEFLAGS}" \
TESTERUID="$(id -u)" \
/bin/bash --login +h -c "/sources/insidechroot.sh 7"
retval=$?
printf "%b" "${CYN}EXITED ${RED}CHROOT${RST} ENVIRONMENT...${RST}\n"
# Cleanup and Backup if chapter 7 successfully finished
if [ "$retval" -eq 7 ]; then
printf "%b" "${GRN}Unmounting Virtual Kernel Filesystems...\n"
sudo umount "${LFS}"/dev/pts
sudo umount "${LFS}"/dev/
sudo umount "${LFS}"/run
sudo umount "${LFS}"/sys
sudo umount "${LFS}"/proc
printf "%b" "${GRN}Cleaning and backing up before starting Chapter 8.\n"
source "${LFS}"/sources/chapter7/cleanup.sh
source "${LFS}"/sources/chapter7/backup.sh
else
exit "$retval"
fi
# Mount virtual kernel filesystems after cleanup and backup
source mountvirtfs.sh
# Enter CHROOT for chapter 8, 9 and 10
sudo chroot "${LFS}" /usr/bin/env \
HOME=/root \
TERM="${TERM}" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
NUMPROCS="${NUMPROCS}" \
MAKEFLAGS="${MAKEFLAGS}" \
TESTERUID="$(id -u)" \
/bin/bash --login +h -c "/sources/insidechroot.sh 8"
printf "%b" "${CYN}EXITED ${RED}CHROOT${RST} ENVIRONMENT...${RST}\n"
|