source: common/libs/func_book_parser@ b4df9e1

2.4 ablfs-more legacy new_features trunk
Last change on this file since b4df9e1 was d68eb1b, checked in by Pierre Labastie <pierre@…>, 11 years ago

Major change to th scripts layout:

  • Do not put the chroot commands in $PROGNAME-commands, but rather in a separate directory chroot-scripts
  • Use the commands in the chroot-scripts directory to generate the CHROOT variables in Makefile
  • The commands are extracted to $PROGNAME-commands only if they do not have role="nodump attribute and they do not begin with "chroot" (for compatibility with previous books where chroot commands did not have the role="nodump" attribute.
  • Property mode set to 100644
File size: 7.4 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" ] && [ ! -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"
34 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
35 fi
36 else
37 cd ${PROGNAME}-$LFSVRS
38 case $PROGNAME in
39 clfs*) git pull >>$LOGDIR/$LOG 2>&1
40 if [ ! $TREE == "development" ]; then
41 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
42 fi
43 ;;
44 lfs | hlfs) svn up >>$LOGDIR/$LOG 2>&1 ;;
45 *) ;;
46 esac
47 fi
48 echo -ne "done\n"
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
61 clfs*)
62 VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
63 *)
64 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
65 esac
66
67 # Clean
68 rm -rf ${PROGNAME}-commands
69
70 # Extract the commands
71 echo -n "Extracting commands for"
72 case ${PROGNAME} in
73 clfs)
74 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
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 \
84 --stringparam sparc $SPARC64_PROC \
85 -o ./${PROGNAME}-commands/ $XSL $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
86 ;;
87
88 clfs2)
89 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
90 xsltproc --nonet \
91 --xinclude \
92 --stringparam vim-lang $VIMLANG \
93 --stringparam timezone $TIMEZONE \
94 --stringparam page $PAGE \
95 --stringparam lang $LANG \
96 -o ./${PROGNAME}-commands/ $XSL $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
97 ;;
98
99 clfs3)
100 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
101 xsltproc --nonet \
102 --xinclude \
103 --stringparam endian x$ENDIAN \
104 --stringparam timezone $TIMEZONE \
105 --stringparam page $PAGE \
106 --stringparam lang $LANG \
107 -o ./${PROGNAME}-commands/ $XSL $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
108 ;;
109
110 hlfs)
111 echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
112 xsltproc --nonet \
113 --xinclude \
114 --stringparam model $MODEL \
115 --stringparam kernel $KERNEL \
116 --stringparam testsuite $TEST \
117 --stringparam bomb-testsuite $BOMB_TEST \
118 --stringparam features x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
119 --stringparam timezone $TIMEZONE \
120 --stringparam page $PAGE \
121 --stringparam lang $LANG \
122 --stringparam grsecurity_host $GRSECURITY_HOST \
123 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
124 ;;
125 lfs)
126 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
127 pushd $BOOK > /dev/null
128 if [ -f process-scripts.sh ]; then
129 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
130 fi
131 popd > /dev/null
132 xsltproc --nonet \
133 --xinclude \
134 --stringparam testsuite $TEST \
135 --stringparam bomb-testsuite $BOMB_TEST \
136 --stringparam vim-lang $VIMLANG \
137 --stringparam full-locale $FULL_LOCALE \
138 --stringparam timezone $TIMEZONE \
139 --stringparam page $PAGE \
140 --stringparam lang $LANG \
141 --stringparam pkgmngt $PKGMNGT \
142 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
143 ;;
144 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
145 exit 1 ;;
146 esac
147
148 echo "done"
149
150 # Make the scripts executable.
151 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
152
153 # Create the packages file. We need it for proper Makefile creation
154 create_package_list
155 create_chroot_scripts
156
157 # Done. Moving on...
158 get_sources
159
160}
161
162#----------------------------#
163create_package_list() { #
164#----------------------------#
165
166 # Create the packages file. We need it for proper Makefile creation
167 rm -f pkg_tarball_list
168 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
169 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
170 echo -n "... "
171 case ${PROGNAME} in
172 clfs*)
173 xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
174 $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
175 ;;
176 hlfs)
177 xsltproc --nonet --xinclude \
178 --stringparam model $MODEL \
179 --stringparam kernel $KERNEL \
180 -o pkg_tarball_list packages.xsl \
181 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
182 ;;
183 lfs)
184 xsltproc --nonet --xinclude \
185 --stringparam pkgmngt $PKGMNGT \
186 -o pkg_tarball_list packages.xsl \
187 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
188 ;;
189 *)
190 esac
191
192 echo "done"
193
194}
195
196#----------------------------#
197create_chroot_scripts() { #
198#----------------------------#
199
200 rm -rf chroot_scripts
201 echo -n "Creating chroot commands scripts from $BOOK"
202 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
203 echo -n "... "
204 case ${PROGNAME} in
205 clfs*)
206 xsltproc --nonet --xinclude \
207 -o chroot-scripts/ chroot.xsl \
208 $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
209 ;;
210 hlfs)
211 xsltproc --nonet --xinclude \
212 -o chroot-scripts/ chroot.xsl \
213 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
214 ;;
215 lfs)
216 xsltproc --nonet --xinclude \
217 -o chroot-scripts/ chroot.xsl \
218 $BOOK/chapter06/chapter06.xml >> $LOGDIR/$LOG 2>&1
219 ;;
220 *)
221 esac
222 echo "done"
223
224}
Note: See TracBrowser for help on using the repository browser.