source: BLFS/jhablfs@ 77349d5

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

Moved BLFS files to the new BLFS dir.

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