Changeset d7c07e0


Ignore:
Timestamp:
11/07/2015 11:36:11 AM (9 years ago)
Author:
Pierre Labastie <pierre@…>
Branches:
2.4, ablfs-more, legacy, new_features, trunk
Children:
5fb012d
Parents:
1670a20
Message:

Memorize answers for circular dependencies. Still, we need a way to
automaitcally answer when competition is between for example optional
and recommended dep.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BLFS/libs/func_dependencies

    r1670a20 rd7c07e0  
    2121# (building a subtree or browsing the tree), but it allows to               #
    2222# check whether a dependency is circular, and to find its parent.           #
     23# Circular dependencies:                                                    #
     24# In case we find a cirdular dependency, it has the form :                  #
     25# parent->dependency_0->...->dependency_n->dependency_0                     #
     26# If we want to build dependency_n before dependency_0, no problem:         #
     27# we just prune the tree at dependency_n. If we want to build first         #
     28# dependency_0, we need to put dependency_n as a dependency of parent,      #
     29# then erase and rebuild the subtree from there. Now, we may have met       #
     30# another circular dependency in the subtree, and erasing the tree makes    #
     31# us forget the decision which was made. So, after first generating the     #
     32# list of dependencies from packages.xml, we keep the generated list in     #
     33# a file <nodeName>.odep, which we modify according to the decision which   #
     34# was made.                                                                 #
    2335#---------------------------------------------------------------------------#
    2436
     
    2840declare -a exchange_triplet
    2941
    30 # In case we find a cirdular dependency, it has the form :
    31 # parent->dependency_0->...->dependency_n->dependency_0
    32 # If we want to build dependency_n before dependency_0,
    33 # no problem: we just prune the tree at dependency_n.
    34 # If we want to build first dependency_0, we need to
    35 # put dependency_n as a dependency of parent and build
    36 # the subtree from there. In this case, the triplet
    37 # above shall contain (parent dependency_0 dependency_n)
     42# When we are backing up from a circular dependency, `exchange_triplet'
     43# shall contain (parent dependency_0 dependency_n)
    3844
    3945#----------------------------#
     
    7581if (( $DEP_LEVEL > 2 )) && (( $depth > 1 )); then dep_level=2; fi
    7682srootlink="${rootlink[*]} "
    77 # start of Depfile
     83# start of DepFile
    7884echo -en "\nNode: $depth${spaceSTR:0:$depth}${RED}$DepFile${OFF}"
    7985
     
    112118        exchange_triplet=($parent $id_of_dep ${DepFile%.dep})
    113119        return 1
    114       else # no exchange: prune
     120      else # no exchange: prune and remove the line(s) from odep...
    115121        lines_to_remove="$lines_to_remove $id_of_dep"
     122        sed -i "/$id_of_dep/d" ${DepFile/.dep/.odep}
    116123      fi
    117124    else # not circular: prune
     
    127134  while [ $flag = true ]; do
    128135    flag=false
    129     xsltproc --stringparam dependencies ${dep_level} \
     136    if [ ! -f "${id_of_dep}.odep" ]; then
     137      xsltproc --stringparam dependencies ${dep_level} \
    130138        --stringparam idofdep $id_of_dep \
    131         -o ${id_of_dep}.dep \
     139        -o ${id_of_dep}.odep \
    132140        ../xsl/dependencies.xsl ../packages.xml
    133 
    134     if [[ -f ${id_of_dep}.dep ]]; then # this dependency has dependencies
    135       sed -i "1i${rootlink[*]} $count" ${id_of_dep}.dep # add the link
     141    fi
     142
     143# Use -s, because it may happen that after removing lines, .odep exists
     144# but is empty.
     145    if [[ -s ${id_of_dep}.odep ]]; then # this dependency has dependencies
     146      sed "1i${rootlink[*]} $count" < ${id_of_dep}.odep \
     147                                    > ${id_of_dep}.dep # add the link
    136148      generate_dependency_tree ${id_of_dep}.dep
    137149# Test return value, in case we exchange dependencies
     
    149161           lineno=$(sed -n /${id_of_dep}/= $DepFile | head -n1)
    150162           sed -i "${lineno}s@${id_of_dep}@${exchange_triplet[2]}@" $DepFile
     163# Do the same for the odep file:
     164           local OdepFile=${DepFile/.dep/.odep}
     165           lineno=$(sed -n /${id_of_dep}/= $OdepFile | head -n1)
     166           sed -i "${lineno}s@${id_of_dep}@${exchange_triplet[2]}@" $OdepFile
    151167           id_of_dep=${exchange_triplet[2]}
    152168           flag=true # we have to regenerate the tree for the new dependency
Note: See TracChangeset for help on using the changeset viewer.