2006-08-24 22:38:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Read and parse the configuration parameters..
|
|
|
|
#
|
|
|
|
set -e
|
|
|
|
|
2021-12-16 13:50:33 +01:00
|
|
|
TRACKFILE=$1
|
|
|
|
if test -z "$TRACKFILE"; then
|
2021-12-19 14:24:04 +01:00
|
|
|
TRACKFILE=tracking-dir/instpkg.xml
|
2021-12-16 13:50:33 +01:00
|
|
|
fi
|
|
|
|
TOPDIR=$2
|
2013-10-29 16:42:03 +01:00
|
|
|
if test -z "$TOPDIR"; then
|
|
|
|
TOPDIR=$(pwd)
|
|
|
|
fi
|
2021-12-16 13:50:33 +01:00
|
|
|
BLFS_FULL=$3
|
2013-10-29 16:42:03 +01:00
|
|
|
if test -z "$BLFS_FULL"; then
|
|
|
|
BLFS_FULL=${TOPDIR}/blfs-xml/tmp/blfs-full.xml
|
|
|
|
fi
|
2021-12-16 13:50:33 +01:00
|
|
|
LFS_FULL=$4
|
2017-08-09 16:18:03 +02:00
|
|
|
if test -z "$LFS_FULL"; then
|
|
|
|
LFS_FULL=${TOPDIR}/lfs-xml/tmp/lfs-full.xml
|
|
|
|
fi
|
2013-10-29 16:42:03 +01:00
|
|
|
declare -r ConfigFile="${TOPDIR}/configuration"
|
|
|
|
declare DepDir="${TOPDIR}/dependencies"
|
|
|
|
declare LibDir="${TOPDIR}/libs"
|
|
|
|
declare PackFile="${TOPDIR}/packages.xml"
|
|
|
|
declare BookXml="${TOPDIR}/book.xml"
|
|
|
|
declare MakeBook="${TOPDIR}/xsl/make_book.xsl"
|
2021-12-12 18:39:03 +01:00
|
|
|
declare GetVersion="${TOPDIR}/xsl/get_version.xsl"
|
2013-10-29 16:42:03 +01:00
|
|
|
declare MakeScripts="${TOPDIR}/xsl/scripts.xsl"
|
|
|
|
declare BookHtml="${TOPDIR}/book-html"
|
|
|
|
declare BLFS_XML="${TOPDIR}/blfs-xml"
|
|
|
|
declare -a TARGET
|
2006-08-24 22:38:22 +02:00
|
|
|
declare DEP_LEVEL
|
|
|
|
declare SUDO
|
2018-09-28 16:35:46 +02:00
|
|
|
declare LANGUAGE
|
2017-04-09 12:29:32 +02:00
|
|
|
declare WRAP_INSTALL
|
2021-11-06 15:43:58 +01:00
|
|
|
declare PACK_INSTALL
|
2018-09-28 16:35:46 +02:00
|
|
|
declare DEL_LA_FILES
|
|
|
|
declare STATS
|
2021-11-06 15:43:58 +01:00
|
|
|
declare SRC_ARCHIVE
|
|
|
|
declare SRC_SUBDIRS
|
|
|
|
declare BUILD_ROOT
|
|
|
|
declare BUILD_SUBDIRS
|
|
|
|
declare KEEP_FILES
|
|
|
|
declare -i JOBS
|
|
|
|
declare CFG_CFLAGS
|
|
|
|
declare CFG_CXXFLAGS
|
|
|
|
declare CFG_LDFLAGS
|
2006-08-24 22:38:22 +02:00
|
|
|
|
|
|
|
#--------------------------#
|
|
|
|
parse_configuration() { #
|
|
|
|
#--------------------------#
|
2013-10-29 16:42:03 +01:00
|
|
|
local -i cntr=0
|
|
|
|
local -a optTARGET
|
2006-08-24 22:38:22 +02:00
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
while read; do
|
2006-08-24 22:38:22 +02:00
|
|
|
|
|
|
|
# Garbage collection
|
|
|
|
case ${REPLY} in
|
|
|
|
\#* | '') continue ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "${REPLY}" in
|
|
|
|
# Create global variables for these parameters.
|
|
|
|
optDependency=* | \
|
|
|
|
MAIL_SERVER=* | \
|
2017-04-09 12:29:32 +02:00
|
|
|
WRAP_INSTALL=* | \
|
2021-11-06 15:43:58 +01:00
|
|
|
PACK_INSTALL=* | \
|
2018-01-12 20:04:19 +01:00
|
|
|
DEL_LA_FILES=* | \
|
2018-02-05 19:12:17 +01:00
|
|
|
STATS=* | \
|
2018-09-28 16:35:46 +02:00
|
|
|
LANGUAGE=* | \
|
2021-11-06 15:43:58 +01:00
|
|
|
SUDO=* | \
|
|
|
|
SRC_ARCHIVE=* | \
|
|
|
|
SRC_SUBDIRS=* | \
|
|
|
|
BUILD_ROOT=* | \
|
|
|
|
BUILD_SUBDIRS=* | \
|
|
|
|
KEEP_FILES=* | \
|
|
|
|
JOBS=* | \
|
|
|
|
CFG_CFLAGS=* | \
|
|
|
|
CFG_CXXFLAGS=* | \
|
|
|
|
CFG_LDFLAGS=* ) eval ${REPLY} # Define/set a global variable..
|
2006-08-24 22:38:22 +02:00
|
|
|
continue ;;
|
|
|
|
esac
|
|
|
|
|
2006-10-24 04:49:37 +02:00
|
|
|
if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
|
2013-10-29 16:42:03 +01:00
|
|
|
echo "$REPLY"
|
|
|
|
optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
|
2006-08-24 22:38:22 +02:00
|
|
|
fi
|
2013-10-29 16:42:03 +01:00
|
|
|
done < $ConfigFile
|
2006-08-24 22:38:22 +02:00
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
if (( $cntr == 0 )); then
|
|
|
|
echo -e "\n>>> NO TARGET SELECTED.. application terminated"
|
|
|
|
echo -e " Run <make> again and select (a) package(s) to build\n"
|
2006-08-24 22:38:22 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
2013-10-29 16:42:03 +01:00
|
|
|
TARGET=(${optTARGET[*]})
|
2006-08-24 22:38:22 +02:00
|
|
|
DEP_LEVEL=$optDependency
|
|
|
|
SUDO=${SUDO:-n}
|
2017-04-09 12:29:32 +02:00
|
|
|
WRAP_INSTALL=${WRAP_INSTALL:-n}
|
2018-01-12 20:04:19 +01:00
|
|
|
DEL_LA_FILES=${DEL_LA_FILES:-n}
|
2018-02-05 19:12:17 +01:00
|
|
|
STATS=${STATS:-n}
|
2021-11-06 15:43:58 +01:00
|
|
|
# Other boolean variables are supposed to be either set or unset. Their values
|
|
|
|
# are not relevant
|
2006-08-24 22:38:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#--------------------------#
|
|
|
|
validate_configuration() { #
|
|
|
|
#--------------------------#
|
|
|
|
local -r dotSTR=".................."
|
2021-11-06 15:43:58 +01:00
|
|
|
local -r PARAM_LIST="DEP_LEVEL SUDO LANGUAGE MAIL_SERVER WRAP_INSTALL PACK_INSTALL DEL_LA_FILES STATS SRC_ARCHIVE SRC_SUBDIRS BUILD_ROOT BUILD_SUBDIRS KEEP_FILES JOBS CFG_CFLAGS CFG_CXXFLAGS CFG_LDFLAGS"
|
2006-08-24 22:38:22 +02:00
|
|
|
local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
|
|
|
local config_param
|
2013-10-29 16:42:03 +01:00
|
|
|
local -i index
|
2006-08-24 22:38:22 +02:00
|
|
|
|
|
|
|
for config_param in ${PARAM_LIST}; do
|
|
|
|
echo -e "`eval echo $PARAM_VALS`"
|
|
|
|
done
|
2013-10-29 16:42:03 +01:00
|
|
|
for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
|
|
|
|
echo -e "TARGET${index}${dotSTR:6} ${L_arrow}${BOLD}${TARGET[${index}]}${OFF}${R_arrow}"
|
|
|
|
done
|
2006-08-24 22:38:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2013-10-29 16:42:03 +01:00
|
|
|
# Generates the root of the dependency tree
|
2006-08-24 22:38:22 +02:00
|
|
|
#
|
|
|
|
#--------------------------#
|
2018-02-05 19:12:17 +01:00
|
|
|
generate_deps() { #
|
2006-08-24 22:38:22 +02:00
|
|
|
#--------------------------#
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
local -i index
|
|
|
|
local DepDir=$1
|
2018-01-28 18:56:55 +01:00
|
|
|
rm -f $DepDir/*.{tree,dep}
|
2013-10-29 16:42:03 +01:00
|
|
|
for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
|
2018-01-28 18:56:55 +01:00
|
|
|
echo 1 b ${TARGET[${index}]} >> $DepDir/root.dep
|
2006-08-24 22:38:22 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Clean configuration file keeping only global default settings.
|
|
|
|
# That prevent "trying to assign nonexistent symbol" messages
|
|
|
|
# and assures that there is no TARGET selected from a previous run
|
|
|
|
#
|
|
|
|
#--------------------------#
|
|
|
|
clean_configuration() { #
|
|
|
|
#--------------------------#
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
|
|
|
|
mv ${ConfigFile}.tmp ${ConfigFile}
|
2006-08-24 22:38:22 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# Constants
|
2013-10-29 16:42:03 +01:00
|
|
|
source ${LibDir}/constants.inc
|
2006-08-24 22:38:22 +02:00
|
|
|
[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
|
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# Dependencies module
|
2013-10-29 16:42:03 +01:00
|
|
|
source ${LibDir}/func_dependencies
|
2006-08-24 22:38:22 +02:00
|
|
|
[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
|
|
|
|
|
|
|
|
#------- MAIN --------
|
2013-10-29 16:42:03 +01:00
|
|
|
if [[ ! -f ${PackFile} ]] ; then
|
2006-08-24 22:38:22 +02:00
|
|
|
echo -e "\tNo packages file has been found.\n"
|
|
|
|
echo -e "\tExecution aborted.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
parse_configuration
|
|
|
|
validate_configuration
|
|
|
|
echo "${SD_BORDER}${nl_}"
|
|
|
|
echo -n "Are you happy with these settings? yes/no (no): "
|
|
|
|
read ANSWER
|
|
|
|
if [ x$ANSWER != "xyes" ] ; then
|
|
|
|
echo "${nl_}Rerun make and fix your settings.${nl_}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "${nl_}${SD_BORDER}${nl_}"
|
2013-10-29 16:42:03 +01:00
|
|
|
|
|
|
|
rm -rf $DepDir
|
|
|
|
mkdir $DepDir
|
|
|
|
generate_deps $DepDir
|
|
|
|
pushd $DepDir > /dev/null
|
|
|
|
set +e
|
2018-01-28 18:56:55 +01:00
|
|
|
generate_subgraph root.dep 1 1 b
|
|
|
|
echo -e "\n${SD_BORDER}"
|
|
|
|
echo Graph contains $(ls |wc -l) nodes
|
|
|
|
echo -e "${SD_BORDER}"
|
|
|
|
echo Cleaning subgraph...
|
|
|
|
clean_subgraph
|
|
|
|
echo done
|
|
|
|
echo Generating the tree
|
|
|
|
echo 1 > root.tree
|
|
|
|
echo 1 >> root.tree
|
|
|
|
cat root.dep >> root.tree
|
|
|
|
generate_dependency_tree root.tree 1
|
|
|
|
echo -e "\n${SD_BORDER}"
|
2021-12-12 18:39:03 +01:00
|
|
|
echo Generating the ordered full dependency list
|
|
|
|
FULL_LIST="$(tree_browse root.tree)"
|
|
|
|
set -e
|
|
|
|
popd > /dev/null
|
|
|
|
#echo "$FULL_LIST"
|
2018-01-28 18:56:55 +01:00
|
|
|
#echo -e \\n provisional end...
|
|
|
|
#exit
|
|
|
|
echo Generating the ordered package list
|
2021-12-12 18:39:03 +01:00
|
|
|
LIST=
|
|
|
|
while read p; do
|
2021-12-16 13:57:01 +01:00
|
|
|
if [ "$p" != "${p%-pass1}" ]; then
|
|
|
|
# If the pass2 is installed, no need for pass1. We get its
|
|
|
|
# installed version from TRACKFILE; We could use PackFile, but
|
|
|
|
# the test would be slightly more complicated.
|
|
|
|
echo Treating $p
|
|
|
|
pass2_v=$(xsltproc --stringparam package "${p%-pass1}" \
|
|
|
|
$GetVersion $TRACKFILE | head -n1)
|
|
|
|
echo Found pass2_v=$pass2_v
|
|
|
|
if [ -n "$pass2_v" ]; then continue; fi
|
|
|
|
# We need to get the installed version from TRACKFILE
|
|
|
|
inst_v=$(xsltproc --stringparam package "$p" $GetVersion $TRACKFILE | \
|
|
|
|
head -n1)
|
|
|
|
if [ -z "$inst_v" ]; then inst_v=0; fi
|
|
|
|
echo Found inst_v=$inst_v
|
|
|
|
# The available version is taken from PackFile
|
|
|
|
avail_v=$(xsltproc --stringparam package "${p%-pass1}" \
|
|
|
|
$GetVersion $PackFile | head -n1)
|
|
|
|
echo Found avail_v=$avail_v
|
|
|
|
versions="$avail_v
|
|
|
|
$inst_v"
|
|
|
|
echo which gives versions=$versions
|
|
|
|
else
|
|
|
|
versions=$(xsltproc --stringparam package "$p" $GetVersion $PackFile)
|
|
|
|
fi
|
2021-12-12 18:39:03 +01:00
|
|
|
if [ "$versions" != "$(sort -V <<<$versions)" ]; then
|
|
|
|
LIST="$LIST $p"
|
|
|
|
fi
|
|
|
|
done <<<$FULL_LIST
|
|
|
|
#echo \""$LIST"\"
|
|
|
|
#echo -e \\n provisional end...
|
|
|
|
#exit
|
2013-10-29 16:42:03 +01:00
|
|
|
rm -f ${BookXml}
|
|
|
|
echo Making XML book
|
2017-08-09 16:18:03 +02:00
|
|
|
xsltproc --stringparam list "$LIST" \
|
2018-01-28 18:56:55 +01:00
|
|
|
--stringparam MTA "$MAIL_SERVER" \
|
2017-08-09 16:18:03 +02:00
|
|
|
--stringparam lfsbook "$LFS_FULL" \
|
2013-10-29 16:42:03 +01:00
|
|
|
-o ${BookXml} \
|
|
|
|
${MakeBook} \
|
|
|
|
$BLFS_FULL
|
|
|
|
echo "making HTML book (may take some time...)"
|
|
|
|
xsltproc -o ${BookHtml}/ \
|
|
|
|
-stringparam chunk.quietly 1 \
|
|
|
|
${BLFS_XML}/stylesheets/blfs-chunked.xsl \
|
|
|
|
${BookXml}
|
|
|
|
if [ ! -d ${BookHtml}/stylesheets ]
|
|
|
|
then mkdir -p ${BookHtml}/stylesheets
|
|
|
|
cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
|
|
|
|
fi
|
|
|
|
if [ ! -d ${BookHtml}/images ]
|
|
|
|
then mkdir -p ${BookHtml}/images
|
|
|
|
cp ${BLFS_XML}/images/*.png ${BookHtml}/images
|
|
|
|
fi
|
|
|
|
for ht in ${BookHtml}/*.html
|
2014-11-17 21:46:38 +01:00
|
|
|
do sed -i 's@\.\./stylesheets@stylesheets@' $ht
|
|
|
|
sed -i 's@\.\./images@images@' $ht
|
2013-10-29 16:42:03 +01:00
|
|
|
done
|
|
|
|
echo -en "\n\tGenerating the build scripts ...\n"
|
|
|
|
rm -rf scripts
|
2018-02-05 19:12:17 +01:00
|
|
|
if test $STATS = y; then
|
|
|
|
LIST_STAT="${TARGET[*]}"
|
|
|
|
else
|
|
|
|
LIST_STAT=""
|
|
|
|
fi
|
2021-11-06 15:43:58 +01:00
|
|
|
xsltproc --xinclude --nonet \
|
|
|
|
--stringparam language "$LANGUAGE" \
|
|
|
|
--stringparam sudo "$SUDO" \
|
|
|
|
--stringparam wrap-install "$WRAP_INSTALL" \
|
|
|
|
--stringparam pack-install "$PACK_INSTALL" \
|
|
|
|
--stringparam del-la-files "$DEL_LA_FILES" \
|
|
|
|
--stringparam list-stat "$LIST_STAT" \
|
|
|
|
--stringparam src-archive "$SRC_ARCHIVE" \
|
|
|
|
--stringparam src-subdirs "$SRC_SUBDIRS" \
|
|
|
|
--stringparam build-root "$BUILD_ROOT" \
|
|
|
|
--stringparam build-subdirs "$BUILD_SUBDIRS" \
|
|
|
|
--stringparam keep-files "$KEEP_FILES" \
|
|
|
|
--param jobs "$JOBS" \
|
|
|
|
--stringparam cfg-cflags "$CFG_CFLAGS" \
|
|
|
|
--stringparam cfg-cxxflags "$CFG_CXXFLAGS" \
|
|
|
|
--stringparam cfg-ldflags "$CFG_LDFLAGS" \
|
|
|
|
--stringparam fqdn "$(hostname -f)" \
|
|
|
|
--output ./scripts/ \
|
|
|
|
${MakeScripts} \
|
2013-10-29 16:42:03 +01:00
|
|
|
${BookXml}
|
|
|
|
# Make the scripts executable.
|
|
|
|
chmod -R +x scripts
|
|
|
|
echo -e "done\n"
|
|
|
|
|
|
|
|
#clean_configuration
|