source: common/libs/func_book_parser@ 327a3ee

ablfs-more trunk
Last change on this file since 327a3ee was 0fa52f2, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove legacy: Remove almost all occurrences of CLFS/clfs

  • Property mode set to 100644
File size: 7.5 KB
Line 
1#!/bin/bash
2
3#----------------------------#
4get_book() { #
5#----------------------------#
6 cd $JHALFSDIR
7
8 if [ -z $WORKING_COPY ] ; then
9# Check for Subversion or git instead of just letting the script fail.
10 test `type -p git` || eval "echo \"This feature requires Git.\"
11 exit 1"
12
13 echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
14
15 case $PROGNAME in
16 lfs) git_root="lfs.git" ;;
17 *) echo "BOOK not defined in function <get_book>"
18 exit 1 ;;
19 esac
20 # Grab a fresh book if it's missing, otherwise, update it from the
21 # repo. If we've already extracted the commands, move on to getting the
22 # sources.
23 if [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
24 git clone $GIT/$git_root ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
25 if [ ! $TREE == "development" ]; then
26 pushd ${PROGNAME}-$LFSVRS > /dev/null
27 echo "Checking out $LFSVRS at $PWD in $TREE"
28 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
29 popd > /dev/null
30 fi
31 else
32 cd ${PROGNAME}-$LFSVRS
33 # If the repo is in "detached head" state, git pull fails, so get
34 # back first to master:
35 git checkout trunk >>$LOGDIR/$LOG 2>&1
36 git pull >>$LOGDIR/$LOG 2>&1
37 if [ ! $TREE == "development" ]; then
38 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
39 fi
40 fi
41 echo -ne "done\n"
42
43 else # Working copy
44 echo -ne "Using $BOOK as book's sources ...\n"
45 fi
46}
47
48#----------------------------#
49extract_commands() { #
50#----------------------------#
51
52 cd $JHALFSDIR
53 # Clean
54 rm -rf ${PROGNAME}-commands
55
56 # Extract the commands
57 echo -n "Extracting commands for"
58 case ${PROGNAME} in
59
60 lfs)
61 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
62 # The scripts pages are xincluded by the book, so must
63 # be generated for running xsltproc
64 pushd $BOOK > /dev/null
65 if [ -f process-scripts.sh ]; then
66 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
67 fi
68 # Recent git versions need version.ent to be generated
69 if [ -f git-version.sh ]; then
70 bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
71 fi
72 popd > /dev/null
73
74 # First profile the book, for revision and arch. Note that
75 # MULTIBLIB is set to "default" if pure 64 bit book. In this
76 # profiling on arch is useless, but does not hurt either.
77 xsltproc --nonet \
78 --xinclude \
79 --stringparam profile.revision "$INITSYS" \
80 --stringparam profile.arch "$MULTILIB" \
81 --output prbook.xml \
82 $BOOK/stylesheets/lfs-xsl/profile.xsl \
83 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
84
85 # Use the profiled book for generating the scriptlets
86 xsltproc --nonet \
87 --stringparam testsuite "$TEST" \
88 --stringparam bomb-testsuite "$BOMB_TEST" \
89 --stringparam ncurses5 "$NCURSES5" \
90 --stringparam strip "$STRIP" \
91 --stringparam del-la-files "$DEL_LA_FILES" \
92 --stringparam full-locale "$FULL_LOCALE" \
93 --stringparam timezone "$TIMEZONE" \
94 --stringparam page "$PAGE" \
95 --stringparam lang "$LANG" \
96 --stringparam pkgmngt "$PKGMNGT" \
97 --stringparam wrap-install "$WRAP_INSTALL" \
98 --stringparam hostname "$HOSTNAME" \
99 --stringparam interface "$INTERFACE" \
100 --stringparam ip "$IP_ADDR" \
101 --stringparam gateway "$GATEWAY" \
102 --stringparam prefix "$PREFIX" \
103 --stringparam broadcast "$BROADCAST" \
104 --stringparam domain "$DOMAIN" \
105 --stringparam nameserver1 "$DNS1" \
106 --stringparam nameserver2 "$DNS2" \
107 --stringparam font "$FONT" \
108 --stringparam fontmap "$FONTMAP" \
109 --stringparam unicode "$UNICODE" \
110 --stringparam keymap "$KEYMAP" \
111 --stringparam local "$LOCAL" \
112 --stringparam log-level "$LOG_LEVEL" \
113 --stringparam script-root "$SCRIPT_ROOT" \
114 --output ./${PROGNAME}-commands/ \
115 $XSL \
116 prbook.xml >> $LOGDIR/$LOG 2>&1
117# Remove flags requesting user action in some cases. Much easier here than
118# in the stylesheet...
119 sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
120 ;;
121 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
122 exit 1 ;;
123 esac
124
125 echo "done"
126
127 # Make the scripts executable.
128 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
129
130 # Create the packages file. We need it for proper Makefile creation
131 # lfs does not use this anymore, but this is taken care in the
132 # function body
133 create_package_list
134 # On the other hand, lfs needs two auxiliary files
135 if [ "${PROGNAME}" = lfs ]; then
136 create_chroot_scripts
137 create_kernfs_scripts
138 fi
139
140 # we create the VERSION variable here. Should maybe go into its own
141 # function. But at this point we can use the profiled xml to get
142 # version from lfs-release in the lfs case.
143 case $PROGNAME in
144 lfs)
145 VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
146 ;;
147 *)
148 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
149 esac
150
151 # Done. Moving on...
152 get_sources
153}
154
155#----------------------------#
156create_package_list() { #
157#----------------------------#
158
159 # Create the packages file. We need it for proper Makefile creation
160 rm -f pkg_tarball_list
161 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
162 if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
163 echo -n "... "
164 case ${PROGNAME} in
165 lfs)
166 # lfs does not use the package list anymore
167 ;;
168 *)
169 esac
170
171 echo "done"
172
173}
174
175#----------------------------#
176create_chroot_scripts() { #
177#----------------------------#
178
179 rm -rf chroot-scripts
180 echo -n "Creating chroot commands scripts from $BOOK"
181 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
182 echo -n "... "
183 case ${PROGNAME} in
184 lfs)
185 xsltproc --nonet --xinclude \
186 -o chroot-scripts/ chroot.xsl \
187 $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
188 ;;
189 *)
190 esac
191 echo "done"
192
193}
194
195#----------------------------#
196create_kernfs_scripts() { #
197#----------------------------#
198
199 rm -rf kernfs-scripts
200 mkdir kernfs-scripts
201 echo -n "Creating virtual kernel FS commands scripts from $BOOK"
202 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
203 echo -n "... "
204 case ${PROGNAME} in
205 lfs)
206 xsltproc --nonet \
207 -o kernfs-scripts/devices.sh kernfs.xsl \
208 $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
209 xsltproc --nonet \
210 -o kernfs-scripts/teardown.sh kernfs.xsl \
211 $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
212 ;;
213 *)
214 esac
215 echo "done"
216
217}
Note: See TracBrowser for help on using the repository browser.