1 | #!/bin/bash
|
---|
2 |
|
---|
3 | #----------------------------#
|
---|
4 | get_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 | #----------------------------#
|
---|
44 | extract_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 | if [ "$ALL_CORES" = "y" ]; then
|
---|
67 | JOBS="\$(nproc)"
|
---|
68 | else
|
---|
69 | JOBS="$N_PARALLEL"
|
---|
70 |
|
---|
71 | fi
|
---|
72 | # First profile the book, for revision and arch. Note that
|
---|
73 | # MULTIBLIB is set to "default" if pure 64 bit book. In this case,
|
---|
74 | # profiling on arch is useless, but does not hurt either.
|
---|
75 | xsltproc --nonet \
|
---|
76 | --xinclude \
|
---|
77 | --stringparam profile.revision "$INITSYS" \
|
---|
78 | --stringparam profile.arch "$MULTILIB" \
|
---|
79 | --output prbook.xml \
|
---|
80 | $BOOK/stylesheets/lfs-xsl/profile.xsl \
|
---|
81 | $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
---|
82 |
|
---|
83 | # Use the profiled book for generating the scriptlets
|
---|
84 | xsltproc --nonet \
|
---|
85 | --stringparam testsuite "$TEST" \
|
---|
86 | --stringparam ncurses5 "$NCURSES5" \
|
---|
87 | --stringparam strip "$STRIP" \
|
---|
88 | --stringparam del-la-files "$DEL_LA_FILES" \
|
---|
89 | --stringparam full-locale "$FULL_LOCALE" \
|
---|
90 | --stringparam timezone "$TIMEZONE" \
|
---|
91 | --stringparam page "$PAGE" \
|
---|
92 | --stringparam lang "$LANG" \
|
---|
93 | --stringparam pkgmngt "$PKGMNGT" \
|
---|
94 | --stringparam wrap-install "$WRAP_INSTALL" \
|
---|
95 | --stringparam hostname "$HOSTNAME" \
|
---|
96 | --stringparam interface "$INTERFACE" \
|
---|
97 | --stringparam ip "$IP_ADDR" \
|
---|
98 | --stringparam gateway "$GATEWAY" \
|
---|
99 | --stringparam prefix "$PREFIX" \
|
---|
100 | --stringparam broadcast "$BROADCAST" \
|
---|
101 | --stringparam domain "$DOMAIN" \
|
---|
102 | --stringparam nameserver1 "$DNS1" \
|
---|
103 | --stringparam nameserver2 "$DNS2" \
|
---|
104 | --stringparam font "$FONT" \
|
---|
105 | --stringparam fontmap "$FONTMAP" \
|
---|
106 | --stringparam unicode "$UNICODE" \
|
---|
107 | --stringparam keymap "$KEYMAP" \
|
---|
108 | --stringparam local "$LOCAL" \
|
---|
109 | --stringparam log-level "$LOG_LEVEL" \
|
---|
110 | --stringparam script-root "$SCRIPT_ROOT" \
|
---|
111 | --stringparam jobs "$JOBS" \
|
---|
112 | --output "./${COMMANDS}/" \
|
---|
113 | $XSL \
|
---|
114 | prbook.xml >> $LOGDIR/$LOG 2>&1
|
---|
115 | # Remove flags requesting user action in some cases. Much easier here than
|
---|
116 | # in the stylesheet...
|
---|
117 | sed -i 's/-iv /-v /' "./${COMMANDS}/"chapter??/*kernel*
|
---|
118 | # If doing a destdir install (PM without wrap), the gcc instructions
|
---|
119 | # fail for two reasons: a missing dir, and gcc -dumpmachine returns a
|
---|
120 | # wrong string.
|
---|
121 | if [ "$PKGMNGT" = y ] && [ "$WRAP_INSTALL" = n ]; then
|
---|
122 | sed -e 's|(gcc|&/xgcc|' \
|
---|
123 | -e '/lto_plug/imkdir -pv $PKG_DEST/usr/lib/bfd-plugins' \
|
---|
124 | -i ./${COMMANDS}/chapter08/*gcc
|
---|
125 | fi
|
---|
126 | echo "done"
|
---|
127 |
|
---|
128 | # Make the scripts executable.
|
---|
129 | chmod -R +x "$JHALFSDIR/${COMMANDS}"
|
---|
130 | create_chroot_scripts
|
---|
131 | create_kernfs_scripts
|
---|
132 |
|
---|
133 | # we create the VERSION variable here. Should maybe go into its own
|
---|
134 | # function. But at this point we can use the profiled xml to get
|
---|
135 | # version from lfs-release in the lfs case.
|
---|
136 | VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
|
---|
137 |
|
---|
138 | # Done. Moving on...
|
---|
139 | get_sources
|
---|
140 | }
|
---|
141 |
|
---|
142 | #----------------------------#
|
---|
143 | create_chroot_scripts() { #
|
---|
144 | #----------------------------#
|
---|
145 |
|
---|
146 | rm -rf chroot-scripts
|
---|
147 | echo -n "Creating chroot commands scripts from $BOOK"
|
---|
148 | if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
---|
149 | echo -n "... "
|
---|
150 | xsltproc --nonet --xinclude \
|
---|
151 | --stringparam jobs_2 "$JOBS_2" \
|
---|
152 | -o chroot-scripts/ chroot.xsl \
|
---|
153 | $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
|
---|
154 | echo "done"
|
---|
155 |
|
---|
156 | }
|
---|
157 |
|
---|
158 | #----------------------------#
|
---|
159 | create_kernfs_scripts() { #
|
---|
160 | #----------------------------#
|
---|
161 |
|
---|
162 | rm -rf kernfs-scripts
|
---|
163 | mkdir kernfs-scripts
|
---|
164 | echo -n "Creating virtual kernel FS commands scripts from $BOOK"
|
---|
165 | if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
---|
166 | echo -n "... "
|
---|
167 | xsltproc --nonet \
|
---|
168 | -o kernfs-scripts/devices.sh kernfs.xsl \
|
---|
169 | $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
|
---|
170 | chmod +x kernfs-scripts/devices.sh
|
---|
171 | xsltproc --nonet \
|
---|
172 | -o kernfs-scripts/teardown.sh kernfs.xsl \
|
---|
173 | $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
|
---|
174 | chmod +x kernfs-scripts/teardown.sh
|
---|
175 |
|
---|
176 | echo "done"
|
---|
177 |
|
---|
178 | }
|
---|