[fe30c61] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | #----------------------------#
|
---|
| 4 | get_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 | case $PROGNAME in
|
---|
[de67016] | 16 | lfs) git_root="lfs.git" ;;
|
---|
[d68eb1b] | 17 | clfs*) ;;
|
---|
[fe30c61] | 18 | *) echo "BOOK not defined in function <get_book>"
|
---|
| 19 | exit 1 ;;
|
---|
| 20 | esac
|
---|
| 21 | # Grab a fresh book if it's missing, otherwise, update it from the
|
---|
| 22 | # repo. If we've already extracted the commands, move on to getting the
|
---|
| 23 | # sources.
|
---|
[de67016] | 24 | if [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
|
---|
[605ea36] | 25 | git clone $GIT/$git_root ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
|
---|
[92b7cb8] | 26 | if [ ! $TREE == "development" ]; then
|
---|
[de57ef4] | 27 | pushd ${PROGNAME}-$LFSVRS > /dev/null
|
---|
[92b7cb8] | 28 | echo "Checking out $LFSVRS at $PWD in $TREE"
|
---|
[ad4ff97] | 29 | git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
|
---|
[de57ef4] | 30 | popd > /dev/null
|
---|
[92b7cb8] | 31 | fi
|
---|
[1cf621b] | 32 | else
|
---|
| 33 | cd ${PROGNAME}-$LFSVRS
|
---|
[de67016] | 34 | # If the repo is in "detached head" state, git pull fails, so get
|
---|
| 35 | # back first to master:
|
---|
| 36 | git checkout trunk >>$LOGDIR/$LOG 2>&1
|
---|
| 37 | git pull >>$LOGDIR/$LOG 2>&1
|
---|
| 38 | if [ ! $TREE == "development" ]; then
|
---|
| 39 | git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
|
---|
| 40 | fi
|
---|
[fe30c61] | 41 | fi
|
---|
[1cf621b] | 42 | echo -ne "done\n"
|
---|
[fe30c61] | 43 |
|
---|
[de57ef4] | 44 | else # Working copy
|
---|
[fe30c61] | 45 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
| 46 | fi
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | #----------------------------#
|
---|
| 50 | extract_commands() { #
|
---|
| 51 | #----------------------------#
|
---|
| 52 |
|
---|
| 53 | cd $JHALFSDIR
|
---|
[d68eb1b] | 54 | # Clean
|
---|
| 55 | rm -rf ${PROGNAME}-commands
|
---|
[fe30c61] | 56 |
|
---|
[d68eb1b] | 57 | # Extract the commands
|
---|
| 58 | echo -n "Extracting commands for"
|
---|
[fe30c61] | 59 | case ${PROGNAME} in
|
---|
| 60 | clfs)
|
---|
[b11c10b] | 61 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
|
---|
[a4acb12] | 62 | xsltproc --nonet \
|
---|
| 63 | --xinclude \
|
---|
| 64 | --stringparam method "$METHOD" \
|
---|
| 65 | --stringparam testsuite "$TEST" \
|
---|
| 66 | --stringparam bomb-testsuite "$BOMB_TEST" \
|
---|
| 67 | --stringparam timezone "$TIMEZONE" \
|
---|
| 68 | --stringparam page "$PAGE" \
|
---|
| 69 | --stringparam lang "$LANG" \
|
---|
| 70 | --stringparam sparc "$SPARC64_PROC" \
|
---|
| 71 | --stringparam x86 "$TARGET" \
|
---|
| 72 | --stringparam mips "$TARGET" \
|
---|
| 73 | -o ./${PROGNAME}-commands/ \
|
---|
| 74 | $XSL \
|
---|
[c9598f2] | 75 | $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 76 | ;;
|
---|
| 77 |
|
---|
| 78 | clfs2)
|
---|
[b11c10b] | 79 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
|
---|
[a4acb12] | 80 | xsltproc --nonet \
|
---|
| 81 | --xinclude \
|
---|
| 82 | --stringparam timezone "$TIMEZONE" \
|
---|
| 83 | --stringparam page "$PAGE" \
|
---|
| 84 | --stringparam lang "$LANG" \
|
---|
| 85 | --output ./${PROGNAME}-commands/ \
|
---|
| 86 | $XSL \
|
---|
[c9598f2] | 87 | $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 88 | ;;
|
---|
| 89 |
|
---|
| 90 | clfs3)
|
---|
[b11c10b] | 91 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
|
---|
[a4acb12] | 92 | xsltproc --nonet \
|
---|
| 93 | --xinclude \
|
---|
| 94 | --stringparam endian x$ENDIAN \
|
---|
| 95 | --stringparam timezone "$TIMEZONE" \
|
---|
| 96 | --stringparam page "$PAGE" \
|
---|
| 97 | --stringparam lang "$LANG" \
|
---|
| 98 | --output ./${PROGNAME}-commands/ \
|
---|
| 99 | $XSL \
|
---|
[c9598f2] | 100 | $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 101 | ;;
|
---|
| 102 |
|
---|
| 103 | hlfs)
|
---|
[139c34e] | 104 | echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
|
---|
[c9598f2] | 105 | xsltproc --nonet \
|
---|
| 106 | --xinclude \
|
---|
[45f8a9c8] | 107 | --stringparam model "$MODEL" \
|
---|
| 108 | --stringparam kernel "$KERNEL" \
|
---|
| 109 | --stringparam testsuite "$TEST" \
|
---|
| 110 | --stringparam bomb-testsuite "$BOMB_TEST" \
|
---|
[c9598f2] | 111 | --stringparam features \
|
---|
| 112 | x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
|
---|
[45f8a9c8] | 113 | --stringparam timezone "$TIMEZONE" \
|
---|
| 114 | --stringparam page "$PAGE" \
|
---|
| 115 | --stringparam lang "$LANG" \
|
---|
| 116 | --stringparam grsecurity_host "$GRSECURITY_HOST" \
|
---|
[c9598f2] | 117 | --output ./${PROGNAME}-commands/ \
|
---|
| 118 | $XSL \
|
---|
| 119 | $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 120 | ;;
|
---|
| 121 | lfs)
|
---|
[b11c10b] | 122 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
|
---|
[13e52a5] | 123 | # The scripts pages are xincluded by the book, so must
|
---|
| 124 | # be generated for running xsltproc
|
---|
[f21dff8] | 125 | pushd $BOOK > /dev/null
|
---|
[66c09d0] | 126 | if [ -f process-scripts.sh ]; then
|
---|
[f0a31de] | 127 | bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
|
---|
| 128 | fi
|
---|
[97b270f] | 129 | # Recent git versions need version.ent to be generated
|
---|
| 130 | if [ -f git-version.sh ]; then
|
---|
[4c32ca8] | 131 | bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
|
---|
[97b270f] | 132 | fi
|
---|
[f21dff8] | 133 | popd > /dev/null
|
---|
[c9598f2] | 134 |
|
---|
[13e52a5] | 135 | # First profile the book, for revision and arch. Note that
|
---|
| 136 | # MULTIBLIB is set to "default" if pure 64 bit book. In this
|
---|
| 137 | # profiling on arch is useless, but does not hurt either.
|
---|
[a4acb12] | 138 | xsltproc --nonet \
|
---|
| 139 | --xinclude \
|
---|
[13e52a5] | 140 | --stringparam profile.revision "$INITSYS" \
|
---|
| 141 | --stringparam profile.arch "$MULTILIB" \
|
---|
| 142 | --output prbook.xml \
|
---|
| 143 | $BOOK/stylesheets/lfs-xsl/profile.xsl \
|
---|
| 144 | $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
---|
| 145 |
|
---|
| 146 | # Use the profiled book for generating the scriptlets
|
---|
| 147 | xsltproc --nonet \
|
---|
[a4acb12] | 148 | --stringparam testsuite "$TEST" \
|
---|
| 149 | --stringparam bomb-testsuite "$BOMB_TEST" \
|
---|
[085435e] | 150 | --stringparam ncurses5 "$NCURSES5" \
|
---|
[dc7fd7b] | 151 | --stringparam strip "$STRIP" \
|
---|
| 152 | --stringparam del-la-files "$DEL_LA_FILES" \
|
---|
[a4acb12] | 153 | --stringparam full-locale "$FULL_LOCALE" \
|
---|
| 154 | --stringparam timezone "$TIMEZONE" \
|
---|
| 155 | --stringparam page "$PAGE" \
|
---|
| 156 | --stringparam lang "$LANG" \
|
---|
| 157 | --stringparam pkgmngt "$PKGMNGT" \
|
---|
| 158 | --stringparam wrap-install "$WRAP_INSTALL" \
|
---|
| 159 | --stringparam hostname "$HOSTNAME" \
|
---|
| 160 | --stringparam interface "$INTERFACE" \
|
---|
| 161 | --stringparam ip "$IP_ADDR" \
|
---|
| 162 | --stringparam gateway "$GATEWAY" \
|
---|
| 163 | --stringparam prefix "$PREFIX" \
|
---|
| 164 | --stringparam broadcast "$BROADCAST" \
|
---|
| 165 | --stringparam domain "$DOMAIN" \
|
---|
| 166 | --stringparam nameserver1 "$DNS1" \
|
---|
| 167 | --stringparam nameserver2 "$DNS2" \
|
---|
[3b43e17b] | 168 | --stringparam font "$FONT" \
|
---|
| 169 | --stringparam fontmap "$FONTMAP" \
|
---|
| 170 | --stringparam unicode "$UNICODE" \
|
---|
| 171 | --stringparam keymap "$KEYMAP" \
|
---|
| 172 | --stringparam local "$LOCAL" \
|
---|
| 173 | --stringparam log-level "$LOG_LEVEL" \
|
---|
[2758d94] | 174 | --stringparam script-root "$SCRIPT_ROOT" \
|
---|
[a4acb12] | 175 | --output ./${PROGNAME}-commands/ \
|
---|
| 176 | $XSL \
|
---|
[13e52a5] | 177 | prbook.xml >> $LOGDIR/$LOG 2>&1
|
---|
[f168be1] | 178 | # Remove flags requesting user action in some cases. Much easier here than
|
---|
| 179 | # in the stylesheet...
|
---|
[ebe1ba6] | 180 | sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
|
---|
[fe30c61] | 181 | ;;
|
---|
[d68eb1b] | 182 | *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
|
---|
[fe30c61] | 183 | exit 1 ;;
|
---|
| 184 | esac
|
---|
| 185 |
|
---|
[b11c10b] | 186 | echo "done"
|
---|
[fe30c61] | 187 |
|
---|
| 188 | # Make the scripts executable.
|
---|
| 189 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
| 190 |
|
---|
| 191 | # Create the packages file. We need it for proper Makefile creation
|
---|
[840b9ba] | 192 | # lfs does not use this anymore, but this is taken care in the
|
---|
| 193 | # function body
|
---|
[fe30c61] | 194 | create_package_list
|
---|
[706e5bf] | 195 | # On the other hand, lfs needs two auxiliary files
|
---|
[13c475b] | 196 | if [ "${PROGNAME}" = lfs ]; then
|
---|
| 197 | create_chroot_scripts
|
---|
| 198 | create_kernfs_scripts
|
---|
| 199 | fi
|
---|
[fe30c61] | 200 |
|
---|
[840b9ba] | 201 | # we create the VERSION variable here. Should maybe go into its own
|
---|
| 202 | # function. But at this point we can use the profiled xml to get
|
---|
| 203 | # version from lfs-release in the lfs case.
|
---|
| 204 | case $PROGNAME in
|
---|
| 205 | clfs*)
|
---|
| 206 | VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 207 | lfs)
|
---|
| 208 | VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
|
---|
| 209 | ;;
|
---|
| 210 | *)
|
---|
| 211 | VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 212 | esac
|
---|
| 213 |
|
---|
[fe30c61] | 214 | # Done. Moving on...
|
---|
| 215 | get_sources
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | #----------------------------#
|
---|
| 219 | create_package_list() { #
|
---|
| 220 | #----------------------------#
|
---|
| 221 |
|
---|
| 222 | # Create the packages file. We need it for proper Makefile creation
|
---|
| 223 | rm -f pkg_tarball_list
|
---|
[b11c10b] | 224 | echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
|
---|
[706e5bf] | 225 | if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
|
---|
[b11c10b] | 226 | echo -n "... "
|
---|
[fe30c61] | 227 | case ${PROGNAME} in
|
---|
[92b7cb8] | 228 | clfs*)
|
---|
[c9598f2] | 229 | xsltproc --nonet --xinclude \
|
---|
| 230 | -o pkg_tarball_list \
|
---|
| 231 | packages.xsl \
|
---|
[92b7cb8] | 232 | $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 233 | ;;
|
---|
| 234 | hlfs)
|
---|
[a4acb12] | 235 | xsltproc --nonet --xinclude \
|
---|
| 236 | --stringparam model "$MODEL" \
|
---|
| 237 | --stringparam kernel "$KERNEL" \
|
---|
| 238 | --output pkg_tarball_list \
|
---|
| 239 | packages.xsl \
|
---|
[fe30c61] | 240 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 241 | ;;
|
---|
| 242 | lfs)
|
---|
[706e5bf] | 243 | # lfs does not use the package list anymore
|
---|
[fe30c61] | 244 | ;;
|
---|
[92b7cb8] | 245 | *)
|
---|
[fe30c61] | 246 | esac
|
---|
| 247 |
|
---|
[b11c10b] | 248 | echo "done"
|
---|
[fe30c61] | 249 |
|
---|
| 250 | }
|
---|
| 251 |
|
---|
[d68eb1b] | 252 | #----------------------------#
|
---|
[13c475b] | 253 | create_chroot_scripts() { #
|
---|
[d68eb1b] | 254 | #----------------------------#
|
---|
| 255 |
|
---|
[13c475b] | 256 | rm -rf chroot-scripts
|
---|
[d68eb1b] | 257 | echo -n "Creating chroot commands scripts from $BOOK"
|
---|
| 258 | if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
---|
| 259 | echo -n "... "
|
---|
| 260 | case ${PROGNAME} in
|
---|
| 261 | clfs*)
|
---|
| 262 | xsltproc --nonet --xinclude \
|
---|
| 263 | -o chroot-scripts/ chroot.xsl \
|
---|
| 264 | $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
|
---|
| 265 | ;;
|
---|
| 266 | hlfs)
|
---|
| 267 | xsltproc --nonet --xinclude \
|
---|
| 268 | -o chroot-scripts/ chroot.xsl \
|
---|
| 269 | $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
---|
| 270 | ;;
|
---|
| 271 | lfs)
|
---|
| 272 | xsltproc --nonet --xinclude \
|
---|
| 273 | -o chroot-scripts/ chroot.xsl \
|
---|
[04de9bc] | 274 | $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
|
---|
[d68eb1b] | 275 | ;;
|
---|
| 276 | *)
|
---|
| 277 | esac
|
---|
| 278 | echo "done"
|
---|
| 279 |
|
---|
| 280 | }
|
---|
[13c475b] | 281 |
|
---|
| 282 | #----------------------------#
|
---|
| 283 | create_kernfs_scripts() { #
|
---|
| 284 | #----------------------------#
|
---|
| 285 |
|
---|
| 286 | rm -rf kernfs-scripts
|
---|
| 287 | mkdir kernfs-scripts
|
---|
| 288 | echo -n "Creating virtual kernel FS commands scripts from $BOOK"
|
---|
| 289 | if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
---|
| 290 | echo -n "... "
|
---|
| 291 | case ${PROGNAME} in
|
---|
| 292 | clfs*)
|
---|
| 293 | xsltproc --nonet --xinclude \
|
---|
| 294 | -o kernfs-scripts/ kernfs.xsl \
|
---|
| 295 | $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
|
---|
| 296 | ;;
|
---|
| 297 | hlfs)
|
---|
| 298 | xsltproc --nonet --xinclude \
|
---|
| 299 | -o kernfs-scripts/ kernfs.xsl \
|
---|
| 300 | $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
---|
| 301 | ;;
|
---|
| 302 | lfs)
|
---|
| 303 | xsltproc --nonet \
|
---|
| 304 | -o kernfs-scripts/devices.sh kernfs.xsl \
|
---|
[04de9bc] | 305 | $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
|
---|
[13c475b] | 306 | xsltproc --nonet \
|
---|
| 307 | -o kernfs-scripts/teardown.sh kernfs.xsl \
|
---|
[ebe1ba6] | 308 | $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
|
---|
[13c475b] | 309 | ;;
|
---|
| 310 | *)
|
---|
| 311 | esac
|
---|
| 312 | echo "done"
|
---|
| 313 |
|
---|
| 314 | }
|
---|