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