diff options
-rw-r--r-- | README.txt | 49 | ||||
-rw-r--r-- | case1.sh | 8 | ||||
-rw-r--r-- | case2.sh | 8 | ||||
-rw-r--r-- | clfs-latest-files.php | 384 | ||||
-rw-r--r-- | create-commands.sh | 645 |
5 files changed, 1094 insertions, 0 deletions
diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..5694a7f --- /dev/null +++ b/README.txt @@ -0,0 +1,49 @@ +This is a beta testing build script. Look through the script before using it. +This script is updated along with the GIT version of the book. + +I got bored building everything manually and wanted to have an automated +process to create build scripts using commands dumped from the book. + +A user can download the book and select targets to dump commands like this: + +git clone git://git.cross-lfs.org/cross-lfs.git +cd cross-lfs/BOOK + +For x86 commands do: make RENDERDIR=/mnt/clfs/sources ARCHS=x86 dump-commands + + or use RENDERDIR=$CLFS/sources (make sure CLFS variable is set.) + +make help will show other targets. + +The xml of the CLFS book isn't perfect and some commands may not be extracted +properly. It is recommended that the dumped commands for cross-tools, +temp-system, and final-system be reviewed before continuing. + +Set the variables at the top of the create-commands script. +The variables are set assuming /mnt/clfs/sources is the home directory of +the dumped commands, the created scripts, and where the build will take place. + +The case1 and case2 scripts are what I used to quickly create the case +constructs in the main script and is incomplete. + +The build scripts require, for now, that all packages be compressed with xz. +If your sources will have different extensions, you can edit the createfiles +script and edit them manually. + +Compress all the source with xz using the following command: + +gunzip *.gz *.tgz && bunzip2 *.bz2 && xz -vv *.tar +(Use compression options at your descretion such as -e or -9) + +Run the create-commands.sh script as the clfs user as created in Chapter 4. +Otherwise, the script will expand the wrong $HOME variable to the scripts. +The reason is that the script should be ran after the clfs user is added +and the environment is created prioer to chapter 5. + +The TESTS variable can be set to remove the check commands so that tests are not ran. +Set the TESTS variable accordingly. + +It is a good idea to view the scripts manually before execution to make sure all +looks well and nothing is missing or ovbious. + +Contact Berzerkula at Freenode IRC #Cross-LFS or email kb0iic at gmail dot com. diff --git a/case1.sh b/case1.sh new file mode 100644 index 0000000..1e1935a --- /dev/null +++ b/case1.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +for pkg in autoconf automake bash binutils bison bootscripts bzip2 cloog coreutils dejagnu dhcpcd diffutils e2fsprogs eglibc expect file findutils flex gawk gcc gettext gmp grep groff gzip hfsutils iana-etc iproute2 iputils kbd kmod less libee libestr libtool linux m4 make man man-pages mpc mpfr ncurses parted powerpcutils patch perl pkg-config ppl procps psmisc readline rsyslog sed shadow sysvinit tar tcl texinfo udev vim xz yaboot zlib; do +upkg=`echo $pkg | sed 's/./\u&/g'` +build=build +SRCDIR=SRCDIR +echo -e " '$pkg')\n echo 'tar xf $pkg-\$$upkg.tar.xz && cd $pkg-\$$upkg' >> \$$SRCDIR/\$$build.sh;\n ;;" +done diff --git a/case2.sh b/case2.sh new file mode 100644 index 0000000..524b26d --- /dev/null +++ b/case2.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +for pkg in autoconf automake bash binutils bison bootscripts bzip2 cloog coreutils dejagnu dhcpcd diffutils e2fsprogs eglibc expect file findutils flex gawk gcc gettext gmp grep groff gzip hfsutils iana-etc iproute2 iputils kbd kmod less libee libestr libtool linux m4 make man man-pages mpc mpfr ncurses parted powerpcutils patch perl pkg-config ppl procps psmisc readline rsyslog sed shadow sysvinit tar tcl texinfo udev vim xz yaboot zlib; do +upkg=`echo $pkg | sed 's/./\u&/g'` +build=build +SRCDIR=SRCDIR +echo -e " '$pkg')\n echo 'cd .. && rm -rf $pkg-\$$upkg' >> \$$SRCDIR/\$$build.sh;\n ;;"; +done diff --git a/clfs-latest-files.php b/clfs-latest-files.php new file mode 100644 index 0000000..d981da4 --- /dev/null +++ b/clfs-latest-files.php @@ -0,0 +1,384 @@ +#!/usr/bin/php +<?php +$dirs = array(); +$vers = array(); + +date_default_timezone_set( "America/Chicago" ); +$date = date( "Y-m-d H:i:s" ); + +// Special cases +$exceptions = array(); +$exceptions[ 'gmp' ] = "UPDIR=/.*(gmp-\d[\d\.-]*\d).*/:DOWNDIR="; + +$regex = array(); +$regex[ 'bzip2' ] = "/^.*current version is ([\d\.]+).*$/"; +$regex[ 'expect' ] = "/^.*Download expect([\d\.]+)\.tar.*$/"; +$regex[ 'less' ] = "/^.*current released version is less-(\d+).*$/"; +$regex[ 'mpc' ] = "/^Version ([\d\.]+).*$/"; +$regex[ 'mpfr' ] = "/^mpfr-([\d\.]+)\.tar.*$/"; +$regex[ 'sysvinit' ] = "/^.*sysvinit-([\d\.]+)dsf\.tar.*$/"; +$regex[ 'tcl' ] = "/^.*Download tcl([\d\.]+)-src.*$/"; +$regex[ 'tzdata' ] = "/^.*tzdata([\d]+[a-z]).*$/"; +$regex[ 'xz' ] = "/^.*xz-([\d\.]*\d).*$/"; +$regex[ 'zlib' ] = "/^.*zlib ([\d\.]*\d).*$/"; + +function find_max( $lines, $regex_match, $regex_replace ) +{ + $a = array(); + foreach ( $lines as $line ) + { + if ( ! preg_match( $regex_match, $line ) ) continue; + + // Isolate the version and put in an array + $slice = preg_replace( $regex_replace, "$1", $line ); + if ( $slice == $line ) continue; + + array_push( $a, $slice ); + } + + // SORT_NATURAL requires php-5.4.0 or later + rsort( $a, SORT_NATURAL ); // Max version is at the top + return ( isset( $a[0] ) ) ? $a[0] : 0; +} + +function http_get_file( $url ) +{ + $r = new HttpRequest( $url, HttpRequest::METH_GET ); + $r->setOptions( array('redirect' => 3) ); + + try + { + $r->send(); + if ($r->getResponseCode() == 200) + { + $dir = $r->getResponseBody(); + } + else + { + //echo "Respose code " . $r->getResponseCode() . "($package)\n"; + //echo $r->getResponseBody() . "($package)\n"; + return "-2"; + } + } + catch (HttpException $ex) + { + //echo $ex; + return "-3"; + } + + $dir = strip_tags( $dir ); + return explode( "\n", $dir ); // An array of lines from the url +} + +function max_parent( $dirpath, $prefix ) +{ + // First, remove a directory + $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash + $position = strrpos( $dirpath, "/" ); + $dirpath = substr ( $dirpath, 0, $position ); + + $lines = http_get_file( $dirpath ); + + $regex_match = "#${prefix}[\d\.]+/#"; + $regex_replace = "#^.*(${prefix}[\d\.]+)/.*$#"; + $max = find_max( $lines, $regex_match, $regex_replace ); + + return "$dirpath/$max"; +} + +function get_packages( $package, $dirpath ) +{ + global $exceptions; + global $regex; + + // Check for ftp + if ( preg_match( "/^ftp/", $dirpath ) ) + { + $dirpath = substr( $dirpath, 6 ); // Remove ftp:// + $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash + $position = strpos( $dirpath, "/" ); // Divide at first slash + $server = substr( $dirpath, 0, $position ); + $path = substr( $dirpath, $position ); + + $conn = ftp_connect( $server ); + ftp_login( $conn, "anonymous", "" ); + + // See if we need special handling + if ( isset( $exceptions[ $package ] ) ) + { + $specials = explode( ":", $exceptions[ $package ] ); + + foreach ( $specials as $i ) + { + list( $op, $regexp ) = explode( "=", $i ); + + switch ($op) + { + case "UPDIR": + // Remove last dir from $path + $position = strrpos( $path, "/" ); + $path = substr( $path, 0, $position ); + + // Get dir listing + $lines = ftp_rawlist ($conn, $path); + $max = find_max( $lines, $regexp, $regexp ); + break; + + case "DOWNDIR": + // Append found directory + $path .= "/$max"; + break; + + default: + echo "Error in specials array for $package\n"; + return 0; + break; + } + } + } + + $lines = ftp_rawlist ($conn, $path); + ftp_close( $conn ); + } + else // http + { + // Customize http directories as needed + if ( $package == "tzdata" ) + { + // Remove two directories + $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash + $position = strrpos( $dirpath, "/" ); + $dirpath = substr ( $dirpath, 0, $position ); + $position = strrpos( $dirpath, "/" ); + $dirpath = substr ( $dirpath, 0, $position ); + //echo "$dirpath\n"; + } + + if ( $package == "bzip2" || + $package == "mpc" ) + { + // Remove one directory + $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash + $position = strrpos( $dirpath, "/" ); + $dirpath = substr ( $dirpath, 0, $position ); + //echo "$dirpath\n"; + } + + if ( $package == "mpfr" ) + { + $dirpath = "http://mpfr.loria.fr/mpfr-current"; + } + + if ( $package == "e2fsprogs" || + $package == "expect" || + $package == "flex" || + $package == "tcl" || + $package == "psmisc" ) + { + $dirpath = "http://sourceforge.net/projects/$package/files"; + } + + if ( $package == "gcc" ) $dirpath = max_parent( $dirpath, "gcc-" ); + if ( $package == "util-linux" ) $dirpath = max_parent( $dirpath, "v." ); + + $lines = http_get_file( $dirpath ); + } // End fetch + + if ( isset( $regex[ $package ] ) ) + { + // Custom search for latest package name + foreach ( $lines as $l ) + { + $ver = preg_replace( $regex[ $package ], "$1", $l ); + if ( $ver == $l ) continue; + return $ver; // Return first match of regex + } + + return 0; // This is an error + } + + if ( $package == "perl" ) // Custom for perl + { + $tmp = array(); + + foreach ( $lines as $l ) + { + if ( preg_match( "/sperl/", $l ) ) continue; // Don't want this + $ver = preg_replace( "/^.*perl-([\d\.]+\d)\.tar.*$/", "$1", $l ); + if ( $ver == $l ) continue; + list( $s1, $s2, $rest ) = explode( ".", $ver ); + if ( $s2 % 2 == 1 ) continue; // Remove odd minor versions + array_push( $tmp, $l ); + } + + $lines = $tmp; + } + + // Most packages are in the form $package-n.n.n + // Occasionally there are dashes (e.g. 201-1) + $max = find_max( $lines, "/$package/", "/^.*$package-([\d\.-]*\d)\.tar.*$/" ); + return $max; +} + +function get_current() +{ + global $dirs; + global $vers; + + // Fetech from git and get wget-list + $current = array(); + $clfsgit = "git://git.cross-lfs.org/cross-lfs.git"; + + $tmpdir = exec( "mktemp -d /tmp/clfscheck.XXXXXX" ); + $cdir = getcwd(); + chdir( $tmpdir ); + exec ( "git clone --quiet $clfsgit" ); + chdir( $cdir ); + + $PAGE = "$tmpdir/cross-lfs/BOOK/materials/*chapter.xml"; + $STYLESHEET = "$tmpdir/cross-lfs/BOOK/stylesheets/wget.xsl"; + + exec( "xsltproc --xinclude --nonet $STYLESHEET $PAGE | uniq", $current ); + exec( "rm -rf $tmpdir" ); + + foreach ( $current as $line ) + { + $file = basename( $line ) . "\n"; + if ( preg_match( "/patch$/", $file ) ) { continue; } // Skip patches + + $file = preg_replace( "/bz2/", '', $file ); // The 2 confusses the regex + + $file = rtrim( $file ); + $pkg_pattern = "/(\D*).*/"; + $pattern = "/\D*(\d.*\d)\D*/"; + + if ( preg_match( "/e2fsprogs/", $file ) ) + { + $pattern = "/e2\D*(\d.*\d)\D*/"; + $pkg_pattern = "/(e2\D*).*/"; + } + + else if ( preg_match( "/tzdata/", $file ) ) + { + $pattern = "/\D*(\d.*[a-z])\.tar\D*/"; + } + + $version = preg_replace( $pattern, "$1", $file ); // Isolate version + $version = preg_replace( "/^\d-/", "", $version ); // Remove leading #- + + // Touch up package names + $pkg_name = preg_replace( $pkg_pattern, "$1", $file ); + $pkg_name = trim( $pkg_name, "-" ); + + if ( preg_match( "/bzip|iproute/", $pkg_name ) ) { $pkg_name .= "2"; } + if ( preg_match( "/^m$/" , $pkg_name ) ) { $pkg_name .= "4"; } + + $dirs[ $pkg_name ] = dirname( $line ); + $vers[ $pkg_name ] = $version; + } +} + +function mail_to_clfs() +{ + global $date; + global $vers; + global $dirs; + + $to = "kb0iic@berzerkula.org"; + $from = "William Harrington <kb0iic@berzerkula.org>"; + $subject = "CLFS GIT Package Currency Check - $date GMT"; + $headers = "From: William Harrington <kb0iic@berzerkula.org"; + + $message = "Package CLFS Upstream Flag\n\n"; + + foreach ( $dirs as $pkg => $dir ) + { + //if ( $pkg != "tzdata" ) continue; //debug + $v = get_packages( $pkg, $dir ); + + $flag = ( $vers[ $pkg ] != $v ) ? "*" : ""; + + // Pad for output + $pad = " "; + $p = substr( $pkg . $pad, 0, 15 ); + $l = substr( $vers[ $pkg ] . $pad, 0, 8 ); + $c = substr( $v . $pad, 0, 10 ); + + $message .= "$p $l $c $flag\n"; + } + + //echo $message; + mail( $to, $subject, $message ); +} + +function html() +{ + + global $date; + global $vers; + global $dirs; + + echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' + 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> +<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> +<head> +<title>CLFS GIT Package Currency Check - $date</title> +<style type='text/css'> +h1, h2 { + text-align : center; +} + +table { + border-width : 1px; + border-spacing : 0px; + border-style : outset; + border-color : gray; + border-collapse : separate; + background-color: white; + margin : 0px auto; +} + +table th { + border-width : 1px; + padding : 2px; + border-style : inset; + border-color : gray; + background-color: white; +} + +table td { + border-width : 1px; + padding : 2px; + border-style : inset; + border-color : gray; + background-color: white; +} +</style> + +</head> +<body> +<h1>CLFS GIT Package Currency Check</h1> +<h2>As of $date GMT</h1> + +<table> +<tr><th>CLFS GIT Package</th> <th>CLFS GIT Version</th> <th>Latest</th> <th>Flag</th></tr>\n"; + + // Get the latest version of each package + foreach ( $dirs as $pkg => $dir ) + { + $v = get_packages( $pkg, $dir ); + $flag = ( $vers[ $pkg ] != $v ) ? "*" : ""; + echo "<tr><td>$pkg</td> <td>${vers[ $pkg ]}</td> <td>$v</td> <td>$flag</td></tr>\n"; + } + + echo "</table> +</body> +</html>\n"; + +} + +get_current(); // Get what is in the book +mail_to_clfs(); +//html(); // Write html output +?> + diff --git a/create-commands.sh b/create-commands.sh new file mode 100644 index 0000000..f61d0be --- /dev/null +++ b/create-commands.sh @@ -0,0 +1,645 @@ +#!/bin/bash + + +clear + +# Set which arch you want to build +# alpha mips mips64 mips64-64 ppc ppc64 ppc64-64 sparc sparc64 sparc64-64 x86 x86_64 x86_64-64 +ARCH=x86 + +# Double check the CLFS_TARGET variable with the book. +# Books other than x86 won't need this, but set this anyway +# The reason is the book commands expect the user to edit the +# CLFS_TARGET variable for the x86 book. Check if the target book +# requires CLFS_TARGET to be edited. Uncomment if not required. +# Move to the end of the file and uncommend the CLFS_TARGET sed +# If this can be commented and the book commands will set CLFS_TARGET. + +#CLFS_TARGET=i686-pc-linux-gnu + +# Set paper size for GROFF: A4 or letter +PAGE=letter + +#Set ZONEINFO to the time zone file to be copied to /etc/localtime +# /usr/share/zoneinfo/America/Chicago for example. +ZONEINFO=America/Chicago + +CMDSDIR=/mnt/clfs/sources/commands/$ARCH # Directory with dumped book commands +SRCDIR=/mnt/clfs/sources # Directory for the created scripts + +#===========BEGIN VERSION VARIABLES============== +ABOOT=0.9b +ARCLOAD=0.5 +AUTOCONF=2.69 +AUTOMAKE=1.12.4 +BASH=4.2 +BC=1.06.95 +BINUTILS=2.23.2 +BISON=3.0 +BOOTSCRIPTS=2.1-pre1 +BZIP2=1.0.6 +CHECK=0.9.10 +CLOOG=0.18.0 +COLO=1.22 +COREUTILS=8.21 +DEJAGNU=1.5.1 +DHCPCD=6.0.5 +DIFFUTILS=3.3 +DVHTOOL=1.0.1 +E2FSPROGS=1.42.8 +ELFTOAOUT=2.3 +EGLIBC=2.18-r23806 +EGLIBC2=2.18 +EUDEV=1.2 +EXPECT=5.45 +FILE=5.14 +FINDUTILS=4.4.2 +FLEX=2.5.37 +GAWK=4.1.0 +GCC=4.8.1 +GETTEXT=0.18.3.1 +GMP=5.1.2 +GREP=2.14 +GROFF=1.22.2 +GRUB=2.00 +GZIP=1.6 +HFSUTILS=3.2.6 +IANAETC=2.30 +IPROUTE2=3.10.0 +IPUTILS=s20121221 +ISL=0.12.1 +KBD=2.0.0 +KMOD=15 +LESS=460 +LIBEE=0.4.1 +LIBESTR=0.1.5 +LIBTOOL=2.4.2 +LINUX=3.10.9 +M4=1.4.16 +MAKE=3.82 +MAN=1.6g +MANPAGES=3.53 +MPC=1.0.1 +MPFR=3.1.2 +NCURSES=5.9 +PARTED=3.1 +PATCH=2.7.1 +PERL=5.18.1 +PKGCONFIG=lite-0.28-1 +POWERPCUTILS=1.1.3.orig +PROCPS=3.2.8 +PSMISC=22.20 +READLINE=6.2 +RSYSLOG=6.4.2 +SED=4.2.2 +SHADOW=4.1.5.1 +SILO=1.4.14 +SYSVINIT=2.88dsf +TAR=1.26 +TCL=8.6.0 +TEXINFO=4.13a +TEXINFO2=4.13 +UTILLINUX=2.23.2 +VIM=7.4 +VIM2=74 +XZ=5.0.5 +YABOOT=1.3.17 +ZLIB=1.2.8 + +if [ "$ARCH" == "" ]; then + echo "ARCH is not set. Please set a proper ARCH variable." + echo -e "alpha mips mips64 mips64-64 ppc ppc64 sparc sparc64 sparc64-64 x86 x86_64 x86_64-64\n" + exit +fi + +for build in cross-tools temp-system testsuite-tools final-system; do + + if [ -e $SRCDIR/$build.sh ]; then + rm $SRCDIR/$build.sh + fi + + echo -e "#!/bin/bash\n\n" >> $SRCDIR/$build.sh; + echo -e "set -e\n" >> $SRCDIR/$build.sh; + if [ "$build" == "final-system" ]; then + echo -e "set +h\n" >> $SRCDIR/$build.sh; + fi + + if [ "$build" == "cross-tools" -o "$build" == "temp-system" ]; then + echo "source $HOME/.bashrc # this would be the clfs user's .bashrc if following the" >> $SRCDIR/$build.sh; + echo " # CLFS book and using the clfs user." >> $SRCDIR/$build.sh; + fi + + if [ "$build" == "testsuite-tools" -o "$build" == "final-system" ]; then + echo -e "if [ -f /root/.bash_profile ]; then\n source /root/.bash_profile\n # this would be the root user's .bash_profile\n # if following the CLFS book and using the booted root user\n # or chrooted root user during multilib builds.\nfi" >> $SRCDIR/$build.sh; + fi + + echo -e "mkdir -pv $SRCDIR/stamps\n\n" >> $SRCDIR/$build.sh; + + if [ "$build" == "temp-system" ]; then + echo -e "source ~/.bashrc\n" >> $SRCDIR/$build.sh; + fi + + cd $CMDSDIR/$build && + + for file in `echo *`; do + pkg=`echo $file | sed 's/[0-9][0-9][0-9]-//'`; + echo -e "#===========$pkg===============\n" >> $SRCDIR/$build.sh; + echo -e "if [ ! -e \"stamps/$file\" ]; then" >> $SRCDIR/$build.sh; + case "$pkg" in #Insert package extract and cd into source commands + "aboot") + echo "tar xf aboot-$ABOOT.tar.xz && cd aboot-$ABOOT" >> $SRCDIR/$build.sh; + ;; + "arcload") + echo "tar xf arcload-$ARCLOAD.tar.xz && cd arcload-$ARCLOAD" >> $SRCDIR/$build.sh; + ;; + "autoconf") + echo "tar xf autoconf-$AUTOCONF.tar.xz && cd autoconf-$AUTOCONF" >> $SRCDIR/$build.sh; + ;; + "automake") + echo "tar xf automake-$AUTOMAKE.tar.xz && cd automake-$AUTOMAKE" >> $SRCDIR/$build.sh; + ;; + "bash") + echo "tar xf bash-$BASH.tar.xz && cd bash-$BASH" >> $SRCDIR/$build.sh; + ;; + "bc") + echo "tar xf bc-$BC.tar.xz && cd bc-$BC" >> $SRCDIR/$build.sh; + ;; + "binutils") + echo "tar xf binutils-$BINUTILS.tar.xz && cd binutils-$BINUTILS" >> $SRCDIR/$build.sh; + ;; + "bison" | "bison-64bit" | "bison-n32") + echo "tar xf bison-$BISON.tar.xz && cd bison-$BISON" >> $SRCDIR/$build.sh; + ;; + "bootscripts") + echo "tar xf bootscripts-$BOOTSCRIPTS.tar.xz && cd bootscripts-$BOOTSCRIPTS" >> $SRCDIR/$build.sh; + ;; + "bzip2" | "bzip2-64bit" | "bzip2-n32") + echo "tar xf bzip2-$BZIP2.tar.xz && cd bzip2-$BZIP2" >> $SRCDIR/$build.sh; + ;; + "cflags") + echo "sed -i '/unset CFLAGS/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/unset CXXFLAGS/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/CLFS_HOST/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/CLFS_TARGET/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/CLFS_TARGET32/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/CC/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/CXX/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/AR/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/AS/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/RANLIB/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/LD/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/STRIP/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/BUILD32/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/BUILDN32/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/BUILD64/d' ~/.bashrc" >> $SRCDIR/$build.sh; + echo "sed -i '/GCCTARGET/d' ~/.bashrc" >> $SRCDIR/$build.sh; + ;; + "choose") + echo "echo \"If the following command fails, you won't be able to chroot with your host machine. Read the choose to boot or chroot section for more information.\"" >> $SRCDIR/$build.sh; + ;; + "check") + echo "tar xf check-$CHECK.tar.xz && cd check-$CHECK" >> $SRCDIR/$build.sh; + ;; + "cloog" | "cloog-64bit" | "cloog-n32") + echo "tar xf cloog-$CLOOG.tar.xz && cd cloog-$CLOOG" >> $SRCDIR/$build.sh; + ;; + "colo") + echo "tar xf colo-$COLO.tar.xz && cd colo-$COLO" >> $SRCDIR/$build.sh; + ;; + "coreutils") + echo "tar xf coreutils-$COREUTILS.tar.xz && cd coreutils-$COREUTILS" >> $SRCDIR/$build.sh; + ;; + "dejagnu") + echo "tar xf dejagnu-$DEJAGNU.tar.xz && cd dejagnu-$DEJAGNU" >> $SRCDIR/$build.sh; + ;; + "dhcpcd") + echo "tar xf dhcpcd-$DHCPCD.tar.xz && cd dhcpcd-$DHCPCD" >> $SRCDIR/$build.sh; + ;; + "diffutils") + echo "tar xf diffutils-$DIFFUTILS.tar.xz && cd diffutils-$DIFFUTILS" >> $SRCDIR/$build.sh; + ;; + "dvhtool") + echo "tar xf dvhtool_$DVHTOOL.orig.tar.xz && cd dvhtool-$DVHTOOL" >> $SRCDIR/$build.sh; + ;; + "e2fsprogs" | "e2fsprogs-64bit" | "e2fsprogs-n32") + echo "tar xf e2fsprogs-$E2FSPROGS.tar.xz && cd e2fsprogs-$E2FSPROGS" >> $SRCDIR/$build.sh; + ;; + "eglibc" | "eglibc-64" | "eglibc-64bit" | "eglibc-n32") + echo "tar xf eglibc-$EGLIBC.tar.xz && cd eglibc-$EGLIBC2" >> $SRCDIR/$build.sh; + ;; + "elf2aout") + echo "tar xf elf2aout-$ELFTOAOUT.tar.xz && cd elftoaout-$ELFTOAOUT" >> $SRCDIR/$build.sh; + ;; + "eudev" | "eudev-64bit" | "eudev-n32") + echo "tar xf eudev-$EUDEV.tar.xz && cd eudev-$EUDEV" >> $SRCDIR/$build.sh; + ;; + "expect") + echo "tar xf expect$EXPECT.tar.xz && cd expect$EXPECT" >> $SRCDIR/$build.sh; + ;; + "file" | "file-64bit" | "file-n32") + echo "tar xf file-$FILE.tar.xz && cd file-$FILE" >> $SRCDIR/$build.sh; + ;; + "findutils") + echo "tar xf findutils-$FINDUTILS.tar.xz && cd findutils-$FINDUTILS" >> $SRCDIR/$build.sh; + ;; + "flex" | "flex-64bit" | "flex-n32") + echo "tar xf flex-$FLEX.tar.xz && cd flex-$FLEX" >> $SRCDIR/$build.sh; + ;; + "gawk") + echo "tar xf gawk-$GAWK.tar.xz && cd gawk-$GAWK" >> $SRCDIR/$build.sh; + ;; + "gcc" | "gcc-static" | "gcc-final") + echo "tar xf gcc-$GCC.tar.xz && cd gcc-$GCC" >> $SRCDIR/$build.sh; + ;; + "gettext" | "gettext-64bit" | "gettext-n32") + echo "tar xf gettext-$GETTEXT.tar.xz && cd gettext-$GETTEXT" >> $SRCDIR/$build.sh; + ;; + "gmp" | "gmp-64bit" | "gmp-n32") + echo "tar xf gmp-$GMP.tar.xz && cd gmp-$GMP" >> $SRCDIR/$build.sh; + ;; + "grep") + echo "tar xf grep-$GREP.tar.xz && cd grep-$GREP" >> $SRCDIR/$build.sh; + ;; + "groff") + echo "tar xf groff-$GROFF.tar.xz && cd groff-$GROFF" >> $SRCDIR/$build.sh; + ;; + "grub") + echo "tar xf grub-$GRUB.tar.xz && cd grub-$GRUB" >> $SRCDIR/$build.sh; + ;; + "gzip") + echo "tar xf gzip-$GZIP.tar.xz && cd gzip-$GZIP" >> $SRCDIR/$build.sh; + ;; + "hfsutils") + echo "tar xf hfsutils-$HFSUTILS.tar.xz && cd hfsutils-$HFSUTILS" >> $SRCDIR/$build.sh; + ;; + "iana-etc") + echo "tar xf iana-etc-$IANAETC.tar.xz && cd iana-etc-$IANAETC" >> $SRCDIR/$build.sh; + ;; + "iproute2") + echo "tar xf iproute2-$IPROUTE2.tar.xz && cd iproute2-$IPROUTE2" >> $SRCDIR/$build.sh; + ;; + "iputils") + echo "tar xf iputils-$IPUTILS.tar.xz && cd iputils-$IPUTILS" >> $SRCDIR/$build.sh; + ;; + "isl" | "isl-64bit" | "isl-n32") + echo "tar xf isl-$ISL.tar.xz && cd isl-$ISL" >> $SRCDIR/$build.sh; + ;; + "kbd") + echo "tar xf kbd-$KBD.tar.xz && cd kbd-$KBD" >> $SRCDIR/$build.sh; + ;; + "kmod" | "kmod-64bit" | "kmod-n32") + echo "tar xf kmod-$KMOD.tar.xz && cd kmod-$KMOD" >> $SRCDIR/$build.sh; + ;; + "less") + echo "tar xf less-$LESS.tar.xz && cd less-$LESS" >> $SRCDIR/$build.sh; + ;; + "libee" | "libee-64bit" | "libee-n32") + echo "tar xf libee-$LIBEE.tar.xz && cd libee-$LIBEE" >> $SRCDIR/$build.sh; + ;; + "libestr" | "libestr-64bit" | "libestr-n32") + echo "tar xf libestr-$LIBESTR.tar.xz && cd libestr-$LIBESTR" >> $SRCDIR/$build.sh; + ;; + "libtool" | "libtool-64bit" | "libtool-n32") + echo "tar xf libtool-$LIBTOOL.tar.xz && cd libtool-$LIBTOOL" >> $SRCDIR/$build.sh; + ;; + "linux" | "linux-headers") + echo "tar xf linux-$LINUX.tar.xz && cd linux-$LINUX" >> $SRCDIR/$build.sh; + ;; + "m4") + echo "tar xf m4-$M4.tar.xz && cd m4-$M4" >> $SRCDIR/$build.sh; + ;; + "make") + echo "tar xf make-$MAKE.tar.xz && cd make-$MAKE" >> $SRCDIR/$build.sh; + ;; + "man") + echo "tar xf man-$MAN.tar.xz && cd man-$MAN" >> $SRCDIR/$build.sh; + ;; + "man-pages") + echo "tar xf man-pages-$MANPAGES.tar.xz && cd man-pages-$MANPAGES" >> $SRCDIR/$build.sh; + ;; + "mpc" | "mpc-64bit" | "mpc-n32") + echo "tar xf mpc-$MPC.tar.xz && cd mpc-$MPC" >> $SRCDIR/$build.sh; + ;; + "mpfr" | "mpfr-64bit" | "mpfr-n32") + echo "tar xf mpfr-$MPFR.tar.xz && cd mpfr-$MPFR" >> $SRCDIR/$build.sh; + ;; + "ncurses" | "ncurses-64bit" | "ncurses-n32") + echo "tar xf ncurses-$NCURSES.tar.xz && cd ncurses-$NCURSES" >> $SRCDIR/$build.sh; + ;; + "parted") + echo "tar xf parted-$PARTED.tar.xz && cd parted-$PARTED" >> $SRCDIR/$build.sh; + ;; + "powerpc-utils") + echo "tar xf powerpc-utils_$POWERPCUTILS.tar.xz && cd pmac-utils" >> $SRCDIR/$build.sh; + ;; + "patch") + echo "tar xf patch-$PATCH.tar.xz && cd patch-$PATCH" >> $SRCDIR/$build.sh; + ;; + "perl" | "perl-64bit" | "perl-n32" | "temp-perl") + echo "tar xf perl-$PERL.tar.xz && cd perl-$PERL" >> $SRCDIR/$build.sh; + ;; + "pkg-config") + echo "tar xf pkg-config-$PKGCONFIG.tar.xz && cd pkg-config-$PKGCONFIG" >> $SRCDIR/$build.sh; + ;; + "procps" | "procps-64bit" | "procps-n32") + echo "tar xf procps-$PROCPS.tar.xz && cd procps-$PROCPS" >> $SRCDIR/$build.sh; + ;; + "psmisc") + echo "tar xf psmisc-$PSMISC.tar.xz && cd psmisc-$PSMISC" >> $SRCDIR/$build.sh; + ;; + "readline" | "readline-64bit" | "readline-n32") + echo "tar xf readline-$READLINE.tar.xz && cd readline-$READLINE" >> $SRCDIR/$build.sh; + ;; + "rsyslog") + echo "tar xf rsyslog-$RSYSLOG.tar.xz && cd rsyslog-$RSYSLOG" >> $SRCDIR/$build.sh; + ;; + "sed") + echo "tar xf sed-$SED.tar.xz && cd sed-$SED" >> $SRCDIR/$build.sh; + ;; + "shadow") + echo "tar xf shadow-$SHADOW.tar.xz && cd shadow-$SHADOW" >> $SRCDIR/$build.sh; + ;; + "silo") + echo "tar xf silo-$SILO.tar.xz && cd silo-$SILO" >> $SRCDIR/$build.sh; + ;; + "sysvinit") + echo "tar xf sysvinit-$SYSVINIT.tar.xz && cd sysvinit-$SYSVINIT" >> $SRCDIR/$build.sh; + ;; + "tar") + echo "tar xf tar-$TAR.tar.xz && cd tar-$TAR" >> $SRCDIR/$build.sh; + ;; + "tcl") + echo "tar xf tcl${TCL}-src.tar.xz && cd tcl$TCL" >> $SRCDIR/$build.sh; + ;; + "texinfo") + echo "tar xf texinfo-$TEXINFO.tar.xz && cd texinfo-$TEXINFO2" >> $SRCDIR/$build.sh; + ;; + "util-linux" | "util-linux-64bit" | "util-linux-n32") + echo "tar xf util-linux-$UTILLINUX.tar.xz && cd util-linux-$UTILLINUX" >> $SRCDIR/$build.sh; + ;; + "vim") + echo "tar xf vim-$VIM.tar.xz && cd vim$VIM2" >> $SRCDIR/$build.sh; + ;; + "xz" | "xz-64bit" | "xz-n32") + echo "tar xf xz-$XZ.tar.xz && cd xz-$XZ" >> $SRCDIR/$build.sh; + ;; + "yaboot") + echo "tar xf yaboot-$YABOOT.tar.xz && cd yaboot-$YABOOT" >> $SRCDIR/$build.sh; + ;; + "zlib" | "zlib-64bit" | "zlib-n32") + echo "tar xf zlib-$ZLIB.tar.xz && cd zlib-$ZLIB" >> $SRCDIR/$build.sh; + ;; + esac + + cat $file >> $SRCDIR/$build.sh; + + case "$pkg" in #Insert source / build directory removal commands + "aboot") + echo "cd .. && rm -rf aboot-$ABOOT" >> $SRCDIR/$build.sh; + ;; + "arcload") + echo "cd .. && rm -rf arcload-$ARCLOAD" >> $SRCDIR/$build.sh; + ;; + "autoconf") + echo "cd .. && rm -rf autoconf-$AUTOCONF" >> $SRCDIR/$build.sh; + ;; + "automake") + echo "cd .. && rm -rf automake-$AUTOMAKE" >> $SRCDIR/$build.sh; + ;; + "bash") + echo "cd .. && rm -rf bash-$BASH" >> $SRCDIR/$build.sh; + ;; + "bc") + echo "cd .. && rm -rf bc-$BC" >> $SRCDIR/$build.sh; + ;; + "binutils") + echo "cd .. && rm -rf binutils-$BINUTILS binutils-build" >> $SRCDIR/$build.sh; + ;; + "bison" | "bison-64bit" | "bison-n32") + echo "cd .. && rm -rf bison-$BISON" >> $SRCDIR/$build.sh; + ;; + "bootscripts") + echo "cd .. && rm -rf bootscripts-$BOOTSCRIPTS" >> $SRCDIR/$build.sh; + ;; + "bzip2" | "bzip2-64bit" | "bzip2-n32") + echo "cd .. && rm -rf bzip2-$BZIP2" >> $SRCDIR/$build.sh; + ;; + "check") + echo "cd .. && rm -rf check-$CHECK" >> $SRCDIR/$build.sh; + ;; + "cloog" | "cloog-64bit" | "cloog-n32") + echo "cd .. && rm -rf cloog-$CLOOG" >> $SRCDIR/$build.sh; + ;; + "colo") + echo "cd .. && rm -rf colo-$COLO" >> $SRCDIR/$build.sh; + ;; + "coreutils") + echo "cd .. && rm -rf coreutils-$COREUTILS" >> $SRCDIR/$build.sh; + ;; + "dejagnu") + echo "cd .. && rm -rf dejagnu-$DEJAGNU" >> $SRCDIR/$build.sh; + ;; + "dhcpcd") + echo "cd .. && rm -rf dhcpcd-$DHCPCD" >> $SRCDIR/$build.sh; + ;; + "diffutils") + echo "cd .. && rm -rf diffutils-$DIFFUTILS" >> $SRCDIR/$build.sh; + ;; + "dvhtool") + echo "cd .. && rm -rf dvhtool-$DVHTOOL.orig" >> $SRCDIR/$build.sh; + ;; + "e2fsprogs" | "e2fsprogs-64bit" | "e2fsprogs-n32") + echo "cd ../../ && rm -rf e2fsprogs-$E2FSPROGS" >> $SRCDIR/$build.sh + ;; + "eglibc" | "eglibc-64" | "eglibc-64bit" | "eglibc-n32") + echo "cd .. && rm -rf eglibc-$EGLIBC2 eglibc-build" >> $SRCDIR/$build.sh; + ;; + "elftoaout") + echo "cd .. && rm -rf elftoaout-$ELFTOAOUT" >> $SRCDIR/$build.sh; + ;; + "eudev" | "eudev-64bit" | "eudev-n32") + echo "cd .. && rm -rf eudev-$EUDEV" >> $SRCDIR/$build.sh; + ;; + "expect") + echo "cd .. && rm -rf expect$EXPECT" >> $SRCDIR/$build.sh; + ;; + "file" | "file-64bit" | "file-n32") + echo "cd .. && rm -rf file-$FILE" >> $SRCDIR/$build.sh; + ;; + "findutils") + echo "cd .. && rm -rf findutils-$FINDUTILS" >> $SRCDIR/$build.sh; + ;; + "flex" | "flex-64bit" | "flex-n32") + echo "cd .. && rm -rf flex-$FLEX" >> $SRCDIR/$build.sh; + ;; + "gawk") + echo "cd .. && rm -rf gawk-$GAWK" >> $SRCDIR/$build.sh; + ;; + "gcc" | "gcc-static" | "gcc-final") + echo "cd .. && rm -rf gcc-$GCC gcc-build" >> $SRCDIR/$build.sh; + ;; + "gettext" | "gettext-64bit" | "gettext-n32") + if [ "$build" == "temp-system" ]; then + echo "cd ../../ && rm -rf gettext-$GETTEXT" >> $SRCDIR/$build.sh; + else + echo "cd .. && rm -rf gettext-$GETTEXT" >> $SRCDIR/$build.sh; + fi + ;; + "gmp" | "gmp-64bit" | "gmp-n32") + echo "cd .. && rm -rf gmp-$GMP" >> $SRCDIR/$build.sh; + ;; + "grep") + echo "cd .. && rm -rf grep-$GREP" >> $SRCDIR/$build.sh; + ;; + "groff") + echo "cd .. && rm -rf groff-$GROFF" >> $SRCDIR/$build.sh; + ;; + "grub") + echo "cd .. && rm -rf grub-$GRUB" >> $SRCDIR/$build.sh; + ;; + "gzip") + echo "cd .. && rm -rf gzip-$GZIP" >> $SRCDIR/$build.sh; + ;; + "hfsutils") + echo "cd .. && rm -rf hfsutils-$HFSUTILS" >> $SRCDIR/$build.sh; + ;; + "iana-etc") + echo "cd .. && rm -rf iana-etc-$IANAETC" >> $SRCDIR/$build.sh; + ;; + "iproute2") + echo "cd .. && rm -rf iproute2-$IPROUTE2" >> $SRCDIR/$build.sh; + ;; + "iputils") + echo "cd .. && rm -rf iputils-$IPUTILS" >> $SRCDIR/$build.sh; + ;; + "isl" | "isl-64bit" | "isl-n32") + echo "cd .. && rm -rf isl-$ISL" >> $SRCDIR/$build.sh; + ;; + "kbd") + echo "cd .. && rm -rf kbd-$KBD" >> $SRCDIR/$build.sh; + ;; + "kmod" | "kmod-64bit" | "kmod-n32") + echo "cd .. && rm -rf kmod-$KMOD" >> $SRCDIR/$build.sh; + ;; + "less") + echo "cd .. && rm -rf less-$LESS" >> $SRCDIR/$build.sh; + ;; + "libee" | "libee-64bit" | "libee-n32") + echo "cd .. && rm -rf libee-$LIBEE" >> $SRCDIR/$build.sh; + ;; + "libestr" | "libestr-64bit" | "libestr-n32") + echo "cd .. && rm -rf libestr-$LIBESTR" >> $SRCDIR/$build.sh; + ;; + "libtool" | "libtool-64bit" | "libtool-n32") + echo "cd .. && rm -rf libtool-$LIBTOOL" >> $SRCDIR/$build.sh; + ;; + "linux" | "linux-headers") + echo "cd .. && rm -rf linux-$LINUX" >> $SRCDIR/$build.sh; + ;; + "m4") + echo "cd .. && rm -rf m4-$M4" >> $SRCDIR/$build.sh; + ;; + "make") + echo "cd .. && rm -rf make-$MAKE" >> $SRCDIR/$build.sh; + ;; + "man") + echo "cd .. && rm -rf man-$MAN" >> $SRCDIR/$build.sh; + ;; + "man-pages") + echo "cd .. && rm -rf man-pages-$MANPAGES" >> $SRCDIR/$build.sh; + ;; + "mpc" | "mpc-64bit" | "mpc-n32") + echo "cd .. && rm -rf mpc-$MPC" >> $SRCDIR/$build.sh; + ;; + "mpfr" | "mpfr-64bit" | "mpfr-n32") + echo "cd .. && rm -rf mpfr-$MPFR" >> $SRCDIR/$build.sh; + ;; + "ncurses" | "ncurses-64bit" | "ncurses-n32") + echo "cd .. && rm -rf ncurses-$NCURSES" >> $SRCDIR/$build.sh; + ;; + "parted") + echo "cd .. && rm -rf parted-$PARTED" >> $SRCDIR/$build.sh; + ;; + "powerpc-utils") + echo "cd .. && rm -rf pmac-utils" >> $SRCDIR/$build.sh; + ;; + "patch") + echo "cd .. && rm -rf patch-$PATCH" >> $SRCDIR/$build.sh; + ;; + "perl" | "perl-64bit" | "perl-n32" | "temp-perl") + echo "cd .. && rm -rf perl-$PERL" >> $SRCDIR/$build.sh; + ;; + "pkg-config") + echo "cd .. && rm -rf pkg-config-$PKGCONFIG" >> $SRCDIR/$build.sh; + ;; + "procps" | "procps-64bit" | "procps-n32") + echo "cd .. && rm -rf procps-$PROCPS" >> $SRCDIR/$build.sh; + ;; + "psmisc") + echo "cd .. && rm -rf psmisc-$PSMISC" >> $SRCDIR/$build.sh; + ;; + "readline" | "readline-64bit" | "readline-n32") + echo "cd .. && rm -rf readline-$READLINE" >> $SRCDIR/$build.sh; + ;; + "rsyslog") + echo "cd .. && rm -rf rsyslog-$RSYSLOG" >> $SRCDIR/$build.sh; + ;; + "sed") + echo "cd .. && rm -rf sed-$SED" >> $SRCDIR/$build.sh; + ;; + "shadow") + echo "cd .. && rm -rf shadow-$SHADOW" >> $SRCDIR/$build.sh; + ;; + "silo") + echo "cd .. && rm -rf silo-$SILO" >> $SRCDIR/$build.sh; + ;; + "sysvinit") + echo "cd .. && rm -rf sysvinit-$SYSVINIT" >> $SRCDIR/$build.sh; + ;; + "tar") + echo "cd .. && rm -rf tar-$TAR" >> $SRCDIR/$build.sh; + ;; + "tcl") + echo "cd ../../ && rm -rf tcl$TCL" >> $SRCDIR/$build.sh; + ;; + "texinfo") + echo "cd .. && rm -rf texinfo-$TEXINFO2" >> $SRCDIR/$build.sh; + ;; + "util-linux" | "util-linux-64bit" | "util-linux-n32") + echo "cd .. && rm -rf util-linux-$UTILLINUX" >> $SRCDIR/$build.sh; + ;; + "vim") + echo "cd .. && rm -rf vim$VIM2" >> $SRCDIR/$build.sh; + ;; + "xz" | "xz-64bit" | "xz-n32") + echo "cd .. && rm -rf xz-$XZ" >> $SRCDIR/$build.sh; + ;; + "yaboot") + echo "cd .. && rm -rf yaboot-$YABOOT" >> $SRCDIR/$build.sh; + ;; + "zlib" | "zlib-64bit" | "zlib-n32") + echo "cd .. && rm -rf zlib-$ZLIB" >> $SRCDIR/$build.sh; + ;; + esac + + echo -e "touch \"stamps/${file}\"" >> $SRCDIR/$build.sh; + echo -e "fi\n" >> $SRCDIR/$build.sh; + done + +done + +sed -i 's@/mnt/clfs@@g' $SRCDIR/{testsuite-tools,final-system}.sh + +# comment the following line if the book being used sets CLFS_TARGET +#sed -i "s@\[target triplet\]@$CLFS_TARGET@" $SRCDIR/cross-tools.sh; +echo "Setting ZONEINFO for eglibc in final-system.sh"; +sed -i "s@\*\*EDITME\[xxx\]EDITME\*\*@$ZONEINFO@" $SRCDIR/final-system.sh; +echo "Setting PAGE for groff paper size in final-system.sh"; +sed -i "s@\*\*EDITME\[paper_size\]EDITME\*\*@$PAGE@" $SRCDIR/final-system.sh; +echo -e "\nVerify CLFS_TARGET is correct in cross-tools.sh" +echo -e "\n Verify ZONEINFO data file is correct at eglibc in final-system.sh"; +echo -e "\n Verify PAGE paper size is correct at groff in final-system.sh"; +echo -e "\n Check GMP page in chapter 10 and gmp section in finalsystem.sh"; +echo -e "\n If you don't want checks, remove those commands from final-system.sh"; + +echo -e "echo \"Do not forget to set the root password before booting into your new systems. See the shadow instruction page at chapter 10 in the book.\"" >> $SRCDIR/final-system.sh; |