[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 vim-lang "$VIMLANG" \
|
---|
| 104 | --stringparam timezone "$TIMEZONE" \
|
---|
| 105 | --stringparam page "$PAGE" \
|
---|
| 106 | --stringparam lang "$LANG" \
|
---|
| 107 | --stringparam sparc "$SPARC64_PROC" \
|
---|
| 108 | --stringparam x86 "$TARGET" \
|
---|
| 109 | --stringparam mips "$TARGET" \
|
---|
| 110 | -o ./${PROGNAME}-commands/ \
|
---|
| 111 | $XSL \
|
---|
[c9598f2] | 112 | $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 113 | ;;
|
---|
| 114 |
|
---|
| 115 | clfs2)
|
---|
[b11c10b] | 116 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
|
---|
[a4acb12] | 117 | xsltproc --nonet \
|
---|
| 118 | --xinclude \
|
---|
| 119 | --stringparam vim-lang "$VIMLANG" \
|
---|
| 120 | --stringparam timezone "$TIMEZONE" \
|
---|
| 121 | --stringparam page "$PAGE" \
|
---|
| 122 | --stringparam lang "$LANG" \
|
---|
| 123 | --output ./${PROGNAME}-commands/ \
|
---|
| 124 | $XSL \
|
---|
[c9598f2] | 125 | $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 126 | ;;
|
---|
| 127 |
|
---|
| 128 | clfs3)
|
---|
[b11c10b] | 129 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
|
---|
[a4acb12] | 130 | xsltproc --nonet \
|
---|
| 131 | --xinclude \
|
---|
| 132 | --stringparam endian x$ENDIAN \
|
---|
| 133 | --stringparam timezone "$TIMEZONE" \
|
---|
| 134 | --stringparam page "$PAGE" \
|
---|
| 135 | --stringparam lang "$LANG" \
|
---|
| 136 | --output ./${PROGNAME}-commands/ \
|
---|
| 137 | $XSL \
|
---|
[c9598f2] | 138 | $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 139 | ;;
|
---|
| 140 |
|
---|
| 141 | hlfs)
|
---|
[139c34e] | 142 | echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
|
---|
[c9598f2] | 143 | xsltproc --nonet \
|
---|
| 144 | --xinclude \
|
---|
[45f8a9c8] | 145 | --stringparam model "$MODEL" \
|
---|
| 146 | --stringparam kernel "$KERNEL" \
|
---|
| 147 | --stringparam testsuite "$TEST" \
|
---|
| 148 | --stringparam bomb-testsuite "$BOMB_TEST" \
|
---|
[c9598f2] | 149 | --stringparam features \
|
---|
| 150 | x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
|
---|
[45f8a9c8] | 151 | --stringparam timezone "$TIMEZONE" \
|
---|
| 152 | --stringparam page "$PAGE" \
|
---|
| 153 | --stringparam lang "$LANG" \
|
---|
| 154 | --stringparam grsecurity_host "$GRSECURITY_HOST" \
|
---|
[c9598f2] | 155 | --output ./${PROGNAME}-commands/ \
|
---|
| 156 | $XSL \
|
---|
| 157 | $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 158 | ;;
|
---|
| 159 | lfs)
|
---|
[b11c10b] | 160 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
|
---|
[f21dff8] | 161 | pushd $BOOK > /dev/null
|
---|
[66c09d0] | 162 | if [ -f process-scripts.sh ]; then
|
---|
[f0a31de] | 163 | bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
|
---|
| 164 | fi
|
---|
[f21dff8] | 165 | popd > /dev/null
|
---|
[c9598f2] | 166 |
|
---|
[a4acb12] | 167 | xsltproc --nonet \
|
---|
| 168 | --xinclude \
|
---|
| 169 | --stringparam revision "$INITSYS" \
|
---|
| 170 | --stringparam testsuite "$TEST" \
|
---|
| 171 | --stringparam bomb-testsuite "$BOMB_TEST" \
|
---|
| 172 | --stringparam vim-lang "$VIMLANG" \
|
---|
[dc7fd7b] | 173 | --stringparam strip "$STRIP" \
|
---|
| 174 | --stringparam del-la-files "$DEL_LA_FILES" \
|
---|
[a4acb12] | 175 | --stringparam full-locale "$FULL_LOCALE" \
|
---|
| 176 | --stringparam timezone "$TIMEZONE" \
|
---|
| 177 | --stringparam page "$PAGE" \
|
---|
| 178 | --stringparam lang "$LANG" \
|
---|
| 179 | --stringparam pkgmngt "$PKGMNGT" \
|
---|
| 180 | --stringparam wrap-install "$WRAP_INSTALL" \
|
---|
| 181 | --stringparam hostname "$HOSTNAME" \
|
---|
| 182 | --stringparam interface "$INTERFACE" \
|
---|
| 183 | --stringparam ip "$IP_ADDR" \
|
---|
| 184 | --stringparam gateway "$GATEWAY" \
|
---|
| 185 | --stringparam prefix "$PREFIX" \
|
---|
| 186 | --stringparam broadcast "$BROADCAST" \
|
---|
| 187 | --stringparam domain "$DOMAIN" \
|
---|
| 188 | --stringparam nameserver1 "$DNS1" \
|
---|
| 189 | --stringparam nameserver2 "$DNS2" \
|
---|
| 190 | --output ./${PROGNAME}-commands/ \
|
---|
| 191 | $XSL \
|
---|
[5e59386] | 192 | $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
---|
[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
|
---|
| 204 | create_package_list
|
---|
[d68eb1b] | 205 | create_chroot_scripts
|
---|
[fe30c61] | 206 |
|
---|
| 207 | # Done. Moving on...
|
---|
| 208 | get_sources
|
---|
| 209 |
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | #----------------------------#
|
---|
| 213 | create_package_list() { #
|
---|
| 214 | #----------------------------#
|
---|
| 215 |
|
---|
| 216 | # Create the packages file. We need it for proper Makefile creation
|
---|
| 217 | rm -f pkg_tarball_list
|
---|
[b11c10b] | 218 | echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
|
---|
| 219 | if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
---|
| 220 | echo -n "... "
|
---|
[fe30c61] | 221 | case ${PROGNAME} in
|
---|
[92b7cb8] | 222 | clfs*)
|
---|
[c9598f2] | 223 | xsltproc --nonet --xinclude \
|
---|
| 224 | -o pkg_tarball_list \
|
---|
| 225 | packages.xsl \
|
---|
[92b7cb8] | 226 | $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
[fe30c61] | 227 | ;;
|
---|
| 228 | hlfs)
|
---|
[a4acb12] | 229 | xsltproc --nonet --xinclude \
|
---|
| 230 | --stringparam model "$MODEL" \
|
---|
| 231 | --stringparam kernel "$KERNEL" \
|
---|
| 232 | --output pkg_tarball_list \
|
---|
| 233 | packages.xsl \
|
---|
[fe30c61] | 234 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 235 | ;;
|
---|
| 236 | lfs)
|
---|
[a4acb12] | 237 | xsltproc --nonet --xinclude \
|
---|
| 238 | --stringparam pkgmngt "$PKGMNGT" \
|
---|
| 239 | --stringparam revision "$INITSYS" \
|
---|
| 240 | --output pkg_tarball_list \
|
---|
| 241 | packages.xsl \
|
---|
[fe30c61] | 242 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 243 | ;;
|
---|
[92b7cb8] | 244 | *)
|
---|
[fe30c61] | 245 | esac
|
---|
| 246 |
|
---|
[b11c10b] | 247 | echo "done"
|
---|
[fe30c61] | 248 |
|
---|
| 249 | }
|
---|
| 250 |
|
---|
[d68eb1b] | 251 | #----------------------------#
|
---|
| 252 | create_chroot_scripts() { #
|
---|
| 253 | #----------------------------#
|
---|
| 254 |
|
---|
| 255 | rm -rf chroot_scripts
|
---|
| 256 | echo -n "Creating chroot commands scripts from $BOOK"
|
---|
| 257 | if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
---|
| 258 | echo -n "... "
|
---|
| 259 | case ${PROGNAME} in
|
---|
| 260 | clfs*)
|
---|
| 261 | xsltproc --nonet --xinclude \
|
---|
| 262 | -o chroot-scripts/ chroot.xsl \
|
---|
| 263 | $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
|
---|
| 264 | ;;
|
---|
| 265 | hlfs)
|
---|
| 266 | xsltproc --nonet --xinclude \
|
---|
| 267 | -o chroot-scripts/ chroot.xsl \
|
---|
| 268 | $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
---|
| 269 | ;;
|
---|
| 270 | lfs)
|
---|
| 271 | xsltproc --nonet --xinclude \
|
---|
| 272 | -o chroot-scripts/ chroot.xsl \
|
---|
| 273 | $BOOK/chapter06/chapter06.xml >> $LOGDIR/$LOG 2>&1
|
---|
| 274 | ;;
|
---|
| 275 | *)
|
---|
| 276 | esac
|
---|
| 277 | echo "done"
|
---|
| 278 |
|
---|
| 279 | }
|
---|