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

Bug#267219: Bug to USB stick works !



Hi,

On Sun, Aug 22, 2004 at 01:07:08PM +0200, Osamu Aoki wrote:
> Here is the latest stable code for bugreporter-udeb.postinst with
> $REPORT_MEDIA_DEV support.

:-( Now I know why REPORT_MEDIA_DEV=nofloppy boot parameter did not
work.  Because code was buggy just for this feature.

I changed it again and worked without exporting these with other
packages.  Looks like all of these are exported.  Nice.

Now you can store log to not only to normal floppy but also to
 * USB memory stick
 * USB HDD
 * USB floppy
 * IDE HDD
 * IDE ZIP
 * etc. 
as long as there is a vfat partition.

Osamu

#!/bin/sh -e 

. /usr/share/debconf/confmodule

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

# REPORT_MEDIA_DEV can be set to use non auto detected devices for report
NO_FLOPPY=0
if [ -n "$REPORT_MEDIA_DEV" ]; then
    if [ "$REPORT_MEDIA_DEV" = "nofloppy" ]; then
	NO_FLOPPY=1
	DEVS=""
	log "Do not search floppy devices"
    else
	DEVS="$REPORT_MEDIA_DEV"
	log "Search a device from $REPORT_MEDIA_DEV"
    fi
else
    DEVS=""
fi

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

log "Genarate files with HW info, debconf database info etc. into $DILOGDIR"
db_progress START 0 7 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

# Idea from rootskel/src-bootfloppy. [2004-08-20]
mountfloppy() {
    # Try mounting USB memory devices (how about firewire?)
    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
    log "Required modules activated."
    if [ "$DEVS" = "" ]; then
	# Find possible block devices on floppy
	if [ -d /dev/floppy ] && [ "$NO_FLOPPY" = "0" ]; then
	    DEVS="$DEVS `find /dev/floppy -type b -name '?' || true`"
	fi
	# Find possible block devices on scsi (including USB floppy and stick)
	if [ -d /dev/scsi ]; then
	    DEVS="$DEVS `find /dev/scsi -type b || true`"
	    #DEVS="$DEVS `find /dev/scsi -type b \( -name 'part*' -o -name '?' \) ||true`"
	fi
    fi
    log "Devices found: $DEVS"
    db_progress STEP 1

    # Mount first vfat block device on /floppy even if USB storage.
    MOUNTED=0
    for dev in $DEVS; do
	if [ -b "$dev" ] && mount $dev -o rw -tvfat /floppy 2>/dev/null; then
	    MOUNTED=1
	    break
	else
	    log "This can not be mounted as vfat, rw: $dev"
	    umount /floppy 2>/dev/null || true
	fi
    done

    if [ "$MOUNTED" = 0 ]; then
	exit 1
    fi

    log "On /floppy, mounted a vfat/rw/block device: $dev"
    return 0
}

if [ -d /floppy ]; then
    umount /floppy 2>/dev/null || true
else
    mkdir /floppy
fi

# Find a floppy or USB storage and mount it on /floppy
if mountfloppy ; then
    db_progress STEP 1
    # Let's try to save many several install logs.
    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
	if [ "$i" = "END" ] ; then
	    log "No space in the storage media."
	    exit 1
	fi
	LOGDIR=debian${i}
	if [ ! -e "/floppy/$LOGDIR" ] ; then
	    log "Found an unused directory name: $LOGDIR"
	    break
	fi
    done
    db_progress STEP 1
    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
    db_progress STEP 1

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

Reply to: