Changeset 3801 in MondoRescue for branches/3.3/mindi


Ignore:
Timestamp:
Feb 16, 2024, 12:43:53 AM (4 months ago)
Author:
Bruno Cornec
Message:

Hopefully improve again commit hook

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi/mindi

    r3795 r3801  
    302302    local outdir incoming counter d found tdir templog
    303303    outdir=$1
    304     noof_lines=$2
    305     counter=$3
    306304    templog=$MINDI_TMP/$$.log
    307305    mkdir -p $outdir
    308306    incoming=`ReadLine`
     307    counter=$3
    309308    > $templog
    310309
    311310    while [ "$incoming" != "" ] ; do
    312         LogFile "DEBUG: Handling $incoming"
    313         if [ "$noof_lines" != "0" ]; then
     311        if [ "$3" = "1" ]; then
    314312            counter=$(($counter+1))
    315             LogProgress $counter $noof_lines
     313            LogProgress $counter $2
    316314        fi
    317315        # Non absolute file names should not arrive till here => skipped
    318316        if [ `echo "$incoming" | cut -c1` != '/' ]; then
    319             LogAll "WARNING: Unable to handle $incoming"
     317            LogFile "WARNING: Unable to handle non-full pathname $incoming"
    320318            incoming=`ReadLine`
    321319            continue
    322320        fi
    323         if [ -e "$incoming" ]; then
    324             LogFile "DEBUG: Adding $incoming"
    325             listfile="$listfile $incoming"
    326         fi
    327         incoming=`ReadLine`
    328     done
    329 
    330     LogAll "Creating mindi tar file"
    331     tar cf - -C / $listfile 2> $templog | (cd "$outdir" ; tar xf -) # || Die "Cannot copy $incoming to $outdir - did you run out of disk space?" $templog
    332 }
    333 
    334 bidon() {
    335 
    336321        # no parent directory of incoming should be a link, copy is not possible in that case
    337322        d=`dirname "$incoming"`
    338323        found="false"
    339324        while [ $d != "/" -a $found = "false" ]; do
    340             if [ -h "$d" ]; then
    341                 found="true"
    342                 LogFile "WARNING: skipping $d as link"
    343                 incoming=`ReadLine`
    344                 continue
    345             fi
     325            [ -h "$d" ] && found="true"
    346326            d=`dirname "$d"`
    347327        done
    348 
    349328        if [ -d "$incoming" -a ! -h "$incoming" ]; then
    350             LogFile "DEBUG: Finding in $incoming"
    351             find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir 0 0
     329            find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir 0 0
    352330        elif [ -e "$incoming" ] && [ $found = "false" ]; then
    353331            if [ ! -h "$incoming" ]; then
    354                 LogFile "DEBUG: Tarring $incoming"
    355332                tar cf - -C / $incoming 2> $templog | (cd "$outdir" ; tar xf -) || Die "Cannot copy $incoming to $outdir - did you run out of disk space?" $templog
    356333            else
    357                 LogFile "DEBUG: Copying $incoming"
    358334                tdir=`dirname "$incoming"`
    359335                if [ ! -e "$outdir/$tdir" ]; then
     
    364340            # Only uncompress modules if not using udevd
    365341            if [ "`echo "$incoming" | grep "lib/modules/.*\..*o\.gz"`" != "" ] && [ "`ps auxww | grep -v grep | grep -qw udevd`" != "" ]; then
    366                     gunzip -f $outdir/$incoming || LogAll "WARNING: Cannot gunzip $outdir/$incoming"
     342                gunzip -f $outdir/$incoming || LogAll "WARNING: Cannot gunzip $outdir/$incoming"
    367343            fi
    368344            [ -x "$outdir" ] && StripExecutable $outdir
    369345        fi
    370346        incoming=`ReadLine`
     347    done
    371348}
    372349
     
    379356    done
    380357    echo $r
     358}
     359
     360
     361DropOptimizedLibraries() {
     362    local outdir filelist list_of_optimized_libraries optimized_lib_name vanilla_lib_name reason msg resolved res
     363    filelist=$1
     364    outdir=$2
     365
     366    list_of_optimized_libraries=`grep "lib/i[5-7]86/" $filelist`
     367    if [ "$list_of_optimized_libraries" = "" ] ; then
     368        return 0
     369    fi
     370    echo -en "Dropping i686-optimized libraries if appropriate"
     371    for optimized_lib_name in $list_of_optimized_libraries ; do
     372        echo -en "."
     373        reason=""
     374        vanilla_lib_name=`echo "$optimized_lib_name" | sed -e 's/i[5-7]86//' -e 's/cmov//' -e 's/nosegneg//' | tr -s '/' '/'`
     375        echo "$vanilla_lib_name" >> $filelist
     376        LogFile "INFO: Adding $vanilla_lib_name to filelist"
     377        mkdir -p $outdir$optimized_lib_name > /dev/null 2> /dev/null
     378        rmdir $outdir$optimized_lib_name > /dev/null 2> /dev/null
     379
     380        # This may return multiple files
     381        for resolved in `mr-read-all-link $vanilla_lib_name`; do
     382            LogFile "INFO: Adding as deps $resolved to filelist"
     383            vanilla_resolved_name=`echo "$resolved" | sed -e 's/i[5-7]86//' -e 's/cmov//' -e 's/nosegneg//' | tr -s '/' '/'`
     384            if [ "$vanilla_resolved_name" != "$resolved" ]; then
     385                mkdir -p $outdir$resolved> /dev/null 2> /dev/null
     386                rmdir $outdir$resolved > /dev/null 2> /dev/null
     387                ln -sf $vanilla_resolved_name $outdir$resolved
     388                LogFile "INFO: Excluding deps $resolved"
     389                grep -Fvx "$resolved" "$filelist" > $filelist.tmp
     390                LogFile "INFO: Replacing it with $vanilla_resolved_name"
     391                echo "$vanilla_resolved_name" >> $filelist.tmp
     392                mv -f $filelist.tmp $filelist
     393            fi
     394        done
     395    done
     396    $AWK '{ print $1; }' $filelist | sort -u > $filelist.tmp
     397    mv -f $filelist.tmp $filelist
     398    echo -e "$DONE"
    381399}
    382400
     
    23322350
    23332351PrepareBigDir() {
    2334     local needlist diskdir res i j k lines lfiles includefile ti templog
     2352    local needlist diskdir res i j k lines lfiles includefile ti
    23352353
    23362354    rm -f $MINDI_CACHE/mindi.iso
    2337     mkdir -p $targetdir
    2338     templog=$MINDI_TMP/$$.log
    2339     needlist=$MINDI_TMP/kernel-modules.conf
    2340     mkdir -p $bigdir/usr/bin $bigdir/usr/sbin $bigdir/tmp
    2341     # Generated file
    2342     includefile=$MINDI_TMP/include-modules.conf
    2343 
    2344     lfiles=`ls $DEPLIST_DIR/* | grep -Ev '/minimal|/udev|/drbd'`
     2355    needlist=$MINDI_TMP/what-we-need.txt
     2356    mkdir -p $bigdir/usr/bin
     2357    mkdir -p $bigdir/usr/sbin
     2358    includefile=$MINDI_TMP/$$.includefile.txt
     2359
     2360    lfiles=`ls $DEPLIST_DIR/* | grep -v /minimal`
    23452361    if [ -e "$DEPLIST_FILE" ]; then
    23462362        lfiles="$DEPLIST_FILE $lfiles"
    23472363    fi
     2364    lines=`grep -vx " *#.*" $lfiles | grep -vx "" | wc -l`
    23482365    ParseModprobeForIncludes $includefile
    2349     ListKernelModulePaths > $needlist
    2350     for f in $lfiles $includefile $needlist; do
    2351         CopyFromConf $f $targetdir
    2352     done
     2366    lines=$(($lines+`cat $includefile | wc -l`))
     2367    cat $lfiles $includefile | GenerateGiantDependencyList $needlist $lines
     2368    res=$?
    23532369    rm -f $includefile
    2354 
     2370    ListKernelModulePaths >> $needlist
     2371    if [ "$res" -ne "0" ] ; then
     2372        Die "You have $res files present in dependency list\nbut absent from filesystem."
     2373    fi
     2374    mkdir -p $bigdir/tmp
    23552375    if [ _"$MONDO_SHARE" != _"" ]; then
    23562376        # TODO: no reason to have the cfg file stored twice
     
    23632383
    23642384    [ -d "/mnt/.boot.d" ] && echo "GENTOO" > $bigdir/tmp/DUMBASS-GENTOO
     2385    DropOptimizedLibraries $needlist $bigdir
     2386    echo -en "INFO: Assembling dependency files"
     2387
     2388    CopyDependenciesToDirectory < $needlist $bigdir `wc -l $needlist` 1
     2389    rm -f $needlist
     2390    echo -e "$DONE"
    23652391
    23662392    # also copy io.sys and msdos.sys, if we can find them
     
    23932419    done
    23942420    if [ -e "$MONDO_SHARE/restore-scripts" ]; then
    2395         mkdir -p $bigdir/usr/bin $bigdir/etc
    23962421        cp -Rdf $MONDO_SHARE/restore-scripts/mondo/* $bigdir/usr/bin 2>> $LOGFILE
    23972422        [ $? -ne 0 ] && [ _"$MONDO_SHARE" != _"" ] && Die "Cannot find/install $MONDO_SHARE/restore-scripts"
     
    24482473    PrepareBootDir
    24492474
    2450     LogFile "---------------------------"
    2451     LogFile "Content of initial bigdir:"
    2452     LogFile "---------------------------- "
    2453     (cd "$bigdir" ; ls -Rla ) >> $LOGFILE
    2454     LogFile "---------------------------"
    24552475}
    24562476
     
    26942714    conf=$1
    26952715    mp=$2
    2696     if [ ! -e $conf ]; then
    2697         # Invoked with a conf file short name fixing...
    2698         conf="$DEPLIST_DIR/$1.conf"
    2699     fi
    2700     if [ ! -e $conf ]; then
    2701         LogAll "Unable to find conf file $conf please report upstream"
    2702         return
    2703     fi
    2704     bconf=`basename $conf .conf`
    2705     echo -en "INFO: Gathering dependencies of $bconf..."
    2706     LogFile "INFO: Gathering dependencies of $conf..."
    2707     lis2=`grep -Ev '^#' $conf | sort -u`
     2716    echo -en "INFO: Gathering dependencies of $conf.conf..."
     2717    LogFile "INFO: Gathering dependencies of $conf.conf..."
     2718    lis2=`grep -Ev '^#' $DEPLIST_DIR/$conf.conf | sort -u`
    27082719    noof_lines=`echo $lis2 | wc -w`
    27092720    progress=0
    2710     LogFile "DEBUG: targetdir: `ls -l $mp/`"
    2711     LogFile "DEBUG: lis2=$lis2"
    27122721    # Get only the files which exist in that list
    27132722    # and potentially their symlink structure
    27142723    # put apart directories for later handling
    2715     touch $MINDI_TMP/$bconf.lis $MINDI_TMP/$bconf.lis2
    27162724    for f in $lis2; do
    27172725        if [ -d $f ]; then
    27182726            for g in `find $f`; do
    2719                 echo $g >> $MINDI_TMP/$bconf.lis
    2720                 LocateDeps $g  >> $MINDI_TMP/$bconf.lis2
     2727                echo $g >> $MINDI_TMP/$conf.lis
     2728                LocateDeps $g  >> $MINDI_TMP/$conf.lis2
    27212729            done
    27222730            lis3="$lis3 $f"
    27232731        else
    27242732            if [ -r $f ]; then
    2725                 echo $f >> $MINDI_TMP/$bconf.lis
    2726                 LocateDeps $f >> $MINDI_TMP/$bconf.lis2
     2733                echo $f >> $MINDI_TMP/$conf.lis
     2734                LocateDeps $f >> $MINDI_TMP/$conf.lis2
    27272735            fi
    27282736        fi
     
    27302738        LogProgress $progress $noof_lines
    27312739    done
    2732     LogFile "DEBUG: lis3=$lis3"
    2733     #LogAll "INFO: Processing all dependencies links for $conf..."
     2740    echo -e "$DONE"
     2741    LogAll "INFO: Processing all dependencies links for $conf.conf..."
    27342742    # And their deps except dirs
    2735     lines=`sort -u $MINDI_TMP/$bconf.lis $MINDI_TMP/$bconf.lis2`
    2736     rm -f $MINDI_TMP/$bconf.lis2
     2743    lines=`sort -u $MINDI_TMP/$conf.lis $MINDI_TMP/$conf.lis2`
     2744    rm -f $MINDI_TMP/$conf.lis2
    27372745    finallist=""
    27382746    # Remove directories from the list, as cp will create them anyway
     
    27402748    # recent bash says that -d is true for a link to a dir !
    27412749    for f in $lines; do
    2742         LogFile "DEBUG: f=$f"
    27432750        if [ -e "$f" -a ! -d "$f" ] || [ -h "$f" ]; then
    2744             LogFile "DEBUG: Test OK"
    27452751            # Do not overwrite files already in destination (avoid using option -n of cp not portable)
    27462752            if [ ! -e "$mp/$f" ]; then
    27472753                finallist="$finallist $f"
    2748                 LogFile "DEBUG: Creating $mp/$f"
    2749             else
    2750                 LogFile "DEBUG: Target exist `ls -al $mp/$f`"
    27512754            fi
    27522755        fi
    27532756    done
    2754     LogFile "DEBUG: finallist=$finallist"
    27552757    # But adds the directory useful in $lis3
    27562758    fnllist=`echo $finallist $lis3 | tr ' ' '\n' | sort -u | tr '\n' ' '`
    2757     echo -e "$DONE"
    2758     if [ _"$fnllist" != _"" ] && [ _"$fnllist" != _" " ]; then
    2759         LogFile "INFO: Copying $conf related files with cp -a --parents $fnllist -t $mp/"
    2760         cp -a --parents $fnllist -t $mp/ 2>$templog  || LogAll "WARNING: Problem in $conf analysis" $templog
    2761     fi
    2762     rm -f $MINDI_TMP/$bconf.lis
     2759    LogFile "INFO: Copying $conf related files with cp -a --parents $fnllist -t $mp/"
     2760    cp -a --parents $fnllist -t $mp/ 2> $templog  || LogAll "WARNING: Problem in $conf analysis" $templog
     2761    rm -f $MINDI_TMP/$conf.lis
    27632762}
    27642763
     
    27732772    > $templog
    27742773
     2774    mkdir -p $targetdir
    27752775    # Check whether /lib64 or /lib or /sbin or /bin is a link and if so explicitly create one in rootfs (Fedora 17 crazyness)
    27762776    for d in bin sbin lib lib64; do
     
    27782778            thelink=`readlink /$d`
    27792779            mkdir -p $targetdir/$thelink || LogAll "ERROR: Unable to create $thelink in $targetdir"
    2780             mv $targetdir/$d/* $targetdir/$d/.??* $targetdir/$thelink
     2780            mv $targetdir/$d/* $targetdir/$d/.??* $targetdir/$thelink 2> /dev/null
    27812781            if [ -d "$targetdir/$d" -a ! -h "$targetdir/$d" ]; then
    27822782                rmdir $targetdir/$d
     
    30303030
    30313031    mkdir -p $targetdir/proc
    3032     cp -a $MY_FSTAB $targetdir/tmp
    30333032    LogFile "---------------------------"
    30343033    LogFile "Content of initial targetdir:"
Note: See TracChangeset for help on using the changeset viewer.