New download code.

This commit is contained in:
Manuel Canales Esparcia 2006-04-30 19:42:10 +00:00
parent c03b616f0a
commit 15cad1689c
9 changed files with 118 additions and 360 deletions

View file

@ -5,7 +5,6 @@
# $Id$
#
#####
declare -r FTP=ftp://ftp.linuxfromscratch.org/pub/lfs/conglomeration
#--- Which target architecture you want to build for,
# used to select proper book and set TARGETS
@ -69,5 +68,3 @@ LFSVRS=development
#--- Name of the makefile
MKFILE=$JHALFSDIR/Makefile
#--- FTP/HTTP mirror used as fallback (full path)
SERVER=ftp://anduin.linuxfromscratch.org/LFS/conglomeration

View file

@ -5,7 +5,6 @@
# $Id$
#
#####
declare -r FTP=ftp://ftp.linuxfromscratch.org/pub/lfs/conglomeration
#--- Which library model to use uclibc/glibc
MODEL=glibc
@ -38,6 +37,3 @@ LFSVRS=development
#--- Name of the makefile
MKFILE=$JHALFSDIR/Makefile
#--- FTP/HTTP mirror used as fallback (full path)
SERVER=ftp://anduin.linuxfromscratch.org/HLFS/conglomeration

View file

@ -8,95 +8,6 @@ set -e # Enable error trapping
###################################
#----------------------------#
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/uclibc/uClibc/' `
#
# How to deal with orphan packages..??
#
VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
case "$PKG" in
"gcc" )
download $PKG "gcc-core-$VRS.tar.bz2"
download $PKG "gcc-g++-$VRS.tar.bz2"
if [ ! "$TEST" = "0" ] ; then
download $PKG "gcc-testsuite-$VRS.tar.bz2" ;
fi
;;
"glibc")
if [ "$MODEL" = "glibc" ] ; then
download $PKG "$PKG-$VRS.tar.bz2"
download $PKG "$PKG-libidn-$VRS.tar.bz2"
fi
;;
"tcl" )
FILE="$PKG$VRS-src.tar.bz2" ; download $PKG $FILE ;;
"uclibc" )
if [ "$MODEL" = "uclibc" ] ; then
download $PKG "$PKG-$VRS.tar.bz2"
fi
;;
"uClibc-locale" )
if [ "$MODEL" = "uclibc" ] ; then
FILE="$PKG-$VRS.tgz" ; PKG="uClibc"
download $PKG $FILE
# There can be no patches for this file
continue
fi
;;
"uClibc-patch" ) continue ;;
* )
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`
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
}
#----------------------------#
chapter3_Makefiles() { # Initialization of the system
#----------------------------#

View file

@ -5,7 +5,6 @@
# $Id$
#
#####
declare -r FTP=ftp://ftp.linuxfromscratch.org/pub/lfs/conglomeration
#--- Location of fstab file (if empty, a template is created)
FSTAB=
@ -32,6 +31,3 @@ LFSVRS=development
#--- Name of the makefile
MKFILE=$JHALFSDIR/Makefile
#--- FTP/HTTP mirror used as fallback (full path)
SERVER=ftp://anduin.linuxfromscratch.org/LFS/conglomeration

View file

@ -521,69 +521,9 @@ get_book() {
fi
}
#----------------------------#
build_patches_file() { # Supply a suitably formated list of patches.
#----------------------------#
local saveIFS=$IFS
local IFS
rm -f patches
LOC_add_patches_entry() {
for f in `grep "/$1-" patcheslist_.wget`; do
basename $f | sed "s|${2}|\&${1}-version;|" >> patches
done
}
case ${PROGNAME} in
hlfs)
echo -n "Creating the HLFS ${L_arrow}${BOLD}$MODEL${R_arrow} specific patches file"
xsltproc --nonet \
--xinclude \
--stringparam model $MODEL \
-o patcheslist_.wget \
patcheslist.xsl \
$BOOK/chapter04/patches.xml
#> /dev/null 2>&1
# .... 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
;;
clfs) # Pull out a list of arch specific patches
echo -n "Creating CLFS ${L_arrow}${BOLD}$ARCH${R_arrow} specific patches file"
xsltproc -xinclude \
-o patcheslist_.wget \
patcheslist.xsl \
$BOOK/materials/${ARCH}-chapter.xml
;;
*) return
esac
IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
for f in `cat packages`; do
IFS=$saveIFS # Restore the system defaults
LOC_add_patches_entry \
`echo $f | sed -e 's/-version//' \
-e 's/-file.*//' \
-e 's/"//g' \
-e 's/uclibc/uClibc/'`
done
rm -f patcheslist_.wget
echo " ...OK"
}
#----------------------------#
extract_commands() { #
#----------------------------#
local saveIFS=$IFS
# Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
@ -647,7 +587,7 @@ extract_commands() { #
--stringparam server $SERVER \
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
;;
*) exit 1
*) exit 1 ;;
esac
echo " ...OK"
@ -655,62 +595,14 @@ extract_commands() { #
# Make the scripts executable.
chmod -R +x $JHALFSDIR/${PROGNAME}-commands
# Grab the patches and package names.
for i in patches packages ; do
rm -f $i
done
#
# Create the packages file. We need it for proper Makefile creation
rm -f packages
case "${PROGNAME}" in
clfs)
################################
# A LOCAL function
# xx_.wget contains arch specific files but in URL format
# Build a file with only arch specific files.. small ugly..
LOC_add_packages_entry() {
local fileMATCH aFILE
# Deal with a non-standard format
if [[ "$1" = "clfs-bootscripts" ]]; then
set -- "bootscripts-cross-lfs" $2
fi
fileMATCH="/$1"
# format.. Filename-Version or FilenameVersion
for aFILE in `grep ${fileMATCH}-*[[:digit:]] packageslist_.wget`; do
# Block vim-x.x-lang file, will add it later based on config flag
if [[ ! "${aFILE}" =~ "vim-$2-lang" ]]; then
echo "$1-version \"$2\"" >> packages
fi
done
}
#################################
# We only want a list arch specific files..
# Unfortunately this script produces URL's which must be converted to a std format
echo -n "Creating CLFS ${L_arrow}${BOLD}${ARCH}${R_arrow} specific packages file"
xsltproc -xinclude \
-o packageslist_.wget \
packageslist.xsl \
$BOOK/materials/${ARCH}-chapter.xml
# This has the correct format but contains packages from every book
echo -n "Creating <${PROGNAME}> specific packages file"
grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
-e 's@">@"@' \
-e '/generic/d' > packages.tmp
# This variable is necessary to make sure the `cat $JHALFSDIR/packages`
# separates each iteration by lines.
# Modify the 'internal field separator' to break on 'LF' only
IFS=$'\x0A'
for f in `cat packages.tmp`; do
IFS=$saveIFS # Restore the system defaults
LOC_add_packages_entry \
`echo $f | sed -e 's/-version//' \
-e 's/-file.*//' \
-e 's/"//g'`
done
rm -f packageslist_.wget packages.tmp
-e '/generic/d' > packages
echo " ...OK"
;;
@ -727,150 +619,123 @@ extract_commands() { #
grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' \
-e 's@">@"@' \
-e '/generic/d' >> packages
echo `grep "glibc" packages | sed 's@glibc@glibc-libidn@'` >> packages
echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
echo " ...OK"
;;
esac
# Download the vim-lang package if it must be installed
if [ "$VIMLANG" = "1" ] && [ ! "$PROGNAME" = "hlfs" ] ; then
echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
fi
# Create the patches file
case "${PROGNAME}" in
hlfs)
build_patches_file ;;
clfs )
build_patches_file ;;
lfs)
grep "^<\!ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
;;
blfs) ;;
*) exit 1
esac
# Done. Moving on...
get_sources
}
#----------------------------#
download() { # Download file, write name to MISSING_FILES.DMP if an error
get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
#----------------------------#
cd $BUILDDIR/sources
local saveIFS=$IFS
local IFS line URL1 URL2 FILE MD5
# Hackish fix for the bash-doc, glibc-{linuxthreads,libidn}
# that don't conform to norms in the URL scheme.
DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
# Test if the packages must be downloaded
if [ "$GETPKG" = "1" ] ; then
[[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
cd $BUILDDIR/sources
[[ -f MD5SUMS ]] && rm MD5SUMS
[[ -f MD5SUMS-$VERSION ]] && rm MD5SUMS-$VERSION
[[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
[[ -f urls.lst ]] && rm urls.lst
# Download a fresh MD5SUMS file
wget $SERVER/pub/lfs/conglomeration/MD5SUMS
# Generate URLs file
create_urls
IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
for line in `cat urls.lst`; do
IFS=$saveIFS # Restore the system defaults
URL1=`echo $line | cut -d" " -f1` # Upstream URL
URL2=`echo $line | cut -d" " -f2` # Fallback URL
FILE=`basename $URL2` # File name
# If the file exists in the archive copy it to the $BUILDDIR/sources dir
# MD5SUM is assumed to be correct from previous download
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -f ${SRC_ARCHIVE}/$2 ]; then
cp ${SRC_ARCHIVE}/$2 .
echo "$2: -- ok"
return
[ -f ${SRC_ARCHIVE}/$FILE ]; then
cp ${SRC_ARCHIVE}/$FILE .
echo "$FILE: -- copied from $SRC_ARCHIVE"
fi
# Find the md5 sum for this package.
if [ $2 != MD5SUMS ] ; then
set +e
MD5=`grep " $2" MD5SUMS`
MD5=`grep " $FILE" 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
echo "${RED}$FILE not found in MD5SUMS${OFF}"
echo "$FILE not found in MD5SUMS" >> MISSING_FILES.DMP
fi
set -e
fi
if [ ! -f $2 ] ; then
case $DL in
wgetFTP ) wget --passive $FTP/$DIR/$2 ;;
wget ) wget $HTTP/$DIR/$2 ;;
curl ) `curl -# $FTP/$DIR/$2 -o $2` ;;
* ) echo "$DL not supported at this time." ;;
esac
if [ ! -f $FILE ] ; then
wget $URL1 || wget $URL2
elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
case $DL in
wgetFTP ) wget --passive -c $FTP/$DIR/$2 ;;
wget ) wget -c $HTTP/$DIR/$2 ;;
curl ) `curl -# -C - $FTP/$DIR/$2 -o $2` ;;
* ) echo "$DL not supported at this time." ;;
esac
wget -N $URL1 || wget -N $URL2
fi
if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
if ! echo "$MD5" | md5sum -c - ; then
exit 1
fi
if [ $2 != MD5SUMS ] ; then
echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
fi
# If we make it this far we should copy the freshly downloaded file
# Copy the freshly downloaded file
# to the source archive.
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -w ${SRC_ARCHIVE} ] &&
[ $2 != MD5SUMS ]; then
echo "Store file:<$2> in package archive"
cp -v $2 ${SRC_ARCHIVE}
[ ! -f ${SRC_ARCHIVE}/$FILE ] ; then
echo "Store file:<$FILE> in package archive"
cp -v $FILE ${SRC_ARCHIVE}
fi
done
fi
}
#----------------------------#
get_sources() {
create_urls() { #
#----------------------------#
cd $JHALFSDIR
# 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.
# Modify the 'internal field separator' to break on 'LF' only
IFS=$'\x0A'
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
if [ -f MISSING_FILES.DMP ] ; then rm MISSING_FILES.DMP ; 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" ] ; 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" ;;
case ${PROGNAME} in
clfs)
echo -n "Creating CLFS <${ARCH}> specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
-o $BUILDDIR/sources/urls.lst urls.xsl \
$BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
hlfs)
echo -n "Creating HLFS <${MODEL}> specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
--stringparam model $MODEL \
-o $BUILDDIR/sources/urls.lst urls.xsl \
$BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
lfs)
echo -n "Creating LFS specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
-o ../sources/urls.lst urls.xsl \
$BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
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
if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
echo -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n\n"
fi
fi
cd $BUILDDIR/sources
}

View file

@ -7,20 +7,25 @@
declare -r SVN="svn://svn.linuxfromscratch.org"
declare -r LOG=000-masterscript.log
declare -r HTTP=http://ftp.lfs-matrix.net/pub/lfs/conglomeration
#--- Mount point for the build
BUILDDIR=/mnt/build_dir
#=== Getting packages ===
#--- Download the source packages 0(no)/1(yes)
GETPKG=0
#--- The local repository for packages/file
# Used only if HPKG = 1
# Used only if GETPKG = 1
# Any missing file will be downloaded and archived here,
# if the user has the right priviledges.
SRC_ARCHIVE=$SRC_ARCHIVE
#--- Download the source packages 0(no)/1(yes)
HPKG=0
# --- Server used as fallback if the file isn't found in
# SRC_ARCHIVE and/or can't be dowloaded from upstream
SERVER=ftp://ftp.lfs-matrix.net
#=== Build options ===
#--- Run the makefile at the end 0(no)/1(yes)
# In BLFS the Makefile can't be run automatically
RUNMAKE=0

View file

@ -84,10 +84,10 @@ validate_config() { # Are the config values sane (within reason)
inline_doc
# First internal variables, then the ones that change the book's flavour, and lastly system configuration variables
local -r blfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG DEPEND TEST"
local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE MODEL GRSECURITY_HOST TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG KEYMAP PAGE TIMEZONE LANG LC_ALL"
local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE METHOD ARCH TARGET TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG KEYMAP VIMLANG PAGE TIMEZONE LANG"
local -r lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG VIMLANG PAGE TIMEZONE LANG"
local -r blfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG DEPEND TEST"
local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE MODEL GRSECURITY_HOST TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG KEYMAP PAGE TIMEZONE LANG LC_ALL"
local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE METHOD ARCH TARGET TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG KEYMAP VIMLANG PAGE TIMEZONE LANG"
local -r lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG VIMLANG PAGE TIMEZONE LANG"
local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
@ -177,7 +177,7 @@ inline_doc
TIMEZONE) echo -e "`eval echo $PARAM_VALS`" ;;
# Validate general parameters..
HPKG) validate_against_str "x0x x1x" ;;
GETPKG) validate_against_str "x0x x1x" ;;
RUNMAKE) validate_against_str "x0x x1x" ;;
REPORT) validate_against_str "x0x x1x"
if [[ "${!config_param}" = "1" ]]; then

View file

@ -44,7 +44,6 @@
<xsl:if test="not(contains(@url,'?'))">
<xsl:value-of select="@url"/>
</xsl:if>
<!-- Using a tab character as fields separator -->
<xsl:text> </xsl:text>
<xsl:value-of select="$server"/>
<xsl:text>/pub/lfs/conglomeration/</xsl:text>

View file

@ -148,7 +148,7 @@ while test $# -gt 0 ; do
esac
;;
--get-packages | -G ) HPKG=1 ;;
--get-packages | -G ) GETPKG=1 ;;
--help | -h ) usage | more && exit ;;
@ -411,18 +411,6 @@ while test $# -gt 0 ; do
shift
done
# 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
@ -491,6 +479,7 @@ if [[ "$PWD" != "$JHALFSDIR" ]]; then
popd 1> /dev/null
fi
[[ "$REPORT" = "1" ]] && cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
[[ "$GETPKG" = "1" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
export XSL=$JHALFSDIR/${XSL}
fi