source: jhalfs@ dc2fee8

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

Removed now uneeded code.

  • Property mode set to 100755
File size: 8.4 KB
RevLine 
[fbb6b78]1#!/bin/sh
[1236262]2
3version="
[63b2859]4jhalfs development
5
[1236262]6Written by Jeremy Huntwork.
[557fe91]7Maintained by Manuel Canales Esparcia.
[1236262]8
9This program is published under the \
[557fe91]10Gnu General Public License, Version 2.
11"
[1236262]12
13usage="\
14Usage: $0 [OPTION]
15
16Options:
[557fe91]17 -h, --help print this help, then exit
18 -V, --version print version number, then exit
19 -L, --LFS-version=VER use VER version of the LFS book
20 -d --directory=DIR use DIR directory for building LFS; all files
21 jhalfs produces will be in the directory
22 DIR/jhalfs
23 -D, --download-client=CLIENT use CLIENT as the program for retrieving
24 packages
[1236262]25"
26
27help="\
28Try '$0 --help' for more information."
29
30exit_missing_arg="\
31echo \"Option '\$1' requires an argument\" >&2
32echo \"\$help\" >&2
33exit 1"
34
35no_dl_client="\
36echo \"Could not find a way to download the LFS sources.\" >&2
37echo \"Attempting to continue.\" >&2"
38
39while test $# -gt 0 ; do
[557fe91]40 case $1 in
41 --version | -V )
42 echo "$version"
43 exit 0
44 ;;
45
46 --help | -h )
47 echo "$usage"
48 exit 0
49 ;;
50
51 --LFS-version | -L )
52 test $# = 1 && eval "$exit_missing_arg"
53 shift
54 case $1 in
55 dev* | SVN | trunk )
56 LFSVRS=development
57 ;;
58 * )
59 echo "$1 is an unsupported version at this time."
60 exit 1
61 ;;
62 esac
63 shift
64 ;;
65
66 --directory | -d )
67 test $# = 1 && eval "$exit_missing_arg"
68 shift
69 BUILDDIR=$1
70 shift
71 ;;
72
73 --download-client | -D )
74 test $# = 1 && eval "$exit_missing_arg"
75 shift
76 DL=$1
77 shift
78 ;;
79
80 * )
81 echo "$usage"
82 exit 1
83 ;;
84 esac
[1236262]85done
86
87# Test to make sure we're running the build as root
88
89if [ "$UID" != "0" ] ; then
[557fe91]90 echo "You must be logged in as root to successfully build LFS."
91 exit 1
[1236262]92fi
93
94# Find the download client to use, if not already specified.
95
96if [ -z $DL ] ; then
97 if [ `type -p wget` ] ; then
[557fe91]98 DL=wget
[1236262]99 elif [ `type -p curl` ] ; then
[557fe91]100 DL=curl
[1236262]101 else
[557fe91]102 eval "$no_dl_client"
[1236262]103 fi
104fi
105
106SVN="svn://svn.linuxfromscratch.org"
107HTTP=http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/conglomeration
[48d7968]108if [ -z $BUILDDIR ] ; then BUILDDIR=/mnt/lfs ; fi
[4dafc45]109JHALFSDIR=$BUILDDIR/jhalfs
[1236262]110LOG=build.log
[f8de156]111MKFILE=$JHALFSDIR/Makefile
[557fe91]112XSL=dump-commands.xsl
[1236262]113
114get_book() {
115 # Check for Subversion instead of just letting the script hit 'svn' and fail.
116 test `type -p svn` || eval "echo \"This feature requires Subversion.\"
[557fe91]117 exit 1"
[4dafc45]118 cd $JHALFSDIR
[fbb6b78]119
[1236262]120 # Test to make sure the LFS version is set
121 if [ -z $LFSVRS ] ; then LFSVRS=development ; fi
122 echo -n "Downloading the LFS Book, version $LFSVRS... "
123
124 # Grab the LFS book fresh if it's missing, otherwise, update it from the
125 # repo. If we've already extracted the commands, move on to getting the
126 # sources.
127 if [ -d lfs-$LFSVRS ] ; then
[557fe91]128 cd lfs-$LFSVRS
129 if svn up | grep -q At && test -d $JHALFSDIR/commands && \
130 test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
131 echo -ne "done\n"
132 get_sources
133 else
134 echo -ne "done\n"
135 extract_commands
136 fi
[1236262]137 else
[557fe91]138 if [ $LFSVRS = development ] ; then
139 svn co $SVN/LFS/trunk/BOOK lfs-$LFSVRS >>$JHALFSDIR/$LOG 2>&1
140 else
141 svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$JHALFSDIR/$LOG 2>&1
142 fi
143 echo -ne "done\n"
144 extract_commands
[1236262]145 fi
146}
147
148extract_commands() {
149 # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
150 test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
[557fe91]151 exit 1"
[4dafc45]152 cd $JHALFSDIR
[1236262]153
154 # Start clean
155 if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands
156 echo -n "Extracting commands... "
157
[dc2fee8]158 # Dump the commands in shell script form from the LFS book.
[557fe91]159 xsltproc --nonet --xinclude -o ./commands/ $XSL \
160 lfs-$LFSVRS/index.xml >>$JHALFSDIR/$LOG 2>&1
[1236262]161
162 # Grab the patches and package names.
[4dafc45]163 cd $JHALFSDIR
[1236262]164 for i in patches packages ; do rm -f $i ; done
165 grep "\-version" lfs-$LFSVRS/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
[557fe91]166 -e '/generic/d' >> packages
[1236262]167 grep "ENTITY" lfs-$LFSVRS/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
168
169 # Done. Moving on...
170 echo -ne "done\n"
171 get_sources
172}
173
174download() {
175 cd $BUILDDIR/sources
176
177 # Hackish fix for the bash-doc package that doesn't conform
178 # to norms in the URL scheme.
179 DIR=`echo $1 | sed 's@-doc@@'`
180
181 # Find the md5 sum for this package.
182 if [ $2 != MD5SUMS ] ; then MD5=`grep " $2" MD5SUMS` ; fi
183
184 if [ ! -f $2 ] ; then
[557fe91]185 case $DL in
186 wget )
187 wget $HTTP/$DIR/$2
188 ;;
189 curl )
190 `curl -# $HTTP/$DIR/$2 -o $2`
191 ;;
192 * )
193 echo "$DL not supported at this time."
194 ;;
195 esac
[1236262]196 elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
[557fe91]197 case $DL in
198 wget )
199 wget -c $HTTP/$DIR/$2
200 ;;
201 curl )
202 `curl -# -C - $HTTP/$DIR/$2 -o $2`
203 ;;
204 * )
205 echo "$DL not supported at this time."
206 ;;
207 esac
[1236262]208 fi
209 if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
210 exit 1
211 fi
212}
213
214get_sources() {
215
[f8de156]216 # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
[1236262]217 # separates each iteration by lines. It is necessary to have the second
218 # ' on the next line.
219 IFS='
220'
221
222 if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
223 cd $BUILDDIR/sources
224 if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
225
226 download "" MD5SUMS
227
228 # Iterate through each package and grab it, along with any patches it needs.
[4dafc45]229 for i in `cat $JHALFSDIR/packages` ; do
[1236262]230 PKG=`echo $i | sed 's/-version.*//'`
[fbb6b78]231
[1236262]232 # Someone used some silly entities right next to the valid package entities.
233 if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
234
235 VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
236 if [ "$PKG" = "tcl" ] ; then
[557fe91]237 FILE="$PKG$VRS-src.tar.bz2"
[1236262]238 else
[557fe91]239 FILE="$PKG-$VRS.tar.bz2"
[1236262]240 fi
241 download $PKG $FILE
[4dafc45]242 for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do
[557fe91]243 PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
244 download $PKG $PATCH
[fbb6b78]245 done
[1236262]246 done
247}
248
[f8de156]249build_Makefile() {
[9e406b5]250 echo -n "Creating Makefile... "
[f8de156]251 cd $JHALFSDIR/commands
[fbb6b78]252
[f8de156]253 # Start with a clean Makefile.tmp file
254 >$MKFILE.tmp
255
[63b2859]256 for file in chapter0{4,5}/* ; do
257 # Keep the script file name
258 i=`basename $file`
259
260 # First append each name of the script files to a list (this will become
[557fe91]261 # the names of the targets in the Makefile
262 list="$list $i"
263
264 # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
265 # and binutils in chapter 5)
266 name=`echo $i | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
267
268 # Drop in the name of the target on a new line.
269 echo -e "\n$i:" >> $MKFILE.tmp
270
271 # Find the version of the command files, if it corresponds with the building of
272 # a specific package
273 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
274
275 # If $vrs isn't empty, we've got a package...
276 if [ "$vrs" != "" ] ; then
277 if [ "$name" = "tcl" ] ; then
278 FILE="$name$vrs-src.tar.bz2"
279 else
280 FILE="$name-$vrs.tar.bz2"
281 fi
282
283 # Insert instructions for unpacking the package and changing directories
284 echo -e "\t\$(call unpack,$FILE)" >> $MKFILE.tmp
285 echo -e "\tROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
286 echo -e "\tcd \$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
287 fi
288
[63b2859]289 # Run the script
290 echo -e "\tsu - lfs -c \"/bin/bash $file\"" >> $MKFILE.tmp
[557fe91]291
292 # Include a touch of the target name so make can check if it's already been made.
293 echo -e "\ttouch \$@" >> $MKFILE.tmp
[f8de156]294 done
[9e406b5]295 # These seds turn the variables '$$LFS' into '$(LFS)' so make will understand,
296 # and remove the ' && \'s from the end of each line of a cat command.
297 sed -i -e 's|\$\$LFS|\$(LFS)|' -e '/^\tcat/,/^\tEOF/s/ \&\& \\//' $MKFILE.tmp
298
[fbb6b78]299 # Stick a variable and some defines at the top of the real makefile
[9e406b5]300 echo "export SRC := /sources" > $MKFILE
301 echo "export LFS := $BUILDDIR" >> $MKFILE
302 echo "define unpack" >> $MKFILE
303 echo -e "\t@cd \$(SRC) ; tar -xvf \$(1) > /tmp/unpacked" >> $MKFILE
304 echo -e "endef\n" >> $MKFILE
305
306 # Drop in the list as the main target 'all:' with each sub-target as a dependency.
307 echo "all: $list" >> $MKFILE
308
309 # Bring over the items from the Makefile.tmp
310 cat $MKFILE.tmp >> $MKFILE
311 rm $MKFILE.tmp
312 echo -ne "done\n"
[f8de156]313}
314
[1236262]315
[4dafc45]316if [ ! -d $JHALFSDIR ] ; then
[557fe91]317 mkdir -p $JHALFSDIR
[1236262]318fi
319
[4dafc45]320>$JHALFSDIR/$LOG
[409488e]321
322if [ "$PWD" != "$JHALFSDIR" ] ; then
323 cp $0 $XSL $JHALFSDIR/
324fi
325
[1236262]326get_book
[f8de156]327build_Makefile
Note: See TracBrowser for help on using the repository browser.