[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#267219: Why just floppy, why not USB stick.



Package: bugreporter-udeb
Version: 0.27
Severity: wishlist
Tags: patch, d-i

Hi,

As you all know, there are more PC with USB port than one with floppy
drive these days. But, bugreporter-udeb try to save data in floppy.  

As I start playing d-i, I realized pluging in empty vfat formatted USB
key before hw-detect was very convienient way to get log out.  I just
mount a scsi device which happen to be USB key.

THis can be done with any USB storage such as USB HDD.

Can we do the same for bugreporter-udeb?  I used init code from
rootskel/src-bootfloppy and updated bugreporter-udeb.postinst script (no
testing yet).  This will not only mount floppy but any USB key (or USB
storage) devices formatted with vfat partition and save log there.  Also
this now create new directory so old report will not be overwritte.

Code (untested) is short and attached.

Code review or your thought is appreciated.

This should address practical functional issues of "USB floppy not
detected" since you can plug in USB key to get data out. #220306, #221575

BTW, where the USB floppies show up?  These bugs may even be taken care
with the followng code for current code:

  find /dev/scsi -name 'part?'||true

(I am sure removing -name 'part?' will take care but makes less
efficient.)  Hmmm... this seem to really fix these bugs too.

Osamu

PS: I found minor efficiency bug in rootskel/src-bootfloppy

PPS: I guess I need to update Release file in CD too to get it working.
But what else is needed to replace udeb in netinst CD?  I need to test
this udeb.  Doing upkg -i bugreporter-udeb* from console while $PWD on
/cdrom/..../bugreporter-udeb* is sufficient?

#!/bin/sh -e 

. /usr/share/debconf/confmodule

log() {
    logger -t bugreporter-udeb -p user.debug "$@"
}

if [ "" = "$DILOGDIR" ]; then
    DILOGDIR=/var/log/
fi
# make sure we have a directory
if [ ! -d $DILOGDIR ]; then
	mkdir -p $DILOGDIR
fi

copy_cdebconf_db() {
    destdir="$1"
    # Save database to disk
    # kill -? <pid-of-debconf>
    cp -a /var/lib/cdebconf "$destdir"
}

db_input critical bugreporter-udeb/insert_floppy || [ $? -eq 30 ]
db_go

# generate files with HW info, debconf database info etc, and store
# them in $DILOGDIR
db_progress START 0 3 debian-installer/bugreporter-udeb/title

/bin/package-versions > $DILOGDIR/package-versions
db_progress STEP 1

/bin/report-hw > $DILOGDIR/hardware-summary
db_progress STEP 1

# Mostly copied from rootskel/src-bootfloppy. [2004-08-20]
mountfloppy() {
    # Try mounting USB memory key
    if [ -x /usr/sbin/usb-discover ]; then
	/usr/sbin/usb-discover
    fi
    # This is currently needed or usb-storage won't load (for ide_fix_driveid).
    modprobe ide-core >/dev/null
    modprobe usb-storage >/dev/null
    modprobe sd_mod >/dev/null
    MOUNTED=0
    while [ "$MOUNTED" = 0 ]; do
	DEVS=""
	if [ -d /dev/floppy ]; then
	    # Should I keep /dev/floppy/?
	    DEVS=/dev/floppy/0
	fi
	# Assuming USB storage partition to be formated with vfat partition
	if [ -d /dev/scsi ]; then
	    DEVS="$DEVS `find /dev/scsi -name 'part?'||true`"
	fi

	ERR=""
	for dev in $DEVS; do
	    if [ "$MOUNTED" = 0 ] && [ -b $dev ]; then
		# Use /floppy as mount point even if USB storage.
		if mount $dev -o rw -tvfat /floppy 2>/dev/null; then
		    MOUNTED=1
		else
		    ERR="$ERR $dev: cannot mount"
		    umount /floppy 2>/dev/null || true
		fi
	    fi
	done

	if [ "$MOUNTED" = 0 ]; then
	    if [ -n "$ERR" ]; then
		# ERR begins with a semicolon
		log "Cannot find $ERR"
	    else
		log "No devices found!"
	    fi
	    exit 1
	fi
	log "Mounted floppy: $dev"
	return 0
}

test -d /floppy || mkdir /floppy
umount /floppy 2>/dev/null || true

if mountfloppy ; then
    log "Floppy or USB storage mounted on /floppy"
    # Since USB key is big, let's try to many several install logs there.
    for i in
            00 01 02 03 04 05 06 07 08 09 \
            10 11 12 13 14 15 16 17 18 19 \
            20 21 22 23 24 25 26 27 28 29 END ; do
	LOGDIR=debian${i}
	if [ ! -e "$LOGDIR" ] ; then
	    break
	fi
	if [ "$i" = "END" ] ; then
	    log "No space in the storage media."
	    exit 1
	fi
    done
    log "Save d-i install logs to $LOGDIR"
    mkdir /floppy/$LOGDIR
    for file in \
	    /var/log/messages \
	    /var/log/syslog \
	    /var/log/partman \
	    $DILOGDIR/hardware-summary \
	    $DILOGDIR/package-versions; do 
	if [ -e $file ]; then
	    cp $file /floppy/$LOGDIR/
	fi
    done

    umount /floppy 2>/dev/null || true
    db_progress STEP 1
    db_progress STOP
else
    db_progress STEP 1
    db_progress STOP
    db_input critical bugreporter-udeb/no_floppy || [ $? -eq 30 ]
    db_go
fi

Attachment: signature.asc
Description: Digital signature


Reply to: