#!/bin/bash # # generate_initcall.sh - Insert initcall into the "initcall_sequence" # file in correct sequence # # First arg is the initcall initcall=$1 # # Get dependency initcall list for this initcall from the dependency # database dependency_initcall_list=$( grep '^'$initcall'[ :]' dependency_list_database | \ sed 's,^.*:,,' ) # # function to find a missing initcall in initcall_sequence function find_missing_initcall() { need_initcall="" for name in $dependency_initcall_list do # test if initcall not done in initcall_sequence if [ "$(grep '^'$name'$' initcall_sequence)" = "" ] then # return needed initcall need_initcall=$name break fi done } # # generate missing initcalls that this initcall needs done first # find_missing_initcall while [ -n "$need_initcall" ] # loop while adding missing initcalls do generate_initcall.sh $need_initcall # NOTE THE RECURSIVE CALL find_missing_initcall done # # Finally add this initcall to initcall_sequence (if missing) if [ "$(grep '^'$initcall'$' initcall_sequence)" = "" ] then echo $initcall >> initcall_sequence fi