Added BLFS framework.

This commit is contained in:
Manuel Canales Esparcia 2005-12-08 21:07:38 +00:00
parent 681f928c7f
commit 5bb78f0713
3 changed files with 381 additions and 1 deletions

View file

@ -10,6 +10,11 @@
<!-- 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>
@ -122,7 +127,9 @@
<xsl:text> || \&#xA;</xsl:text>
</xsl:when>
<xsl:when test="contains(string(),'MD5')">
<xsl:text>wget ftp://anduin.linuxfromscratch.org/BLFS/conglomeration/</xsl:text>
<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"/>

337
jhablfs Executable file
View file

@ -0,0 +1,337 @@
#!/bin/sh
#
# Load the configuration file
#
source jhablfs.conf
version="
jhablfs development \$Date: 2005-12-04 13:24:26 +0100 (dom, 04 dic 2005) $
Written by Jeremy Huntwork and Manuel Canales Esparcia.
This program is published under the \
Gnu General Public License, Version 2.
"
usage="\
Usage: $0 [OPTION]
Options:
-h, --help print this help, then exit
-V, --version print version number, then exit
-B, --BLFS-version VER checkout VER version of the BLFS book.
Supported versions at this time are:
dev* | trunk | SVN aliases for Development BLFS
-W, --working-copy DIR use the local working copy placed in DIR
as the BLFS book
-D, --dependencies TYPE 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
-S, --server the FTP/HTTP server used as fallback. If no
specified, the one set in jhablfs.conf is used.
-T, --testsuites add support to run the optional testsuites
"
help="\
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 BLFS sources.\" >&2
echo \"Attempting to continue.\" >&2"
HEADER="# This file is automatically generated by jhablfs
# EDIT THIS FILE MANUALLY TO SUIT YOUR NEEDS
#
# Generated on `date \"+%F %X %Z\"`"
###################################
### FUNCTIONS ###
###################################
#----------------------------#
get_book() {
#----------------------------#
# 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"
cd $JHABLFSDIR
if [ -z $WC ] ; then
echo -n "Downloading the BLFS Book, version $BLFSVRS... "
# Grab the BLFS book fresh if it's missing, otherwise, update it from the
# repo. If we've already extracted the commands, move on.
if [ -d blfs-$BLFSVRS ] ; then
cd blfs-$BLFSVRS
if LC_ALL=C svn up | grep -q At && test -d $JHABLFSDIR/commands ; then
echo -ne "done\n"
# Set the canonical book version
cd $JHABLFSDIR
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
else
echo -ne "done\n"
# Set the canonical book version
cd $JHABLFSDIR
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
extract_commands
fi
else
case $BLFSVRS in
development)
svn co $SVN/BLFS/trunk/BOOK blfs-$BLFSVRS >>$LOGDIR/$LOG 2>&1 ;;
esac
echo -ne "done\n"
# Set the canonical book version
cd $JHABLFSDIR
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 $JHABLFSDIR
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
extract_commands
fi
}
#----------------------------#
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 $JHABLFSDIR
# Start clean
if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands
echo -n "Extracting commands... "
# Dump the commands in shell script form from the BLFS book.
xsltproc --nonet --xinclude --stringparam testsuite $TEST \
--stringparam server $SERVER -o ./commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
# Make the scripts executable.
chmod -R +x $JHABLFSDIR/commands
# Done. Moving on...
echo -ne "done\n"
}
#----------------------------#
build_Makefile() {
#----------------------------#
echo -n "Creating Makefile... "
cd $JHABLFSDIR/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 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 )
i=config-gnome
;;
gnome/pre-install-config )
i=pre-intall-config-gnome
;;
kde/config )
i=config-kde
;;
kde/pre-install-config )
i=pre-intall-config-kde
;;
* )
i=`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
$i: $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/$i && \\
$JHABLFSDIR/commands/$file >>logs/$i 2>&1 && \\
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >>logs/$i
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"
}
###################################
### MAIN ###
###################################
# Evaluate any command line switches
while test $# -gt 0 ; do
case $1 in
--version | -V )
echo "$version"
exit 0
;;
--help | -h )
echo "$usage"
exit 0
;;
--BLFS-version | -B )
test $# = 1 && eval "$exit_missing_arg"
shift
case $1 in
dev* | SVN | trunk )
BLFSVRS=development
;;
* )
echo "$1 is an unsupported version at this time."
exit 1
;;
esac
;;
--working-copy | -W )
test $# = 1 && eval "$exit_missing_arg"
shift
if [ -f $1/use-unzip.xml ] ; then
WC=1
BOOK=$1
else
echo -e "\nLook like $1 isn't a proper BLFS working copy."
echo -e "Verify your selection and the command line.\n"
exit 1
fi
;;
--dependencies | -D )
test $# = 1 && eval "$exit_missing_arg"
shift
case $1 in
required )
DEPEND=0
;;
recommended )
DEPEND=1
;;
optional )
DEPEND=2
;;
* )
echo "$1 is not a proper dependencies type."
exit 1
;;
esac
;;
--testsuites | -T ) TEST=1 ;;
--server | -S )
test $# = 1 && eval "$exit_missing_arg"
shift
case $1 in
*conglomeration )
SERVER=$1
;;
* )
echo "$1 is not a proper path to the BLFS packages."
exit 1
;;
esac
;;
--all-dependencies | -D ) DEPEND=1 ;;
esac
shift
done
if [ -z $BOOK ] ; then
BOOK=blfs-$BLFSVRS
fi
[[ ! -d $JHABLFSDIR ]] && mkdir -pv $JHABLFSDIR
[[ "$PWD" != "$JHABLFSDIR" ]] && cp -v $FILES $JHABLFSDIR/
[[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR
>$LOGDIR/$LOG
get_book
build_Makefile

36
jhablfs.conf Normal file
View file

@ -0,0 +1,36 @@
#####
#
# Configuration file for the jhablfs build script
#
#####
declare -r SVN="svn://svn.linuxfromscratch.org"
declare -r LOG=000-jhablfs.log
#--- Working directories
JHABLFSDIR=~/jhablfs
LOGDIR=$JHABLFSDIR/logs
MKFILE=$JHABLFSDIR/Makefile
#--- Book version
BLFSVRS=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
#--- Files that will be copied to $JHALFSDIR
FILES="functions dump-blfs-scripts.xsl"