source: jhablfs@ 5bb78f0

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 5bb78f0 was 5bb78f0, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Added BLFS framework.

  • Property mode set to 100755
File size: 8.2 KB
RevLine 
[5bb78f0]1#!/bin/sh
2
3#
4# Load the configuration file
5#
6source jhablfs.conf
7
8
9version="
10jhablfs development \$Date: 2005-12-04 13:24:26 +0100 (dom, 04 dic 2005) $
11
12Written by Jeremy Huntwork and Manuel Canales Esparcia.
13
14This program is published under the \
15Gnu General Public License, Version 2.
16"
17
18usage="\
19Usage: $0 [OPTION]
20
21Options:
22 -h, --help print this help, then exit
23
24 -V, --version print version number, then exit
25
26 -B, --BLFS-version VER checkout VER version of the BLFS book.
27 Supported versions at this time are:
28
29 dev* | trunk | SVN aliases for Development BLFS
30
31 -W, --working-copy DIR use the local working copy placed in DIR
32 as the BLFS book
33
34 -D, --dependencies TYPE add dependencies of type TYPE to the build tree.
35 If not set, both required a recommended are used.
36 Possible values are:
37
38 required only required dependecies are used
39 recommended both required a recommended dependencies are used
40 optional all dependencies are used
41
42 -S, --server the FTP/HTTP server used as fallback. If no
43 specified, the one set in jhablfs.conf is used.
44
45 -T, --testsuites add support to run the optional testsuites
46
47"
48
49help="\
50Try '$0 --help' for more information."
51
52exit_missing_arg="\
53echo \"Option '\$1' requires an argument\" >&2
54echo \"\$help\" >&2
55exit 1"
56
57no_dl_client="\
58echo \"Could not find a way to download the BLFS sources.\" >&2
59echo \"Attempting to continue.\" >&2"
60
61HEADER="# This file is automatically generated by jhablfs
62# EDIT THIS FILE MANUALLY TO SUIT YOUR NEEDS
63#
64# Generated on `date \"+%F %X %Z\"`"
65
66
67###################################
68### FUNCTIONS ###
69###################################
70
71
72#----------------------------#
73get_book() {
74#----------------------------#
75 # Check for Subversion instead of just letting the script hit 'svn' and fail.
76 test `type -p svn` || eval "echo \"This feature requires Subversion.\"
77 exit 1"
78 cd $JHABLFSDIR
79
80 if [ -z $WC ] ; then
81 echo -n "Downloading the BLFS Book, version $BLFSVRS... "
82
83 # Grab the BLFS book fresh if it's missing, otherwise, update it from the
84 # repo. If we've already extracted the commands, move on.
85 if [ -d blfs-$BLFSVRS ] ; then
86 cd blfs-$BLFSVRS
87 if LC_ALL=C svn up | grep -q At && test -d $JHABLFSDIR/commands ; then
88 echo -ne "done\n"
89 # Set the canonical book version
90 cd $JHABLFSDIR
91 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
92 else
93 echo -ne "done\n"
94 # Set the canonical book version
95 cd $JHABLFSDIR
96 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
97 extract_commands
98 fi
99 else
100 case $BLFSVRS in
101 development)
102 svn co $SVN/BLFS/trunk/BOOK blfs-$BLFSVRS >>$LOGDIR/$LOG 2>&1 ;;
103 esac
104 echo -ne "done\n"
105 # Set the canonical book version
106 cd $JHABLFSDIR
107 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
108 extract_commands
109 fi
110 else
111 echo -ne "Using $BOOK as book's sources ...\n"
112 # Set the canonical book version
113 cd $JHABLFSDIR
114 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
115 extract_commands
116 fi
117}
118
119#----------------------------#
120extract_commands() {
121#----------------------------#
122 # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
123 test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
124 exit 1"
125 cd $JHABLFSDIR
126
127 # Start clean
128 if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands
129 echo -n "Extracting commands... "
130
131 # Dump the commands in shell script form from the BLFS book.
132 xsltproc --nonet --xinclude --stringparam testsuite $TEST \
133 --stringparam server $SERVER -o ./commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
134
135 # Make the scripts executable.
136 chmod -R +x $JHABLFSDIR/commands
137
138 # Done. Moving on...
139 echo -ne "done\n"
140}
141
142
143#----------------------------#
144build_Makefile() {
145#----------------------------#
146 echo -n "Creating Makefile... "
147 cd $JHABLFSDIR/commands
148
149 # Start with a clean Makefile file
150 >$MKFILE
151
152
153 # Add a header, some variables and include the function file
154 # to the top of the real Makefile.
155(
156 cat << EOF
157$HEADER
158
159include functions
160
161EOF
162) > $MKFILE
163
164 # Drop in a dummy target 'all:'.
165(
166 cat << EOF
167all:
168 @echo -e "\nThere is no default target predefined"
169 @echo -e "You must to tell what package(s) you want to install"
170 @echo -e "or edit the \"all\" Makefile target to create your own"
171 @echo -e "defualt target.\n"
172 @exit
173EOF
174) >> $MKFILE
175
176 # Bring over the build targets.
177 for file in */* ; do
178 # Keep the script file name
179 case $file in
180 gnome/config )
181 i=config-gnome
182 ;;
183 gnome/pre-install-config )
184 i=pre-intall-config-gnome
185 ;;
186 kde/config )
187 i=config-kde
188 ;;
189 kde/pre-install-config )
190 i=pre-intall-config-kde
191 ;;
192 * )
193 i=`basename $file`
194 ;;
195 esac
196
197 # Dump the package dependencies.
198 REQUIRED=`grep "REQUIRED" $file | sed 's/# REQUIRED://' | tr -d '\n'`
199 if [ "$DEPEND" != "0" ] ; then
200 RECOMMENDED=`grep "RECOMMENDED" $file | sed 's/# RECOMMENDED://' | tr -d '\n'`
201 fi
202 if [ "$DEPEND" = "2" ] ; then
203 OPTIONAL=`grep "OPTIONAL" $file | sed 's/# OPTIONAL://' | tr -d '\n'`
204 fi
205
206 # Drop in the name of the target on a new line plus its dependencies
207 # and call the echo_message function.
208(
209 cat << EOF
210
211$i: $REQUIRED $RECOMMENDED $OPTIONAL
212 @\$(call echo_message, Building)
213EOF
214) >> $MKFILE
215
216 # Insert date and disk usage at the top of the log file, the script run
217 # and date and disk usage again at the bottom of the log file.
218(
219 cat << EOF
220 @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >logs/$i && \\
221 $JHABLFSDIR/commands/$file >>logs/$i 2>&1 && \\
222 echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >>logs/$i
223EOF
224) >> $MKFILE
225
226 # Include a touch of the target name so make can check
227 # if it's already been made.
228(
229 cat << EOF
230 @touch \$@
231EOF
232) >> $MKFILE
233
234 done
235 echo -ne "done\n"
236}
237
238
239
240###################################
241### MAIN ###
242###################################
243
244# Evaluate any command line switches
245
246while test $# -gt 0 ; do
247 case $1 in
248 --version | -V )
249 echo "$version"
250 exit 0
251 ;;
252
253 --help | -h )
254 echo "$usage"
255 exit 0
256 ;;
257
258 --BLFS-version | -B )
259 test $# = 1 && eval "$exit_missing_arg"
260 shift
261 case $1 in
262 dev* | SVN | trunk )
263 BLFSVRS=development
264 ;;
265 * )
266 echo "$1 is an unsupported version at this time."
267 exit 1
268 ;;
269 esac
270 ;;
271
272 --working-copy | -W )
273 test $# = 1 && eval "$exit_missing_arg"
274 shift
275 if [ -f $1/use-unzip.xml ] ; then
276 WC=1
277 BOOK=$1
278 else
279 echo -e "\nLook like $1 isn't a proper BLFS working copy."
280 echo -e "Verify your selection and the command line.\n"
281 exit 1
282 fi
283 ;;
284
285 --dependencies | -D )
286 test $# = 1 && eval "$exit_missing_arg"
287 shift
288 case $1 in
289 required )
290 DEPEND=0
291 ;;
292 recommended )
293 DEPEND=1
294 ;;
295 optional )
296 DEPEND=2
297 ;;
298 * )
299 echo "$1 is not a proper dependencies type."
300 exit 1
301 ;;
302 esac
303 ;;
304
305 --testsuites | -T ) TEST=1 ;;
306
307 --server | -S )
308 test $# = 1 && eval "$exit_missing_arg"
309 shift
310 case $1 in
311 *conglomeration )
312 SERVER=$1
313 ;;
314 * )
315 echo "$1 is not a proper path to the BLFS packages."
316 exit 1
317 ;;
318 esac
319 ;;
320
321 --all-dependencies | -D ) DEPEND=1 ;;
322 esac
323 shift
324done
325
326if [ -z $BOOK ] ; then
327 BOOK=blfs-$BLFSVRS
328fi
329
330[[ ! -d $JHABLFSDIR ]] && mkdir -pv $JHABLFSDIR
331[[ "$PWD" != "$JHABLFSDIR" ]] && cp -v $FILES $JHABLFSDIR/
332[[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR
333>$LOGDIR/$LOG
334
335get_book
336build_Makefile
337
Note: See TracBrowser for help on using the repository browser.