source: common/libs/func_book_parser@ 4dfe8f9

ablfs-more trunk
Last change on this file since 4dfe8f9 was 87eb9e9, checked in by Pierre Labastie <pierre.labastie@…>, 2 years ago

Make the kernel filesystem scriptlets executable

This is so that they can be run from the main Makefile, instead
of having to edit them to put them inside the Makefile.

  • Property mode set to 100644
File size: 6.1 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 lfs document, branch/tag/commit: $COMMIT... "
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.
18 if [ ! -d "$BOOK"/.git ]; then
19 git clone "$REPO" "$BOOK" >>"$LOGDIR/$LOG" 2>&1
20 if [ "$COMMIT" != trunk ]; then
21 pushd "$BOOK" >/dev/null
22 echo "Checking out $COMMIT at $PWD"
23 git checkout "$COMMIT" >>"$LOGDIR/$LOG" 2>&1
24 popd >/dev/null
25 fi
26 else
27 cd "$BOOK"
28 # If the repo is in "detached head" state, git pull fails, so get
29 # back first to trunk:
30 git checkout trunk >>"$LOGDIR/$LOG" 2>&1
31 git pull >>"$LOGDIR/$LOG" 2>&1
32 if [ "$COMMIT" != "trunk" ]; then
33 git checkout "$COMMIT" >>"$LOGDIR/$LOG" 2>&1
34 fi
35 fi
36 echo -ne "done\n"
37
38 else # Working copy
39 echo -ne "Using $BOOK as book's sources ...\n"
40 fi
41}
42
43#----------------------------#
44extract_commands() { #
45#----------------------------#
46
47 cd $JHALFSDIR
48 # Clean
49 rm -rf "$COMMANDS"
50
51 # Extract the commands
52 echo -n "Extracting commands for"
53 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
54 # The scripts pages are xincluded by the book, so must
55 # be generated for running xsltproc
56 pushd $BOOK > /dev/null
57 if [ -f process-scripts.sh ]; then
58 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
59 fi
60 # Recent git versions need version.ent to be generated
61 if [ -f git-version.sh ]; then
62 bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
63 fi
64 popd > /dev/null
65
66 # First profile the book, for revision and arch. Note that
67 # MULTIBLIB is set to "default" if pure 64 bit book. In this case,
68 # profiling on arch is useless, but does not hurt either.
69 xsltproc --nonet \
70 --xinclude \
71 --stringparam profile.revision "$INITSYS" \
72 --stringparam profile.arch "$MULTILIB" \
73 --output prbook.xml \
74 $BOOK/stylesheets/lfs-xsl/profile.xsl \
75 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
76
77 # Use the profiled book for generating the scriptlets
78 xsltproc --nonet \
79 --stringparam testsuite "$TEST" \
80 --stringparam ncurses5 "$NCURSES5" \
81 --stringparam strip "$STRIP" \
82 --stringparam del-la-files "$DEL_LA_FILES" \
83 --stringparam full-locale "$FULL_LOCALE" \
84 --stringparam timezone "$TIMEZONE" \
85 --stringparam page "$PAGE" \
86 --stringparam lang "$LANG" \
87 --stringparam pkgmngt "$PKGMNGT" \
88 --stringparam wrap-install "$WRAP_INSTALL" \
89 --stringparam hostname "$HOSTNAME" \
90 --stringparam interface "$INTERFACE" \
91 --stringparam ip "$IP_ADDR" \
92 --stringparam gateway "$GATEWAY" \
93 --stringparam prefix "$PREFIX" \
94 --stringparam broadcast "$BROADCAST" \
95 --stringparam domain "$DOMAIN" \
96 --stringparam nameserver1 "$DNS1" \
97 --stringparam nameserver2 "$DNS2" \
98 --stringparam font "$FONT" \
99 --stringparam fontmap "$FONTMAP" \
100 --stringparam unicode "$UNICODE" \
101 --stringparam keymap "$KEYMAP" \
102 --stringparam local "$LOCAL" \
103 --stringparam log-level "$LOG_LEVEL" \
104 --stringparam script-root "$SCRIPT_ROOT" \
105 --output "./${COMMANDS}/" \
106 $XSL \
107 prbook.xml >> $LOGDIR/$LOG 2>&1
108 # Remove flags requesting user action in some cases. Much easier here than
109 # in the stylesheet...
110 sed -i 's/-iv /-v /' "./${COMMANDS}/"chapter??/*kernel*
111 # If doing a destdir install (PM without wrap), the gcc instructions
112 # fail for two reasons: a missing dir, and gcc -dumpmachine returns a
113 # wrong string.
114 if [ "$PKGMNGT" = y ] && [ "$WRAP_INSTALL" = n ]; then
115 sed -e 's|(gcc|&/xgcc|' \
116 -e '/lto_plug/imkdir -pv $PKG_DEST/usr/lib/bfd-plugins' \
117 -i ./${COMMANDS}/chapter08/*gcc
118 fi
119 echo "done"
120
121 # Make the scripts executable.
122 chmod -R +x "$JHALFSDIR/${COMMANDS}"
123 create_chroot_scripts
124 create_kernfs_scripts
125
126 # we create the VERSION variable here. Should maybe go into its own
127 # function. But at this point we can use the profiled xml to get
128 # version from lfs-release in the lfs case.
129 VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
130
131 # Done. Moving on...
132 get_sources
133}
134
135#----------------------------#
136create_chroot_scripts() { #
137#----------------------------#
138
139 rm -rf chroot-scripts
140 echo -n "Creating chroot commands scripts from $BOOK"
141 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
142 echo -n "... "
143 xsltproc --nonet --xinclude \
144 -o chroot-scripts/ chroot.xsl \
145 $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
146 echo "done"
147
148}
149
150#----------------------------#
151create_kernfs_scripts() { #
152#----------------------------#
153
154 rm -rf kernfs-scripts
155 mkdir kernfs-scripts
156 echo -n "Creating virtual kernel FS commands scripts from $BOOK"
157 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
158 echo -n "... "
159 xsltproc --nonet \
160 -o kernfs-scripts/devices.sh kernfs.xsl \
161 $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
162 chmod +x kernfs-scripts/devices.sh
163 xsltproc --nonet \
164 -o kernfs-scripts/teardown.sh kernfs.xsl \
165 $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
166 chmod +x kernfs-scripts/teardown.sh
167
168 echo "done"
169
170}
Note: See TracBrowser for help on using the repository browser.