Changeset 3660


Ignore:
Timestamp:
May 3, 2017, 11:27:10 AM (3 weeks ago)
Author:
bruno
Message:

Mutualize code in CopyFromConf? to reuse

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi/mindi

    r3653 r3660  
    26172617}
    26182618
     2619CopyFromConf() {
     2620
     2621    conf=$1
     2622    echo -en "INFO: Gathering dependencies of $conf.conf..."
     2623    lis2=`grep -Ev '^#' $DEPLIST_DIR/$conf.conf | sort -u`
     2624    noof_lines=`echo $lis2 | wc -w`
     2625    progress=0
     2626    lis=""
     2627    # Get only the files which exist in that list
     2628    # and potentially their symlink structure
     2629    for f in $lis2; do
     2630        if [ -d $f ]; then
     2631            for g in `find $f`; do
     2632                echo $g >> $MINDI_TMP/$conf.lis
     2633                LocateDeps $g  >> $MINDI_TMP/$conf.lis2
     2634            done
     2635            lis3="$lis3 $f"
     2636        else
     2637            if [ -r $f ]; then
     2638                echo $f >> $MINDI_TMP/$conf.lis
     2639                LocateDeps $f >> $MINDI_TMP/$conf.lis2
     2640            fi
     2641        fi
     2642        progress=$(($progress+1))
     2643        LogProgress $progress $noof_lines
     2644    done
     2645    echo -e "$DONE"
     2646    echo -en "INFO: Processing all dependencies links..."
     2647    # And their deps
     2648    lines=`sort -u $MINDI_TMP/$conf.lis $MINDI_TMP/$conf2.lis2`
     2649    noof_lines=`echo $lines | wc -w`
     2650    progress=0
     2651    for f in $lines; do
     2652        mr-read-all-link $f >> $MINDI_TMP/$conf.lis
     2653        if [ "`echo $f | cut -c1`" = "/" ]; then
     2654            j=`echo $f | cut -c2-`
     2655            [ "$j" != "" ] && rm -f $mountpoint/$j
     2656        fi
     2657        progress=$(($progress+1))
     2658        LogProgress $progress $noof_line
     2659    done
     2660    echo -e "$DONE"
     2661    finallist=""
     2662    # Remove directories from the list, as tar/cp will create them anyway
     2663    # and it may hurt if /lib is in it as on Debian/Ubuntu
     2664    # recent bash says that -d is true for a link to a dir !
     2665    for f in `sort -u $MINDI_TMP/$conf.lis`; do
     2666        if [ -e "$f" -a ! -d "$f" ] || [ -h "$f" ]; then
     2667            # Do not overwrite files already in destination (avoid using option -n of cp not portable)
     2668            if [ ! -e "$mountpoint/$f" ]; then
     2669                finallist="$finallist $f"
     2670            fi
     2671        fi
     2672    done
     2673    # But adds the directory useful in $lis3
     2674    fnllist=`echo $finallist | tr ' ' '\n' | sort -u | tr '\n' ' '`
     2675    LogFile "INFO: Copying $conf related files with cp -a --parents $fnllist $lis3 -t $mountpoint/"
     2676    cp -a --parents $fnllist $lis3 -t $mountpoint/ 2> $templog  || LogAll "WARNING: Problem in $conf analysis" $templog
     2677    rm -f $MINDI_TMP/$conf.lis $MINDI_TMP/$conf.lis2
     2678}
    26192679
    26202680MakeBootInitFile() {
     
    26982758
    26992759    # Copy of files from the minimal env needed as per the deplist.d/minimal.conf (which includes all busybox deps)
    2700     echo -en "INFO: Gathering dependencies of required files..."
    2701     rm -f $MINDI_TMP/minimal.lis $MINDI_TMP/minimal2.lis
    2702     lines=`cat $DEPLIST_DIR/minimal.conf | grep -vE " *#.*|^#" | sort -u`
    2703     noof_lines=`echo $lines | wc -w`
    2704     progress=0
    2705     for f in $lines; do
    2706         if [ -d $f ]; then
    2707             for g in `find $f`; do
    2708                 echo $g >> $MINDI_TMP/minimal.lis
    2709                 LocateDeps $g  >> $MINDI_TMP/minimal2.lis
    2710             done
    2711         else
    2712             if [ -r $f ]; then
    2713                 echo $f >> $MINDI_TMP/minimal.lis
    2714                 LocateDeps $f >> $MINDI_TMP/minimal2.lis
    2715             fi
    2716         fi
    2717         progress=$(($progress+1))
    2718         LogProgress $progress $noof_lines
    2719     done
    2720     echo -e "$DONE"
    2721     echo -en "INFO: Processing all dependencies links..."
    2722     lines=`sort -u $MINDI_TMP/minimal.lis $MINDI_TMP/minimal2.lis`
    2723     noof_lines=`echo $lines | tr ' ' '\n' | wc -l`
    2724     progress=0
    2725     for f in $lines; do
    2726         mr-read-all-link $f >> $MINDI_TMP/minimal.lis
    2727         progress=$(($progress+1))
    2728         LogProgress $progress $noof_lines
    2729     done
    2730     echo -e "$DONE"
    2731     # Initial / are trucated by tar
    2732     finallist=""
    2733     # Remove directories from the list, as tar/cp will create them anyway
    2734     # and it may hurt if /lib is in it as on Debian/Ubuntu
    2735     # recent bash says that -d is true for a link to a dir !
    2736     for f in `sort -u $MINDI_TMP/minimal.lis`; do
    2737         if [ -e "$f" -a ! -d "$f" ] || [ -h $f ]; then
    2738             # Do not overwrite files already in destination (avoid using option -n of cp not portable)
    2739             if [ ! -e "$mountpoint/$f" ]; then
    2740                 finallist="$finallist $f"
    2741             fi
    2742         fi
    2743     done
    2744     rm -f $MINDI_TMP/minimal.lis $MINDI_TMP/minimal2.lis
    2745 
    2746     fnllist=`echo $finallist | tr ' ' '\n' | sort -u | tr '\n' ' '`
    2747     LogFile "INFO: Copy the minimal env with cp -a --parents $fnllist -t $mountpoint"
    2748     cp -a --parents $fnllist -t $mountpoint 2> $templog || LogAll "WARNING: Problem in minimal analysis" $templog
     2760    CopyFromConf minimal
    27492761
    27502762    # In case target /bin dir still doesn't exist, create it before using it
     
    27872799        fi
    27882800        if [ -x /sbin/udevd ] || [ -x /usr/bin/udevd ] || [ -x /usr/lib/systemd/systemd-udevd ] || [ -x /lib/systemd/systemd-udevd ]; then
    2789             lis2=`grep -Ev '^#' $DEPLIST_DIR/udev.conf`
    2790             lis=""
    2791             # Get only the files which exist in that list
    2792             # and potentially their symlink structure
    2793             for i in $lis2; do
    2794                 if [ -h $i ]; then
    2795                     j=$i
    2796                     while [ -h $j ]; do
    2797                         lis="$lis $j"
    2798                         j=`readlink -f $j`
    2799                     done
    2800                     lis="$lis $j"
    2801                 elif [ -d $i ]; then
    2802                     lis3="$lis3 $i"
    2803                 elif [ -f $i ]; then
    2804                     lis="$lis $i"
    2805                 fi
    2806             done
    2807             # And their deps
    2808             LocateDeps $lis > $MINDI_TMP/udev.lis
    2809             for i in $lis; do
    2810                 if [ "`echo $i | cut -c1`" = "/" ]; then
    2811                     j=`echo $i | cut -c2-`
    2812                     [ "$j" != "" ] && rm -f $mountpoint/$j
    2813                 fi
    2814                 echo "$i" >> $MINDI_TMP/udev.lis
    2815             done
    2816             finallist=""
    2817             # Remove directories from the list, as tar/cp will create them anyway
    2818             # and it may hurt if /lib is in it as on Debian/Ubuntu
    2819             # recent bash says that -d is true for a link to a dir !
    2820             for f in `sort -u $MINDI_TMP/udev.lis`; do
    2821                 if [ -e "$f" -a ! -d "$f" ] || [ -h "$f" ]; then
    2822                     # Do not overwrite files already in destination (avoid using option -n of cp not portable)
    2823                     if [ ! -e "$mountpoint/$f" ]; then
    2824                         finallist="$finallist $f"
    2825                     fi
    2826                 fi
    2827             done
    2828             # But adds the directory useful for udev in $lis3
    2829             fnllist=`echo $finallist | tr ' ' '\n' | sort -u | tr '\n' ' '`
    2830             LogFile "INFO: Copying udev related files with cp -a --parents $fnllist -t $mountpoint/"
    2831             cp -a --parents $fnllist $lis3 -t $mountpoint/ 2> $templog  || LogAll "WARNING: Problem in udev.lis analysis" $templog
    2832             rm -f $MINDI_TMP/udev.lis
     2801            CopyFromConf udev
    28332802        else
    28342803            LogAll "WARNING: udevd daemon not in standard place (/sbin or /usr/bin)"
Note: See TracChangeset for help on using the changeset viewer.