forked from emmett1/lfs-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-toolchain
executable file
·124 lines (104 loc) · 2.34 KB
/
01-toolchain
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
#!/bin/sh -e
fetch() {
for s in $source; do
filename=${s##*/}
if [ "$s" != "$filename" ]; then
if [ ! -f $SRCDIR/$filename ]; then
echo "fetching $s"
curl -C - -L --fail --ftp-pasv --retry 999 --retry-delay 3 -o $SRCDIR/$filename.part $s && \
mv $SRCDIR/$filename.part $SRCDIR/$filename || {
echo "failed fetch $s"
exit 1
}
fi
fi
done
}
unpack() {
rm -fr "$WORKDIR/$pkg"
mkdir -p "$WORKDIR/$pkg"
for src in $source; do
filename=${src##*/}
case $src in
*.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip)
echo "extracting $filename..."
tar -xf "$SRCDIR/$filename" -C "$WORKDIR/$pkg" || {
echo "failed extracting $filename"
exit 1
};;
esac
done
}
buildtc() {
cd $WORKDIR/$name
(set -e -x; build)
if [ $? -ne 0 ]; then
echo "!!! build $name-$version failed !!!"
exit 1
else
echo "--- build $name-$version success ---"
fi
[ "$name" ] && rm -fr $WORKDIR/$name
echo $name-$version > $LFS/tools/$(basename $script)
}
checkdone() {
if [ -e $LFS/tools/$(basename $script) ]; then
echo "*** skip $(basename $script) ***"
return 1
else
echo ">>> building $(basename $script) <<<"
return 0
fi
}
build() {
:
}
main() {
for script in $TCDIR/[0-9][0-9]-*; do
checkdone || continue
cd $CWD
. $script
pkg=$name
fetch
unpack
buildtc
unset source name version build
#build_stage1 $script
done
}
if [ $(id -u) = 0 ]; then
echo "$0 script need to run as regular user!"
exit 1
fi
CWD=$PWD
if [ -f $CWD/config ]; then
. $CWD/config
fi
PATH=/tools/bin:/bin:/usr/bin
TCDIR=$CWD/toolchain
PATCHDIR=$CWD/patches
FILEDIR=$CWD/files
LFS_TGT=x86_64-lfs-linux-gnu
LFS_TGT32=i686-lfs-linux-gnu
MAKEFLAGS="${MAKEFLAGS:--j$(nproc)}"
LFS="${LFS:-$CWD/lfs-rootfs}"
PKGDIR="${PKGDIR:-$CWD/pkg}"
SRCDIR="${SRCDIR:-$CWD/src}"
WORKDIR="${WORKDIR:-$CWD/work}"
CFLAGS="${CFLAGS:--O2 -march=x86-64 -pipe}"
export LC_ALL=C PATH MAKEFLAGS LFS LFS_TGT LFS_TGT32
mkdir -p $SRCDIR $PKGDIR $WORKDIR
if [ ! -d $LFS/tools ]; then
mkdir -pv $LFS/tools
fi
if [ ! -w $LFS ]; then
echo "'$LFS' directory has no right access"
echo "Please run 'chown -Rv $USER:$USER $LFS' as root"
exit 1
fi
if [ ! -L /tools ] || [ $(realpath /tools) != $LFS/tools ]; then
echo "Please create required '/tools' symlink by running 'ln -svf $LFS/tools /tools' as root"
exit 1
fi
main $@
exit 0