source: common/libs/func_book_parser@ af20a03

new_features
Last change on this file since af20a03 was 77fa8ba, checked in by Pierre Labastie <pierre@…>, 9 years ago

Add IP, hostname, domain, etc to the list of configuration parameters.
Font and encoding are in configuration too, but are not passed to the build
commands
Works only for LFS

  • Property mode set to 100644
File size: 8.2 KB
RevLine 
[fe30c61]1#!/bin/bash
2
3# $Id$
4
5#----------------------------#
6get_book() { #
7#----------------------------#
8 cd $JHALFSDIR
9
10 if [ -z $WORKING_COPY ] ; then
11 # Check for Subversion instead of just letting the script hit 'svn' and fail.
12 test `type -p svn` || eval "echo \"This feature requires Subversion.\"
13 exit 1"
14 echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
15
16 case $PROGNAME in
17 lfs) svn_root="LFS" ;;
18 hlfs) svn_root="HLFS" ;;
[d68eb1b]19 clfs*) ;;
[fe30c61]20 *) echo "BOOK not defined in function <get_book>"
21 exit 1 ;;
22 esac
23 # Grab a fresh book if it's missing, otherwise, update it from the
24 # repo. If we've already extracted the commands, move on to getting the
25 # sources.
[92b7cb8]26 if [ $PROGNAME == "lfs" ] || [ $PROGNAME == "hlfs" ] && [ ! -d ${PROGNAME}-${LFSVRS}/.svn ]; then
27 svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
28 elif [ $PROGNAME == "clfs" ] || [ $PROGNAME == "clfs2" ] || [ $PROGNAME == "clfs3" ] && [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
29 echo $TREE
30 git clone $GIT ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
31 if [ ! $TREE == "development" ]; then
32 cd ${PROGNAME}-$LFSVRS
33 echo "Checking out $LFSVRS at $PWD in $TREE"
[ad4ff97]34 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
[92b7cb8]35 fi
[1cf621b]36 else
37 cd ${PROGNAME}-$LFSVRS
[92b7cb8]38 case $PROGNAME in
[ad4ff97]39 clfs*) git pull >>$LOGDIR/$LOG 2>&1
[7ce6de2]40 if [ ! $TREE == "development" ]; then
41 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
42 fi
43 ;;
[92b7cb8]44 lfs | hlfs) svn up >>$LOGDIR/$LOG 2>&1 ;;
45 *) ;;
46 esac
[fe30c61]47 fi
[1cf621b]48 echo -ne "done\n"
[fe30c61]49
50 else
51 echo -ne "Using $BOOK as book's sources ...\n"
52 fi
53}
54
55#----------------------------#
56extract_commands() { #
57#----------------------------#
58
59 cd $JHALFSDIR
60 case $PROGNAME in
[92b7cb8]61 clfs*)
[a1dd968]62 VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
[fe30c61]63 *)
64 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
65 esac
66
[d68eb1b]67 # Clean
68 rm -rf ${PROGNAME}-commands
[fe30c61]69
[d68eb1b]70 # Extract the commands
71 echo -n "Extracting commands for"
[fe30c61]72 case ${PROGNAME} in
73 clfs)
[b11c10b]74 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[fe30c61]75 xsltproc --nonet \
76 --xinclude \
77 --stringparam method $METHOD \
78 --stringparam testsuite $TEST \
79 --stringparam bomb-testsuite $BOMB_TEST \
80 --stringparam vim-lang $VIMLANG \
81 --stringparam timezone $TIMEZONE \
82 --stringparam page $PAGE \
83 --stringparam lang $LANG \
[650acce]84 --stringparam sparc $SPARC64_PROC \
[3f83cb0]85 --stringparam x86 $TARGET \
86 --stringparam mips $TARGET \
[92b7cb8]87 -o ./${PROGNAME}-commands/ $XSL $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]88 ;;
89
90 clfs2)
[b11c10b]91 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[fe30c61]92 xsltproc --nonet \
93 --xinclude \
94 --stringparam vim-lang $VIMLANG \
95 --stringparam timezone $TIMEZONE \
96 --stringparam page $PAGE \
97 --stringparam lang $LANG \
[92b7cb8]98 -o ./${PROGNAME}-commands/ $XSL $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]99 ;;
100
101 clfs3)
[b11c10b]102 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[fe30c61]103 xsltproc --nonet \
104 --xinclude \
[9436828]105 --stringparam endian x$ENDIAN \
[fe30c61]106 --stringparam timezone $TIMEZONE \
107 --stringparam page $PAGE \
108 --stringparam lang $LANG \
[92b7cb8]109 -o ./${PROGNAME}-commands/ $XSL $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]110 ;;
111
112 hlfs)
[139c34e]113 echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
[fe30c61]114 xsltproc --nonet \
115 --xinclude \
116 --stringparam model $MODEL \
[5c575e1]117 --stringparam kernel $KERNEL \
[fe30c61]118 --stringparam testsuite $TEST \
119 --stringparam bomb-testsuite $BOMB_TEST \
[31eb678]120 --stringparam features x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
[fe30c61]121 --stringparam timezone $TIMEZONE \
122 --stringparam page $PAGE \
123 --stringparam lang $LANG \
124 --stringparam grsecurity_host $GRSECURITY_HOST \
125 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
126 ;;
127 lfs)
[b11c10b]128 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
[f21dff8]129 pushd $BOOK > /dev/null
[66c09d0]130 if [ -f process-scripts.sh ]; then
[f0a31de]131 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
132 fi
[f21dff8]133 popd > /dev/null
[77fa8ba]134 xsltproc --nonet \
135 --xinclude \
136 --stringparam testsuite $TEST \
137 --stringparam bomb-testsuite $BOMB_TEST \
138 --stringparam vim-lang $VIMLANG \
139 --stringparam full-locale $FULL_LOCALE \
140 --stringparam timezone $TIMEZONE \
141 --stringparam page $PAGE \
142 --stringparam lang $LANG \
143 --stringparam pkgmngt $PKGMNGT \
144 --stringparam hostname $HOSTNAME \
145 --stringparam interface $INTERFACE \
146 --stringparam ip $IP_ADDR \
147 --stringparam gateway $GATEWAY \
148 --stringparam prefix $PREFIX \
149 --stringparam broadcast $BROADCAST \
150 --stringparam domain $DOMAIN \
151 --stringparam nameserver1 $DNS1 \
152 --stringparam nameserver2 $DNS2 \
[fe30c61]153 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
154 ;;
[d68eb1b]155 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
[fe30c61]156 exit 1 ;;
157 esac
158
[b11c10b]159 echo "done"
[fe30c61]160
161 # Make the scripts executable.
162 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
163
164 # Create the packages file. We need it for proper Makefile creation
165 create_package_list
[d68eb1b]166 create_chroot_scripts
[fe30c61]167
168 # Done. Moving on...
169 get_sources
170
171}
172
173#----------------------------#
174create_package_list() { #
175#----------------------------#
176
177 # Create the packages file. We need it for proper Makefile creation
178 rm -f pkg_tarball_list
[b11c10b]179 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
180 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
181 echo -n "... "
[fe30c61]182 case ${PROGNAME} in
[92b7cb8]183 clfs*)
[fe30c61]184 xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
[92b7cb8]185 $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]186 ;;
187 hlfs)
[6d48bb7]188 xsltproc --nonet --xinclude \
[139c34e]189 --stringparam model $MODEL \
190 --stringparam kernel $KERNEL \
191 -o pkg_tarball_list packages.xsl \
[fe30c61]192 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
193 ;;
194 lfs)
[7072e1f]195 xsltproc --nonet --xinclude \
196 --stringparam pkgmngt $PKGMNGT \
197 -o pkg_tarball_list packages.xsl \
[fe30c61]198 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
199 ;;
[92b7cb8]200 *)
[fe30c61]201 esac
202
[b11c10b]203 echo "done"
[fe30c61]204
205}
206
[d68eb1b]207#----------------------------#
208create_chroot_scripts() { #
209#----------------------------#
210
211 rm -rf chroot_scripts
212 echo -n "Creating chroot commands scripts from $BOOK"
213 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
214 echo -n "... "
215 case ${PROGNAME} in
216 clfs*)
217 xsltproc --nonet --xinclude \
218 -o chroot-scripts/ chroot.xsl \
219 $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
220 ;;
221 hlfs)
222 xsltproc --nonet --xinclude \
223 -o chroot-scripts/ chroot.xsl \
224 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
225 ;;
226 lfs)
227 xsltproc --nonet --xinclude \
228 -o chroot-scripts/ chroot.xsl \
229 $BOOK/chapter06/chapter06.xml >> $LOGDIR/$LOG 2>&1
230 ;;
231 *)
232 esac
233 echo "done"
234
235}
Note: See TracBrowser for help on using the repository browser.