-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsfs-tools
executable file
·240 lines (232 loc) · 8.64 KB
/
sfs-tools
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
#!/bin/bash
########################## sfs-tools #####################################
#
# Copyright 2018 to 2022 J. E. Garrott Sr, Puyallup, WA, USA
# Copyright 2018 to 2022 "nobodino", Bordeaux, FRANCE
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#--------------------------------------------------------------------------
#
# Note: Much of this script is inspired from the LFS manual chapter 5
# Copyright © 1999-2021 Gerard Beekmans and may be
# copied under the MIT License.
#
#--------------------------------------------------------------------------
#
# script to build 'tools' for Slackware From Scratch (SFS)
# script to be executed once 'su - sfs' has been performed.
#
#
# It doesn't respect exactly the list of the packages given in the LFS book.
# Some packages needed for testing in the chapter 6 have been skipped.
# Some other packages have been added to be able to build slackware.
#
# Everything will be done automatically in this script.
#--------------------------------------------------------------------------
#
# Above july 2018, revisions made through github project:
# https://github.com/nobodino/slackware-from-scratch
#
#*******************************************************************
# set -xv
#*******************************************************************
# the directory where will be built slackware from scratch
#*******************************************************************
export SFS=/mnt/sfs
#*******************************************************************
# the directory where is stored the resynced slackware sources
#*******************************************************************
export RDIR=$SFS/source
#*******************************************************************
# the directory where will be stored the slackware source for SFS
#*******************************************************************
export SRCDIR=$SFS/scripts
SFS_TGT=$(uname -m)-sfs-linux-gnu
export SFS_TGT
#*******************************************************************
# set your own MAKEFLAGS
#*******************************************************************
export MAKEFLAGS='-j 32'
#*******************************************************************
export GREEN="\\033[1;32m"
export NORMAL="\\033[0;39m"
export RED="\\033[1;31m"
export PINK="\\033[1;35m"
export BLUE="\\033[1;34m"
export YELLOW="\\033[1;33m"
#*******************************************************************
echo_begin () {
#*****************************
echo
echo "You have decided to build 'tools' for sfs (aka Slackware From Scratch)."
echo
echo "You are at the end of paragraph 4.4 of LFS-8.4 book"
echo
echo "The last command you executed was:"
echo
echo -e "$GREEN" "source ~/.bash_profile" "$NORMAL"
echo
echo "Your Slackware source packages are in: $RDIR"
echo "Your MAKEFLAGS are: $MAKEFLAGS"
echo "Are you ok with this?"
echo
echo "From now everything will be built automatically until the end."
echo "When you're ready just press <1> for begin or <2> for quit."
echo
PS3="Your choice:"
select build in begin quit
do
if [[ "$build" = "begin" ]]
then
break
else [[ "$build" = "quit" ]]
echo -e "$GREEN" "You have decided to quit. Goodbye." "$NORMAL" && exit 1
fi
done
echo -e "$RED" "You chose to build 'tools' for SFS." "$NORMAL"
}
ada_choice () {
#*****************************
PS3="Your choice:"
echo
echo -e "$GREEN" "Do you want to build the tools with gnat ada: yes or no." "$NORMAL"
echo
select ada_enable in yes no
do
if [[ "$ada_enable" = "yes" ]]
then
echo
echo -e "$RED" "You decided to build the tools with gnat ada. It will be quiet long" "$NORMAL"
echo
break
elif [[ "$ada_enable" = "no" ]]
then
echo
echo -e "$RED" "You decided to build the tools without gnat ada." "$NORMAL"
echo -e "$YELLOW" "You may chose that option when building a minimal SFS system with no gnat compiler." "$NORMAL"
echo
break
fi
done
}
copy_src () {
#*****************************
cd $SRCDIR && cp -rv $SRCDIR/build/* $RDIR
cd $RDIR/l/gmp || exit 1
export GMPVER=${VERSION:-$(echo gmp-*.tar.?z | cut -d - -f 2 | rev | cut -f 3- -d . | rev)}
cp -v $RDIR/l/gmp/gmp-"$GMPVER".tar.?z "$RDIR/d/gcc" || exit 1
cd $RDIR/l/libmpc || exit 1
export LIBMPCVER=${VERSION:-$(echo mpc-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
cp -v $RDIR/l/libmpc/mpc-"$LIBMPCVER".tar.?z "$RDIR/d/gcc" || exit 1
cd $RDIR/l/mpfr || exit 1
export MPFRVER=${VERSION:-$(echo mpfr-*.tar.?z | cut -d - -f 2 | rev | cut -f 3- -d . | rev)}
cp -v $RDIR/l/mpfr/mpfr-"$MPFRVER".tar.?z "$RDIR/d/gcc" || exit 1
}
test_to_go () {
#*****************************
echo
echo "Are you to go on ok?"
echo
PS3="Your choice:"
select build in go-on quit
do
if [[ "$build" = "go-on" ]]
then
break
else [[ "$build" = "quit" ]]
echo -e "$RED" "You have decided to quit. Goodbye." "$NORMAL" && exit 1
fi
done
echo -e "$GREEN" "You chose to continue the process of building 'tools' for SFS." "$NORMAL"
}
strip_libs () {
#*****************************
/usr/bin/strip --strip-unneeded /tools/{,s}bin/*
rm -rf /tools/{,share}/{info,man,doc}
find /tools/{lib,libexec} -name \*.la -delete
}
echo_end () {
#*****************************
chown -fR root:root $SFS/source
#*****************************
echo "The building of tools for sfs is finished."
echo
if [[ "$ada_enable" = "yes" ]]
then
echo "Now you can exit from 'sfs environment"
echo
echo
elif [[ "$ada_enable" = "no" ]]
then
echo
fi
echo "Just type:"
echo
echo -e "$GREEN" "source chroot_sfs" "$NORMAL"
echo
}
#*****************************
# core script
#*****************************
echo_begin
#*****************************
copy_src
test_to_go
cd "$SRCDIR" || exit 1
cd $RDIR/d/binutils && source tools_binutils_sp1 || exit 1
cd $RDIR/d/gcc && source tools_gcc_sp1 || exit 1
cd $RDIR/k && source tools_linux-headers || exit 1
cd $RDIR/l/glibc && source tools_glibc || exit 1
cd $RDIR/d/gcc && source tools_libstdc || exit 1
cd $RDIR/d/binutils && source tools_binutils_sp2 || exit 1
cd $RDIR/l/gmp && source tools_gmp || exit 1
cd $RDIR/l/isl && source tools_isl || exit 1
cd $RDIR/d/gcc && source tools_gcc_sp2 || exit 1
cd $RDIR/d/m4 && source tools_m4 || exit 1
cd $RDIR/l/ncurses && source tools_ncurses || exit 1
cd $RDIR/a/bash/ && source tools_bash || exit 1
cd $RDIR/d/bison && source tools_bison || exit 1
cd $RDIR/a/bzip2 && source tools_bzip2 || exit 1
cd $RDIR/a/coreutils && source tools_coreutils || exit 1
cd $RDIR/ap/diffutils && source tools_diffutils || exit 1
cd $RDIR/a/file && source tools_file || exit 1
cd $RDIR/a/findutils && source tools_findutils || exit 1
cd $RDIR/a/gawk && source tools_gawk || exit 1
cd $RDIR/a/gettext && source tools_gettext || exit 1
cd $RDIR/a/grep && source tools_grep || exit 1
cd $RDIR/a/gzip && source tools_gzip || exit 1
cd $RDIR/d/automake && source tools_automake || exit 1
cd $RDIR/d/make && source tools_make || exit 1
cd $RDIR/a/patch && source tools_patch || exit 1
cd $RDIR/d/perl && source tools_perl || exit 1
cd $RDIR/l/zlib && source tools_zlib || exit 1
cd $RDIR/a/xz && source tools_xz || exit 1
cd $RDIR/d/python3 && source tools_python || exit 1
cd $RDIR/a/sed && source tools_sed || exit 1
cd $RDIR/a/tar && source tools_tar || exit 1
cd $RDIR/ap/texinfo && source tools_texinfo || exit 1
cd $RDIR/a/lzip && source tools_lzip || exit 1
cd $RDIR/a/which && source tools_which || exit 1
cd $RDIR/a/util-linux && source tools_util-linux || exit 1
cd $RDIR/l/zstd && source tools_zstd || exit 1
cd $RDIR/l/glibc && source tools_glibc_repair || exit 1
strip_libs
echo_end
exit 0