source: common/libs/func_book_parser@ c4ad7bf

2.4 ablfs-more legacy new_features trunk
Last change on this file since c4ad7bf 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
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 \
[92b7cb8]85 -o ./${PROGNAME}-commands/ $XSL $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]86 ;;
87
88 clfs2)
[b11c10b]89 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[fe30c61]90 xsltproc --nonet \
91 --xinclude \
92 --stringparam vim-lang $VIMLANG \
93 --stringparam timezone $TIMEZONE \
94 --stringparam page $PAGE \
95 --stringparam lang $LANG \
[92b7cb8]96 -o ./${PROGNAME}-commands/ $XSL $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]97 ;;
98
99 clfs3)
[b11c10b]100 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[fe30c61]101 xsltproc --nonet \
102 --xinclude \
[9436828]103 --stringparam endian x$ENDIAN \
[fe30c61]104 --stringparam timezone $TIMEZONE \
105 --stringparam page $PAGE \
106 --stringparam lang $LANG \
[92b7cb8]107 -o ./${PROGNAME}-commands/ $XSL $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]108 ;;
109
110 hlfs)
[139c34e]111 echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
[fe30c61]112 xsltproc --nonet \
113 --xinclude \
114 --stringparam model $MODEL \
[5c575e1]115 --stringparam kernel $KERNEL \
[fe30c61]116 --stringparam testsuite $TEST \
117 --stringparam bomb-testsuite $BOMB_TEST \
[31eb678]118 --stringparam features x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
[fe30c61]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)
[b11c10b]126 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
[f21dff8]127 pushd $BOOK > /dev/null
[66c09d0]128 if [ -f process-scripts.sh ]; then
[f0a31de]129 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
130 fi
[f21dff8]131 popd > /dev/null
[fe30c61]132 xsltproc --nonet \
133 --xinclude \
134 --stringparam testsuite $TEST \
135 --stringparam bomb-testsuite $BOMB_TEST \
136 --stringparam vim-lang $VIMLANG \
[b339c94]137 --stringparam full-locale $FULL_LOCALE \
[fe30c61]138 --stringparam timezone $TIMEZONE \
139 --stringparam page $PAGE \
140 --stringparam lang $LANG \
[7072e1f]141 --stringparam pkgmngt $PKGMNGT \
[fe30c61]142 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
143 ;;
[d68eb1b]144 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
[fe30c61]145 exit 1 ;;
146 esac
147
[b11c10b]148 echo "done"
[fe30c61]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
[d68eb1b]155 create_chroot_scripts
[fe30c61]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
[b11c10b]168 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
169 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
170 echo -n "... "
[fe30c61]171 case ${PROGNAME} in
[92b7cb8]172 clfs*)
[fe30c61]173 xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
[92b7cb8]174 $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]175 ;;
176 hlfs)
[6d48bb7]177 xsltproc --nonet --xinclude \
[139c34e]178 --stringparam model $MODEL \
179 --stringparam kernel $KERNEL \
180 -o pkg_tarball_list packages.xsl \
[fe30c61]181 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
182 ;;
183 lfs)
[7072e1f]184 xsltproc --nonet --xinclude \
185 --stringparam pkgmngt $PKGMNGT \
186 -o pkg_tarball_list packages.xsl \
[fe30c61]187 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
188 ;;
[92b7cb8]189 *)
[fe30c61]190 esac
191
[b11c10b]192 echo "done"
[fe30c61]193
194}
195
[d68eb1b]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.