source: common/libs/func_book_parser@ 0ad3a33

2.4 ablfs-more legacy trunk
Last change on this file since 0ad3a33 was 0ad3a33, checked in by Pierre Labastie <pierre@…>, 8 years ago

When choosing the LFS book, we should not depend on docbook-xml. This is achieved by directly treating the revision attribute in lfs.xsl, instead of using profiling from docbook-xsl.

  • Property mode set to 100644
File size: 9.2 KB
Line 
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" ;;
19 clfs*) ;;
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.
26 if [ $PROGNAME == "lfs" ] || [ $PROGNAME == "hlfs" ] &&
27 [ ! -d ${PROGNAME}-${LFSVRS}/.svn ]; then
28 svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
29 elif [ $PROGNAME == "clfs" ] || [ $PROGNAME == "clfs2" ] ||
30 [ $PROGNAME == "clfs3" ] && [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
31 echo $TREE
32 git clone $GIT ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
33 if [ ! $TREE == "development" ]; then
34 cd ${PROGNAME}-$LFSVRS
35 echo "Checking out $LFSVRS at $PWD in $TREE"
36 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
37 fi
38 else
39 cd ${PROGNAME}-$LFSVRS
40 case $PROGNAME in
41 clfs*) git pull >>$LOGDIR/$LOG 2>&1
42 if [ ! $TREE == "development" ]; then
43 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
44 fi
45 ;;
46 lfs | hlfs) svn up >>$LOGDIR/$LOG 2>&1 ;;
47 *) ;;
48 esac
49 fi
50 echo -ne "done\n"
51
52 else
53 echo -ne "Using $BOOK as book's sources ...\n"
54 fi
55}
56
57#----------------------------#
58extract_commands() { #
59#----------------------------#
60
61 cd $JHALFSDIR
62 case $PROGNAME in
63 clfs*)
64 VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
65 lfs)
66 if [ "$INITSYS" = "sysv" ] ; then
67 VERSION=$(grep 'ENTITY version ' $BOOK/general.ent| cut -d\" -f2)
68 else
69 VERSION=$(grep 'ENTITY versiond' $BOOK/general.ent| cut -d\" -f2)
70 fi
71 ;;
72 *)
73 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
74 esac
75
76 # Clean
77 rm -rf ${PROGNAME}-commands
78
79 # Extract the commands
80 echo -n "Extracting commands for"
81 case ${PROGNAME} in
82 clfs)
83 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
84 xsltproc --nonet \
85 --xinclude \
86 --stringparam method $METHOD \
87 --stringparam testsuite $TEST \
88 --stringparam bomb-testsuite $BOMB_TEST \
89 --stringparam vim-lang $VIMLANG \
90 --stringparam timezone $TIMEZONE \
91 --stringparam page $PAGE \
92 --stringparam lang $LANG \
93 --stringparam sparc $SPARC64_PROC \
94 --stringparam x86 $TARGET \
95 --stringparam mips $TARGET \
96 -o ./${PROGNAME}-commands/ \
97 $XSL \
98 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
99 ;;
100
101 clfs2)
102 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
103 xsltproc --nonet \
104 --xinclude \
105 --stringparam vim-lang $VIMLANG \
106 --stringparam timezone $TIMEZONE \
107 --stringparam page $PAGE \
108 --stringparam lang $LANG \
109 --output ./${PROGNAME}-commands/ \
110 $XSL \
111 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
112 ;;
113
114 clfs3)
115 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
116 xsltproc --nonet \
117 --xinclude \
118 --stringparam endian x$ENDIAN \
119 --stringparam timezone $TIMEZONE \
120 --stringparam page $PAGE \
121 --stringparam lang $LANG \
122 --output ./${PROGNAME}-commands/ \
123 $XSL \
124 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
125 ;;
126
127 hlfs)
128 echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
129 xsltproc --nonet \
130 --xinclude \
131 --stringparam model $MODEL \
132 --stringparam kernel $KERNEL \
133 --stringparam testsuite $TEST \
134 --stringparam bomb-testsuite $BOMB_TEST \
135 --stringparam features \
136 x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
137 --stringparam timezone $TIMEZONE \
138 --stringparam page $PAGE \
139 --stringparam lang $LANG \
140 --stringparam grsecurity_host $GRSECURITY_HOST \
141 --output ./${PROGNAME}-commands/ \
142 $XSL \
143 $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
144 ;;
145 lfs)
146 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
147 pushd $BOOK > /dev/null
148 if [ -f process-scripts.sh ]; then
149 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
150 fi
151 popd > /dev/null
152
153 xsltproc --nonet \
154 --xinclude \
155 --stringparam revision $INITSYS \
156 --stringparam testsuite $TEST \
157 --stringparam bomb-testsuite $BOMB_TEST \
158 --stringparam vim-lang $VIMLANG \
159 --stringparam full-locale $FULL_LOCALE \
160 --stringparam timezone $TIMEZONE \
161 --stringparam page $PAGE \
162 --stringparam lang $LANG \
163 --stringparam pkgmngt $PKGMNGT \
164 --output ./${PROGNAME}-commands/ \
165 $XSL \
166 $BOOK/index.xml
167 ;;
168 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
169 exit 1 ;;
170 esac
171
172 echo "done"
173
174 # Make the scripts executable.
175 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
176
177 # Create the packages file. We need it for proper Makefile creation
178 create_package_list
179 create_chroot_scripts
180
181 # Done. Moving on...
182 get_sources
183
184}
185
186#----------------------------#
187create_package_list() { #
188#----------------------------#
189
190 # Create the packages file. We need it for proper Makefile creation
191 rm -f pkg_tarball_list
192 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
193 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
194 echo -n "... "
195 case ${PROGNAME} in
196 clfs*)
197 xsltproc --nonet --xinclude \
198 -o pkg_tarball_list \
199 packages.xsl \
200 $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
201 ;;
202 hlfs)
203 xsltproc --nonet --xinclude \
204 --stringparam model $MODEL \
205 --stringparam kernel $KERNEL \
206 --output pkg_tarball_list \
207 packages.xsl \
208 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
209 ;;
210 lfs)
211 xsltproc --nonet --xinclude \
212 --stringparam pkgmngt $PKGMNGT \
213 --stringparam revision $INITSYS \
214 --output pkg_tarball_list \
215 packages.xsl \
216 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
217 ;;
218 *)
219 esac
220
221 echo "done"
222
223}
224
225#----------------------------#
226create_chroot_scripts() { #
227#----------------------------#
228
229 rm -rf chroot_scripts
230 echo -n "Creating chroot commands scripts from $BOOK"
231 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
232 echo -n "... "
233 case ${PROGNAME} in
234 clfs*)
235 xsltproc --nonet --xinclude \
236 -o chroot-scripts/ chroot.xsl \
237 $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
238 ;;
239 hlfs)
240 xsltproc --nonet --xinclude \
241 -o chroot-scripts/ chroot.xsl \
242 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
243 ;;
244 lfs)
245 xsltproc --nonet --xinclude \
246 -o chroot-scripts/ chroot.xsl \
247 $BOOK/chapter06/chapter06.xml >> $LOGDIR/$LOG 2>&1
248 ;;
249 *)
250 esac
251 echo "done"
252
253}
Note: See TracBrowser for help on using the repository browser.