#!/bin/sh

# Hi Jon

#attached find a little script to do the patching.

#I suggest to package this script together with whatever GUI(?) SMSCB app,
#and run in from postinst. Then up the pkg to extras-devel. If you prefer, I 
#can do the packaging and upload to extras-devel repo.

#cheers
#jOERG





#----------- 8X -- (snip) ----------------------------

#!/bin/sh
# file: /usr/local/bin/patch-libsms
# perm: chmod +x /usr/local/bin/patch-libsms
#
# USAGE:
# ~# patch-libsms
# (needs root permisions)
#
# this script will patch the libsms.so library to fix a bug, so N900
# finally could receive cell broadcast SMS
# There'll be a backup of the original file so you can revert if the 
# results are not satisfactory
#
# see http://lists.maemo.org/pipermail/maemo-developers/2011-June/028434.html
# All kudos to Jonathan Wilson for digging into this and finally find the 
patch
#
# Alas xargs -Ixx printf is *really* too slow, and -I not supported by busybox
# busybox awk doesn't support gsub function :-/
# so you have to install *something* anyway, either a binary to patch, or a
# interpreter like perl to run a proper script, 
# or you get proper awk from gawk package in SDK repo:
# IroN900:~# apt-cache policy gawk
# gawk:
#   Installed: 1:3.1.4-2osso.2
#   Candidate: 1:3.1.4-2osso.2
#   Version table:
#  *** 1:3.1.4-2osso.2 0
#         500 http://repository.maemo.org fremantle/sdk/free Packages
#         100 /var/lib/dpkg/status
# IroN900:~# apt-get install gawk
#
# (C)Joerg Reisenweber, joerg add openmoko dodd org, GPLv2
# thanks to Paul ;-)


LOG=/home/user/MyDocs/.documents/$( basename $0).log
LIBSMS=/usr/lib/libsms.so.0.0.0
BACKUP=/home/user/$(basename $LIBSMS)
MD5ORIG=6d9560f64f97dd18ccbd3119229717ae
MD5PATCHED=fff53e239c8a46c97015a8ef78f9e7ad

#set -vx
dd if=/dev/zero of=$LOG bs=2k count=1 2>/dev/null || (echo "Can not create 
logfile $LOG, exiting!"; exit 5)
trap "cleanup" exit
cleanup(){
  trap - exit
  if [ -f $LOG ]
  then
#    exec
    echo -e "An Error occured! Please keep the logfile $LOG, and provide it to 
developers for analyzing what happend\nThe logfile:" >&3
    cat $LOG >&3
  fi
  exit
}

exec 3>&2 1>$LOG 2>&1
set -e

echo "checking $LIBSMS for correct MD5 checksum, so we can apply patch..."
echo "$MD5ORIG  $LIBSMS" | md5sum -c 

echo "creating backup of $LIBSMS to $BACKUP..."
cp -va $LIBSMS $BACKUP

# change byte DD78 from 0xFF to 0x52, (changes a CMP R3, #0xFF 
# instruction to a CMP R3, #0x52 instruction) then change DD7C from 0x00 to 
# 0x52 and DD7F from 0x03 to 0xC3 (changes a MOVEQ R3, #0 instruction into a 
# MOVGT R3, #0x52)
echo "patching $LIBSMS..."
od -Ax -tx1 -w1 -v $LIBSMS | awk '/00dd78 ff/ { $0 = "00dd78 52"} /00dd7c 00/ 
{ $0 = "00dd7c 52"} /00dd7f 03/ { $0 = "00dd7f c3"} { gsub(/^.* /, "0x"); 
printf "%c", strtonum($0) }'

echo "checking result for correctness..."
if !echo "$MD5PATCHED  $LIBSMS" | md5sum -c
then
  echo "result incorrect! Restoring from backup $BACKUP..."
  cp -va $BACKUP $LIBSMS
  echo "removing backup..."
  rm $BACKUP
  echo "======== system info ==========="
  osso-product-info
  exit 5
fi

rm $LOG
_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers

Reply via email to