OESF Portables Forum

Everything Else => Zaurus Distro Support and Discussion => Distros, Development, and Model Specific Forums => Archived Forums => Debian => Topic started by: ZDevil on October 18, 2007, 05:08:48 am

Title: Titchy Updater.sh Decoded?
Post by: ZDevil on October 18, 2007, 05:08:48 am
Hi,
Could someone decode the updater.sh from Titchy into a text file, please?
I badly need this to get access into the Debian ISO image to fix my root account setting, without being forced to reformat the disk before that.    
A million thanks in advance!

 [ You are not allowed to view attachments ]
Title: Titchy Updater.sh Decoded?
Post by: tux on October 18, 2007, 05:36:42 am
Quote from: ZDevil
Hi,
Could someone decode the updater.sh from Titchy into a text file, please?
I badly need this to get access into the Debian ISO image to fix my root account setting, without being forced to reformat the disk before that.    
A million thanks in advance!

 [ You are not allowed to view attachments ]
 On the Titchylinux site, if you poke around are three files that I found. Two of them are .py files that decode and encode the updater file. or so it says. The updater file is there also. I'm trying to attach them all now. Hope they help.   I'm obviously going to have to put a fake .deb on the end of them. The real name and type should be obvious.  

So just remove the .deb extension and you should be able to use them on your desktop to do what you want. I presume the process is decode, edit, encode and apply?

Cheers!

By the way, if the attachment bug bites, you can find them at the Neil's site if you wander about. I found them. On the Installing page, scroll down to the bottom of the screen and click on attachments. The files are there.  Take a bit of discovering though!

Must emphasize, the updater file I have uploaded is the original!
Title: Titchy Updater.sh Decoded?
Post by: ZDevil on October 18, 2007, 06:04:58 am
Thanks!  

Ok, now I would like to make a new updater.sh by disabling the automatic disk formatting actions.

Here is the full decoded updater.sh from titchy:
Code: [Select]
#!/bin/sh

DATAPATH=$1
TMPPATH=/tmp/update
TMPDATA=$TMPPATH/tmpdata.bin
TMPHEAD=$TMPPATH/tmphead.bin

WFLG_KERNEL=0
WFLG_INITRD=0
WFLG_HDD=0

RO_MTD_LINE=`cat /proc/mtd | grep "root" | tail -n 1`
if [ "$RO_MTD_LINE" = "" ]; then
    RO_MTD_LINE=`cat /proc/mtd | grep "\.*\<2\>" | tail -n 1`
fi
RO_MTD_NO=`echo $RO_MTD_LINE | cut -d: -f1 | cut -dd -f2`
RO_MTD_SIZE_HEX=`echo $RO_MTD_LINE | cut -d" " -f2`
RO_MTD=/dev/mtd$RO_MTD_NO
RO_MTDBLK=/dev/mtdblock$RO_MTD_NO
RO_MTD_SIZE=`dc 0x$RO_MTD_SIZE_HEX 1024 /`

RW_MTD_LINE=`cat /proc/mtd | grep "home" | tail -n 1`
if [ "$RW_MTD_LINE" = "" ]; then
    RW_MTD_LINE=`cat /proc/mtd | grep "\.*\<2\>" | tail -n 1`
fi
RW_MTD_NO=`echo $RW_MTD_LINE | cut -d: -f1 | cut -dd -f2`
RW_MTD_SIZE_HEX=`echo $RW_MTD_LINE | cut -d" " -f2`
RW_MTD=/dev/mtd$RW_MTD_NO
RW_MTDBLK=/dev/mtdblock$RW_MTD_NO
RW_MTD_SIZE=`dc 0x$RW_MTD_SIZE_HEX 1024 /`

LOGOCAL_MTD=/dev/mtd1

VERBLOCK=0x48000
MVRBLOCK=0x70000

RESULT=0

Cleanup(){
    rm -f $VTMPNAME > /dev/null 2>&1
    rm -f $MTMPNAME > /dev/null 2>&1
    rm $CTRLPATH/* > /dev/null 2>&1
    exit $1
}
trap 'Cleanup 1' 1 15
trap '' 2 3

get_dev_pcmcia()
{
while read SOCKET CLASS DRIVER INSTANCE DEVS MAJOR MINOR;
do
    echo $DEVS
done
}
get_dev_pcmcia_slot()
{
    grep "^$1" /var/lib/pcmcia/stab | get_dev_pcmcia
}
sleep 1
IDE1=`get_dev_pcmcia_slot 1`
if [ "$IDE1" = "" ]; then
    echo "Error! There is no microdrive. Now retrying..."
    while [ "$IDE1" = "" ]; do
    IDE1=`get_dev_pcmcia_slot 1`
    done
    echo "Found microdrive!"
fi

### Check model ###
/sbin/writerominfo
MODEL=`cat /proc/deviceinfo/product`
if [ "$MODEL" != "SL-C3000" ] && [ "$MODEL" != "SL-C3100" ] && [ "$MODEL" != "SL-C3200" ]
then
    echo 'Model: '$MODEL
    echo 'Error! Invalid model.'
    echo 'Please reboot.'
    while true
    do
    done
fi

mkdir -p $TMPPATH > /dev/null 2>&1

cd $DATAPATH/

#
# First do the kernel.
#
for TARGETFILE in zImage.bin zimage.bin ZIMAGE.BIN
do
    if [ -e $DATAPATH/$TARGETFILE -a $WFLG_KERNEL = 0 ]
    then
        # Get the size of the kernel.
        DATASIZE=`wc -c $TARGETFILE`
        DATASIZE=`echo $DATASIZE | cut -d' ' -f1`

        echo 'Updating kernel.'
        echo $TARGETFILE':'$DATASIZE' bytes'
        /sbin/nandlogical $LOGOCAL_MTD WRITE 0xe0000 $DATASIZE \
            $TARGETFILE > /dev/null 2>&1

        WFLG_KERNEL=1

    fi
done

echo ''
echo 'Formatting microdrive...'
for s in 1 2 3; do
  if [ ! -f /hdd$s/NotAvailable ]; then
    umount /hdd$s
  fi
done
echo 0 | sfdisk /dev/${IDE1} 2>/dev/null >/dev/null
if [ "$?" != "0" ]; then
    echo "Error!"
    exit "$?"
fi
dd if=/dev/zero of=/dev/${IDE1}1 bs=512 count=1 2>/dev/null >/dev/null
mke2fs -j /dev/${IDE1}1 2> /dev/null > /dev/null
e2fsck -p /dev/${IDE1}1 > /dev/null
if [ "$?" != "0" ]; then
    echo "Error!"
    exit "$?"
fi

mount -t ext3 -o noatime /dev/${IDE1}1 /hdd1
if [ "$?" != "0" ]; then
    echo "Error!"
    exit "$?"
fi

## Debian Install CD
cd $DATAPATH/
for TARGETFILE in debian.iso DEBIAN.ISO
do
    if [ -e $DATAPATH/$TARGETFILE ]; then
        echo 'Extracting Debian installer...'
        mkdir $TMPPATH/media

        mount -o loop -t iso9660 $TARGETFILE $TMPPATH/media
        if [ "$?" != "0" ]; then
            echo "Error!"
            exit "$?"
        fi
        cp -a $TMPPATH/media/dists $TMPPATH/media/pool $DATAPATH/
        cp $TMPPATH/media/install/netwinder/initrd.gz /hdd1/tmpinitrd.gz
        umount $TMPPATH/media

        gunzip /hdd1/tmpinitrd.gz
        if [ "$?" != "0" ]; then
            echo "Error!"
            exit "$?"
        fi

        mount -o loop /hdd1/tmpinitrd $TMPPATH/media
        if [ "$?" != "0" ]; then
            echo "Error!"
            exit "$?"
        fi

        cp -R $TMPPATH/media/* /hdd1
        if [ "$?" != "0" ]; then
            echo "Error!"
            exit "$?"
        fi

        umount $TMPPATH/media
        rm /hdd1/tmpinitrd

        cat >/hdd1/lib/debian-installer-startup.d/S99cdrom <mkdir /cdrom
mount /dev/mmcblk0p1 /cdrom
cd /
for s in cdrom/*.DEB cdrom/*.deb; do
  if [ -e \$s ]; then
    ar -x \$s
    tar xzf data.tar.gz
    rm data.tar.gz control.tar.gz
  fi
done
END

    fi
done

sync
umount /hdd1

echo
echo 'Debian Installer successfully installed!'

exit 0

So my question is: Will it do to remove the lines from 107 to 130, i.e. starting from "echo '' echo 'Formatting microdrive...' ..." ?

Here is the attachment FYI.  
Title: Titchy Updater.sh Decoded?
Post by: tux on October 18, 2007, 02:48:48 pm
 Glad you found the files of help. I think you may well be ok with stripping those lines you mention. But, being too lazy to count he lines, I'm not sure whether you mean to snip the ones below?

mount -t ext3 -o noatime /dev/${IDE1}1 /hdd1
if [ "$?" != "0" ]; then
   echo "Error!"
   exit "$?"
fi


Don't they mount the drive, which I think is essential?

Any way I'm sure there must be much more expert eyes watching this thread than mine. Good luck with it.  

You'll have noticed that I appear to have cured the powering up problem with 'Big Z', I think I'll adopt that name for the surgically enhanced little fellow!