#!/bin/sh # # patching driverupdate # Uwe Gansert # # Version 0.6 # DECODED="/tmp/ay_update.tgz" TMP_MOUNT="/tmp/ay_update_tmp_mount" VERBOSE=1 BACKUP=`date +"%m_%d_%H_%m_%S"` BACKUP="linux_$BACKUP" MD5="" DU_MUST_EXIST=0 DO_IMAGE=1 error() { echo "ERROR!" echo -e " $1" exit -1 } logging() { if [ "$VERBOSE" == "1" ]; then echo -e " $1" fi } if [ "$DO_IMAGE" == "1" ]; then MKFS=`which mkfs.cramfs 2>/dev/null`; if [ -z "$MKFS" ]; then error "mkfs.cramfs needed but can't be found" fi; fi; if [ ! -d "./linux" ]; then logging "no extracted driverupdate found. Looking for image" if [ -s driverupdate ]; then logging "driverupdate image found" RSYNC=`which rsync` logging "rsync found: $RSYNC" if [ -z "$RSYNC" ]; then error "rsync is needed but can't be found" fi mkdir -p "$TMP_MOUNT" || error " mkdir "$TMP_MOUNT" failed" logging "mounting driverupdate to $TMP_MOUNT" mount -oloop driverupdate "$TMP_MOUNT" || error " mount -oloop driverupdate "$TMP_MOUNT" failed" logging "copy driverupdate content" $RSYNC -a "${TMP_MOUNT}/linux" . || error " rsync -a \"${TMP_MOUNT}/linux\" . failed" umount "$TMP_MOUNT" rmdir "$TMP_MOUNT" else if [ $DU_MUST_EXIST == "1" ]; then error "driverupdate not found. Wrong directory?" fi; logging "no driverupdate image found. A new driverupdate will be created." fi else logging "already extracted driverupdate found." logging "doing backup to $BACKUP" cp -a linux $BACKUP fi logging "decode patch to $DECODED" #$OPENSSL base64 -d -out "$DECODED" < $DECODED #EOT if [ ! -s "$DECODED" ]; then error "decoding update tar failed" fi if [ ! -z "$MD5" ]; then if [ `md5sum $DECODED` != "$MD5" ]; then error "MD5SUM of $DECODED is wrong" fi fi; tar xfz "$DECODED" || error "unpacking update tar failed" rm -f "$DECODED" logging "patching driverupdate was a success" if [ "$DO_IMAGE" == "1" ]; then logging "creating image" mkdir ay_tmp mv linux ay_tmp rm -f driverupdate $MKFS ay_tmp driverupdate rm -rf ay_tmp fi; exit 0