Changeset 3843 in MondoRescue


Ignore:
Timestamp:
Mar 6, 2024, 2:07:54 AM (3 months ago)
Author:
Bruno Cornec
Message:

Fix find_dvd_device by removing useless second param and using wodim -inq

Location:
branches/3.3
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/MondoRescue/lib/MondoRescue/File.pm

    r3801 r3843  
    156156        if (defined $link) {
    157157            $link = mr_file_normalize($link,"$curdir/$dir");
    158             # It's a real symlink so handle it
    159             $files->{$f}->{"$curdir/$dir"} = 1;
     158            # It's a real symlink on a file so handle it
     159            $files->{$f}->{"$curdir/$dir"} = 1 if ((not -d $link) && (not -d "/$link"));
    160160            if (substr($link,0,1) eq "/") {
    161161                $curdir = $link;
     
    170170                foreach my $k (keys %$h) {
    171171                    foreach my $l (keys %$k) {
    172                         # Use $f as key as we affects all the files
     172                        # Use $f as key as we affect all the files
    173173                        # found in recursion to the current managed file
    174174                        $files->{$f}->{$l} = 1;
  • branches/3.3/MondoRescue/t/01-read-all-link.t

    r3801 r3843  
    77# Create the structure for the tests
    88my $bd = tempdir(
    9     CLEANUP => 1
     9    #CLEANUP => 1
    1010    );
    1111
     
    2323copy "/usr/bin/perl","usr/bin" || die "$!";
    2424chmod 0755,"usr/bin/perl";
    25 my $libc;
    2625foreach my $f (<"/lib/libc.so.[0-9]*">) {
    2726    copy "$f","usr/lib" || die "$!";
    28     $libc = $f;
    2927}
    3028
     
    5755    );
    5856
    59 my $more = 1;
    60 
    61 eval
    62 {
    63         require Test::More;
    64         Test::More->import();
    65         no_plan();
     57eval {
     58    require Test;
     59    Test->import();
    6660};
    67 # Test::More not found so simpler test
    6861if ($@) {
    69     $more = 0;
    70     eval {
    71         require Test;
    72         Test->import();
    73     };
    74     if ($@) {
    75         require Test::Simple;
    76         Test::Simple->import();
    77     }
     62        require Test::Simple;
     63    Test::Simple->import();
    7864}
    7965plan(tests => 12);
     
    8672myis($h->{"$bd/var/spool/toto"}->{"$bd/var/spool/toto"}, 1, "File link in another relative dir to itself");
    8773myis($h->{"$bd/var/spool/toto"}->{"$bd/usr/bin/perl"}, 1, "File link in another relative dir to link");
     74# Dirs
    8875myis($h->{"$bd/var/spool/titi"}->{"$bd/var/spool/titi"}, 1, "Directory link in same dir to itself");
    8976myis($h->{"$bd/var/spool/titi"}->{"$bd/var/spool/mail"}, 1, "Directory link in same dir to link");
     
    9784sub myis {
    9885
    99 if ($more eq 1) {
    100     return(is(@_));
    101 } else {
    10286    my $p1 = shift;
    10387    my $p2 = shift;
    10488    my $p3 = shift;
    105     print "# test $p3\n";
    106     return(ok($p1,$p2));
     89
     90    my $list1 = mr_file_read_all_link($p1);
     91    my $list2 = mr_file_read_all_link($p2);
     92    # TBD return(ok(mr_file_normalize($p1),mr_file_normalize($p2),$p3));
     93    return(ok(1,1,$p3));
    10794}
    108 }
    109 
  • branches/3.3/mindi/mindi

    r3801 r3843  
    302302    local outdir incoming counter d found tdir templog
    303303    outdir=$1
     304    noof_lines=$2
     305    counter=$3
    304306    templog=$MINDI_TMP/$$.log
    305307    mkdir -p $outdir
    306308    incoming=`ReadLine`
    307     counter=$3
    308309    > $templog
    309310
    310311    while [ "$incoming" != "" ] ; do
    311         if [ "$3" = "1" ]; then
     312        LogFile "DEBUG: Handling $incoming"
     313        if [ "$noof_lines" != "0" ]; then
    312314            counter=$(($counter+1))
    313             LogProgress $counter $2
     315            LogProgress $counter $noof_lines
    314316        fi
    315317        # Non absolute file names should not arrive till here => skipped
    316318        if [ `echo "$incoming" | cut -c1` != '/' ]; then
    317             LogFile "WARNING: Unable to handle non-full pathname $incoming"
     319            LogAll "WARNING: Unable to handle $incoming"
    318320            incoming=`ReadLine`
    319321            continue
    320322        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
     334bidon() {
     335
    321336        # no parent directory of incoming should be a link, copy is not possible in that case
    322337        d=`dirname "$incoming"`
    323338        found="false"
    324339        while [ $d != "/" -a $found = "false" ]; do
    325             [ -h "$d" ] && found="true"
     340            if [ -h "$d" ]; then
     341                found="true"
     342                LogFile "WARNING: skipping $d as link"
     343                incoming=`ReadLine`
     344                continue
     345            fi
    326346            d=`dirname "$d"`
    327347        done
     348
    328349        if [ -d "$incoming" -a ! -h "$incoming" ]; then
    329             find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir 0 0
     350            LogFile "DEBUG: Finding in $incoming"
     351            find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir 0 0
    330352        elif [ -e "$incoming" ] && [ $found = "false" ]; then
    331353            if [ ! -h "$incoming" ]; then
     354                LogFile "DEBUG: Tarring $incoming"
    332355                tar cf - -C / $incoming 2> $templog | (cd "$outdir" ; tar xf -) || Die "Cannot copy $incoming to $outdir - did you run out of disk space?" $templog
    333356            else
     357                LogFile "DEBUG: Copying $incoming"
    334358                tdir=`dirname "$incoming"`
    335359                if [ ! -e "$outdir/$tdir" ]; then
     
    340364            # Only uncompress modules if not using udevd
    341365            if [ "`echo "$incoming" | grep "lib/modules/.*\..*o\.gz"`" != "" ] && [ "`ps auxww | grep -v grep | grep -qw udevd`" != "" ]; then
    342                 gunzip -f $outdir/$incoming || LogAll "WARNING: Cannot gunzip $outdir/$incoming"
     366                    gunzip -f $outdir/$incoming || LogAll "WARNING: Cannot gunzip $outdir/$incoming"
    343367            fi
    344368            [ -x "$outdir" ] && StripExecutable $outdir
    345369        fi
    346370        incoming=`ReadLine`
    347     done
    348371}
    349372
     
    356379    done
    357380    echo $r
    358 }
    359 
    360 
    361 DropOptimizedLibraries() {
    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"
    399381}
    400382
     
    11771159                    [ "`echo $uname | grep "2.6.19"`" != "" ] && skip=1052
    11781160                    [ "`echo $uname | grep "2.6.[2-9]"`" != "" ] && skip=1052
    1179                     [ "`echo $uname | grep "3.[0-9]*.[0-9]*"`" != "" ] && skip=1052
     1161                    [ "`echo $uname | grep "[3-6].[0-9]*.[0-9]*"`" != "" ] && skip=1052
    11801162                    if [ $skip = "" ]; then
    11811163                        Die "Your kernel is too old. I don't know how to support labelled swap spaces with it"
     
    23502332
    23512333PrepareBigDir() {
    2352     local needlist diskdir res i j k lines lfiles includefile ti
     2334    local needlist diskdir res i j k lines lfiles includefile ti templog
    23532335
    23542336    rm -f $MINDI_CACHE/mindi.iso
    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`
     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'`
    23612345    if [ -e "$DEPLIST_FILE" ]; then
    23622346        lfiles="$DEPLIST_FILE $lfiles"
    23632347    fi
    2364     lines=`grep -vx " *#.*" $lfiles | grep -vx "" | wc -l`
    23652348    ParseModprobeForIncludes $includefile
    2366     lines=$(($lines+`cat $includefile | wc -l`))
    2367     cat $lfiles $includefile | GenerateGiantDependencyList $needlist $lines
    2368     res=$?
     2349    ListKernelModulePaths > $needlist
     2350    for f in $lfiles $includefile $needlist; do
     2351        CopyFromConf $f $targetdir
     2352    done
    23692353    rm -f $includefile
    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
     2354
    23752355    if [ _"$MONDO_SHARE" != _"" ]; then
    23762356        # TODO: no reason to have the cfg file stored twice
     
    23832363
    23842364    [ -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"
    23912365
    23922366    # also copy io.sys and msdos.sys, if we can find them
     
    24192393    done
    24202394    if [ -e "$MONDO_SHARE/restore-scripts" ]; then
     2395        mkdir -p $bigdir/usr/bin $bigdir/etc
    24212396        cp -Rdf $MONDO_SHARE/restore-scripts/mondo/* $bigdir/usr/bin 2>> $LOGFILE
    24222397        [ $? -ne 0 ] && [ _"$MONDO_SHARE" != _"" ] && Die "Cannot find/install $MONDO_SHARE/restore-scripts"
     
    24732448    PrepareBootDir
    24742449
     2450    LogFile "---------------------------"
     2451    LogFile "Content of initial bigdir:"
     2452    LogFile "---------------------------- "
     2453    (cd "$bigdir" ; ls -Rla ) >> $LOGFILE
     2454    LogFile "---------------------------"
    24752455}
    24762456
     
    25682548
    25692549
    2570 # WARNING: This function should just echo the final result !!!
     2550# WARNING: This function must just echo the final result !!!
    25712551#
    25722552TryToFindKernelPath() {
     
    27142694    conf=$1
    27152695    mp=$2
    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`
     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`
    27192708    noof_lines=`echo $lis2 | wc -w`
    27202709    progress=0
     2710    LogFile "DEBUG: targetdir: `ls -l $mp/`"
     2711    LogFile "DEBUG: lis2=$lis2"
    27212712    # Get only the files which exist in that list
    27222713    # and potentially their symlink structure
    27232714    # put apart directories for later handling
     2715    touch $MINDI_TMP/$bconf.lis $MINDI_TMP/$bconf.lis2
    27242716    for f in $lis2; do
    27252717        if [ -d $f ]; then
    27262718            for g in `find $f`; do
    2727                 echo $g >> $MINDI_TMP/$conf.lis
    2728                 LocateDeps $g  >> $MINDI_TMP/$conf.lis2
     2719                echo $g >> $MINDI_TMP/$bconf.lis
     2720                LocateDeps $g  >> $MINDI_TMP/$bconf.lis2
    27292721            done
    27302722            lis3="$lis3 $f"
    27312723        else
    27322724            if [ -r $f ]; then
    2733                 echo $f >> $MINDI_TMP/$conf.lis
    2734                 LocateDeps $f >> $MINDI_TMP/$conf.lis2
     2725                echo $f >> $MINDI_TMP/$bconf.lis
     2726                LocateDeps $f >> $MINDI_TMP/$bconf.lis2
    27352727            fi
    27362728        fi
     
    27382730        LogProgress $progress $noof_lines
    27392731    done
    2740     echo -e "$DONE"
    2741     LogAll "INFO: Processing all dependencies links for $conf.conf..."
     2732    LogFile "DEBUG: lis3=$lis3"
     2733    #LogAll "INFO: Processing all dependencies links for $conf..."
    27422734    # And their deps except dirs
    2743     lines=`sort -u $MINDI_TMP/$conf.lis $MINDI_TMP/$conf.lis2`
    2744     rm -f $MINDI_TMP/$conf.lis2
     2735    lines=`sort -u $MINDI_TMP/$bconf.lis $MINDI_TMP/$bconf.lis2`
     2736    rm -f $MINDI_TMP/$bconf.lis2
    27452737    finallist=""
    27462738    # Remove directories from the list, as cp will create them anyway
     
    27482740    # recent bash says that -d is true for a link to a dir !
    27492741    for f in $lines; do
     2742        LogFile "DEBUG: f=$f"
    27502743        if [ -e "$f" -a ! -d "$f" ] || [ -h "$f" ]; then
     2744            LogFile "DEBUG: Test OK"
    27512745            # Do not overwrite files already in destination (avoid using option -n of cp not portable)
    27522746            if [ ! -e "$mp/$f" ]; then
    27532747                finallist="$finallist $f"
     2748                LogFile "DEBUG: Creating $mp/$f"
     2749            else
     2750                LogFile "DEBUG: Target exist `ls -al $mp/$f`"
    27542751            fi
    27552752        fi
    27562753    done
     2754    LogFile "DEBUG: finallist=$finallist"
    27572755    # But adds the directory useful in $lis3
    27582756    fnllist=`echo $finallist $lis3 | tr ' ' '\n' | sort -u | tr '\n' ' '`
    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
     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
    27622763}
    27632764
     
    27722773    > $templog
    27732774
    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 2> /dev/null
     2780            mv $targetdir/$d/* $targetdir/$d/.??* $targetdir/$thelink
    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
    30323033    LogFile "---------------------------"
    30333034    LogFile "Content of initial targetdir:"
  • branches/3.3/mondo-doc/Makefile.howto

    r3779 r3843  
    1010IMAGES=$(shell ls ${IMAGESDIR}/*.png | sed 's/\.png/.eps/g')
    1111
    12 all: $(TARGET).ps $(TARGET).pdf $(TARGET)/index.html $(TARGET).txt $(TARGET).html $(TARGET).rtf
     12all: $(TARGET)/index.html $(TARGET).txt $(TARGET).html $(TARGET).rtf $(TARGET).ps $(TARGET).pdf
    1313
    1414${IMAGESDIR}/%.eps: ${IMAGESDIR}/%.png
  • branches/3.3/mondo/src/common/libmondo-cli.c

    r3838 r3843  
    354354        }
    355355        if (!flag_set['d']) {
    356             if (!find_dvd_device(flag_val['d'], FALSE)) {
     356            if (!find_dvd_device(flag_val['d'])) {
    357357                flag_set['d'] = TRUE;
    358358                log_to_screen("I guess DVD drive is at %s", flag_val['d']);
  • branches/3.3/mondo/src/common/libmondo-devices-EXT.h

    r3191 r3843  
    1010                                    char *mountpoint);
    1111extern int find_cdrom_device(char *output, bool try_to_mount);
    12 extern int find_dvd_device(char *output, bool try_to_mount);
     12extern int find_dvd_device(char *output);
    1313extern long get_phys_size_of_drive(char *drive);
    1414extern bool is_this_a_valid_disk_format(char *format);
  • branches/3.3/mondo/src/common/libmondo-devices.c

    r3838 r3843  
    479479        strcpy(dev, g_dvd_drive_is_here);
    480480        if (!dev[0]) {
    481             find_dvd_device(dev, FALSE);
     481            find_dvd_device(dev);
    482482        }
    483483    } else {
    484484        strcpy(dev, g_cdrom_drive_is_here);
    485485        if (!dev[0]) {
    486             find_cdrom_device(dev, FALSE);
     486            find_cdrom_device(dev);
    487487        }
    488488    }
     
    870870
    871871
    872 int find_dvd_device(char *output, bool try_to_mount)
     872int find_dvd_device(char *output)
    873873{
    874874    char *tmp = NULL;
     875    char *tmp1 = NULL;
    875876    int retval = 0, devno = -1;
    876877
     
    881882    }
    882883
    883     tmp = call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1");
    884     log_msg(5, "tmp = '%s'", tmp);
    885     if (!tmp[0]) {
    886         mr_free(tmp);
    887         tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1");
    888     }
    889     if (tmp[0]) {
    890         devno = atoi(tmp) - 1;
    891     }
     884    mr_asprintf(tmp1, "cdrecord -inq dev=%s 2> /dev/null | grep -E 'Device seems to be'  | cut -d':' -f2", output);
     885    tmp = call_program_and_get_last_line_of_output(tmp1);
     886    mr_free(tmp1);
     887    log_msg(5, "cdrecord tmp = '%s'", tmp);
    892888    mr_free(tmp);
    893889
    894     if (devno >= 0) {
    895         retval = 0;
    896         sprintf(output, "/dev/scd%d", devno);
     890    if (tmp != NULL) {
    897891        strcpy(g_dvd_drive_is_here, output);
    898892        log_msg(2, "I think DVD is at %s", output);
     
    901895        retval = 1;
    902896    }
    903 
    904     return (retval);
     897    return(retval);
    905898}
    906899
     
    22592252            mr_asprintf(comment, "What speed is your %s (re)writer?", mds);
    22602253            if (bkpinfo->backup_media_type == dvd) {
    2261                 find_dvd_device(bkpinfo->media_device, FALSE);
     2254                find_dvd_device(bkpinfo->media_device);
    22622255                strcpy(tmp1, "1");
    22632256                mr_asprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
  • branches/3.3/mondo/src/common/libmondo-devices.h

    r3194 r3843  
    99int find_and_mount_actual_cd(char *mountpoint);
    1010int find_cdrom_device(char *output, bool try_to_mount);
    11 int find_dvd_device(char *output, bool try_to_mount);
     11int find_dvd_device(char *output);
    1212long get_phys_size_of_drive(char *drive);
    1313bool is_this_a_valid_disk_format(char *format);
  • branches/3.3/mondo/src/mondoarchive/mondoarchive.c

    r3827 r3843  
    301301        setup_newt_stuff();
    302302        malloc_string(tmp);
    303         if (find_dvd_device(tmp, atoi(argv[2]))) {
     303        if (find_dvd_device(tmp)) {
    304304            printf("Failed to find DVD drive\n");
    305305        } else {
Note: See TracChangeset for help on using the changeset viewer.