-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild_lfs.sh
More file actions
executable file
·297 lines (235 loc) · 4.34 KB
/
build_lfs.sh
File metadata and controls
executable file
·297 lines (235 loc) · 4.34 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#!/bin/bash
int_build_env()
{
export SCRIPT_NAME="LFS BUILD SCRIPT"
export SCRIPT_VERSION="1.0.0.0"
export LINUX_NAME="LFS"
export DISTRIBUTION_VERSION="1.0.0"
export ISO_FILENAME="LFS-${SCRIPT_VERSION}.iso"
# BASE
export KERNEL_BRANCH="4.x"
export BASEDIR=`realpath --no-symlinks $PWD`
export WORKDIR=${BASEDIR}/workspace
export SOURCEDIR=${WORKDIR}/source
export ROOTFSDIR=${WORKDIR}/rootfs
export BUILDDIR=${WORKDIR}/build
export OUTDIR=${WORKDIR}/output
export ISODIR=${OUTDIR}/iso
#cross compile
export CROSS_COMPILE64=$BASEDIR/cross_gcc/x86_64-linux/bin/x86_64-linux-
export ARCH64="x86_64"
export CROSS_COMPILEi386=$BASEDIR/cross_gcc/i386-linux/bin/i386-linux-
export ARCHi386="i386"
#Dir and mode
export ETCDIR="etc"
export MODE="754"
export DIRMODE="755"
export CONFMODE="644"
#cflags
export CFLAGS=-m64
export CXXFLAGS=-m64
#setting JFLAG
if [ -z "$2" ]
then
export JFLAG=4
else
export JFLAG=$2
fi
}
prepare_dirs () {
cd ${BASEDIR}
if [ ! -d ${WORKDIR} ]
then
mkdir -p ${WORKDIR}
fi
if [ ! -d ${SOURCEDIR} ];
then
mkdir -p ${SOURCEDIR}
fi
if [ ! -d ${ROOTFSDIR} ];
then
mkdir -p ${ROOTFSDIR}
fi
if [ ! -d ${BUILDDIR} ];
then
mkdir -p ${BUILDDIR}
fi
if [ ! -d ${OUTDIR} ];
then
mkdir -p ${OUTDIR}
fi
if [ ! -d ${ISODIR} ];
then
mkdir -p ${ISODIR}
fi
}
build_kernel () {
}
build_busybox () {
}
build_extras () {
#Build extra soft
cd ${BASEDIR}/${BUILD_OTHER_DIR}
if [ "$1" == "-c" ]
then
./build_other_main.sh --clean
elif [ "$1" == "-b" ]
then
./build_other_main.sh --build
fi
}
generate_rootfs () {
}
generate_image () {
}
test_qemu () {
cd ${BASEDIR}
if [ -f ${ISO_FILENAME} ];
then
qemu-system-x86_64 -m 128M -cdrom ${ISO_FILENAME} -boot d -vga std
fi
}
clean_files () {
rm -rf ${WORKDIR}
}
init_work_dir()
{
prepare_dirs
}
clean_work_dir()
{
clean_files
}
build_all()
{
build_kernel -b
build_busybox -b
build_extras -b
}
rebuild_all()
{
clean_all
build_all
}
clean_all()
{
build_kernel -c
build_busybox -c
build_extras -c
}
wipe_rebuild()
{
clean_work_dir
init_work_dir
rebuild_all
}
help_msg()
{
echo -e "#################################################################################\n"
echo -e "############################Utility to Build LFS ###########################\n"
echo -e "#################################################################################\n"
echo -e "Help message --help\n"
echo -e "Build All: --build-all\n"
echo -e "Rebuild All: --rebuild-all\n"
echo -e "Clean All: --clean-all\n"
echo -e "Wipe and rebuild --wipe-rebuild\n"
echo -e "Building kernel: --build-kernel --rebuild-kernel --clean-kernel\n"
echo -e "Building other soft: --build-other --rebuild-other --clean-other\n"
echo -e "Creating root-fs: --create-rootfs\n"
echo -e "Create ISO Image: --create-img\n"
echo -e "Cleaning work dir: --clean-work-dir\n"
echo -e "Test with Qemu --Run-qemu\n"
echo "###################################################################################"
}
option()
{
if [ -z "$1" ]
then
help_msg
exit 1
fi
if [ "$1" == "--build-all" ]
then
build_all
fi
if [ "$1" == "--rebuild-all" ]
then
rebuild_all
fi
if [ "$1" == "--clean-all" ]
then
clean_all
fi
if [ "$1" == "--wipe-rebuild" ]
then
wipe_rebuild
fi
if [ "$1" == "--build-kernel" ]
then
build_kernel -b
elif [ "$1" == "--rebuild-kernel" ]
then
build_kernel -c
build_kernel -b
elif [ "$1" == "--clean-kernel" ]
then
build_kernel -c
fi
if [ "$1" == "--build-busybox" ]
then
build_busybox -b
elif [ "$1" == "--rebuild-busybox" ]
then
build_busybox -c
build_busybox -b
elif [ "$1" == "--clean-busybox" ]
then
build_busybox -c
fi
if [ "$1" == "--build-uboot" ]
then
build_uboot -b
elif [ "$1" == "--rebuild-uboot" ]
then
build_uboot -c
build_uboot -b
elif [ "$1" == "--clean-uboot" ]
then
build_uboot -c
fi
if [ "$1" == "--build-other" ]
then
build_extras -b
elif [ "$1" == "--rebuild-other" ]
then
build_extras -c
build_extras -b
elif [ "$1" == "--clean-other" ]
then
build_extras -c
fi
if [ "$1" == "--create-rootfs" ]
then
generate_rootfs
fi
if [ "$1" == "--create-img" ]
then
generate_image
fi
if [ "$1" == "--clean-work-dir" ]
then
clean_work_dir
fi
if [ "$1" == "--Run-qemu" ]
then
test_qemu
fi
}
main()
{
int_build_env
init_work_dir
option $1
}
#starting of script
main $1