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