2006-05-23 20:38:23 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
set -e
|
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
declare -i cntr=0
|
|
|
|
declare -a spaceSTR=" "
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
generate_dependency_tree() { #
|
|
|
|
#----------------------------#
|
|
|
|
: <<inline_doc
|
|
|
|
function: Create a dependency tree for the TARGET
|
|
|
|
input vars: none
|
|
|
|
externals: vars: TARGET
|
|
|
|
PKGXML
|
|
|
|
DEP_LEVEL
|
|
|
|
func: do_dependencies
|
2006-05-25 00:47:56 +02:00
|
|
|
modifies: vars: PKGXML
|
2006-05-24 21:31:48 +02:00
|
|
|
BLFS_XML
|
|
|
|
returns: nothing
|
|
|
|
output: files: $TARGET.dep
|
|
|
|
$TARGET-index.xml.tmp
|
|
|
|
depure.txt
|
|
|
|
on error: nothing
|
|
|
|
on success: nothing
|
|
|
|
inline_doc
|
|
|
|
|
|
|
|
local ENTRY_START
|
|
|
|
local ENTRY_END
|
2006-05-25 00:47:56 +02:00
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
#---------------------
|
|
|
|
# Create the working directory and cd into it
|
2006-05-25 19:37:05 +02:00
|
|
|
if [[ -d $TARGET ]] ; then
|
|
|
|
echo -e "\tERROR: Looks like $TARGET has been already processed."
|
|
|
|
echo -e "\tPlease delete or rename the $TARGET directory.\n"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
mkdir $TARGET && cd $TARGET
|
|
|
|
fi
|
2006-05-24 21:31:48 +02:00
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# XML file of the target package
|
|
|
|
PKGXML=`grep "^$TARGET[[:space:]]" ../packages | cut -f2`
|
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# The BLFS sources directory.
|
|
|
|
BLFS_XML=`echo $PKGXML | sed -e 's,/.*,,'`
|
|
|
|
|
|
|
|
if [[ ! -d ../$BLFS_XML ]] ; then
|
|
|
|
echo -e "\tThe BLFS book sources directory is missing.\n"
|
|
|
|
echo -e "\tExecution aborted.\n"
|
|
|
|
cd .. && rmdir $TARGET
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# XInclude stuff
|
|
|
|
ENTRY_START="<xi:include xmlns:xi=\"http://www.w3.org/2003/XInclude\" href=\"../"
|
|
|
|
ENTRY_END="\"/>"
|
|
|
|
|
|
|
|
echo -en "\tGenerating $TARGET dependencies tree ..."
|
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# Create target package dependencies list
|
|
|
|
case $TARGET in
|
2006-05-27 14:16:14 +02:00
|
|
|
# Skip the creation when all dependencies are circular.
|
|
|
|
alsa-lib | cracklib | libexif | unixodbc ) ;;
|
2006-05-24 21:31:48 +02:00
|
|
|
# Meta-packages at target level
|
|
|
|
# KDE and Gnome-{core,full} could be made via packages.sh, but not sure yet how.
|
|
|
|
alsa ) # When target "alsa", use all alsa-* packages
|
2006-05-25 19:37:05 +02:00
|
|
|
mkdir dependencies
|
2006-05-24 21:31:48 +02:00
|
|
|
echo -e "alsa-oss\nalsa-firmware\nalsa-tools\nalsa-utils\n \
|
|
|
|
alsa-plugins\nalsa-lib" > dependencies/$TARGET.dep
|
|
|
|
;;
|
2006-05-25 19:37:05 +02:00
|
|
|
xorg7 ) # At atarget level, add also x-config and x-setup
|
|
|
|
mkdir dependencies
|
|
|
|
echo -e "x-config\nx-setup\nrman\nxterm2\nxorg7-driver\nxorg7-server\nluit\n \
|
|
|
|
xorg7-font\nxorg7-data\nxorg7-app\nxbitmaps\nmesalib\nlibdrm\n \
|
|
|
|
xorg7-lib\nxorg7-util\nxorg7-proto" > dependencies/$TARGET.dep
|
|
|
|
;;
|
2006-05-24 21:31:48 +02:00
|
|
|
* ) # Default
|
|
|
|
xsltproc --stringparam dependencies $DEP_LEVEL \
|
|
|
|
-o dependencies/$TARGET.dep \
|
2006-05-27 12:33:12 +02:00
|
|
|
../libs/dependencies.xsl ../$PKGXML
|
2006-05-24 21:31:48 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# Start with a clean $TARGET-index.xml.tmp file
|
|
|
|
> $TARGET-index.xml.tmp
|
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# Write the XInclude
|
2006-05-27 14:16:14 +02:00
|
|
|
case $TARGET in
|
|
|
|
# If there is no usefull XML page, skip it.
|
|
|
|
alsa | arts | gnome-core | gnome-full | kde-core | kde-full | kde-koffice ) ;;
|
|
|
|
* )
|
|
|
|
echo -e " $ENTRY_START$PKGXML$ENTRY_END" >> $TARGET-index.xml.tmp
|
|
|
|
;;
|
|
|
|
esac
|
2006-05-24 21:31:48 +02:00
|
|
|
|
|
|
|
#------------------P---
|
|
|
|
# Start with a clean depure.txt file
|
|
|
|
> depure.txt
|
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# If have dependencies, write its XInclude and find sub-dependencies
|
|
|
|
if [[ -f dependencies/$TARGET.dep ]]; then
|
|
|
|
echo -e "Start loop for PKG $TARGET\n" >> depure.txt
|
|
|
|
mkdir xincludes && do_dependencies $TARGET
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "done"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-23 20:38:23 +02:00
|
|
|
#-----------------------#
|
2006-05-24 21:31:48 +02:00
|
|
|
do_dependencies() { # Loop to find sub-dependencies :::WARNING::: THIS IS A RECURVISE FUNCTION
|
2006-05-23 20:38:23 +02:00
|
|
|
#-----------------------#
|
2006-05-24 21:31:48 +02:00
|
|
|
: <<inline_doc
|
|
|
|
function: Loop through all the packages and create a sub-dependency tree
|
|
|
|
input vars: $1, package name
|
|
|
|
externals: vars: $DEP_LEVEL
|
|
|
|
$TARGET
|
|
|
|
$PRINT_SERVER
|
|
|
|
$KBR5
|
|
|
|
$GHOSTSCRIPT
|
|
|
|
$MAILSERVER
|
|
|
|
file: depure.txt
|
|
|
|
$TARGET-index.xml.tmp
|
|
|
|
$PKG.dep
|
2006-05-25 00:47:56 +02:00
|
|
|
$PKG.inc
|
2006-05-24 21:31:48 +02:00
|
|
|
modifies: files
|
|
|
|
returns: nothing
|
|
|
|
output: file: $PKG-xinc.tmp
|
|
|
|
depure.txt
|
|
|
|
$TARGET-index.xml.tmp
|
|
|
|
on error: exit
|
2006-05-25 00:47:56 +02:00
|
|
|
on success:
|
2006-05-24 21:31:48 +02:00
|
|
|
inline_doc
|
|
|
|
|
2006-05-23 20:38:23 +02:00
|
|
|
set -e
|
|
|
|
local PKG=$1
|
|
|
|
local saveIFS=$IFS
|
|
|
|
local DEP_LV=$DEP_LEVEL
|
|
|
|
local line line2 DEP
|
|
|
|
echo -e "\tPKG is $PKG" >> depure.txt
|
|
|
|
echo -e "\tDEP_LEVEL for $PKG is $DEP_LV\n" >> depure.txt
|
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
#------------------
|
|
|
|
# If a premade xinclude file exists, use it. If not, create one
|
2006-05-23 20:38:23 +02:00
|
|
|
if [[ -f xincludes/$PKG.xinc ]] ; then
|
|
|
|
echo -e "\tReusing xinclude file for PKG $PKG" >> depure.txt
|
|
|
|
IFS=$'\x0A'
|
|
|
|
for line in `cat xincludes/$PKG.xinc` ; do
|
|
|
|
IFS=$saveIFS
|
|
|
|
# Remove the Xinclude entry if found. We want the most newer one.
|
|
|
|
# Using double quotes to let bash expand variables.
|
|
|
|
# Remove also the empty line created. Can not be done in one step
|
|
|
|
# due that d requires the pattner between /, but we have a lot of /
|
|
|
|
# inside the pattner.
|
|
|
|
sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
|
|
|
|
# Write the XInclude
|
|
|
|
echo -e "$line" >> $TARGET-index.xml.tmp
|
|
|
|
done
|
2006-05-24 21:31:48 +02:00
|
|
|
return
|
|
|
|
fi
|
2006-05-25 00:47:56 +02:00
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
#------------------
|
|
|
|
# Start with a clean $PKG.xinc.tmp file
|
|
|
|
> xincludes/$PKG.xinc.tmp
|
|
|
|
for DEP in `cat dependencies/$PKG.dep`; do
|
|
|
|
# Special packages (a lot of hacks)
|
|
|
|
case $DEP in
|
2006-05-25 00:47:56 +02:00
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
db ) # The proper version of DB is installed in LFS
|
2006-05-25 00:47:56 +02:00
|
|
|
continue ;;
|
2006-05-24 21:31:48 +02:00
|
|
|
hal-requirements ) # ID value don't have their own XML package file
|
|
|
|
continue ;;
|
|
|
|
perl-* | tk-perl ) DEP=perl-modules ;;
|
|
|
|
|
2006-05-23 20:38:23 +02:00
|
|
|
# Orphan links (proper link must be created when generating the book)
|
2006-05-27 14:16:14 +02:00
|
|
|
arts ) DEP=aRts ;;
|
2006-05-23 20:38:23 +02:00
|
|
|
# Set values for alternative packages
|
|
|
|
# X is a meta-package, thus handled in another way.
|
2006-05-24 21:31:48 +02:00
|
|
|
LPRng | cups ) DEP=$PRINT_SERVER ;;
|
|
|
|
mitkrb | heimdal ) DEP=$KBR5 ;;
|
|
|
|
gs | espgs ) DEP=$GHOSTSCRIPT ;;
|
2006-05-26 19:58:21 +02:00
|
|
|
server-mail ) DEP=$MAIL_SERVER ;;
|
2006-05-24 21:31:48 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
#------------------
|
|
|
|
echo -e "\tDEP for $PKG is $DEP" >> depure.txt
|
2006-05-27 14:16:14 +02:00
|
|
|
# Prevent circular dependencies
|
|
|
|
# If all dependencies are circular, the creation of the *.dep file
|
|
|
|
# must be skipped, not placed here, to avoid that the script will bomb
|
|
|
|
# due empty *.xinc files
|
2006-05-24 21:31:48 +02:00
|
|
|
case $DEP in
|
2006-05-25 00:47:56 +02:00
|
|
|
jadetex | perl-* | lynx | Links | w3m )
|
|
|
|
# Optional dependencies are runtime only
|
|
|
|
[[ "$PKG" = "docbook-utils" ]] && continue
|
|
|
|
;;
|
|
|
|
libxslt )
|
|
|
|
# libxml2-->libxslt-->libxml2
|
|
|
|
[[ "$PKG" = "libxml2" ]] && continue
|
|
|
|
;;
|
|
|
|
openldap | postgresql | $KBR5 )
|
|
|
|
# cyrus-sasl-->several-->cyrus-sasl
|
|
|
|
[[ "$PKG" = "cyrus-sasl" ]] && continue
|
|
|
|
;;
|
|
|
|
espgs )
|
|
|
|
# sendmail-->espgs-->cups-->php-->sendmail
|
2006-05-26 19:58:21 +02:00
|
|
|
[[ "$PKG" = "$MAIL_SERVER" ]] && continue
|
2006-05-25 00:47:56 +02:00
|
|
|
;;
|
|
|
|
aRts )
|
|
|
|
# esound-->aRts-->esound
|
|
|
|
[[ "$PKG" = "esound" ]] && continue
|
|
|
|
;;
|
2006-05-27 14:16:14 +02:00
|
|
|
gimp | sane )
|
|
|
|
# imagemagick-->{sane}-->gimp-->imagemagick
|
2006-05-25 00:47:56 +02:00
|
|
|
[[ "$PKG" = "imagemagick" ]] && continue
|
2006-05-24 21:31:48 +02:00
|
|
|
;;
|
2006-05-27 14:16:14 +02:00
|
|
|
ffmpeg )
|
|
|
|
# alsa-plugins-->ffmpeg-->several-->alsa-plugins
|
|
|
|
[[ "$PKG" = "alsa-plugins" ]] && continue
|
|
|
|
;;
|
2006-05-24 21:31:48 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
#------------------
|
|
|
|
echo -e "\tDEP_LEVEL for $DEP is $DEP_LV" >> depure.txt
|
|
|
|
# XML file of dependency package
|
|
|
|
DEP_XML=`grep "^$DEP[[:space:]]" ../packages | cut -f2`
|
|
|
|
echo -e "\t\tDEP_XML is $DEP_XML\n" >> depure.txt
|
|
|
|
case $DEP in
|
2006-05-27 14:16:14 +02:00
|
|
|
x-window-system | alsa ) ;; # No page for that (proper link must be created when generating the book)
|
2006-05-24 21:31:48 +02:00
|
|
|
xorg7 ) ;; # This page will be dump in the xorg7.xinc file
|
|
|
|
* )
|
|
|
|
# Remove the Xinclude entry if found
|
|
|
|
sed -e "s,^[[:space:]]*$ENTRY_START$DEP_XML$ENTRY_END,," \
|
|
|
|
-e '/./!d' -i xincludes/$PKG.xinc.tmp
|
|
|
|
# Write the XInclude
|
|
|
|
echo -e " $ENTRY_START$DEP_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
#------------------
|
|
|
|
# If not already created, create its dependencies list
|
|
|
|
if [[ ! -f dependencies/$DEP.dep ]] ; then
|
2006-05-23 20:38:23 +02:00
|
|
|
case $DEP in
|
2006-05-27 14:16:14 +02:00
|
|
|
# Skip the creation when all dependencies are circular.
|
|
|
|
alsa-lib | cracklib | libexif | unixodbc ) ;;
|
2006-05-24 21:31:48 +02:00
|
|
|
# Meta-packages at dependency level (ugly *.dep files, but work for now)
|
|
|
|
alsa ) # When dependency "alsa", use all alsa-* packages
|
|
|
|
echo -e "alsa-oss\nalsa-firmware\nalsa-tools\nalsa-utils\n \
|
|
|
|
alsa-plugins\nalsa-lib" > dependencies/$DEP.dep
|
|
|
|
;;
|
|
|
|
x-window-system ) # X11 alternatives
|
|
|
|
echo -e "x-config\nx-setup\n$X11" > dependencies/$DEP.dep
|
|
|
|
;;
|
2006-05-25 19:37:05 +02:00
|
|
|
xorg7 )
|
|
|
|
echo -e "rman\nxterm2\nxorg7-driver\nxorg7-server\nluit\nxorg7-font\n \
|
2006-05-24 21:31:48 +02:00
|
|
|
xorg7-data\nxorg7-app\nxbitmaps\nmesalib\nlibdrm\n \
|
|
|
|
xorg7-lib\nxorg7-util\nxorg7-proto" > dependencies/$DEP.dep
|
|
|
|
;;
|
|
|
|
* ) xsltproc --stringparam dependencies $DEP_LV \
|
2006-05-27 12:33:12 +02:00
|
|
|
-o dependencies/$DEP.dep ../libs/dependencies.xsl ../$DEP_XML
|
2006-05-23 20:38:23 +02:00
|
|
|
;;
|
|
|
|
esac
|
2006-05-24 21:31:48 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#------------------
|
|
|
|
# If needed, process its dependencies
|
|
|
|
if [[ -f dependencies/$DEP.dep ]] ; then
|
|
|
|
# If a premade xinclude file esist, include it
|
|
|
|
if [[ -f xincludes/$DEP.xinc ]] ; then
|
|
|
|
echo -e "\tReusing xinclude file for PKG $DEP (to solve $PKG)\n" >> depure.txt
|
|
|
|
IFS=$'\x0A'
|
|
|
|
for line2 in `cat xincludes/$DEP.xinc` ; do
|
|
|
|
IFS=$saveIFS
|
2006-05-23 20:38:23 +02:00
|
|
|
# Remove the Xinclude entry if found
|
2006-05-24 21:31:48 +02:00
|
|
|
sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
|
2006-05-23 20:38:23 +02:00
|
|
|
# Write the XInclude
|
2006-05-24 21:31:48 +02:00
|
|
|
echo -e "$line2" >> xincludes/$PKG.xinc.tmp
|
|
|
|
done
|
|
|
|
#------------------
|
|
|
|
# Create the xinclude file
|
|
|
|
else
|
|
|
|
echo -e "\nStart new loop for PKG $DEP (to solve $PKG)\n" >> depure.txt
|
|
|
|
#
|
|
|
|
# >>>>>> THIS IS A RECURSIVE FUNCTION CALL.. BEWARE OF GREMLINS. <<<<<<
|
|
|
|
#
|
|
|
|
# If the recursion depth is not too great this is an acceptable methodology for a script language
|
|
|
|
# However, uncontrolled recursion will cause a seg-fault due to stack issues with local variables.
|
2006-05-25 00:47:56 +02:00
|
|
|
#
|
2006-05-24 21:31:48 +02:00
|
|
|
set +e
|
|
|
|
[[ "${VERBOSITY}" > 0 ]] && echo -ne "\nrecursive call: $((++cntr)) ${spaceSTR:0:$cntr} ${RED}$DEP${OFF}"
|
|
|
|
do_dependencies $DEP
|
|
|
|
[[ "${VERBOSITY}" > 0 ]] && echo -ne "\nrecursive ret: $cntr ${spaceSTR:0:$((cntr--))} ${GREEN}$DEP${OFF}\tUsing the new xinclude file for PKG $DEP (to solve $PKG)"
|
|
|
|
set -e
|
2006-05-25 00:47:56 +02:00
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
# Include it when done
|
|
|
|
echo -e "\tUsing the new xinclude file for PKG $DEP (to solve $PKG)\n" >> depure.txt
|
|
|
|
IFS=$'\x0A'
|
|
|
|
for line2 in `cat xincludes/$DEP.xinc` ; do
|
|
|
|
IFS=$saveIFS
|
|
|
|
# Remove the Xinclude entry if found
|
|
|
|
sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
|
|
|
|
# Write the XInclude
|
|
|
|
echo -e "$line2" >> xincludes/$PKG.xinc.tmp
|
|
|
|
done
|
2006-05-23 20:38:23 +02:00
|
|
|
fi
|
|
|
|
fi
|
2006-05-24 21:31:48 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
#------------------
|
|
|
|
if [[ "$PKG" = "xorg7" ]] ; then
|
|
|
|
# Add their XInclude
|
|
|
|
PKG_XML=`grep "^$PKG[[:space:]]" ../packages | cut -f2`
|
|
|
|
echo -e " $ENTRY_START$PKG_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
|
2006-05-23 20:38:23 +02:00
|
|
|
fi
|
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
#------------------
|
|
|
|
mv xincludes/$PKG.xinc.tmp xincludes/$PKG.xinc
|
|
|
|
echo -e "Using the new xinclude file for PKG $PKG" >> depure.txt
|
|
|
|
IFS=$'\x0A'
|
|
|
|
for line in `cat xincludes/$PKG.xinc` ; do
|
|
|
|
IFS=$saveIFS
|
|
|
|
# Remove the Xinclude entry if found.
|
|
|
|
sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
|
|
|
|
# Write the XInclude
|
|
|
|
echo -e "$line" >> $TARGET-index.xml.tmp
|
|
|
|
done
|
|
|
|
|
|
|
|
echo -e "\nEnd loop for PKG $PKG\n" >> depure.txt
|
2006-05-23 20:38:23 +02:00
|
|
|
}
|