[HTC Sensation] hinxnz:
I just downloaded latest rom/recovery and had a look, I had to edit a few things in rom.zip and now it successfully flashes with normal recovery flash option.

The reason checksum is failing is because the code for checking it won't work because if the system image equals one checksum, it cannot equal another different one, so I edited it to check for both instead.

The reason why the backuptool.sh is failing is basically the order of how the script calls parts of its code, so I edited it to call them in the right order, well AFAIK to get ROM flashing without errors in recovery.

I have attached the updater-script and backuptool.sh that I edited to get it working.

In updater-script, I replaced these lines:

if range_sha1("/dev/block/platform/msm_sdcc.1/by-name/system", "28,0,32767,32768,32770,32825,32827,33285,65535,65536,65538,98304,98306,98361,98363,98821,131069,131072,131074,163840,163842,163897,163899,164357,173416,196608,196610,197068,204798") == "c303703d3f2758573e0e3e64c1045848710ee1a4" then
if range_sha1("/dev/block/platform/msm_sdcc.1/by-name/system", "34,32767,32768,32770,32825,32827,33285,65535,65536,65538,66050,97792,98304,98306,98361,98363,98821,131069,131072,131074,131586,163328,163840,163842,163897,163899,164357,173416,173928,196096,196608,196610,197068,204798,204799") == "5b196df1d46cd11d9e029d898c028997a719cc55" then
ui_print("Verified the updated system image.");
else
abort("system partition has unexpected non-zero contents after OTA update");
endif;
else
ui_print("system partition has unexpected contents after OTA update");
endif;

with these ones:

if range_sha1("/dev/block/platform/msm_sdcc.1/by-name/system", "28,0,32767,32768,32770,32825,32827,33285,65535,65536,65538,98304,98306,98361,98363,98821,131069,131072,131074,163840,163842,163897,163899,164357,173416,196608,196610,197068,204798") == "c303703d3f2758573e0e3e64c1045848710ee1a4"; then
ui_print("Verified the updated system image."); else
if range_sha1("/dev/block/platform/msm_sdcc.1/by-name/system", "34,32767,32768,32770,32825,32827,33285,65535,65536,65538,66050,97792,98304,98306,98361,98363,98821,131069,131072,131074,131586,163328,163840,163842,163897,163899,164357,173416,173928,196096,196608,196610,197068,204798,204799") == "5b196df1d46cd11d9e029d898c028997a719cc55"; then
ui_print("Verified the updated system image."); else
abort("system partition has unexpected contents after OTA update");
endif; endif;

In backuptool.sh, I replaced these lines:

case "$1" in
backup)
mkdir -p $C
if check_prereq; then
if check_whitelist system; then
exit 127
fi
fi
check_blacklist system
preserve_addon_d
run_stage pre-backup
run_stage backup
run_stage post-backup
;;
restore)
if check_prereq; then
if check_whitelist tmp; then
exit 127
fi
fi
check_blacklist tmp
run_stage pre-restore
run_stage restore
run_stage post-restore
restore_addon_d
rm -rf $C
sync
;;
*)
echo "Usage: $0 {backup|restore}"
exit 1
esac

with these ones:

case "$1" in
backup)
mkdir -p $C
if check_prereq; then
preserve_addon_d
check_whitelist system
check_blacklist system
run_stage pre-backup
run_stage backup
run_stage post-backup
fi
;;
restore)
if check_prereq; then
check_whitelist tmp
check_blacklist tmp
run_stage pre-restore
run_stage restore
run_stage post-restore
restore_addon_d
rm -rf $C
sync
fi
;;
*)
echo "Usage: $0 {backup|restore}"
exit 1
esac

Edit: I understand now, that you said "It calculate checksums only selected blocks but it fails at the first condition", it checks different blocks so hence the different checksum and is then correct, I was mistaken but why not the first condition matching? Maybe it has to do with resizing. The second condition matches because one of them had to with my edit to continue the script.

Edit: blocks 28,0 not matching as others are also included in second condition, do match.

I also wondering why two checksums are used and why not just the one with those two blocks included.