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