source: common/libs/func_book_parser@ 9f89fae

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

LFS: Simplify git repo management

Use inly one variable, REPO, containing the LFS git repo url. The
BLFS Makefile hardcodes the LFS and BLFS git repo urls, so no need
to pass them.

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