Added base files from George's jhalfs-experimental-2 POC.
WARNING: This code is broken due files renaming.
This commit is contained in:
parent
d2fb765e70
commit
0170229c2b
22 changed files with 4756 additions and 0 deletions
190
BLFS/blfs.xsl
Normal file
190
BLFS/blfs.xsl
Normal file
|
@ -0,0 +1,190 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:exsl="http://exslt.org/common"
|
||||
extension-element-prefixes="exsl"
|
||||
version="1.0">
|
||||
|
||||
<!-- XSLT stylesheet to create shell scripts from BLFS books. -->
|
||||
|
||||
<!-- Run optional test suites? -->
|
||||
<xsl:param name="testsuite" select="0"/>
|
||||
|
||||
<!-- FTP/HTTP server -->
|
||||
<xsl:param name="server">
|
||||
ftp://anduin.linuxfromscratch.org/BLFS/conglomeration
|
||||
</xsl:param>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates select="//sect1"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="sect1">
|
||||
<xsl:if test="count(descendant::screen/userinput) > 0 and
|
||||
count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
||||
<!-- The dirs names -->
|
||||
<xsl:variable name="pi-dir" select="../../processing-instruction('dbhtml')"/>
|
||||
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
||||
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
||||
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
||||
<!-- The file names -->
|
||||
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
||||
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
||||
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
||||
<!-- Package variables -->
|
||||
<xsl:param name="package" select="sect1info/keywordset/keyword[@role='package']"/>
|
||||
<xsl:param name="ftpdir" select="sect1info/keywordset/keyword[@role='ftpdir']"/>
|
||||
<!-- Creating dirs and files -->
|
||||
<exsl:document href="{$dirname}/{$filename}" method="text">
|
||||
<xsl:text>#!/bin/sh
set -e

</xsl:text>
|
||||
<xsl:apply-templates select="sect2 | screen">
|
||||
<xsl:with-param name="package" select="$package"/>
|
||||
<xsl:with-param name="ftpdir" select="$ftpdir"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:if test="sect2[@role='package']">
|
||||
<xsl:text>cd ~/sources/</xsl:text>
|
||||
<xsl:value-of select="$ftpdir"/>
|
||||
<xsl:text>
rm -rf $UNPACKDIR

</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>exit</xsl:text>
|
||||
</exsl:document>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="sect2">
|
||||
<xsl:param name="package" select="foo"/>
|
||||
<xsl:param name="ftpdir" select="foo"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@role = 'package'">
|
||||
<xsl:apply-templates select="para"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:text>mkdir -p ~/sources/</xsl:text>
|
||||
<xsl:value-of select="$ftpdir"/>
|
||||
<xsl:text>
cd ~/sources/</xsl:text>
|
||||
<xsl:value-of select="$ftpdir"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:apply-templates select="itemizedlist/listitem/para">
|
||||
<xsl:with-param name="package" select="$package"/>
|
||||
<xsl:with-param name="ftpdir" select="$ftpdir"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="@role = 'installation'">
|
||||
<xsl:text>tar -xvf </xsl:text>
|
||||
<xsl:value-of select="$package"/>
|
||||
<xsl:text>.* > /tmp/unpacked
</xsl:text>
|
||||
<xsl:text>UNPACKDIR=`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'`
</xsl:text>
|
||||
<xsl:text>cd $UNPACKDIR
</xsl:text>
|
||||
<xsl:apply-templates select=".//screen | .//para/command"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="@role = 'configuration'">
|
||||
<xsl:apply-templates select=".//screen"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="para">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@role = 'required'">
|
||||
<xsl:text># REQUIRED: </xsl:text>
|
||||
<xsl:apply-templates select="xref"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="@role = 'recommended'">
|
||||
<xsl:text># RECOMMENDED: </xsl:text>
|
||||
<xsl:apply-templates select="xref"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="@role = 'optional'">
|
||||
<xsl:text># OPTIONAL: </xsl:text>
|
||||
<xsl:apply-templates select="xref"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="xref">
|
||||
<xsl:value-of select="@linkend"/>
|
||||
<xsl:text>  </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="itemizedlist/listitem/para">
|
||||
<xsl:param name="package" select="foo"/>
|
||||
<xsl:param name="ftpdir" select="foo"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(string(),'HTTP')">
|
||||
<xsl:text>wget </xsl:text>
|
||||
<xsl:value-of select="ulink/@url"/>
|
||||
<xsl:text> || \
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(string(),'FTP')">
|
||||
<xsl:text>wget </xsl:text>
|
||||
<xsl:value-of select="ulink/@url"/>
|
||||
<xsl:text> || \
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(string(),'MD5')">
|
||||
<xsl:text>wget </xsl:text>
|
||||
<xsl:value-of select="$server"/>
|
||||
<xsl:text>/</xsl:text>
|
||||
<xsl:value-of select="$ftpdir"/>
|
||||
<xsl:text>/</xsl:text>
|
||||
<xsl:value-of select="$package"/>
|
||||
<xsl:text>.bz2
</xsl:text>
|
||||
<!-- Commented out due that we don't know where the package
|
||||
will be dowloaded from.
|
||||
<xsl:text>echo "</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'sum: ')"/>
|
||||
<xsl:text>  </xsl:text>
|
||||
<xsl:value-of select="$package"/>
|
||||
<xsl:text>" | md5sum -c -
</xsl:text>-->
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(string(),'patch')">
|
||||
<xsl:text>wget </xsl:text>
|
||||
<xsl:value-of select="ulink/@url"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="screen">
|
||||
<xsl:if test="child::* = userinput">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@role = 'nodump'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="@role = 'root'">
|
||||
<xsl:text>sudo </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="userinput" mode="screen"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="para/command">
|
||||
<xsl:if test="$testsuite != '0' and
|
||||
(contains(string(),'test') or
|
||||
contains(string(),'check'))">
|
||||
<xsl:value-of select="substring-before(string(),'make')"/>
|
||||
<xsl:text>make -k</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'make')"/>
|
||||
<xsl:text> || true
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="userinput" mode="screen">
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="replaceable">
|
||||
<xsl:text>**EDITME</xsl:text>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text>EDITME**</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
30
BLFS/config
Normal file
30
BLFS/config
Normal file
|
@ -0,0 +1,30 @@
|
|||
#####
|
||||
#
|
||||
# Configuration file for the blfs module
|
||||
#
|
||||
#####
|
||||
|
||||
#--- Book's sources directory
|
||||
# If you have previously checked out the book from the repository
|
||||
BOOK=
|
||||
|
||||
#--- Book version
|
||||
LFSVRS=development
|
||||
|
||||
#--- FTP/HTTP mirror used as fallback (full path)
|
||||
SERVER=ftp://anduin.linuxfromscratch.org/BLFS/conglomeration
|
||||
|
||||
#--- Dependencies 0(required)/1(recommended)/2(optional)
|
||||
DEPEND=1
|
||||
|
||||
#--- Run test suites 0(no)/1(yes)
|
||||
TEST=0
|
||||
|
||||
|
||||
#==== INTERNAL VARIABLES ====
|
||||
# Don't edit it unless you know what you are doing
|
||||
|
||||
#--- Default stylesheet
|
||||
XSL=dump-blfs-scripts.xsl
|
||||
MKFILE=$JHALFSDIR/blfs-Makefile
|
||||
|
100
BLFS/master.sh
Executable file
100
BLFS/master.sh
Executable file
|
@ -0,0 +1,100 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
#----------------------------#
|
||||
build_Makefile() {
|
||||
#----------------------------#
|
||||
echo -n "Creating Makefile... "
|
||||
cd $JHALFSDIR/${PROGNAME}-commands
|
||||
|
||||
# Start with a clean Makefile file
|
||||
>$MKFILE
|
||||
|
||||
|
||||
# Add a header, some variables and include the function file
|
||||
# to the top of the real Makefile.
|
||||
(
|
||||
cat << EOF
|
||||
$HEADER
|
||||
|
||||
include makefile-functions
|
||||
|
||||
EOF
|
||||
) > $MKFILE
|
||||
|
||||
# Drop in a dummy target 'all:'.
|
||||
(
|
||||
cat << EOF
|
||||
all:
|
||||
@echo -e "\nThere is no default target predefined"
|
||||
@echo -e "You must to tell what package(s) you want to install"
|
||||
@echo -e "or edit the \"all\" Makefile target to create your own"
|
||||
@echo -e "defualt target.\n"
|
||||
@exit
|
||||
EOF
|
||||
) >> $MKFILE
|
||||
|
||||
# Bring over the build targets.
|
||||
for file in */* ; do
|
||||
# Keep the script file name
|
||||
case $file in
|
||||
gnome/config )
|
||||
this_script=config-gnome
|
||||
;;
|
||||
gnome/pre-install-config )
|
||||
this_script=pre-intall-config-gnome
|
||||
;;
|
||||
kde/config )
|
||||
this_script=config-kde
|
||||
;;
|
||||
kde/pre-install-config )
|
||||
this_script=pre-intall-config-kde
|
||||
;;
|
||||
* )
|
||||
this_script=`basename $file`
|
||||
;;
|
||||
esac
|
||||
|
||||
# Dump the package dependencies.
|
||||
REQUIRED=`grep "REQUIRED" $file | sed 's/# REQUIRED://' | tr -d '\n'`
|
||||
if [ "$DEPEND" != "0" ] ; then
|
||||
RECOMMENDED=`grep "RECOMMENDED" $file | sed 's/# RECOMMENDED://' | tr -d '\n'`
|
||||
fi
|
||||
if [ "$DEPEND" = "2" ] ; then
|
||||
OPTIONAL=`grep "OPTIONAL" $file | sed 's/# OPTIONAL://' | tr -d '\n'`
|
||||
fi
|
||||
|
||||
# Drop in the name of the target on a new line plus its dependencies
|
||||
# and call the echo_message function.
|
||||
(
|
||||
cat << EOF
|
||||
|
||||
$this_script: $REQUIRED $RECOMMENDED $OPTIONAL
|
||||
@\$(call echo_message, Building)
|
||||
EOF
|
||||
) >> $MKFILE
|
||||
|
||||
# Insert date and disk usage at the top of the log file, the script run
|
||||
# and date and disk usage again at the bottom of the log file.
|
||||
(
|
||||
cat << EOF
|
||||
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >logs/$this_script && \\
|
||||
$JHALFSDIR/${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
|
||||
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >>logs/$this_script
|
||||
EOF
|
||||
) >> $MKFILE
|
||||
|
||||
# Include a touch of the target name so make can check
|
||||
# if it's already been made.
|
||||
(
|
||||
cat << EOF
|
||||
@touch \$@
|
||||
EOF
|
||||
) >> $MKFILE
|
||||
|
||||
done
|
||||
echo -ne "done\n"
|
||||
}
|
||||
|
||||
|
||||
|
0
CLFS/clfs.xsl
Normal file
0
CLFS/clfs.xsl
Normal file
66
CLFS/config
Normal file
66
CLFS/config
Normal file
|
@ -0,0 +1,66 @@
|
|||
#####
|
||||
#
|
||||
# Configuration file for the CLFS module
|
||||
#
|
||||
#####
|
||||
|
||||
declare -r HTTP=http://ftp.lfs-matrix.net/pub/clfs/conglomeration
|
||||
|
||||
#--- Which target architecture,
|
||||
# used to select proper book and set TARGETS
|
||||
#--------------------------------
|
||||
TARGET32=""
|
||||
TARGET=
|
||||
# >>>> 32-32 BUILD <<<<
|
||||
# ARCH=x86 ; TARGET="i486-pc-linux-gnu"
|
||||
# ARCH=x86 ; TARGET="i586-pc-linux-gnu"
|
||||
# ARCH=x86 ; TARGET="i686-pc-linux-gnu"
|
||||
# ARCH=ppc ; TARGET="powerpc-unknown-linux-gnu"
|
||||
# ARCH=mips ; TARGET="mipsel-unknown-linux-gnu"
|
||||
# ARCH=mips ; TARGET="mis-unknown-linux-gnu"
|
||||
# ARCH=sparc ; TARGET="sparcv9-unknown-linux-gnu"
|
||||
# ARCH=sparcv8 ; TARGET="sparc-unknown-linux-gnu"
|
||||
#--------------------------------
|
||||
# >>>> 64-64 BUILD <<<<
|
||||
ARCH=x86_64-64 ; TARGET="x86_64-unknown-linux-gnu"
|
||||
# ARCH=mips64-64 ; TARGET="mipsel-unknown-linux-gnu"
|
||||
# ARCH=mips64-64 ; TARGET="mis-unknown-linux-gnu"
|
||||
# ARCH=sparc64-64 ; TARGET="sparc64-unknown-linux-gnu"
|
||||
# ARCH=alpha ; TARGET="alpha-unknown-linux-gnu"
|
||||
#--------------------------------
|
||||
# >>>> MULTILIB 32/64 <<<<
|
||||
# ARCH=x86_64 ; TARGET="x86_64-unknown-linux-gnu" ; TARGET32="i686-pc-linux-gnu"
|
||||
# ARCH=mips64 ; TARGET="mipsel-unknown-linux-gnu" ; TARGET32="mipsel-unknown-linux-gnu"
|
||||
# ARCH=mips64 ; TARGET="mis-unknown-linux-gnu" ; TARGET32="mis-unknown-linux-gnu"
|
||||
# ARCH=sparc64 ; TARGET="sparc64-unknown-linux-gnu" ; TARGET32="sparcv9-unknown-linux-gnu"
|
||||
|
||||
#--- Create a minimal boot system 0(chroot)/1(bootmin)
|
||||
# NOTE: not all combinations are 'bootable' yet.
|
||||
BOOTMINIMAL=1
|
||||
|
||||
#--- Location of fstab file (if empty, a template is created)
|
||||
FSTAB=$BUILDDIR/sources/fstab
|
||||
|
||||
#--- Location of kernel config file (if the kernel is to be compiled)
|
||||
#--- This file MUST reside in the sources directory
|
||||
CONFIG=$BUILDDIR/sources/linux-2.6.15.1-x86_64.config
|
||||
|
||||
#--- Book's sources directory
|
||||
# If you have previously checked out the book from the repository
|
||||
BOOK=
|
||||
|
||||
#==== INTERNAL VARIABLES ====
|
||||
# Don't edit it unless you know what you are doing
|
||||
|
||||
#--- Files that will be copied to $JHALFSDIR
|
||||
FILES=""
|
||||
|
||||
#--- Default stylesheet
|
||||
XSL=dump-clfs-scripts.xsl
|
||||
|
||||
#--- Book version
|
||||
LFSVRS=development
|
||||
MKFILE=$JHALFSDIR/clfs-Makefile
|
||||
|
||||
#--- FTP/HTTP mirror used as fallback (full path)
|
||||
SERVER=ftp://anduin.linuxfromscratch.org/LFS/conglomeration
|
1318
CLFS/master.sh
Executable file
1318
CLFS/master.sh
Executable file
File diff suppressed because it is too large
Load diff
38
HLFS/config
Normal file
38
HLFS/config
Normal file
|
@ -0,0 +1,38 @@
|
|||
#####
|
||||
#
|
||||
# Configuration file for the HLFS module
|
||||
#
|
||||
#####
|
||||
declare -r HTTP=http://ftp.lfs-matrix.net/pub/hlfs/conglomeration
|
||||
|
||||
#--- Which library model to use uclibc/glibc
|
||||
MODEL=glibc
|
||||
|
||||
#--- The host system has grsecurity options enabled 0(no)/1(yes)
|
||||
GRSECURITY_HOST=0
|
||||
|
||||
#--- Location of fstab file (if empty, a template is created)
|
||||
FSTAB=$BUILDDIR/sources/fstab
|
||||
|
||||
#--- Location of kernel config file (if the kernel is to be compiled)
|
||||
CONFIG=$BUILDDIR/sources/linux-2.6.14.6-HLFS.config
|
||||
|
||||
#--- Book's sources directory
|
||||
# If you have previously checked out the book from the repository
|
||||
BOOK=
|
||||
|
||||
#==== INTERNAL VARIABLES ====
|
||||
# Don't edit it unless you know what you are doing
|
||||
|
||||
#--- Files that will be copied to $JHAHLFSDIR
|
||||
FILES="dump-hlfs-scripts.xsl hlfs-patcheslist_.xsl"
|
||||
|
||||
#--- Default stylesheet
|
||||
XSL=dump-hlfs-scripts.xsl
|
||||
|
||||
#--- Book version
|
||||
LFSVRS=development
|
||||
MKFILE=$JHALFSDIR/hlfs-Makefile
|
||||
|
||||
#--- FTP/HTTP mirror used as fallback (full path)
|
||||
SERVER=ftp://anduin.linuxfromscratch.org/HLFS/conglomeration
|
59
HLFS/functions
Normal file
59
HLFS/functions
Normal file
|
@ -0,0 +1,59 @@
|
|||
BOLD= "[0;1m"
|
||||
RED= "[1;31m"
|
||||
GREEN= "[0;32m"
|
||||
ORANGE= "[0;33m"
|
||||
BLUE= "[1;34m"
|
||||
WHITE= "[00m"
|
||||
|
||||
define echo_message
|
||||
@echo $(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo $(BOLD)$(1) target $(BLUE)$@$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------$(WHITE)
|
||||
endef
|
||||
|
||||
define unpack
|
||||
@if [ -f $(HLFS)$(SRC)/$(1).bz2 ] ; then \
|
||||
cd $(HLFS)$(SRC) ; tar -xvjf $(1).bz2 > /tmp/unpacked ; \
|
||||
else \
|
||||
cd $(HLFS)$(SRC) ; tar -xvzf $(1).gz > /tmp/unpacked ; \
|
||||
fi ;
|
||||
endef
|
||||
|
||||
define unpack2
|
||||
@cd $(HLFS)$(SRC) ; /tools/bin/tar -xvf $(1) > /tmp/unpacked
|
||||
endef
|
||||
|
||||
define echo_finished
|
||||
@echo $(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo $(BOLD) Finished the build of $(BLUE)HLFS-$(1)$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo -e \\t\\t$(RED)W A R N I N G$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo
|
||||
@echo To be able to boot your new HLFS system you need to follow
|
||||
@echo the next steps:$(WHITE)
|
||||
@echo
|
||||
@echo -e \\t- Enter to the chroot using the command found
|
||||
@echo -e \\tin chapter06/revisedchroot.html
|
||||
@echo
|
||||
@echo -e \\t- Set a password for the root user
|
||||
@echo
|
||||
@echo -e \\t- Edit /etc/fstab, /etc/hosts, /etc/sysconfig/clock,
|
||||
@echo -e \\t/etc/sysconfig/console, /etc/sysconfig/network,
|
||||
@echo -e \\t/etc/sysconfig//network-devices/ifconfig.eth0/ipv4 and
|
||||
@echo -e \\tany other configuration file required to suit your needs.
|
||||
@echo
|
||||
@echo -e \\t- Set-up Grub. See chapter08/grub.html
|
||||
@echo
|
||||
@echo -e \\t- Unmount the filesystems.
|
||||
@echo
|
||||
@echo If you are an experienced HLFS user, several of those steps can be
|
||||
@echo skipped or done in a different way. But then, that is something
|
||||
@echo that you already know and there is no need to discuss it here.
|
||||
@echo $(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------$(WHITE)
|
||||
endef
|
230
HLFS/hlfs.xsl
Normal file
230
HLFS/hlfs.xsl
Normal file
|
@ -0,0 +1,230 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE xsl:stylesheet [
|
||||
<!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
|
||||
%general-entities;
|
||||
]>
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:exsl="http://exslt.org/common"
|
||||
extension-element-prefixes="exsl"
|
||||
version="1.0">
|
||||
|
||||
<!-- XSLT stylesheet to create shell scripts from LFS books. -->
|
||||
|
||||
<!-- Run optional test suites? -->
|
||||
<xsl:param name="testsuite" select="0"/>
|
||||
|
||||
<!-- Run toolchain test suites? -->
|
||||
<xsl:param name="toolchaintest" select="1"/>
|
||||
|
||||
<!-- Install vim-lang package? -->
|
||||
<xsl:param name="vim-lang" select="1"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates select="//sect1"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="sect1">
|
||||
<xsl:if test="count(descendant::screen/userinput) > 0 and
|
||||
count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
||||
<!-- The dirs names -->
|
||||
<xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
||||
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
||||
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
||||
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
||||
<!-- The file names -->
|
||||
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
||||
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
||||
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
||||
<!-- The build order -->
|
||||
<xsl:variable name="position" select="position()"/>
|
||||
<xsl:variable name="order">
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($position) = 1">
|
||||
<xsl:text>00</xsl:text>
|
||||
<xsl:value-of select="$position"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length($position) = 2">
|
||||
<xsl:text>0</xsl:text>
|
||||
<xsl:value-of select="$position"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$position"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- Creating dirs and files -->
|
||||
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
||||
<!-- Add a header to each script -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="@id='ch-system-changingowner' or
|
||||
@id='ch-system-creatingdirs' or
|
||||
@id='ch-system-createfiles'">
|
||||
<xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="@id='ch-tools-stripping' or
|
||||
@id='ch-system-strippingagain'">
|
||||
<xsl:text>#!/bin/sh
</xsl:text>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:otherwise>
|
||||
<xsl:text>#!/bin/sh
set -e

</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:if test="sect2[@role='installation'] or
|
||||
@id='ch-tools-adjusting' or
|
||||
@id='ch-system-readjusting'">
|
||||
<xsl:text>cd $PKGDIR
</xsl:text>
|
||||
<xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
|
||||
<xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="@id='ch-tools-uclibc'">
|
||||
<xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; 
</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="@id='ch-system-uclibc'">
|
||||
<xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; 
</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="@id='ch-system-glibc'">
|
||||
<xsl:text>tar -xvf ../glibc-libidn-&glibc-version;.*
</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="@id='ch-tools-glibc'">
|
||||
<xsl:text>tar -xvf ../glibc-libidn-&glibc-version;.*
</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="@id='ch-system-gcc'">
|
||||
<xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; 
</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="@id='ch-tools-gcc'">
|
||||
<xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; 
</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="@id='bootable-bootscripts'">
|
||||
<xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; 
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select=".//para/userinput | .//screen"/>
|
||||
<xsl:text>exit</xsl:text>
|
||||
</exsl:document>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="screen">
|
||||
<xsl:if test="child::* = userinput">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@role = 'nodump'"/>
|
||||
<xsl:when test="@condition != $model"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="userinput" mode="screen"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="para/userinput">
|
||||
<xsl:if test="$testsuite != '0' and
|
||||
(contains(string(),'test') or contains(string(),'check'))">
|
||||
<xsl:value-of select="substring-before(string(),'make')"/>
|
||||
<xsl:text>make -k</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'make')"/>
|
||||
<xsl:text> || true
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="userinput" mode="screen">
|
||||
<xsl:choose>
|
||||
<!-- Estandarized package formats -->
|
||||
<xsl:when test="contains(string(),'tar.gz')">
|
||||
<xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
||||
<xsl:text>tar.*</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- Avoiding a race condition in a patch -->
|
||||
<xsl:when test="contains(string(),'debian_fixes')">
|
||||
<xsl:value-of select="substring-before(string(),'patch')"/>
|
||||
<xsl:text>patch -Z</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'patch')"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
|
||||
<!-- Copying the kernel config file -->
|
||||
<xsl:when test="string() = 'make mrproper'">
|
||||
<xsl:text>make mrproper
</xsl:text>
|
||||
<xsl:text>cp -v /sources/kernel-config .config
</xsl:text>
|
||||
</xsl:when>
|
||||
|
||||
<!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
||||
<xsl:when test="$testsuite = '0' and
|
||||
(ancestor::sect1[@id='ch-system-coreutils'] or
|
||||
ancestor::sect1[@id='ch-system-module-init-tools']) and
|
||||
(contains(string(),'check') or
|
||||
contains(string(),'dummy'))"/>
|
||||
|
||||
<!-- Fixing toolchain test suites run -->
|
||||
<xsl:when test="string() = 'make check' or
|
||||
string() = 'make -k check'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$toolchaintest = '0'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>make -k check || true</xsl:text>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(string(),'glibc-check-log')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$toolchaintest = '0'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before(string(),'
')"/>
|
||||
<xsl:text> || true
</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'
')"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(string(),'test_summary') or
|
||||
contains(string(),'expect -c')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$toolchaintest = '0'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- Don't stop on strip run -->
|
||||
<xsl:when test="contains(string(),'strip ')">
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text> || true
</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- The rest of commands -->
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Deal with definable values defined inside <replaceable> -->
|
||||
<xsl:template match="replaceable">
|
||||
<xsl:choose>
|
||||
<xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
||||
<xsl:text>$TIMEZONE</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="ancestor::sect1[@id='ch-system-uclibc']">
|
||||
<xsl:text>$TIMEZONE</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
||||
<xsl:text>$PAGE</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>**EDITME</xsl:text>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text>EDITME**</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
662
HLFS/master.sh
Executable file
662
HLFS/master.sh
Executable file
|
@ -0,0 +1,662 @@
|
|||
#!/bin/sh
|
||||
set -e # Enable error trapping
|
||||
|
||||
|
||||
###################################
|
||||
### FUNCTIONS ###
|
||||
###################################
|
||||
|
||||
|
||||
#----------------------------#
|
||||
get_sources() { #
|
||||
#----------------------------#
|
||||
local IFS
|
||||
|
||||
# Test if the packages must be downloaded
|
||||
if [ ! "$HPKG" = "1" ] ; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Modify the 'internal field separator' to break on 'LF' only
|
||||
IFS=$'\x0A'
|
||||
|
||||
if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
||||
cd $BUILDDIR/sources
|
||||
|
||||
> MISSING_FILES.DMP # Files not in md5sum end up here
|
||||
|
||||
if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
||||
if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
|
||||
|
||||
# Retrieve the master md5sum file
|
||||
download "" MD5SUMS
|
||||
|
||||
# Iterate through each package and grab it, along with any patches it needs.
|
||||
for i in `cat $JHALFSDIR/packages` ; do
|
||||
PKG=`echo $i | sed -e 's/-version.*//' \
|
||||
-e 's/-file.*//' \
|
||||
-e 's/uclibc/uClibc/' `
|
||||
|
||||
# Needed for Groff patchlevel patch on UTF-8 branch
|
||||
GROFFLEVEL=`grep "groff-patchlevel" $JHALFSDIR/packages | sed -e 's/groff-patchlevel //' -e 's/"//g'`
|
||||
|
||||
#
|
||||
# How to deal with orphan packages..??
|
||||
#
|
||||
VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
||||
case "$PKG" in
|
||||
"expect-lib" ) continue ;; # not valid packages
|
||||
"linux-dl" ) continue ;;
|
||||
"groff-patchlevel" ) continue ;;
|
||||
"uClibc-patch" ) continue ;;
|
||||
|
||||
"tcl" ) FILE="$PKG$VRS-src.tar.bz2" ; download $PKG $FILE ;;
|
||||
"vim-lang" ) FILE="vim-$VRS-lang.tar.bz2"; PKG="vim" ; download $PKG $FILE ;;
|
||||
"udev-config" ) FILE="$VRS" ; PKG="udev" ; download $PKG $FILE ;;
|
||||
|
||||
"uClibc-locale" ) FILE="$PKG-$VRS.tar.bz2" ; PKG="uClibc"
|
||||
download $PKG $FILE
|
||||
# There can be no patches for this file
|
||||
continue ;;
|
||||
|
||||
"gcc" ) download $PKG "gcc-core-$VRS.tar.bz2"
|
||||
download $PKG "gcc-g++-$VRS.tar.bz2"
|
||||
;;
|
||||
"glibc") download $PKG "$PKG-$VRS.tar.bz2"
|
||||
download $PKG "$PKG-libidn-$VRS.tar.bz2"
|
||||
;;
|
||||
* ) FILE="$PKG-$VRS.tar.bz2"
|
||||
download $PKG $FILE
|
||||
;;
|
||||
esac
|
||||
|
||||
for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do
|
||||
PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
||||
download $PKG $PATCH
|
||||
done
|
||||
|
||||
done
|
||||
|
||||
# .... U G L Y .... what to do with the grsecurity patch to the kernel..
|
||||
download grsecurity `grep grsecurity $JHALFSDIR/patches`
|
||||
|
||||
# .... U G L Y .... deal with uClibc-locale-xxxxx.tar.bz2 format issue.
|
||||
bzcat uClibc-locale-030818.tar.bz2 | gzip > uClibc-locale-030818.tgz
|
||||
|
||||
if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
|
||||
echo -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check <MISSING_FILES.DMP> for names ${OFF}\n\n"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
chapter4_Makefiles() { # Initialization of the system
|
||||
#----------------------------#
|
||||
local TARGET LOADER
|
||||
|
||||
echo "${YELLOW} Processing Chapter-4 scripts ${OFF}"
|
||||
|
||||
# Define a few model dependant variables
|
||||
if [[ ${MODEL} = "uclibc" ]]; then
|
||||
TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
||||
else
|
||||
TARGET="tools-linux-gnu"; LOADER="ld-linux.so.2"
|
||||
fi
|
||||
|
||||
# 022-
|
||||
# If /home/hlfs is already present in the host, we asume that the
|
||||
# hlfs user and group are also presents in the host, and a backup
|
||||
# of their bash init files is made.
|
||||
(
|
||||
cat << EOF
|
||||
020-creatingtoolsdir:
|
||||
@\$(call echo_message, Building)
|
||||
@mkdir -v \$(MOUNT_PT)/tools && \\
|
||||
rm -fv /tools && \\
|
||||
ln -sv \$(MOUNT_PT)/tools /
|
||||
@if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
||||
mkdir \$(MOUNT_PT)/sources; \\
|
||||
fi;
|
||||
@chmod a+wt \$(MOUNT_PT)/sources && \\
|
||||
touch \$@
|
||||
|
||||
021-addinguser: 020-creatingtoolsdir
|
||||
@\$(call echo_message, Building)
|
||||
@if [ ! -d /home/lfs ]; then \\
|
||||
groupadd lfs; \\
|
||||
useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
||||
else \\
|
||||
touch user-lfs-exist; \\
|
||||
fi;
|
||||
@chown lfs \$(MOUNT_PT)/tools && \\
|
||||
chown lfs \$(MOUNT_PT)/sources && \\
|
||||
touch \$@
|
||||
|
||||
022-settingenvironment: 021-addinguser
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
||||
mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
||||
fi;
|
||||
@if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
||||
mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
||||
fi;
|
||||
@echo "set +h" > /home/lfs/.bashrc && \\
|
||||
echo "umask 022" >> /home/lfs/.bashrc && \\
|
||||
echo "HLFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
|
||||
echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
||||
echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
||||
echo "export HLFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
||||
echo "" >> /home/lfs/.bashrc && \\
|
||||
echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
|
||||
echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
|
||||
echo "export target ldso" >> /home/lfs/.bashrc && \\
|
||||
echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
||||
chown lfs:lfs /home/lfs/.bashrc && \\
|
||||
touch envars && \\
|
||||
touch \$@
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
|
||||
}
|
||||
|
||||
#----------------------------#
|
||||
chapter5_Makefiles() { # Bootstrap or temptools phase
|
||||
#----------------------------#
|
||||
local file
|
||||
local this_script
|
||||
|
||||
echo "${YELLOW} Processing Chapter-5 scripts${OFF}"
|
||||
|
||||
for file in chapter05/* ; do
|
||||
# Keep the script file name
|
||||
this_script=`basename $file`
|
||||
|
||||
# Skip this script depending on jhalfs.conf flags set.
|
||||
case $this_script in
|
||||
# If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
||||
*tcl* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
|
||||
*expect* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
|
||||
*dejagnu* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
|
||||
# Test if the stripping phase must be skipped
|
||||
*stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
||||
# Select the appropriate library
|
||||
*glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;;
|
||||
*uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
# First append each name of the script files to a list (this will become
|
||||
# the names of the targets in the Makefile
|
||||
chapter5="$chapter5 $this_script"
|
||||
|
||||
# Grab the name of the target (minus the -headers or -cross in the case of gcc
|
||||
# and binutils in chapter 5)
|
||||
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
|
||||
|
||||
# >>>>>>>>>> U G L Y <<<<<<<<<
|
||||
# Adjust 'name' and patch a few scripts on the fly..
|
||||
case $name in
|
||||
linux-libc) name=linux-libc-headers
|
||||
;;
|
||||
uclibc) # this sucks as method to deal with gettext/libint inside uClibc
|
||||
sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter05/$this_script
|
||||
;;
|
||||
gcc) # to compensate for the compiler test inside gcc (which fails), disable error trap
|
||||
sed 's@^gcc -o test test.c@set +e; gcc -o test test.c@' -i chapter05/$this_script
|
||||
;;
|
||||
esac
|
||||
|
||||
# Set the dependency for the first target.
|
||||
if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
||||
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
||||
#--------------------------------------------------------------------#
|
||||
#
|
||||
# Drop in the name of the target on a new line, and the previous target
|
||||
# as a dependency. Also call the echo_message function.
|
||||
wrt_target "$this_script" "$PREV"
|
||||
|
||||
# Find the version of the command files, if it corresponds with the building of
|
||||
# a specific package
|
||||
vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
||||
# If $vrs isn't empty, we've got a package...
|
||||
if [ "$vrs" != "" ] ; then
|
||||
# Deal with non-standard names
|
||||
case $name in
|
||||
tcl) FILE="$name$vrs-src.tar" ;;
|
||||
uclibc) FILE="uClibc-$vrs.tar" ;;
|
||||
gcc) FILE="gcc-core-$vrs.tar" ;;
|
||||
*) FILE="$name-$vrs.tar" ;;
|
||||
esac
|
||||
# Insert instructions for unpacking the package and to set the PKGDIR variable.
|
||||
wrt_unpack "$FILE"
|
||||
fi
|
||||
|
||||
case $this_script in
|
||||
*binutils* ) # Dump the path to sources directory for later removal
|
||||
echo -e '\techo "$(MOUNT_PT)$(SRC)/$$ROOT" >> sources-dir' >> $MKFILE.tmp
|
||||
;;
|
||||
*adjusting* ) # For the Adjusting phase we must to cd to the binutils-build directory.
|
||||
echo -e '\t@echo "export PKGDIR=$(MOUNT_PT)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
||||
;;
|
||||
* ) # Everything else, add a true statment so we don't confuse make
|
||||
echo -e '\ttrue' >> $MKFILE.tmp
|
||||
;;
|
||||
esac
|
||||
|
||||
# Insert date and disk usage at the top of the log file, the script run
|
||||
# and date and disk usage again at the bottom of the log file.
|
||||
wrt_run_as_su "${this_script}" "${file}"
|
||||
|
||||
# Remove the build directory(ies) except if the package build fails
|
||||
# (so we can review config.cache, config.log, etc.)
|
||||
# For Binutils the sources must be retained for some time.
|
||||
if [ "$vrs" != "" ] ; then
|
||||
if [[ ! `_IS_ $this_script binutils` ]]; then
|
||||
wrt_remove_build_dirs "$name"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Remove the Binutils pass 1 sources after a successful Adjusting phase.
|
||||
if [[ `_IS_ $this_script adjusting` ]] ; then
|
||||
(
|
||||
cat << EOF
|
||||
@rm -r \`cat sources-dir\` && \\
|
||||
rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
||||
rm sources-dir
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
fi
|
||||
|
||||
# Include a touch of the target name so make can check if it's already been made.
|
||||
echo -e '\t@touch $@' >> $MKFILE.tmp
|
||||
#
|
||||
#--------------------------------------------------------------------#
|
||||
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
# Keep the script file name for Makefile dependencies.
|
||||
PREV=$this_script
|
||||
done # end for file in chapter05/*
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
chapter6_Makefiles() { # sysroot or chroot build phase
|
||||
#----------------------------#
|
||||
local TARGET LOADER
|
||||
local file
|
||||
local this_script
|
||||
|
||||
#
|
||||
# Set these definitions early and only once
|
||||
#
|
||||
if [[ ${MODEL} = "uclibc" ]]; then
|
||||
TARGET="pc-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
||||
else
|
||||
TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
|
||||
fi
|
||||
|
||||
echo -e "${YELLOW} Processing Chapter-6 scripts ${OFF}"
|
||||
for file in chapter06/* ; do
|
||||
# Keep the script file name
|
||||
this_script=`basename $file`
|
||||
|
||||
# Skip this script depending on jhalfs.conf flags set.
|
||||
case $this_script in
|
||||
# We'll run the chroot commands differently than the others, so skip them in the
|
||||
# dependencies and target creation.
|
||||
*chroot* ) continue ;;
|
||||
# Test if the stripping phase must be skipped
|
||||
*-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
||||
# Select the appropriate library
|
||||
*glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;;
|
||||
*uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
# First append each name of the script files to a list (this will become
|
||||
# the names of the targets in the Makefile
|
||||
chapter6="$chapter6 $this_script"
|
||||
|
||||
# Grab the name of the target
|
||||
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
||||
|
||||
#
|
||||
# Sed replacement for 'nodump' tag in xml scripts until Manuel has a chance to fix them
|
||||
#
|
||||
case $name in
|
||||
kernfs)
|
||||
# We are using LFS instead of HLFS..
|
||||
sed 's/HLFS/LFS/' -i chapter06/$this_script
|
||||
# Remove sysctl code if host does not have grsecurity enabled
|
||||
if [[ "$GRSECURITY_HOST" = "0" ]]; then
|
||||
sed '/sysctl/d' -i chapter06/$this_script
|
||||
fi
|
||||
;;
|
||||
module-init-tools)
|
||||
if [[ "$TEST" = "0" ]]; then # This needs rework....
|
||||
sed '/make distclean/d' -i chapter06/$this_script
|
||||
fi
|
||||
;;
|
||||
glibc) # PATCH.. Turn off error trapping for the remainder of the script.
|
||||
sed 's|^make install|make install; set +e|' -i chapter06/$this_script
|
||||
;;
|
||||
uclibc) # PATCH..
|
||||
sed 's/EST5EDT/${TIMEZONE}/' -i chapter06/$this_script
|
||||
# PATCH.. Cannot use interactive programs/scripts.
|
||||
sed 's/make menuconfig/make oldconfig/' -i chapter06/$this_script
|
||||
sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter06/$this_script
|
||||
;;
|
||||
gcc) # PATCH..
|
||||
sed 's/rm /rm -f /' -i chapter06/$this_script
|
||||
;;
|
||||
esac
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
||||
#--------------------------------------------------------------------#
|
||||
#
|
||||
# Drop in the name of the target on a new line, and the previous target
|
||||
# as a dependency. Also call the echo_message function.
|
||||
wrt_target "$this_script" "$PREV"
|
||||
|
||||
# Find the version of the command files, if it corresponds with the building of
|
||||
# a specific package
|
||||
vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
||||
|
||||
# If $vrs isn't empty, we've got a package...
|
||||
# Insert instructions for unpacking the package and changing directories
|
||||
if [ "$vrs" != "" ] ; then
|
||||
# Deal with non-standard names
|
||||
case $name in
|
||||
tcl) FILE="$name$vrs-src.tar.*" ;;
|
||||
uclibc) FILE="uClibc-$vrs.tar.*" ;;
|
||||
gcc) FILE="gcc-core-$vrs.tar.*" ;;
|
||||
*) FILE="$name-$vrs.tar.*" ;;
|
||||
esac
|
||||
wrt_unpack2 "$FILE"
|
||||
wrt_target_vars
|
||||
fi
|
||||
|
||||
case $this_script in
|
||||
*readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
|
||||
echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
||||
;;
|
||||
*glibc* | *uclibc* ) # For glibc and uClibc we need to set TIMEZONE envar.
|
||||
wrt_export_timezone
|
||||
;;
|
||||
*groff* ) # For Groff we need to set PAGE envar.
|
||||
wrt_export_pagesize
|
||||
;;
|
||||
esac
|
||||
|
||||
# In the mount of kernel filesystems we need to set HLFS and not to use chroot.
|
||||
if [[ `_IS_ $this_script kernfs` ]] ; then
|
||||
wrt_run_as_root "${this_script}" "${file}"
|
||||
#
|
||||
# The rest of Chapter06
|
||||
else
|
||||
wrt_run_as_chroot1 "${this_script}" "${file}"
|
||||
fi
|
||||
#
|
||||
# Remove the build directory(ies) except if the package build fails.
|
||||
if [ "$vrs" != "" ] ; then
|
||||
wrt_remove_build_dirs "$name"
|
||||
fi
|
||||
#
|
||||
# Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
|
||||
if [[ `_IS_ $this_script readjusting` ]] ; then
|
||||
(
|
||||
cat << EOF
|
||||
@rm -r \`cat sources-dir\` && \\
|
||||
rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
||||
rm sources-dir
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
fi
|
||||
|
||||
# Include a touch of the target name so make can check if it's already been made.
|
||||
echo -e '\t@touch $@' >> $MKFILE.tmp
|
||||
#
|
||||
#--------------------------------------------------------------------#
|
||||
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
# Keep the script file name for Makefile dependencies.
|
||||
PREV=$this_script
|
||||
done # end for file in chapter06/*
|
||||
|
||||
}
|
||||
|
||||
#----------------------------#
|
||||
chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
|
||||
#----------------------------#
|
||||
local file
|
||||
local this_script
|
||||
|
||||
echo "${YELLOW} Processing Chapter-7 scripts ${OFF}"
|
||||
for file in chapter07/*; do
|
||||
# Keep the script file name
|
||||
this_script=`basename $file`
|
||||
|
||||
# Grub must be configured manually.
|
||||
# The filesystems can't be unmounted via Makefile and the user
|
||||
# should enter the chroot environment to create the root
|
||||
# password, edit several files and setup Grub.
|
||||
case $this_script in
|
||||
*grub) continue ;;
|
||||
*reboot) continue ;;
|
||||
*console) continue ;; # Use the file generated by lfs-bootscripts
|
||||
|
||||
*kernel) # How does Manuel add this string to the file..
|
||||
sed 's|cd \$PKGDIR.*||' -i chapter07/$this_script
|
||||
# You cannot run menuconfig from within the makefile
|
||||
sed 's|make menuconfig|make oldconfig|' -i chapter07/$this_script
|
||||
# The files in the conglomeration dir are xxx.bz2
|
||||
sed 's|.patch.gz|.patch.bz2|' -i chapter07/$this_script
|
||||
sed 's|gunzip|bunzip2|' -i chapter07/$this_script
|
||||
# If defined include the keymap in the kernel
|
||||
if [[ -n "$KEYMAP" ]]; then
|
||||
sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i chapter07/$this_script
|
||||
else
|
||||
sed '/loadkeys -m/d' -i chapter07/$this_script
|
||||
sed '/drivers\/char/d' -i chapter07/$this_script
|
||||
fi
|
||||
# If no .config file is supplied, the kernel build is skipped
|
||||
[[ -z $CONFIG ]] && continue
|
||||
;;
|
||||
*usage) # The script bombs, disable error trapping
|
||||
sed 's|set -e|set +e|' -i chapter07/$this_script
|
||||
;;
|
||||
*profile) # Add the config values to the script
|
||||
sed "s|LC_ALL=\*\*EDITME.*EDITME\*\*|LC_ALL=$LC_ALL|" -i chapter07/$this_script
|
||||
sed "s|LANG=\*\*EDITME.*EDITME\*\*|LANG=$LANG|" -i chapter07/$this_script
|
||||
;;
|
||||
esac
|
||||
|
||||
# First append then name of the script file to a list (this will become
|
||||
# the names of the targets in the Makefile
|
||||
chapter7="$chapter7 $this_script"
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
||||
#--------------------------------------------------------------------#
|
||||
#
|
||||
# Drop in the name of the target on a new line, and the previous target
|
||||
# as a dependency. Also call the echo_message function.
|
||||
wrt_target "$this_script" "$PREV"
|
||||
|
||||
if [[ `_IS_ $this_script bootscripts` ]] ; then
|
||||
vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
||||
FILE="lfs-bootscripts-$vrs.tar.*"
|
||||
# The bootscript pkg references both lfs AND blfs bootscripts...
|
||||
# see XML script for other additions to bootscripts file
|
||||
# PATCH
|
||||
vrs=`grep "^blfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
||||
sed "s|make install$|make install; cd ../blfs-bootscripts-$vrs|" -i chapter07/$this_script
|
||||
wrt_unpack2 "$FILE"
|
||||
(
|
||||
cat << EOF
|
||||
echo "\$(MOUNT_PT)\$(SRC)/blfs-bootscripts-$vrs" > sources-dir
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
fi
|
||||
|
||||
if [[ `_IS_ $this_script kernel` ]] ; then
|
||||
# not much really, script does everything..
|
||||
echo -e "\t@cp -f $CONFIG \$(MOUNT_PT)/sources/kernel-config" >> $MKFILE.tmp
|
||||
fi
|
||||
|
||||
# Check if we have a real /etc/fstab file
|
||||
if [[ `_IS_ $this_script fstab` ]] && [[ -n "$FSTAB" ]] ; then
|
||||
wrt_copy_fstab "$this_script"
|
||||
else
|
||||
# Initialize the log and run the script
|
||||
wrt_run_as_chroot2 "${this_script}" "${file}"
|
||||
fi
|
||||
|
||||
# Remove the build directory except if the package build fails.
|
||||
if [[ `_IS_ $this_script bootscripts` ]]; then
|
||||
(
|
||||
cat << EOF
|
||||
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
||||
@rm -r \`cat sources-dir\` && \\
|
||||
rm sources-dir
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
fi
|
||||
|
||||
# Include a touch of the target name so make can check if it's already been made.
|
||||
echo -e '\t@touch $@' >> $MKFILE.tmp
|
||||
#
|
||||
#--------------------------------------------------------------------#
|
||||
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
# Keep the script file name for Makefile dependencies.
|
||||
PREV=$this_script
|
||||
done # for file in chapter07/*
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
build_Makefile() { # Construct a Makefile from the book scripts
|
||||
#----------------------------#
|
||||
echo -e "${GREEN}Creating Makefile... ${OFF}"
|
||||
|
||||
cd $JHALFSDIR/${PROGNAME}-commands
|
||||
# Start with a clean Makefile.tmp file
|
||||
>$MKFILE.tmp
|
||||
|
||||
chapter4_Makefiles
|
||||
chapter5_Makefiles
|
||||
chapter6_Makefiles
|
||||
chapter7_Makefiles
|
||||
|
||||
# Add a header, some variables and include the function file
|
||||
# to the top of the real Makefile.
|
||||
(
|
||||
cat << EOF
|
||||
$HEADER
|
||||
|
||||
SRC= /sources
|
||||
MOUNT_PT= $BUILDDIR
|
||||
PAGE= $PAGE
|
||||
TIMEZONE= $TIMEZONE
|
||||
|
||||
include makefile-functions
|
||||
|
||||
EOF
|
||||
) > $MKFILE
|
||||
|
||||
|
||||
# Add chroot commands
|
||||
i=1
|
||||
for file in chapter06/*chroot* ; do
|
||||
chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
||||
-e '/^export/d' \
|
||||
-e '/^logout/d' \
|
||||
-e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
||||
-e 's|\\$|&&|g' \
|
||||
-e 's|exit||g' \
|
||||
-e 's|$| -c|' \
|
||||
-e 's|"$$HLFS"|$(MOUNT_PT)|'\
|
||||
-e 's|set -e||'`
|
||||
echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
|
||||
# Drop in the main target 'all:' and the chapter targets with each sub-target
|
||||
# as a dependency.
|
||||
(
|
||||
cat << EOF
|
||||
all: chapter4 chapter5 chapter6 chapter7
|
||||
@\$(call echo_finished,$VERSION)
|
||||
|
||||
chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
||||
|
||||
chapter5: chapter4 $chapter5 restore-hlfs-env
|
||||
|
||||
chapter6: chapter5 $chapter6
|
||||
|
||||
chapter7: chapter6 $chapter7
|
||||
|
||||
clean-all: clean
|
||||
rm -rf ./{hlfs-commands,logs,Makefile,dump-hlfs-scripts.xsl,functions,packages,patches}
|
||||
|
||||
clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter4
|
||||
|
||||
clean-chapter4:
|
||||
-if [ ! -f user-hlfs-exist ]; then \\
|
||||
userdel hlfs; \\
|
||||
rm -rf /home/hlfs; \\
|
||||
fi;
|
||||
rm -rf \$(MOUNT_PT)/tools
|
||||
rm -f /tools
|
||||
rm -f envars user-hlfs-exist
|
||||
rm -f 02* logs/02*.log
|
||||
|
||||
clean-chapter5:
|
||||
rm -rf \$(MOUNT_PT)/tools/*
|
||||
rm -f $chapter5 restore-hlfs-env sources-dir
|
||||
cd logs && rm -f $chapter5 && cd ..
|
||||
|
||||
clean-chapter6:
|
||||
-umount \$(MOUNT_PT)/sys
|
||||
-umount \$(MOUNT_PT)/proc
|
||||
-umount \$(MOUNT_PT)/dev/shm
|
||||
-umount \$(MOUNT_PT)/dev/pts
|
||||
-umount \$(MOUNT_PT)/dev
|
||||
rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
||||
rm -f $chapter6
|
||||
cd logs && rm -f $chapter6 && cd ..
|
||||
|
||||
clean-chapter7:
|
||||
rm -f $chapter7
|
||||
cd logs && rm -f $chapter7 && cd ..
|
||||
|
||||
restore-hlfs-env:
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
||||
mv -fv /home/lfs/.bashrc.XXX /home/hlfs/.bashrc; \\
|
||||
fi;
|
||||
@if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
|
||||
mv -v /home/lfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
|
||||
fi;
|
||||
@chown lfs:lfs /home/lfs/.bash* && \\
|
||||
touch \$@
|
||||
|
||||
EOF
|
||||
) >> $MKFILE
|
||||
|
||||
# Bring over the items from the Makefile.tmp
|
||||
cat $MKFILE.tmp >> $MKFILE
|
||||
rm $MKFILE.tmp
|
||||
echo -ne "${GREEN}done\n${OFF}"
|
||||
}
|
||||
|
||||
|
25
HLFS/patcheslist.xsl
Normal file
25
HLFS/patcheslist.xsl
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version='1.0' encoding='ISO-8859-1'?>
|
||||
|
||||
<!-- Get list of patch files from the BLFS Book -->
|
||||
<!-- $LastChangedBy: bdubbs $ -->
|
||||
<!-- $Date$ -->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="1.0">
|
||||
|
||||
<xsl:output method="text"/>
|
||||
|
||||
<!-- No text needed -->
|
||||
<xsl:template match="//text()">
|
||||
<xsl:text/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Just grab the url from the ulink tags that have .patch in the name -->
|
||||
<xsl:template match="//ulink">
|
||||
<xsl:if test="contains(@url, '.patch') or contains(@url, '.patch.gz') and contains(@url, 'linuxfromscratch')">
|
||||
<xsl:value-of select="@url"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
34
LFS/config
Normal file
34
LFS/config
Normal file
|
@ -0,0 +1,34 @@
|
|||
#####
|
||||
#
|
||||
# Configuration file for the LFS module
|
||||
#
|
||||
#####
|
||||
declare -r HTTP=http://ftp.lfs-matrix.net/pub/lfs/conglomeration
|
||||
|
||||
#--- Location of fstab file (if empty, a template is created)
|
||||
FSTAB=$BUILDDIR/sources/fstab
|
||||
|
||||
#--- Location of kernel config file (if the kernel is to be compiled)
|
||||
CONFIG=$PWD/config_files/linux-2.6.15.1-LFS.config
|
||||
|
||||
#--- Book's sources directory
|
||||
# If you have previously checked out the book from the repository
|
||||
BOOK=
|
||||
|
||||
#==== INTERNAL VARIABLES ====
|
||||
# Don't edit it unless you know what you are doing
|
||||
|
||||
#--- Files that will be copied to $JHALFSDIR
|
||||
FILES=""
|
||||
|
||||
#--- Default stylesheet
|
||||
XSL=dump-lfs-scripts.xsl
|
||||
|
||||
#--- Book version
|
||||
LFSVRS=development
|
||||
|
||||
#--- Name of the makefile
|
||||
MKFILE=$JHALFSDIR/lfs-Makefile
|
||||
|
||||
#--- FTP/HTTP mirror used as fallback (full path)
|
||||
SERVER=ftp://anduin.linuxfromscratch.org/LFS/conglomeration
|
196
LFS/lfs.xsl
Normal file
196
LFS/lfs.xsl
Normal file
|
@ -0,0 +1,196 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE xsl:stylesheet [
|
||||
<!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
|
||||
%general-entities;
|
||||
]>
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:exsl="http://exslt.org/common"
|
||||
extension-element-prefixes="exsl"
|
||||
version="1.0">
|
||||
|
||||
<!-- XSLT stylesheet to create shell scripts from LFS books. -->
|
||||
|
||||
<!-- Run optional test suites? -->
|
||||
<xsl:param name="testsuite" select="0"/>
|
||||
|
||||
<!-- Run toolchain test suites? -->
|
||||
<xsl:param name="toolchaintest" select="1"/>
|
||||
|
||||
<!-- Install vim-lang package? -->
|
||||
<xsl:param name="vim-lang" select="1"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates select="//sect1"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="sect1">
|
||||
<xsl:if test="count(descendant::screen/userinput) > 0 and
|
||||
count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
||||
<!-- The dirs names -->
|
||||
<xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
||||
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
||||
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
||||
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
||||
<!-- The file names -->
|
||||
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
||||
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
||||
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
||||
<!-- The build order -->
|
||||
<xsl:variable name="position" select="position()"/>
|
||||
<xsl:variable name="order">
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($position) = 1">
|
||||
<xsl:text>00</xsl:text>
|
||||
<xsl:value-of select="$position"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length($position) = 2">
|
||||
<xsl:text>0</xsl:text>
|
||||
<xsl:value-of select="$position"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$position"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<!-- Creating dirs and files -->
|
||||
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@id='ch-system-changingowner' or
|
||||
@id='ch-system-creatingdirs' or
|
||||
@id='ch-system-createfiles'">
|
||||
<xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="@id='ch-tools-stripping' or
|
||||
@id='ch-system-strippingagain'">
|
||||
<xsl:text>#!/bin/sh
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>#!/bin/sh
set -e

</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="sect2[@role='installation'] or
|
||||
@id='ch-tools-adjusting' or
|
||||
@id='ch-system-readjusting'">
|
||||
<xsl:text>cd $PKGDIR
</xsl:text>
|
||||
<xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
|
||||
<xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select=".//para/userinput | .//screen"/>
|
||||
<xsl:text>exit</xsl:text>
|
||||
</exsl:document>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="screen">
|
||||
<xsl:if test="child::* = userinput">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@role = 'nodump'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="userinput" mode="screen"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="para/userinput">
|
||||
<xsl:if test="$testsuite != '0' and
|
||||
(contains(string(),'test') or
|
||||
contains(string(),'check'))">
|
||||
<xsl:value-of select="substring-before(string(),'make')"/>
|
||||
<xsl:text>make -k</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'make')"/>
|
||||
<xsl:text> || true
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="userinput" mode="screen">
|
||||
<xsl:choose>
|
||||
<!-- Estandarized package formats -->
|
||||
<xsl:when test="contains(string(),'tar.gz')">
|
||||
<xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
||||
<xsl:text>tar.*</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- Avoiding a race condition in a patch -->
|
||||
<xsl:when test="contains(string(),'debian_fixes')">
|
||||
<xsl:value-of select="substring-before(string(),'patch')"/>
|
||||
<xsl:text>patch -Z</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'patch')"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- Copying the kernel config file -->
|
||||
<xsl:when test="string() = 'make mrproper'">
|
||||
<xsl:text>make mrproper
</xsl:text>
|
||||
<xsl:text>cp -v ../kernel-config .config
</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
||||
<xsl:when test="$testsuite = '0' and
|
||||
(ancestor::sect1[@id='ch-system-coreutils'] or
|
||||
ancestor::sect1[@id='ch-system-module-init-tools']) and
|
||||
(contains(string(),'check') or
|
||||
contains(string(),'dummy'))"/>
|
||||
<!-- Fixing toolchain test suites run -->
|
||||
<xsl:when test="string() = 'make check' or
|
||||
string() = 'make -k check'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$toolchaintest = '0'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>make -k check || true</xsl:text>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(string(),'glibc-check-log')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$toolchaintest = '0'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before(string(),'
')"/>
|
||||
<xsl:text> || true
</xsl:text>
|
||||
<xsl:value-of select="substring-after(string(),'
')"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(string(),'test_summary') or
|
||||
contains(string(),'expect -c')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$toolchaintest = '0'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- Don't stop on strip run -->
|
||||
<xsl:when test="contains(string(),'strip ')">
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text> || true
</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- The rest of commands -->
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="replaceable">
|
||||
<xsl:choose>
|
||||
<xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
||||
<xsl:text>$TIMEZONE</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
||||
<xsl:text>$PAGE</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>**EDITME</xsl:text>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text>EDITME**</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
392
LFS/master.sh
Executable file
392
LFS/master.sh
Executable file
|
@ -0,0 +1,392 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
###################################
|
||||
### FUNCTIONS ###
|
||||
###################################
|
||||
|
||||
|
||||
|
||||
#----------------------------#
|
||||
chapter4_Makefiles() {
|
||||
#----------------------------#
|
||||
|
||||
# If /home/lfs is already present in the host, we asume that the
|
||||
# lfs user and group are also presents in the host, and a backup
|
||||
# of their bash init files is made.
|
||||
(
|
||||
cat << EOF
|
||||
020-creatingtoolsdir:
|
||||
@\$(call echo_message, Building)
|
||||
@mkdir -v \$(MOUNT_PT)/tools && \\
|
||||
rm -fv /tools && \\
|
||||
ln -sv \$(MOUNT_PT)/tools / && \\
|
||||
touch \$@
|
||||
|
||||
021-addinguser: 020-creatingtoolsdir
|
||||
@\$(call echo_message, Building)
|
||||
@if [ ! -d /home/lfs ]; then \\
|
||||
groupadd lfs; \\
|
||||
useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
||||
else \\
|
||||
touch user-lfs-exist; \\
|
||||
fi;
|
||||
@chown lfs \$(MOUNT_PT)/tools && \\
|
||||
chown lfs \$(MOUNT_PT)/sources && \\
|
||||
touch \$@
|
||||
|
||||
022-settingenvironment: 021-addinguser
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
||||
mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
||||
fi;
|
||||
@if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
||||
mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
||||
fi;
|
||||
@echo "set +h" > /home/lfs/.bashrc && \\
|
||||
echo "umask 022" >> /home/lfs/.bashrc && \\
|
||||
echo "LFS=/mnt/lfs" >> /home/lfs/.bashrc && \\
|
||||
echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
||||
echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
||||
echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
||||
echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
||||
chown lfs:lfs /home/lfs/.bashrc && \\
|
||||
touch envars && \\
|
||||
touch \$@
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
#----------------------------#
|
||||
chapter5_Makefiles() {
|
||||
#----------------------------#
|
||||
for file in chapter05/* ; do
|
||||
# Keep the script file name
|
||||
this_script=`basename $file`
|
||||
|
||||
# If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
||||
if [ "$TOOLCHAINTEST" = "0" ]; then
|
||||
if [[ `_IS_ ${this_script} tcl` ]] || [[ `_IS_ ${this_script} expect` ]] || [[ `_IS_ ${this_script} dejagnu` ]] ; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
# Test if the stripping phase must be skipped
|
||||
if [ "$STRIP" = "0" ] && [[ `_IS_ ${this_script} stripping` ]] ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# NOTE Replace with xsl work...
|
||||
if [[ `_IS_ $this_script adjusting` ]]; then
|
||||
sed '/cd $PKGDIR/d' -i chapter05/$this_script
|
||||
fi
|
||||
|
||||
# First append each name of the script files to a list (this will become
|
||||
# the names of the targets in the Makefile
|
||||
chapter5="$chapter5 ${this_script}"
|
||||
|
||||
# Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
||||
# and binutils in chapter 5)
|
||||
name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
||||
|
||||
# Set the dependency for the first target.
|
||||
if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
||||
|
||||
# Drop in the name of the target on a new line, and the previous target
|
||||
# as a dependency. Also call the echo_message function.
|
||||
wrt_target "${this_script}" "$PREV"
|
||||
|
||||
# Find the version of the command files, if it corresponds with the building of
|
||||
# a specific package
|
||||
vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
||||
|
||||
# If $vrs isn't empty, we've got a package...
|
||||
if [ "$vrs" != "" ] ; then
|
||||
if [ "$name" = "tcl" ] ; then
|
||||
FILE="$name$vrs-src.tar"
|
||||
else
|
||||
FILE="$name-$vrs.tar"
|
||||
fi
|
||||
|
||||
# Insert instructions for unpacking the package and to set
|
||||
# the PKGDIR variable.
|
||||
wrt_unpack "$FILE"
|
||||
echo -e '\ttrue' >> $MKFILE.tmp
|
||||
fi
|
||||
|
||||
# Insert date and disk usage at the top of the log file, the script run
|
||||
# and date and disk usage again at the bottom of the log file.
|
||||
wrt_run_as_su "${this_script}" "$file"
|
||||
|
||||
# Remove the build directory(ies) except if the package build fails
|
||||
# (so we can review config.cache, config.log, etc.)
|
||||
if [ "$vrs" != "" ] ; then
|
||||
wrt_remove_build_dirs "$name"
|
||||
fi
|
||||
|
||||
# Include a touch of the target name so make can check
|
||||
# if it's already been made.
|
||||
echo -e '\t@touch $@' >> $MKFILE.tmp
|
||||
|
||||
# Keep the script file name for Makefile dependencies.
|
||||
PREV=${this_script}
|
||||
done # end for file in chapter05/*
|
||||
}
|
||||
|
||||
#----------------------------#
|
||||
chapter6_Makefiles() {
|
||||
#----------------------------#
|
||||
for file in chapter06/* ; do
|
||||
# Keep the script file name
|
||||
this_script=`basename $file`
|
||||
|
||||
# We'll run the chroot commands differently than the others, so skip them in the
|
||||
# dependencies and target creation.
|
||||
if [[ `_IS_ ${this_script} chroot` ]] ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Test if the stripping phase must be skipped
|
||||
if [ "$STRIP" = "0" ] && [[ `_IS_ ${this_script} stripping` ]] ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# NOTE Replace with xsl work...
|
||||
if [[ `_IS_ $this_script adjusting` ]]; then
|
||||
sed '/cd $PKGDIR/d' -i chapter06/$this_script
|
||||
fi
|
||||
|
||||
# First append each name of the script files to a list (this will become
|
||||
# the names of the targets in the Makefile
|
||||
chapter6="$chapter6 ${this_script}"
|
||||
|
||||
# Grab the name of the target
|
||||
name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@'`
|
||||
|
||||
# Drop in the name of the target on a new line, and the previous target
|
||||
# as a dependency. Also call the echo_message function.
|
||||
wrt_target "${this_script}" "$PREV"
|
||||
|
||||
# Find the version of the command files, if it corresponds with the building of
|
||||
# a specific package
|
||||
vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
||||
|
||||
# If $vrs isn't empty, we've got a package...
|
||||
# Insert instructions for unpacking the package and changing directories
|
||||
if [ "$vrs" != "" ] ; then
|
||||
FILE="$name-$vrs.tar.*"
|
||||
wrt_unpack2 "$FILE"
|
||||
fi
|
||||
|
||||
if [[ `_IS_ ${this_script} glibc` ]] ; then # For Glibc we need to set TIMEZONE envar.
|
||||
wrt_export_timezone
|
||||
elif [[ `_IS_ ${this_script} groff` ]] ; then # For Groff we need to set PAGE envar.
|
||||
wrt_export_pagesize
|
||||
fi
|
||||
|
||||
# In the mount of kernel filesystems we need to set LFS
|
||||
# and not to use chroot.
|
||||
if [[ `_IS_ ${this_script} kernfs` ]] ; then
|
||||
wrt_run_as_root "${this_script}" "$file"
|
||||
else # The rest of Chapter06
|
||||
wrt_run_as_chroot1 "${this_script}" "$file"
|
||||
fi
|
||||
|
||||
# Remove the build directory(ies) except if the package build fails.
|
||||
if [ "$vrs" != "" ] ; then
|
||||
wrt_remove_build_dirs "$name"
|
||||
fi
|
||||
|
||||
# Include a touch of the target name so make can check
|
||||
# if it's already been made.
|
||||
echo -e '\t@touch $@' >> $MKFILE.tmp
|
||||
|
||||
# Keep the script file name for Makefile dependencies.
|
||||
PREV=${this_script}
|
||||
done # end for file in chapter06/*
|
||||
}
|
||||
|
||||
#----------------------------#
|
||||
chapter789_Makefiles() {
|
||||
#----------------------------#
|
||||
for file in chapter0{7,8,9}/* ; do
|
||||
# Keep the script file name
|
||||
this_script=`basename $file`
|
||||
|
||||
# Grub must be configured manually.
|
||||
# The filesystems can't be unmounted via Makefile and the user
|
||||
# should enter the chroot environment to create the root
|
||||
# password, edit several files and setup Grub.
|
||||
if [[ `_IS_ ${this_script} grub` ]] || [[ `_IS_ ${this_script} reboot` ]] ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# If no .config file is supplied, the kernel build is skipped
|
||||
if [ -z $CONFIG ] && [[ `_IS_ ${this_script} kernel` ]] ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# First append each name of the script files to a list (this will become
|
||||
# the names of the targets in the Makefile
|
||||
chapter789="$chapter789 ${this_script}"
|
||||
|
||||
# Drop in the name of the target on a new line, and the previous target
|
||||
# as a dependency. Also call the echo_message function.
|
||||
wrt_target "${this_script}" "$PREV"
|
||||
|
||||
# Find the bootscripts and kernel package names
|
||||
if [[ `_IS_ ${this_script} bootscripts` ]] || [[ `_IS_ ${this_script} kernel` ]] ; then
|
||||
if [[ `_IS_ ${this_script} bootscripts` ]] ; then
|
||||
vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
||||
FILE="lfs-bootscripts-$vrs.tar.*"
|
||||
elif [[ `_IS_ ${this_script} kernel` ]] ; then
|
||||
vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
||||
FILE="linux-$vrs.tar.*"
|
||||
fi
|
||||
wrt_unpack2 "$FILE"
|
||||
fi
|
||||
|
||||
# Put in place the kernel .config file
|
||||
if [[ `_IS_ ${this_script} kernel` ]] ; then
|
||||
(
|
||||
cat << EOF
|
||||
@cp $CONFIG \$(MOUNT_PT)/sources/kernel-config
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
fi
|
||||
|
||||
# Check if we have a real /etc/fstab file
|
||||
if [[ `_IS_ ${this_script} fstab` ]] && [[ -n "$FSTAB" ]] ; then
|
||||
wrt_copy_fstab "${this_script}"
|
||||
else
|
||||
# Initialize the log and run the script
|
||||
wrt_run_as_chroot2 "$this_script" "$file"
|
||||
fi
|
||||
|
||||
# Remove the build directory except if the package build fails.
|
||||
if [[ `_IS_ ${this_script} bootscripts` ]] || [[ `_IS_ ${this_script} kernel` ]] ; then
|
||||
wrt_remove_build_dirs "dummy"
|
||||
fi
|
||||
|
||||
# Include a touch of the target name so make can check
|
||||
# if it's already been made.
|
||||
echo -e '\t@touch $@' >> $MKFILE.tmp
|
||||
|
||||
# Keep the script file name for Makefile dependencies.
|
||||
PREV=${this_script}
|
||||
done # for file in chapter0{7,8,9}/*
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
build_Makefile() {
|
||||
#----------------------------#
|
||||
echo -n "Creating Makefile... "
|
||||
cd $JHALFSDIR/${PROGNAME}-commands
|
||||
|
||||
# Start with a clean Makefile.tmp file
|
||||
>$MKFILE.tmp
|
||||
|
||||
chapter4_Makefiles
|
||||
chapter5_Makefiles
|
||||
chapter6_Makefiles
|
||||
chapter789_Makefiles
|
||||
|
||||
|
||||
# Add a header, some variables and include the function file
|
||||
# to the top of the real Makefile.
|
||||
(
|
||||
cat << EOF
|
||||
$HEADER
|
||||
|
||||
SRC= /sources
|
||||
MOUNT_PT= $BUILDDIR
|
||||
PAGE= $PAGE
|
||||
TIMEZONE= $TIMEZONE
|
||||
|
||||
include makefile-functions
|
||||
|
||||
EOF
|
||||
) > $MKFILE
|
||||
|
||||
|
||||
# Add chroot commands
|
||||
i=1
|
||||
for file in chapter06/*chroot* ; do
|
||||
chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
|
||||
-e 's/ */ /g' -e 's|\\$|&&|g' -e 's|exit||g' -e 's|$| -c|' \
|
||||
-e 's|"$$LFS"|$(MOUNT_PT)|' -e 's|set -e||'`
|
||||
echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
|
||||
# Drop in the main target 'all:' and the chapter targets with each sub-target
|
||||
# as a dependency.
|
||||
(
|
||||
cat << EOF
|
||||
all: chapter4 chapter5 chapter6 chapter789
|
||||
@\$(call echo_finished,$VERSION)
|
||||
|
||||
chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
||||
|
||||
chapter5: chapter4 $chapter5 restore-lfs-env
|
||||
|
||||
chapter6: chapter5 $chapter6
|
||||
|
||||
chapter789: chapter6 $chapter789
|
||||
|
||||
clean-all: clean
|
||||
rm -rf ./{lfs-commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
|
||||
|
||||
clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
|
||||
|
||||
clean-chapter4:
|
||||
-if [ ! -f user-lfs-exist ]; then \\
|
||||
userdel lfs; \\
|
||||
rm -rf /home/lfs; \\
|
||||
fi;
|
||||
rm -rf \$(MOUNT_PT)/tools
|
||||
rm -f /tools
|
||||
rm -f envars user-lfs-exist
|
||||
rm -f 02* logs/02*.log
|
||||
|
||||
clean-chapter5:
|
||||
rm -rf \$(MOUNT_PT)/tools/*
|
||||
rm -f $chapter5 restore-lfs-env sources-dir
|
||||
cd logs && rm -f $chapter5 && cd ..
|
||||
|
||||
clean-chapter6:
|
||||
-umount \$(MOUNT_PT)/sys
|
||||
-umount \$(MOUNT_PT)/proc
|
||||
-umount \$(MOUNT_PT)/dev/shm
|
||||
-umount \$(MOUNT_PT)/dev/pts
|
||||
-umount \$(MOUNT_PT)/dev
|
||||
rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
||||
rm -f $chapter6
|
||||
cd logs && rm -f $chapter6 && cd ..
|
||||
|
||||
clean-chapter789:
|
||||
rm -f $chapter789
|
||||
cd logs && rm -f $chapter789 && cd ..
|
||||
|
||||
restore-lfs-env:
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
||||
mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
||||
fi;
|
||||
@if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
||||
mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
||||
fi;
|
||||
@chown lfs:lfs /home/lfs/.bash* && \\
|
||||
touch \$@
|
||||
|
||||
EOF
|
||||
) >> $MKFILE
|
||||
|
||||
# Bring over the items from the Makefile.tmp
|
||||
cat $MKFILE.tmp >> $MKFILE
|
||||
rm $MKFILE.tmp
|
||||
echo -ne "done\n"
|
||||
}
|
||||
|
||||
|
1
blfs
Symbolic link
1
blfs
Symbolic link
|
@ -0,0 +1 @@
|
|||
master.sh
|
1
clfs
Symbolic link
1
clfs
Symbolic link
|
@ -0,0 +1 @@
|
|||
master.sh
|
801
common/common-functions
Normal file
801
common/common-functions
Normal file
|
@ -0,0 +1,801 @@
|
|||
#!/bin/bash
|
||||
set +e
|
||||
|
||||
# VT100 colors
|
||||
declare -r BLACK=$'\e[1;30m'
|
||||
declare -r DK_GRAY=$'\e[0;30m'
|
||||
|
||||
declare -r RED=$'\e[31m'
|
||||
declare -r GREEN=$'\e[32m'
|
||||
declare -r YELLOW=$'\e[33m'
|
||||
declare -r BLUE=$'\e[34m'
|
||||
declare -r MAGENTA=$'\e[35m'
|
||||
declare -r CYAN=$'\e[36m'
|
||||
declare -r WHITE=$'\e[37m'
|
||||
|
||||
declare -r OFF=$'\e[0m'
|
||||
declare -r BOLD=$'\e[1m'
|
||||
declare -r REVERSE=$'\e[7m'
|
||||
declare -r HIDDEN=$'\e[8m'
|
||||
|
||||
declare -r tab_=$'\t'
|
||||
declare -r nl_=$'\n'
|
||||
|
||||
declare -r DD_BORDER="${BOLD}${WHITE}==============================================================================${OFF}"
|
||||
declare -r SD_BORDER="${BOLD}${WHITE}------------------------------------------------------------------------------${OFF}"
|
||||
declare -r STAR_BORDER="${BOLD}${WHITE}******************************************************************************${OFF}"
|
||||
|
||||
# bold yellow > < pair
|
||||
declare -r R_arrow=$'\e[1;33m>\e[0m'
|
||||
declare -r L_arrow=$'\e[1;33m<\e[0m'
|
||||
|
||||
|
||||
|
||||
usage() {
|
||||
'clear'
|
||||
cat <<- -EOF-
|
||||
${DD_BORDER}
|
||||
${BOLD}
|
||||
Usage: $0 ${BOLD}[OPTION]
|
||||
|
||||
Options:
|
||||
${BOLD} -h, --help${OFF}
|
||||
print this help, then exit
|
||||
${BOLD} --readme${OFF}
|
||||
print a small readme file, then exit
|
||||
${BOLD} -V, --version${OFF}
|
||||
print version number, then exit
|
||||
${BOLD} -d --directory DIR${OFF}
|
||||
use DIR directory for building HLFS; all files jhahlfs produces will be
|
||||
in the directory DIR/jhahlfs. Default is \"/mnt/lfs\".
|
||||
${BOLD} --rebuild${OFF}
|
||||
clean the build directory before to perfom any other task. The directory
|
||||
is cleaned only if it was populated by a previous jhahlfs run.
|
||||
${BOLD} -P, --get-packages${OFF}
|
||||
download the packages and patches. This assumes that the server declared in the
|
||||
jhahlfs.conf file has the proper packages and patches for the book version being
|
||||
processed.
|
||||
${BOLD} -D, --download-client CLIENT
|
||||
use CLIENT as the program for retrieving packages (use in conjunction with -P)
|
||||
${BOLD} -W, --working-copy DIR${OFF}
|
||||
use the local working copy placed in DIR as the HLFS book
|
||||
${BOLD} -L, --HLFS-version VER${OFF}
|
||||
checkout VER version of the HLFS book. Supported versions at this time are:
|
||||
dev* | trunk | SVN aliases for Development HLFS
|
||||
${BOLD} --fstab FILE${OFF}
|
||||
use FILE as the /etc/fstab file for the HLFS system. If not specified,
|
||||
a default /etc/fstab file with dummy values is created.
|
||||
${BOLD} -C, --kernel-config FILE${OFF}
|
||||
use the kernel configuration file specified in FILE to build the kernel.
|
||||
if the file is not found, or if not specified, the kernel build is skipped.
|
||||
${BOLD} -M, --run-make${OFF}
|
||||
run make on the generated Makefile
|
||||
${DD_BORDER}
|
||||
-EOF-
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
blfs_usage() {
|
||||
'clear'
|
||||
cat <<- -EOF-
|
||||
${DD_BORDER}
|
||||
${BOLD}
|
||||
Usage: $0 ${BOLD}[OPTION]
|
||||
|
||||
Options:
|
||||
${BOLD} -h, --help${OFF}
|
||||
print this help, then exit
|
||||
|
||||
${BOLD} -V, --version${OFF}
|
||||
print version number, then exit
|
||||
|
||||
${BOLD} -B, --BLFS-version VER${OFF}
|
||||
checkout VER version of the BLFS book.
|
||||
If not set, the development version is used.
|
||||
|
||||
Supported versions at this time are:
|
||||
dev* | trunk | SVN aliases for Development BLFS
|
||||
|
||||
${BOLD} -W, --working-copy DIR${OFF}
|
||||
use the local working copy placed in DIR as the BLFS book
|
||||
|
||||
${BOLD} -D, --dependencies TYPE${OFF}
|
||||
add dependencies of type TYPE to the build tree.
|
||||
If not set, both required a recommended are used.
|
||||
|
||||
Possible values are:
|
||||
|
||||
required only required dependecies are used
|
||||
recommended both required a recommended dependencies are used
|
||||
optional all dependencies are used
|
||||
|
||||
${BOLD} -S, --server SERVER${OFF}
|
||||
set the FTP/HTTP server used as fallback to download the packages.
|
||||
If not specified, the one set in jhablfs.conf is used.
|
||||
|
||||
${BOLD} -T, --testsuites${OFF}
|
||||
add support to run the optional testsuites
|
||||
${DD_BORDER}
|
||||
-EOF-
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
_inline_doc="
|
||||
This script, ${PROGNAME}, strives to create an accurate makefile
|
||||
directly from the xml files used to generate the Hardened Linux From
|
||||
Scratch document.
|
||||
The usage of this script assumes you have read and are familiar with
|
||||
the book and therefore the configuration variables found in jhahlfs.conf
|
||||
will have meaning to you. There are a limited number of command line
|
||||
switches which, if used, will override the config file settings.
|
||||
|
||||
NOTES::
|
||||
*. The resulting Makefile takes considerable time to run to completion,
|
||||
lay in a supply of caffeine beverages.
|
||||
|
||||
*. It is recommended that you temporarily unpack your linux kernel and
|
||||
run <make menuconfig> and configure the kernal as per the book and save
|
||||
the resulting .config file.
|
||||
|
||||
*. Chapter07 contains numerous command files which require customizing
|
||||
before you start console, profile, hosts, network, fstab, kernel.
|
||||
"
|
||||
|
||||
version="
|
||||
${BOLD}\"${PROGNAME}\"${OFF} script module (development) \$Date$
|
||||
|
||||
Written by Jeremy Huntwork,
|
||||
Manuel Caneles Esparcia,
|
||||
George Boudreau
|
||||
|
||||
This program is published under the ${BOLD}Gnu General Public License, Version 2.${OFF}
|
||||
"
|
||||
|
||||
|
||||
no_empty_builddir() {
|
||||
'clear'
|
||||
cat <<- -EOF-
|
||||
${DD_BORDER}
|
||||
|
||||
${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
|
||||
Looks like the \$BUILDDIR directory contains subdirectories
|
||||
from a previous HLFS build.
|
||||
|
||||
Please format the partition mounted on \$BUILDDIR or set
|
||||
a different build directory before running jhahlfs.
|
||||
${OFF}
|
||||
${DD_BORDER}
|
||||
-EOF-
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
help="${nl_}Try '$0 --help' for more information."
|
||||
|
||||
|
||||
exit_missing_arg="\
|
||||
echo \"Option '\$1' requires an argument\" >&2
|
||||
echo \"\$help\" >&2
|
||||
exit 1"
|
||||
|
||||
no_dl_client="\
|
||||
echo \"Could not find a way to download the CLFS sources.\" >&2
|
||||
echo \"Attempting to continue.\" >&2"
|
||||
|
||||
HEADER="# This file is automatically generated by jhalfs
|
||||
# DO NOT EDIT THIS FILE MANUALLY
|
||||
#
|
||||
# Generated on `date \"+%F %X %Z\"`"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_target() { #
|
||||
#----------------------------------#
|
||||
local i=$1
|
||||
local PREV=$2
|
||||
(
|
||||
cat << EOF
|
||||
|
||||
$i: $PREV
|
||||
@\$(call echo_message, Building)
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_unpack() { #
|
||||
#----------------------------------#
|
||||
local FILE=$1
|
||||
(
|
||||
cat << EOF
|
||||
@\$(call unpack,$FILE)
|
||||
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
||||
|
||||
chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#=============================#
|
||||
wrt_unpack3() { # Unpack and set 'ROOT' var
|
||||
#=============================#
|
||||
local FILE=$1
|
||||
(
|
||||
cat << EOF
|
||||
@\$(call unpack3,$FILE)
|
||||
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
||||
|
||||
chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_unpack2() { #
|
||||
#----------------------------------#
|
||||
local FILE=$1
|
||||
(
|
||||
cat << EOF
|
||||
@\$(call unpack2,$FILE)
|
||||
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#=============================#
|
||||
wrt_unpack4() { # Unpack and set 'ROOT' var
|
||||
#=============================#
|
||||
local FILE=$1
|
||||
(
|
||||
cat << EOF
|
||||
@\$(call unpack4,$FILE)
|
||||
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_target_vars() { # Target vars for hlfs (cross-build method)
|
||||
#----------------------------------#
|
||||
(
|
||||
cat << EOF
|
||||
echo "export target=$(uname -m)-${TARGET}" >> envars && \\
|
||||
echo "export ldso=/lib/${LOADER}" >> envars
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_run_as_su() { #
|
||||
#----------------------------------#
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
(
|
||||
cat << EOF
|
||||
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
|
||||
su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\
|
||||
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#==================================#
|
||||
wrt_run_as_lfs() { # header to log file, execute script, footer to log file
|
||||
#==================================#
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
(
|
||||
cat << EOF
|
||||
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
|
||||
su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\
|
||||
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_run_as_root() { #
|
||||
#----------------------------------#
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
(
|
||||
cat << EOF
|
||||
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
|
||||
export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
|
||||
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#=============================#
|
||||
wrt_run_as_root2() { # Some scripts must be run as root..
|
||||
#=============================#
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
(
|
||||
cat << EOF
|
||||
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >logs/$this_script && \\
|
||||
source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
|
||||
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >>logs/$this_script
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_remove_build_dirs() { #
|
||||
#----------------------------------#
|
||||
local name=$1
|
||||
(
|
||||
cat << EOF
|
||||
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
||||
if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
|
||||
rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
||||
fi;
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_remove_build_dirs2() { #
|
||||
#----------------------------------#
|
||||
local name=$1
|
||||
(
|
||||
cat << EOF
|
||||
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
rm -r \$(SRC)/\$\$ROOT && \\
|
||||
if [ -e \$(SRC)/$name-build ]; then \\
|
||||
rm -r \$(SRC)/$name-build; \\
|
||||
fi;
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_run_as_chroot1() { #
|
||||
#----------------------------------#
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
(
|
||||
cat << EOF
|
||||
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
|
||||
\$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
|
||||
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_run_as_chroot2() { #
|
||||
#----------------------------------#
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
(
|
||||
cat << EOF
|
||||
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
|
||||
\$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
|
||||
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_copy_fstab() { #
|
||||
#----------------------------------#
|
||||
local i=$1
|
||||
(
|
||||
cat << EOF
|
||||
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$i && \\
|
||||
cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1 && \\
|
||||
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$i
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
#----------------------------------#
|
||||
wrt_copy_fstab2() { #
|
||||
#----------------------------------#
|
||||
local i=$1
|
||||
(
|
||||
cat << EOF
|
||||
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >logs/$i && \\
|
||||
cp -v $FSTAB /etc/fstab >>logs/$i 2>&1 && \\
|
||||
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >>logs/$i
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_export_timezone() { #
|
||||
#----------------------------------#
|
||||
echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_export_pagesize() { #
|
||||
#----------------------------------#
|
||||
echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_export_pkgdir() { #
|
||||
#----------------------------------#
|
||||
(
|
||||
cat << EOF
|
||||
@echo "export PKGDIR=\$(SRC)/binutils-build" > envars
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
run_make() {
|
||||
#----------------------------#
|
||||
# Test if make must be run.
|
||||
if [ "$RUNMAKE" = "1" ] ; then
|
||||
# Test to make sure we're running the build as root
|
||||
if [ "$UID" != "0" ] ; then
|
||||
echo "You must be logged in as root to successfully build LFS."
|
||||
exit 1
|
||||
fi
|
||||
# Build the system
|
||||
if [ -e $MKFILE ] ; then
|
||||
echo -ne "Building the LFS system...\n"
|
||||
cd $JHALFSDIR && make -f ${PROGNAME}-Makefile
|
||||
echo -ne "done\n"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
clean_builddir() {
|
||||
#----------------------------#
|
||||
# Test if the clean must be done.
|
||||
if [ "$CLEAN" = "1" ] ; then
|
||||
# Test to make sure we're running the clean as root
|
||||
if [ "$UID" != "0" ] ; then
|
||||
echo "You must be logged in as root to clean the build directory."
|
||||
exit 1
|
||||
fi
|
||||
# Test to make sure that the build directory was populated by jhalfs
|
||||
if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
||||
echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
||||
exit 1
|
||||
else
|
||||
# Clean the build directory
|
||||
echo -ne "Cleaning $BUILDDIR...\n"
|
||||
rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,usr,var}
|
||||
echo -ne "Cleaning $JHALFSDIR...\n"
|
||||
rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
|
||||
echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
|
||||
rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
||||
echo -ne "done\n"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#----------------------------#
|
||||
get_book() {
|
||||
#----------------------------#
|
||||
cd $JHALFSDIR
|
||||
|
||||
if [ -z $WC ] ; then
|
||||
# Check for Subversion instead of just letting the script hit 'svn' and fail.
|
||||
test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
||||
exit 1"
|
||||
echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
|
||||
|
||||
case $PROGNAME in
|
||||
lfs) svn_root="LFS" ;;
|
||||
hlfs) svn_root="HLFS" ;;
|
||||
clfs) svn_root="cross-lfs" ;;
|
||||
blfs) svn_root="BLFS" ;;
|
||||
*) echo "BOOK not defined in function <get_book>"
|
||||
exit 1 ;;
|
||||
esac
|
||||
# Grab a fresh LFS book if it's missing, otherwise, update it from the
|
||||
# repo. If we've already extracted the commands, move on to getting the
|
||||
# sources.
|
||||
if [ -d ${PROGNAME}-$LFSVRS ] ; then
|
||||
cd ${PROGNAME}-$LFSVRS
|
||||
if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/commands && \
|
||||
test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
|
||||
echo -ne "done\n"
|
||||
# Set the canonical book version
|
||||
cd $JHALFSDIR
|
||||
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
||||
get_sources
|
||||
else
|
||||
echo -ne "done\n"
|
||||
# Set the canonical book version
|
||||
cd $JHALFSDIR
|
||||
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
||||
extract_commands
|
||||
fi
|
||||
else
|
||||
case $LFSVRS in
|
||||
development)
|
||||
svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
||||
alphabetical)
|
||||
svn co $SVN/${svn_root}/branches/$LFSVRS/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
||||
esac
|
||||
echo -ne "done\n"
|
||||
# Set the canonical book version
|
||||
cd $JHALFSDIR
|
||||
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
||||
extract_commands
|
||||
fi
|
||||
else
|
||||
echo -ne "Using $BOOK as book's sources ...\n"
|
||||
# Set the canonical book version
|
||||
cd $JHALFSDIR
|
||||
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
||||
extract_commands
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
build_patches_file() { # Supply a suitably formated list of patches.
|
||||
#----------------------------#
|
||||
local saveIFS=$IFS
|
||||
|
||||
LOC_add_patches_entry() {
|
||||
for f in `grep "/$1-" patcheslist_.wget`; do
|
||||
basename $f | sed "s|${2}|\&${1}-version;|" >> patches
|
||||
done
|
||||
}
|
||||
|
||||
xsltproc --nonet \
|
||||
--xinclude \
|
||||
-o patcheslist_.wget \
|
||||
hlfs-patcheslist_.xsl \
|
||||
$BOOK/index.xml > /dev/null 2>&1
|
||||
|
||||
rm -f patches
|
||||
|
||||
IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
||||
for f in `cat packages`; do
|
||||
IFS=$saveIFS
|
||||
LOC_add_patches_entry \
|
||||
`echo $f | sed -e 's/-version//' \
|
||||
-e 's/-file.*//' \
|
||||
-e 's/"//g' \
|
||||
-e 's/uclibc/uClibc/'`
|
||||
done
|
||||
|
||||
# .... U G L Y .... what to do with the grsecurity patch to the kernel..
|
||||
for f in `grep "/grsecurity-" patcheslist_.wget`; do
|
||||
basename $f >> patches
|
||||
done
|
||||
|
||||
IFS=$saveIFS
|
||||
rm -f patcheslist_.wget
|
||||
}
|
||||
|
||||
|
||||
|
||||
#----------------------------#
|
||||
extract_commands() { #
|
||||
#----------------------------#
|
||||
# Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
||||
test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
||||
exit 1"
|
||||
|
||||
cd $JHALFSDIR
|
||||
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
||||
|
||||
# Start clean
|
||||
if [ -d commands ]; then
|
||||
rm -rf commands
|
||||
mkdir -v commands
|
||||
fi
|
||||
echo -n "Extracting commands..."
|
||||
|
||||
# Dump the commands in shell script form from the HLFS book.
|
||||
case ${PROGNAME} in
|
||||
clfs)
|
||||
echo "${tab_}Extracting commands for ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
||||
xsltproc --xinclude \
|
||||
--nonet \
|
||||
--output ./${PROGNAME}-commands/ \
|
||||
$BOOK/stylesheets/dump-commands.xsl $BOOK/$ARCH-index.xml
|
||||
;;
|
||||
hlfs)
|
||||
echo "${tab_}Extracting commands for ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS architecture"
|
||||
xsltproc --nonet \
|
||||
--xinclude \
|
||||
--stringparam model $MODEL \
|
||||
--stringparam testsuite $TEST \
|
||||
--stringparam toolchaintest $TOOLCHAINTEST \
|
||||
--stringparam vim-lang $VIMLANG \
|
||||
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
||||
;;
|
||||
lfs)
|
||||
echo "${tab_}Extracting commands for ${L_arrow}${BOLD}LFS${R_arrow} build"
|
||||
xsltproc --nonet \
|
||||
--xinclude \
|
||||
--stringparam testsuite $TEST \
|
||||
--stringparam toolchaintest $TOOLCHAINTEST \
|
||||
--stringparam vim-lang $VIMLANG \
|
||||
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
||||
;;
|
||||
blfs)
|
||||
echo "${tab_}Extracting commands for ${L_arrow}${BOLD}BLFS${R_arrow} build"
|
||||
xsltproc --nonet \
|
||||
--xinclude \
|
||||
--stringparam testsuite $TEST \
|
||||
--stringparam server $SERVER \
|
||||
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
||||
;;
|
||||
*) exit 1
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# Make the scripts executable.
|
||||
chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
||||
|
||||
# Grab the patches and package names.
|
||||
cd $JHALFSDIR
|
||||
for i in patches packages ; do rm -f $i ; done
|
||||
grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
|
||||
-e '/generic/d' >> packages
|
||||
|
||||
# Download the vim-lang package if it must be installed
|
||||
if [ "$VIMLANG" = "1" ] ; then
|
||||
echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
|
||||
fi
|
||||
echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
|
||||
|
||||
# There is no HLFS patches.ent file so we will create one.
|
||||
|
||||
case "${PROGNAME}" in
|
||||
hlfs) build_patches_file ;;
|
||||
clfs) ;;
|
||||
lfs) ;;
|
||||
blfs) ;;
|
||||
*) exit 1
|
||||
esac
|
||||
|
||||
|
||||
# Done. Moving on...
|
||||
echo -ne " ... done\n"
|
||||
get_sources
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
download() { # Download file, write name to MISSING_FILES.DMP if an error
|
||||
#----------------------------#
|
||||
cd $BUILDDIR/sources
|
||||
|
||||
# Hackish fix for the bash-doc, glibc-{linuxthreads,libidn} and
|
||||
# module-init-tools-testsuite packages that don't conform to
|
||||
# norms in the URL scheme.
|
||||
DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
|
||||
|
||||
# Find the md5 sum for this package.
|
||||
if [ $2 != MD5SUMS ] ; then
|
||||
set +e
|
||||
MD5=`grep " $2" MD5SUMS`
|
||||
if [ $? -ne 0 ]; then
|
||||
set -e
|
||||
echo "${RED}$2 not found in MD5SUMS${OFF}"
|
||||
echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP
|
||||
return
|
||||
fi
|
||||
set -e
|
||||
fi
|
||||
|
||||
if [ ! -f $2 ] ; then
|
||||
case $DL in
|
||||
wget ) wget $HTTP/$DIR/$2 ;;
|
||||
curl ) `curl -# $HTTP/$DIR/$2 -o $2` ;;
|
||||
* ) echo "$DL not supported at this time." ;;
|
||||
esac
|
||||
elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
|
||||
case $DL in
|
||||
wget ) wget -c $HTTP/$DIR/$2 ;;
|
||||
curl ) `curl -# -C - $HTTP/$DIR/$2 -o $2` ;;
|
||||
* ) echo "$DL not supported at this time." ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
|
||||
exit 1
|
||||
fi
|
||||
if [ $2 != MD5SUMS ] ; then
|
||||
echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
get_sources() {
|
||||
#----------------------------#
|
||||
|
||||
# Test if the packages must be downloaded
|
||||
if [ "$HPKG" = "1" ] ; then
|
||||
|
||||
# This variable is necessary to make sure the `cat $JHALFSDIR/packages`
|
||||
# separates each iteration by lines. It is necessary to have the second
|
||||
# ' on the next line.
|
||||
IFS='
|
||||
'
|
||||
|
||||
if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
||||
cd $BUILDDIR/sources
|
||||
if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
||||
if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
|
||||
|
||||
download "" MD5SUMS
|
||||
|
||||
# Iterate through each package and grab it, along with any patches it needs.
|
||||
for i in `cat $JHALFSDIR/packages` ; do
|
||||
PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'`
|
||||
|
||||
# There are some entities that aren't valid packages.
|
||||
if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" -o "$PKG" = "groff-patchlevel" ] ; then continue ; fi
|
||||
|
||||
VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
||||
case $PKG in
|
||||
tcl) FILE="$PKG$VRS-src.tar.bz2" ;;
|
||||
vim-lang) PKG="vim"
|
||||
FILE="vim-$VRS-lang.tar.bz2" ;;
|
||||
udev-config) PKG="udev"
|
||||
FILE="$VRS" ;;
|
||||
*) FILE="$PKG-$VRS.tar.bz2" ;;
|
||||
esac
|
||||
download $PKG $FILE
|
||||
|
||||
# Download any associated patches
|
||||
for patch in `grep "&$PKG-version" $JHALFSDIR/patches` ; do
|
||||
PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
||||
download $PKG $PATCH
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
#-----------------------------------------------#
|
||||
_IS_() # Function to test build scripts names
|
||||
#-----------------------------------------------#
|
||||
{
|
||||
# Returns substr $2 or null str
|
||||
# Must use string testing
|
||||
case $1 in
|
||||
*$2*) echo "$2" ;;
|
||||
*) echo "" ;;
|
||||
esac
|
||||
}
|
49
common/config
Normal file
49
common/config
Normal file
|
@ -0,0 +1,49 @@
|
|||
#####
|
||||
#
|
||||
# Masterscript configuration file
|
||||
#
|
||||
#####
|
||||
|
||||
declare -r SVN="svn://svn.linuxfromscratch.org"
|
||||
declare -r LOG=000-masterscript.log
|
||||
|
||||
#--- Mount point for the build
|
||||
BUILDDIR=/mnt/SourceFiles
|
||||
|
||||
#--- Download the source packages 0(no)/1(yes)
|
||||
HPKG=0
|
||||
|
||||
#--- Run the makefile at the end 0(no)/1(yes)
|
||||
RUNMAKE=0
|
||||
|
||||
#--- Run test suites 0(no)/1(yes)
|
||||
TEST=1
|
||||
|
||||
#--- Run the toolchain tests 0(no)/1(yes)
|
||||
TOOLCHAINTEST=1
|
||||
|
||||
#--- Run the stripping phases 0(no)/1(yes)
|
||||
STRIP=1
|
||||
|
||||
#--- page definition for groff letter/A4
|
||||
PAGE=letter
|
||||
|
||||
#--- set default timezone.
|
||||
TIMEZONE=America/Toronto
|
||||
|
||||
#--- install the optional vim-lang package 0(no)/1(yes)
|
||||
VIMLANG=0
|
||||
|
||||
#--- Language information, /etc/profile see <locale -a> for values
|
||||
LC_ALL=en_CA
|
||||
LANG=en_CA
|
||||
|
||||
#--- Include the keymap in the kernel if defined
|
||||
KEYMAP=/usr/share/kbd/keymaps/i386/qwerty/us.map.gz
|
||||
|
||||
#==== INTERNAL VARIABLES ====
|
||||
# Don't edit it unless you know what you are doing
|
||||
|
||||
#--- Working directories
|
||||
JHALFSDIR=$BUILDDIR/jhalfs
|
||||
LOGDIR=$JHALFSDIR/logs
|
105
common/makefile-functions
Normal file
105
common/makefile-functions
Normal file
|
@ -0,0 +1,105 @@
|
|||
BOLD= "[0;1m"
|
||||
RED= "[1;31m"
|
||||
GREEN= "[0;32m"
|
||||
ORANGE= "[0;33m"
|
||||
BLUE= "[1;34m"
|
||||
WHITE= "[00m"
|
||||
|
||||
define echo_message
|
||||
@echo $(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo $(BOLD)$(1) target $(BLUE)$@$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------$(WHITE)
|
||||
endef
|
||||
|
||||
define unpack
|
||||
@if [ -f $(MOUNT_PT)$(SRC)/$(1).bz2 ] ; then \
|
||||
cd $(MOUNT_PT)$(SRC) ; tar -xvjf $(1).bz2 > /tmp/unpacked ; \
|
||||
else \
|
||||
cd $(MOUNT_PT)$(SRC) ; tar -xvzf $(1).gz > /tmp/unpacked ; \
|
||||
fi ;
|
||||
endef
|
||||
|
||||
define unpack2
|
||||
@cd $(MOUNT_PT)$(SRC) ; /tools/bin/tar -xvf $(1) > /tmp/unpacked
|
||||
endef
|
||||
|
||||
define unpack3
|
||||
@cd $(MOUNT_PT)$(SRC) ; tar -xvf $(1) > /tmp/unpacked
|
||||
endef
|
||||
|
||||
define unpack4
|
||||
@cd $(SRC) ; tar -xvf $(1) > /tmp/unpacked
|
||||
endef
|
||||
|
||||
define echo_finished
|
||||
@echo $(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo $(BOLD) Finished the build of $(BLUE)$(1)$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo -e \\t\\t$(RED)W A R N I N G$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo
|
||||
@echo To be able to boot your new LFS system you need to follow
|
||||
@echo the next steps:$(WHITE)
|
||||
@echo
|
||||
@echo -e \\t- Enter to the chroot using the command found
|
||||
@echo -e \\tin 8.4 Entering the Chroot Environment
|
||||
@echo
|
||||
@echo -e \\t- Set a password for the root user
|
||||
@echo
|
||||
@echo -e \\t- Edit /etc/fstab, /etc/hosts, /etc/sysconfig/clock,
|
||||
@echo -e \\t/etc/sysconfig/console, /etc/sysconfig/network,
|
||||
@echo -e \\t/etc/sysconfig//network-devices/ifconfig.eth0/ipv4 and
|
||||
@echo -e \\tany other configuration file required to suit your needs.
|
||||
@echo
|
||||
@echo -e \\t- Set-up Grub. See chapter08/grub.html
|
||||
@echo
|
||||
@echo -e \\t- Unmount the filesystems.
|
||||
@echo
|
||||
@echo If you are an experienced LFS user, several of those steps can be
|
||||
@echo skipped or done in a different way. But then, that is something
|
||||
@echo that you already know and there is no need to discuss it here.
|
||||
@echo $(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------$(WHITE)
|
||||
endef
|
||||
|
||||
define echo_boot_finished
|
||||
@echo $(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo $(BOLD) Finished building a minimal boot system for $(BLUE)$(1)$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo -e \\t\\t$(RED)W A R N I N G$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo
|
||||
@echo The build is not complete. Follow the next steps:$(WHITE)
|
||||
@echo
|
||||
@echo -e \\t- Enter to the chroot using the command found
|
||||
@echo -e \\tin 8.4 Entering the Chroot Environment
|
||||
@echo
|
||||
@echo -e \\t- Set a password for the root user
|
||||
@echo
|
||||
@echo -e \\t- Edit /etc/fstab, /etc/hosts, /etc/sysconfig/clock,
|
||||
@echo -e \\t/etc/sysconfig/console, /etc/sysconfig/network,
|
||||
@echo -e \\t/etc/sysconfig//network-devices/ifconfig.eth0/ipv4 and
|
||||
@echo -e \\tany other configuration file required to suit your needs.
|
||||
@echo
|
||||
@echo -e \\t- Set-up Grub.
|
||||
@echo
|
||||
@echo -e \\t- Unmount the filesystems.
|
||||
@echo
|
||||
@echo If you are an experienced LFS user, several of those steps can be
|
||||
@echo skipped or done in a different way. But then, that is something
|
||||
@echo that you already know and there is no need to discuss it here.
|
||||
@echo $(BOLD)
|
||||
@echo $(BOLD)$(YELLOW)
|
||||
@echo Boot the new partition. Once you are logged in issue the following cmds
|
||||
@echo -e \\t cd /jhahlfs
|
||||
@echo -e \\t make XXXXXXXX
|
||||
@echo The build process should resume. Follow any instructions that appear.
|
||||
@echo --------------------------------------------------------------------------------
|
||||
@echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD)
|
||||
@echo --------------------------------------------------------------------------------$(WHITE)
|
||||
endef
|
1
hlfs
Symbolic link
1
hlfs
Symbolic link
|
@ -0,0 +1 @@
|
|||
master.sh
|
1
lfs
Symbolic link
1
lfs
Symbolic link
|
@ -0,0 +1 @@
|
|||
master.sh
|
457
master.sh
Executable file
457
master.sh
Executable file
|
@ -0,0 +1,457 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
|
||||
#>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
|
||||
#-----------------------#
|
||||
simple_error() { # Basic error trap.... JUST DIE
|
||||
#-----------------------#
|
||||
# If +e then disable text output
|
||||
if [[ "$-" =~ "e" ]]; then
|
||||
echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
see_ya() {
|
||||
echo -e "\n\t${BOLD}Goodbye and thank you for choosing ${L_arrow}JHALFS${R_arrow}\n"
|
||||
}
|
||||
##### Simple error TRAPS
|
||||
# ctrl-c SIGINT
|
||||
# ctrl-y
|
||||
# ctrl-z SIGTSTP
|
||||
# SIGHUP 1 HANGUP
|
||||
# SIGINT 2 INTRERRUPT FROM KEYBOARD Ctrl-C
|
||||
# SIGQUIT 3
|
||||
# SIGKILL 9 KILL
|
||||
# SIGTERM 15 TERMINATION
|
||||
# SIGSTOP 17,18,23 STOP THE PROCESS
|
||||
#####
|
||||
set -e
|
||||
trap see_ya 0
|
||||
trap simple_error ERR
|
||||
trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
|
||||
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
||||
PROGNAME=$(basename $0)
|
||||
VERSION="0.0.1"
|
||||
MODULE=$PROGNAME.module
|
||||
MODULE_CONFIG=$PROGNAME.conf
|
||||
|
||||
echo -n "Loading common-func.module..."
|
||||
source common-func.module
|
||||
[[ $? > 0 ]] && echo "common-func.module did not load.." && exit
|
||||
echo "OK"
|
||||
#
|
||||
|
||||
if [ ! -L $0 ] ; then
|
||||
echo "${nl_}${tab_}${BOLD}${RED}This script cannot be called directly: EXITING ${OFF}${nl_}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n "Loading masterscript.conf..."
|
||||
source masterscript.conf
|
||||
[[ $? > 0 ]] && echo "masterscript.conf did not load.." && exit
|
||||
echo "OK"
|
||||
#
|
||||
echo -n "Loading config module <$MODULE_CONFIG>..."
|
||||
source $MODULE_CONFIG
|
||||
[[ $? > 0 ]] && echo "$MODULE_CONFIG did not load.." && exit 1
|
||||
echo "OK"
|
||||
#
|
||||
echo -n "Loading code module <$MODULE>..."
|
||||
source $MODULE
|
||||
if [[ $? > 0 ]]; then
|
||||
echo "$MODULE did not load.."
|
||||
exit 2
|
||||
fi
|
||||
echo "OK"
|
||||
#
|
||||
echo "---------------${nl_}"
|
||||
|
||||
|
||||
#===========================================================
|
||||
# If the var BOOK contains something then, maybe, it points
|
||||
# to a working doc.. set WC=1, else 'null'
|
||||
#===========================================================
|
||||
WC=${BOOK:+1}
|
||||
#===========================================================
|
||||
|
||||
|
||||
#*******************************************************************#
|
||||
|
||||
|
||||
#----------------------------#
|
||||
check_requirements() { # Simple routine to validate gcc and kernel versions against requirements
|
||||
#----------------------------#
|
||||
# Minimum values acceptable
|
||||
# bash 3.0>
|
||||
# gcc 3.0>
|
||||
# kernel 2.6.2>
|
||||
|
||||
[[ $1 = "1" ]] && echo "${nl_}BASH: ${L_arrow}${BOLD}${BASH_VERSION}${R_arrow}"
|
||||
case $BASH_VERSION in
|
||||
[3-9].*) ;;
|
||||
*) 'clear'
|
||||
echo -e "
|
||||
$DD_BORDER
|
||||
\t\t${OFF}${RED}BASH version ${BOLD}${YELLOW}-->${WHITE} $BASH_VERSION ${YELLOW}<--${OFF}${RED} is too old.
|
||||
\t\t This script requires 3.0${OFF}${RED} or greater
|
||||
$DD_BORDER"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ $1 = "1" ]] && echo "GCC: ${L_arrow}${BOLD}`gcc -dumpversion`${R_arrow}"
|
||||
case `gcc -dumpversion` in
|
||||
[3-9].[0-9].* ) ;;
|
||||
*) 'clear'
|
||||
echo -e "
|
||||
$DD_BORDER
|
||||
\t\t${OFF}${RED}GCC version ${BOLD}${YELLOW}-->${WHITE} $(gcc -dumpversion) ${YELLOW}<--${OFF}${RED} is too old.
|
||||
\t\t This script requires ${BOLD}${WHITE}3.0${OFF}${RED} or greater
|
||||
$DD_BORDER"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
#
|
||||
# >>>> Check kernel version against the minimum acceptable level <<<<
|
||||
#
|
||||
[[ $1 = "1" ]] && echo "LINUX: ${L_arrow}${BOLD}`uname -r`${R_arrow}"
|
||||
|
||||
local IFS
|
||||
declare -i major minor revision change
|
||||
min_kernel_vers=2.6.2
|
||||
|
||||
IFS=".-" # Split up w.x.y.z as well as w.x.y-rc (catch release candidates)
|
||||
set -- $min_kernel_vers # set postional parameters to minimum ver values
|
||||
major=$1; minor=$2; revision=$3
|
||||
#
|
||||
set -- `uname -r` # Set postional parameters to user kernel version
|
||||
#Compare against minimum acceptable kernel version..
|
||||
(( $1 > major )) && return
|
||||
(( $1 == major )) && ((( $2 > minor )) ||
|
||||
((( $2 == minor )) && (( $3 >= revision )))) && return
|
||||
|
||||
# oops.. write error msg and die
|
||||
echo -e "
|
||||
$DD_BORDER
|
||||
\t\t${OFF}${RED}The kernel version ${BOLD}${YELLOW}-->${WHITE} $(uname -r) ${YELLOW}<--${OFF}${RED} is too old.
|
||||
\t\tThis script requires version ${BOLD}${WHITE}$min_kernel_vers${OFF}${RED} or greater
|
||||
$DD_BORDER"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
validate_config() { # Are the config values sane (within reason)
|
||||
#----------------------------#
|
||||
local -r lfs_PARAM_LIST="BUILDDIR HPKG TEST TOOLCHAINTEST STRIP VIMLANG PAGE RUNMAKE"
|
||||
local -r blfs_PARAM_LIST="BUILDDIR TEST DEPEND"
|
||||
local -r hlfs_PARAM_LIST="BUILDDIR HPKG MODEL TEST TOOLCHAINTEST STRIP VIMLANG PAGE GRSECURITY_HOST RUNMAKE TIMEZONE"
|
||||
local -r clfs_PARAM_LIST="ARCH BOOTMINIMAL RUNMAKE MKFILE"
|
||||
local -r global_PARAM_LIST="BUILDDIR HPKG RUNMAKE TEST TOOLCHAINTEST STRIP PAGE TIMEZONE VIMLANG"
|
||||
|
||||
local PARAM_LIST=
|
||||
|
||||
local -r ERROR_MSG='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid, ${nl_}check the config file ${BOLD}${GREEN}\<$PROGNAME.conf\>${OFF}'
|
||||
local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
||||
local config_param
|
||||
local validation_str
|
||||
|
||||
write_error_and_die() {
|
||||
echo -e "\n${DD_BORDER}"
|
||||
echo -e "`eval echo ${ERROR_MSG}`" >&2
|
||||
echo -e "${DD_BORDER}\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set +e
|
||||
for PARAM_GROUP in global_PARAM_LIST ${PROGNAME}_PARAM_LIST; do
|
||||
for config_param in ${!PARAM_GROUP}; do
|
||||
# This is a tricky little piece of code.. executes a cmd string.
|
||||
[[ $1 = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
|
||||
case $config_param in
|
||||
BUILDDIR) # We cannot have an <empty> or </> root mount point
|
||||
if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
|
||||
write_error_and_die
|
||||
fi
|
||||
continue ;;
|
||||
TIMEZONE) continue;;
|
||||
MKFILE) continue;;
|
||||
HPKG) validation_str="x0x x1x" ;;
|
||||
RUNMAKE) validation_str="x0x x1x" ;;
|
||||
TEST) validation_str="x0x x1x" ;;
|
||||
STRIP) validation_str="x0x x1x" ;;
|
||||
VIMLANG) validation_str="x0x x1x" ;;
|
||||
DEPEND) validation_str="x0x x1x x2x" ;;
|
||||
MODEL) validation_str="xglibcx xuclibcx" ;;
|
||||
PAGE) validation_str="xletterx xA4x" ;;
|
||||
ARCH) validation_str="xx86x xx86_64x xx86_64-64x xsparcx xsparcv8x xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xalphax" ;;
|
||||
TOOLCHAINTEST) validation_str="x0x x1x" ;;
|
||||
GRSECURITY_HOST) validation_str="x0x x1x" ;;
|
||||
BOOTMINIMAL) validation_str="x0x x1x";;
|
||||
*)
|
||||
echo "WHAT PARAMETER IS THIS.. <<${config_param}>>"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
#
|
||||
# This is the 'regexp' test available in bash-3.0..
|
||||
# using it as a poor man's test for substring
|
||||
if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
|
||||
# parameter value entered is no good
|
||||
write_error_and_die
|
||||
fi
|
||||
done # for loop
|
||||
|
||||
# Not further tests needed on globals
|
||||
if [[ "$PARAM_GROUP" = "global_PARAM_LIST" ]]; then
|
||||
echo " ${BOLD}${GREEN}${PARAM_GROUP%%_*T} parameters are valid${OFF}"
|
||||
continue
|
||||
fi
|
||||
|
||||
for config_param in LC_ALL LANG; do
|
||||
[[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
||||
[[ -z "${!config_param}" ]] && continue
|
||||
# See it the locale values exist on this machine
|
||||
[[ "`locale -a | grep -c ${!config_param}`" > 0 ]] && continue
|
||||
|
||||
# If you make it this far then there is a problem
|
||||
write_error_and_die
|
||||
done
|
||||
|
||||
for config_param in FSTAB CONFIG KEYMAP BOOK; do
|
||||
[[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
||||
if [[ $config_param = BOOK ]]; then
|
||||
[[ ! "${WC}" = 1 ]] && continue
|
||||
fi
|
||||
[[ -z "${!config_param}" ]] && continue
|
||||
[[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue
|
||||
|
||||
# If you make it this far then there is a problem
|
||||
write_error_and_die
|
||||
done
|
||||
echo " ${BOLD}${GREEN}${PARAM_GROUP%%_*T} parameters are valid${OFF}"
|
||||
done
|
||||
set -e
|
||||
echo "$tab_***${BOLD}${GREEN}Config parameters look good${OFF}***"
|
||||
}
|
||||
|
||||
|
||||
|
||||
###################################
|
||||
### MAIN ###
|
||||
###################################
|
||||
|
||||
# Evaluate any command line switches
|
||||
|
||||
while test $# -gt 0 ; do
|
||||
case $1 in
|
||||
--version | -V )
|
||||
clear
|
||||
echo "$version"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--help | -h )
|
||||
if [[ "$PROGNAME" = "blfs" ]]; then
|
||||
blfs_usage
|
||||
else
|
||||
usage
|
||||
fi
|
||||
;;
|
||||
|
||||
--LFS-version | -L )
|
||||
test $# = 1 && eval "$exit_missing_arg"
|
||||
shift
|
||||
case $1 in
|
||||
dev* | SVN | trunk )
|
||||
LFSVRS=development
|
||||
;;
|
||||
6.1.1 )
|
||||
echo "For stable 6.1.1 book, please use jhalfs-0.2."
|
||||
exit 0
|
||||
;;
|
||||
alpha*)
|
||||
LFSVRS=alphabetical
|
||||
;;
|
||||
* )
|
||||
echo "$1 is an unsupported version at this time."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
--directory | -d )
|
||||
test $# = 1 && eval "$exit_missing_arg"
|
||||
shift
|
||||
BUILDDIR=$1
|
||||
JHALFSDIR=$BUILDDIR/jhalfs
|
||||
LOGDIR=$JHALFSDIR/logs
|
||||
MKFILE=$JHALFSDIR/${PROGNAME}-Makefile
|
||||
;;
|
||||
|
||||
--rebuild ) CLEAN=1 ;;
|
||||
|
||||
--download-client | -D )
|
||||
echo "The download feature is temporarily disable.."
|
||||
exit
|
||||
test $# = 1 && eval "$exit_missing_arg"
|
||||
shift
|
||||
DL=$1
|
||||
;;
|
||||
|
||||
--working-copy | -W )
|
||||
test $# = 1 && eval "$exit_missing_arg"
|
||||
shift
|
||||
if [ -f $1/patches.ent ] ; then
|
||||
WC=1
|
||||
BOOK=$1
|
||||
else
|
||||
echo -e "\nLook like $1 isn't a supported working copy."
|
||||
echo -e "Verify your selection and the command line.\n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
--testsuites | -T ) TEST=1 ;;
|
||||
--get-packages | -P ) HPKG=1 ;;
|
||||
--run-make | -M ) RUNMAKE=1 ;;
|
||||
--no-toolchain-test ) TOOLCHAINTEST=0 ;;
|
||||
--no-strip ) STRIP=0 ;;
|
||||
--no-vim-lang ) VIMLANG=0 ;;
|
||||
|
||||
--page_size )
|
||||
test $# = 1 && eval "$exit_missing_arg"
|
||||
shift
|
||||
case $1 in
|
||||
letter | A4 )
|
||||
PAGE=$1
|
||||
;;
|
||||
* )
|
||||
echo "$1 isn't a supported page size."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
--timezone )
|
||||
test $# = 1 && eval "$exit_missing_arg"
|
||||
shift
|
||||
if [ -f /usr/share/zoneinfo/$1 ] ; then
|
||||
TIMEZONE=$1
|
||||
else
|
||||
echo -e "\nLooks like $1 isn't a valid timezone description."
|
||||
echo -e "Verify your selection and the command line.\n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
--fstab )
|
||||
test $# = 1 && eval "$exit_missing_arg"
|
||||
shift
|
||||
if [ -f $1 ] ; then
|
||||
FSTAB=$1
|
||||
else
|
||||
echo -e "\nFile $1 not found. Verify your command line.\n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
--kernel-config | -C )
|
||||
test $# = 1 && eval "$exit_missing_arg"
|
||||
shift
|
||||
if [ -f $1 ] ; then
|
||||
CONFIG=$1
|
||||
else
|
||||
echo -e "\nFile $1 not found. Verify your command line.\n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
* )
|
||||
if [[ "$PROGNAME" = "blfs" ]]; then
|
||||
blfs_usage
|
||||
else
|
||||
usage
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
# Prevents setting "-d /" by mistake.
|
||||
|
||||
if [ $BUILDDIR = / ] ; then
|
||||
echo -ne "\nThe root directory can't be used to build LFS.\n\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
|
||||
# and notify the user about that.
|
||||
|
||||
if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
|
||||
eval "$no_empty_builddir"
|
||||
fi
|
||||
|
||||
# If requested, clean the build directory
|
||||
clean_builddir
|
||||
|
||||
# Find the download client to use, if not already specified.
|
||||
|
||||
if [ -z $DL ] ; then
|
||||
if [ `type -p wget` ] ; then
|
||||
DL=wget
|
||||
elif [ `type -p curl` ] ; then
|
||||
DL=curl
|
||||
else
|
||||
eval "$no_dl_client"
|
||||
fi
|
||||
fi
|
||||
|
||||
#===================================================
|
||||
# Set the document location...
|
||||
# BOOK is either defined in
|
||||
# xxx.config
|
||||
# comand line
|
||||
# default
|
||||
# If set by conf file leave or cmd line leave it
|
||||
# alone otherwise load the default version
|
||||
#===================================================
|
||||
BOOK=${BOOK:=$PROGNAME-$LFSVRS}
|
||||
#===================================================
|
||||
|
||||
if [[ ! -d $JHALFSDIR ]]; then
|
||||
mkdir -pv $JHALFSDIR
|
||||
fi
|
||||
|
||||
if [[ "$PWD" != "$JHALFSDIR" ]]; then
|
||||
cp -v makefile-functions $JHALFSDIR/
|
||||
if [[ -n "$FILES" ]]; then
|
||||
cp -v $FILES $JHALFSDIR/
|
||||
fi
|
||||
sed 's,FAKEDIR,'$BOOK',' $XSL > $JHALFSDIR/${XSL}
|
||||
export XSL=$JHALFSDIR/${XSL}
|
||||
fi
|
||||
|
||||
if [[ ! -d $LOGDIR ]]; then
|
||||
mkdir -v $LOGDIR
|
||||
fi
|
||||
>$LOGDIR/$LOG
|
||||
echo "---------------${nl_}"
|
||||
|
||||
|
||||
# Check for minumum gcc and kernel versions
|
||||
check_requirements 1 # 0/1 0-do not display values.
|
||||
echo "---------------${nl_}"
|
||||
validate_config 1 # 0/1 0-do not display values
|
||||
echo "---------------${nl_}"
|
||||
get_book
|
||||
echo "---------------${nl_}"
|
||||
build_Makefile
|
||||
echo "---------------${nl_}"
|
||||
#run_make
|
||||
|
Reference in a new issue