blob: e5aba2de26f714b05d524f8614e1aee439a97663 (
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
155
156
157
158
159
|
#!/bin/bash
set -u
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"
printf "%b" "${IRED}*** ${IREDB}WARNING${RST} \
${IWHT}POTENTIAL DATA LOSS \
${IREDB}WARNING ${RST}${IRED}***${GRN}\n${RST}"
printf "%b" "${GRN}Automatic creation of partition(s), filesystem(s) \n\
and mounting will occur unless manually performed\n\
before continuing.${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\n"
else
printf "%b" "\b${IWHT}Build ${IRED}ABORTED!\n\n"
exit 0
fi
else
printf "%b" "\b${IWHT}Selection ${IRED}FAILURE!${RST}\n\n"
exit 1
fi
# Create LFS directory if it doesn't exist
printf "%b" "${GRN}Creating LFS directory at ${YLW}${LFS}${GRN}... ${RST}"
if [[ -d "${LFS}" ]]; then
printf "%b" "${IGRN}EXISTS${RST}\n"
else
if ! mkdir "${LFS}" >/dev/null 2>&1; then
printf "%b" "${IRED}FAILED!${RST}\n"
exit 1
fi
fi
# Setup partition, filesystem, format and mount if
# LFS filesystem is not previously mounted
if ! grep -q "${LFS}" /proc/mounts; then
printf "%b" "${GRN}Preparing LFS partition and filesystem${RST}...\n"
source setupdisk.sh "${LFS_DISK}" "${LFS_PART}"
printf "%b" " ${IGRN}Mounting ${IWHT}${LFS_DISK}${LFS_PART} ${IGRN}at \
${IWHT}${LFS}${RST}\n"
sudo mount "${LFS_DISK}${LFS_PART}" "${LFS}"
printf "%b" " ${IGRN}Changing ownership of ${IWHT}${LFS}${IGRN} \
to user ${IWHT}${USER}${RST}\n"
sudo chown "${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
printf "%b" "${GRN}Copying required files to ${YLW}${LFS}/sources \
${GRN}target directory... ${RST}"
if ! cp -rf ./*.sh chapter* ./*.csv "${LFS}/sources"; then
printf "%b" "${IRED}FAILED!${RST}\n"
else
printf "%b" "${GRN}OK${RST}\n"
fi
cd "${LFS}/sources" || exit 1
# Download packages and patches
printf "%b" "\n${IWHT}============ ${IGRN}Downloading source files and patches \
${IWHT}============${RST}\n"
source download.sh
retval=$?
if [[ "$retval" -ne 0 ]]; then
exit 1
fi
# Chapter 5
printf "%b" "\n${IWHT}============ ${IGRN}Building ${IYLW}Chapter 5${IWHT} \
============${RST}\n"
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
printf "%b" "\n${IWHT}============ ${IGRN}Building ${IYLW}Chapter 6${IWHT} \
============${RST}\n"
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
printf "%b" "\n${YLW}Chapter 6 ${GRN}cleanup and backup${RST}\n"
source chapter6/cleanup.sh
source chapter6/backup.sh
# Prepare chroot scripts to be executable for owner, group and others
chmod ugo+x preparechroot.sh
chmod ugo+x insidechroot.sh
printf "%b" "\n${CYN}PREPARING ${RED}CHROOT${CYN} ENVIRONMENT...${RST}\n"
sudo ./preparechroot.sh "${LFS}"
printf "%b" "\n${CYN}ENTERING ${RED}CHROOT${CYN} 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"
printf "%b" "\n${CYN}EXITED ${RED}CHROOT${CYN} ENVIRONMENT...${RST}\n"
|