Hi,
The Samsung ODIN .tar.md5 format files contain an embedded md5sum signature for download checking. I found this handy bash script for checking .tar.md5 format for md5sum. Original sources are (thanks to contributors!)
http://stackoverflow.com/questions/...how-to-remove-md5-extension/17751305#17751305
http://stackoverflow.com/questions/...-case-in-bash-shell-scripting/2264435#2264435
I've added lowercase conversion and echoing both signatures, just for checking.
The script (source it and you'll have check_tar_md5 command in your env).
Code:
#! /bin/bash
check_tar_md5 () {
local file="${1:?Required: file to check}"
[[ ! -f "$file" ]] && {
echo "File not found: $file" >&2
return 1
}
local filename="$(basename "$file")"
if [ "${filename##*.}" = md5 ]; then filename="${filename%.*}"; fi;
local md5_line_length=$(printf "%032d *%s\n" 0 "$filename" | wc -c)
local embedded_md5=$(tail -c $md5_line_length "$file" | tr [A-Z] [a-z] | ( read md5 rest; echo $md5 ) )
local actual_md5=$(head -c -$md5_line_length "$file" | md5sum | ( read md5 rest; echo $md5 ) )
echo "Embedded md5: " $embedded_md5
echo "Actual md5: " $actual_md5
if [ $embedded_md5 = $actual_md5 ]; then
echo "$file: OK"
else
echo "$file: FAILED"
return 1
fi
}
[[ ! -z "$1" ]] && check_tar_md5 "$1"
Related
Newer cwm's now do nandroid's via .dup files.
These files are nothing but metadata that links each backup to the real files in the clockworkmod/blobs directory.
This script merely allows you to recreate a tree from a .dup file + blobs directory. This is helpful if you want to extract a few files from a backup and not have to restore it.
link
To use :
wget -O recreate.sh http://goo.gl/wz3IU
chmod 755 recreate.sh
./recreate.sh
Totally off topic but I haven't seen you around here in years. You rooted my Nexus One for me via TeamView back when the N1 first came out.
Crazy how long ago that seems when I couldn't even root my first Android device, haha.
Anyway, sorry to go off topic.
Just wanted to say thanks all these years later. You got my going in the XDA Android scene and here I am a few years later tweaking ROMs and starting to learn to build from source.
Sent from my SGH-T999 using xda premium
Don't mention it
Glad to see it got you motivated.
Yea I don't post around much anymore. I just wrote this quick thing for myself thought I'd share it
hi. i found this thread while searching and thought it would be a really useful tool. i was having problems with my cwm6 backups and so made the following amendments to the script :
IFS=$'\n' <- added new line
while read line; do
if [ "$line" != "dedupe 2" ]; then
inc=$(($inc+1))
prog=$(($inc / $chunk))
type=$(echo $line | cut -f1) <- removed -d " "
item=$(echo $line | cut -f8) <- removed -d " "
link=$(echo $line | cut -f9) <- added new line
hashFolder=$(echo $line | cut -f9 | cut -d "/" -f1) <- removed -d " "
hashFile=$(echo $line | cut -f9 | cut -d "/" -f2) <- removed -d " "
if [ "$type" = "f" -a ! -z "$hashFolder" -a ! -z "$hashFile" ]; then
if [ -f "$blobFolder/$hashFolder/$hashFile" ]; then
cp "$blobFolder/$hashFolder/$hashFile" "$outputFolder/$item"
else
echo "No blob for " $item " found"
fi
elif [ "$type" = "l" ]; then <- added new line
ln -s $link $item <- added new line
else
mkdir -p $outputFolder/$item
fi
if [ $last -ne $prog ]; then
if [ $(($prog % 10)) -eq 0 ]; then
echo -n $prog%
elif [ $(($prog % 4)) -eq 0 ]; then
echo -n '.'
fi
last=$prog
fi
fi
this accommodated the tabs, filenames containing spaces, and links in my dup files.
This is simple linux script I've made to separate all apps from one big zip file made by Helium sever -> PC download. Helium wiki says to don't try to do anything with this file, but I didn't want to restore all that stuff that I've backuped before bootloader unlock on my nexus 4. I'm sure it can be writed better, but it's working
Just place script file and unziped backup folder (must be named "backup") in one directory. After execution of the script everything should be ready to copying to carbon folder on your sd card/internal memory and restoring like after normal backup.
Tested on Ubuntu 14.04.
I'm not responsible for data loss or any other problem. Use at your own risk.
Constructive criticism welcome.
Code:
#!/bin/bash
DIRECTORY='./backup'
if [ -f $DIRECTORY/backup.json ]; then
cp $DIRECTORY/backup.json $DIRECTORY/temp.json
sed -e "s/{\"packages\"://g" $DIRECTORY/temp.json > $DIRECTORY/temp2.json
tr '[]' ' ' < $DIRECTORY/temp2.json | tee $DIRECTORY/temp.json
tr '}' '\n' < $DIRECTORY/temp.json | tee $DIRECTORY/temp2.json
sed -e "s/,{/{/g" $DIRECTORY/temp2.json > $DIRECTORY/temp.json
sed -e 's/^[ \t]*//' $DIRECTORY/temp.json > $DIRECTORY/temp2.json
sed '/^$/d' $DIRECTORY/temp2.json > $DIRECTORY/temp.json
sed 's/\([^|]\)$/\1}/' $DIRECTORY/temp.json > $DIRECTORY/temp_last.json
fi;
count=`ls -1 $DIRECTORY/*.ab 2>/dev/null | wc -l`
if [ $count != 0 ]; then
for i in $DIRECTORY/*.ab ; do
AB=$(basename $i)
mkdir -p $DIRECTORY/${AB%.*}
mv -i $DIRECTORY/$AB $DIRECTORY/${AB%.*}/
if [ -f $DIRECTORY/${AB%.*}.png ]; then
mv -i $DIRECTORY/${AB%.*}.png $DIRECTORY/${AB%.*}/._${AB%.*}.png
fi;
if [ ! -f $DIRECTORY/${AB%.*}/${AB%.*}.json ];then
touch $DIRECTORY/${AB%.*}/${AB%.*}.json
fi;
while read p; do
if [[ "$p" =~ "${AB%.*}" ]]; then
echo "$p" > $DIRECTORY/${AB%.*}/${AB%.*}.json
fi;
done <$DIRECTORY/temp_last.json
done;
fi;
rm $DIRECTORY/temp.json
rm $DIRECTORY/temp2.json
rm $DIRECTORY/temp_last.json
exit;
Credits to: ameer1234567890
Official Thread:Online Nandroid Backup / Nandroid Backup without re-booting
I wanted to use Ameer's script/app on my new Galaxy S7 but it was not recognized.
I was able to make it work myself by generating the correct patch file using this script:
Code:
mount -o rw,remount /system
echo "dev: size erasesize name" > /system/partlayout4nandroid
cd `find /dev -name by-name`
for d in * ; do
lc=`echo $d | tr [A-Z] [a-z]`
dev=`readlink $d | awk -F/ '{print $NF}'`
hex=$(printf "%07x\n" `dd if=$d of=/dev/null bs=1m 2>&1 | grep bytes | awk '{print $1/1024}'`)
echo "$dev: $hex 0000000 \"$lc\"" >> /system/partlayout4nandroid
done;
mount -o ro,remount /system
I had also to change this line :
Code:
if $bb [ "`$bb cat /system/partlayout4nandroid | $bb egrep "(mtd|mmc|bml|nand|act)"`" != "" ]; then
to
Code:
if $bb [ "`$bb cat /system/partlayout4nandroid | $bb egrep "([B]sda|[/B]mtd|mmc|bml|nand|act)"`" != "" ]; then
Cheers
Basically what I want to do is convert this into batch script for windows and by using Linux Binaries from Sourceforge create a script that basically does the same thing except it doesnt have to be pushed into my Phone's system it works directly in windows using ADB commands!
The script in question looks like this
Spoiler: THIS Script
Bash:
#adb shell mkdir /data/media/0/PartitionImages
#adb push .\backupPartitions.sh /data/media/0/PartitionImages/backupPartitions.sh
#adb shell chmod 0755 /data/media/0/PartitionImages/backupPartitions.sh
#adb shell /data/media/0/PartitionImages/backupPartitions.sh
#adb pull /data/media/0/PartitionImages .\PartitionImages
max_blocks=102400
names=""
compress=0
while getopts "h?bzn:" opt; do
case "$opt" in
h|\?)
echo "Usage $0 [-z] [-b MaxBlocks] [-n partition1 ] [-n partition2 ]"
echo " options:"
echo "-z optional to tar.gz the output folder default=false"
echo "-b 102400 optional maximum number of blocks of the partition - 0 will dump all partitions default=$max_blocks"
echo "-n partitionName... optional - one or more partitions to dump"
exit 0
;;
z) compress=1
;;
b) max_blocks=$OPTARG
;;
n) names+=" $OPTARG"
;;
esac
done
script=$(readlink -f "$0")
script_path=$(dirname "$script")
serial=$(cat /sys/class/android_usb/f_accessory/device/iSerial)
serial_date=$serial/$(date +"%Y_%m_%d_%H_%M_%S")
output_path=$script_path/$serial_date
echo "********************************"
echo "Backup partitions TO $output_path"
echo "********************************"
mkdir -p $output_path
part_dir=$(find /dev/block/platform -name by-name)
partitions=$(ls -la $part_dir | awk '{if ( $10 == "->") print $9 ">" $11 }')
getprop > $output_path/build.prop
echo "Id Name Size MD5" > $output_path/partitions.txt
for f in $partitions
do
part_id=$(echo $f | sed 's/^[^>]*>\/dev\/block\///')
part_name=$(echo $f | sed 's/>.*//')
size=$(cat /proc/partitions | awk -v p=$part_id '{if ( $4 == p ) print $3}')
checksum="0"
skip=0
if [ $max_blocks -gt 0 -a $size -gt $max_blocks ]
then
skip=1
echo "Skipping $part_name Id $part_id due to size"
else
if [ "$names" -ne "" ]
then
if echo $names | grep -w $part_name > /dev/null; then
skip=0
else
skip=1
echo "Skipping $part_name Id $part_id"
fi
fi
fi
if [ "$skip" -eq "0" ]
then
echo "Processing $part_name Id $part_id Size $size";
dd if=/dev/block/$part_id of=$output_path/$part_name.img
checksum=$(md5sum -b $output_path/$part_name.img | sed 's/ .*//')
fi
echo "$part_id $part_name $size $checksum" >> $output_path/partitions.txt
done
if [ "$compress" -eq "1" ]
then
cd $script_path
tar cz $serial_date > $output_path.tar.gz
rm -rf $output_path
fi
its from an old Xda Dev thread original post and author
givitago
I tried by guidelines from an "Appendix N. Converting DOS Batch Files to Shell Scripts" from another site to turn the shell script variables into batch script ones but since I got no experience with either of them my attempt turned into an amalgamation of the two's code in one..
Spoiler: it turned Into THIS
Code:
::adb shell mkdir /data/media/0/PartitionImages
::adb push .\backupPartitions.sh /data/media/0/PartitionImages/backupPartitions.sh
::adb shell chmod 0755 /data/media/0/PartitionImages/backupPartitions.sh
::adb shell /data/media/0/PartitionImages/backupPartitions.sh
::adb pull /data/media/0/PartitionImages .\PartitionImages
%max_blocks==102400
%names==""
%compress==0
while getopts "h?bzn:" opt; do
case "$opt" in
h|\?)
echo "Usage $0 [-z] [-b MaxBlocks] [-n partition1 ] [-n partition2 ]"
echo " options:"
echo "-z optional to tar.gz the output folder default=false"
echo "-b 102400 optional maximum number of blocks of the partition - 0 will dump all partitions default=$max_blocks"
echo "-n partitionName... optional - one or more partitions to dump"
exit 0
;;
z) compress=1
;;
b) max_blocks=$OPTARG
;;
n) names+=" $OPTARG"
;;
esac
done
%script%==%(echo %CD% "%0")
%script_path%==(dirname "%script")
%serial%==%(adb shell cat /sys/class/android_usb/f_accessory/device/iSerial)
%serial_date%==%serial% /%(date +"%Y_%m_%d_%H_%M_%S")
%output_path%==%script_path%/%serial_date%
echo "********************************"
echo "Backup partitions TO $output_path"
echo "********************************"
mkdir -p %output_path%
%part_dir%==%(adb shell find /dev/block/platform -name by-name)
%partitions%==%(ls -la %part_dir% | awk '{if ( %10 == "->") print %9 ">" %11 }')
adb shell getprop > %output_path%/build.prop
echo "Id Name Size MD5" > %output_path%/partitions.txt
for %%i in %partitions do
%part_id=%(echo %f | sed 's/^[^>]*>\/dev\/block\///')
%part_name=%(echo %f | sed 's/>.*//')
%size=%(adb shell cat /proc/partitions | awk -v p==%part_id% '{if ( %4 == p ) print %3}')
checksum="0"
skip==0
if [ %max_blocks -gt 0 -a %size -gt %max_blocks ]
then
skip=1
echo "Skipping %part_name% Id %part_id% due to size"
else
if [ "%names" -ne "" ]
then
if echo %names | grep -w %part_name% > /dev/null; then
skip==0
else
skip==1
echo "Skipping %part_name% Id %part_id%"
fi
fi
fi
if [ "$skip" -eq "0" ]
then
echo "Processing %part_name% Id %part_id% Size %size";
'adb shell pull' /dev/block/%part_id% %output_path%/%part_name%.img
checksum==%(md5sum -b %output_path%/%part_name%.img | sed 's/ .*//')
fi
echo "%part_id% %part_name% %size %checksum" >> %output_path%/partitions.txt
done
if [ "%compress" -eq "1" ]
then
cd %script_path%
tar cz %serial_date% > %output_path%.tar.gz
rm -rf %output_path%
fi
additionally I have pretty much all linux commands's binaries on the same folder as the .bat script so as long as the syntax is correct and nothing finniky going on it should work technically but since I got no experience I can't do this on my own...
You may use the DOS script used here
[TOOL][ADB][WIN]Android Partitions Backupper / Cloner
Hi all, wrote a Windows CMD script that backups / clones partitions of an Android device via ADB because I wasn't content with any 3rd-party APK what claims to do this job. The backups /clones are stored on Windows computer as...
forum.xda-developers.com
as a template.
jwoegerbauer said:
You may use the DOS script used here
[TOOL][ADB][WIN]Android Partitions Backupper / Cloner
Hi all, wrote a Windows CMD script that backups / clones partitions of an Android device via ADB because I wasn't content with any 3rd-party APK what claims to do this job. The backups /clones are stored on Windows computer as...
forum.xda-developers.com
as a template.
Click to expand...
Click to collapse
I have tried that script itself and it failed at "DM-Verity" and SELinux enforcement also for some reason no logs at all in temp folder
Hi
I am evaluating SM-S908E_12_Opensource provided by Samsung opensource site
The parameters in the build.sh provided by the opensource configure the vendor_dlkm.img to EXT4.
However, the original firmware's vendor_dlkm.img is F2FS
Could someone advise what are the modifications need to be made in the build.sh to configure the vendor_dlkm to F2FS
The following is code snipplet of build.sh:
:
local vendor_dlkm_props_file
if [ -z "${VENDOR_DLKM_PROPS}" ]; then
vendor_dlkm_props_file="$(mktemp)"
echo -e "vendor_dlkm_fs_type=ext4\n" >> ${vendor_dlkm_props_file}
echo -e "use_dynamic_partition_size=true\n" >> ${vendor_dlkm_props_file}
echo -e "ext_mkuserimg=mkuserimg_mke2fs\n" >> ${vendor_dlkm_props_file}
echo -e "ext4_share_dup_blocks=true\n" >> ${vendor_dlkm_props_file}
else
vendor_dlkm_props_file="${VENDOR_DLKM_PROPS}"
if [[ -f "${ROOT_DIR}/${vendor_dlkm_props_file}" ]]; then
vendor_dlkm_props_file="${ROOT_DIR}/${vendor_dlkm_props_file}"
elif [[ "${vendor_dlkm_props_file}" != /* ]]; then
echo "VENDOR_DLKM_PROPS must be an absolute path or relative to ${ROOT_DIR}: ${vendor_dlkm_props_file}"
exit 1
:
:
I had tried to amending vendor_dlkm_fs_type=f2fs which end the build with the following error:
:
extra/test/mmrm_test_module.ko
========================================================
Trimming unused modules
2022-07-15 08:00:53 - build_image.py - ERROR : Failed to build /home/cara/Downloads/SM-S908E_12_Opensource/K2/Kernel/out/msm-waipio-waipio-gki/dist/vendor_dlkm.img from /home/cara/Downloads/SM-S908E_12_Opensource/K2/Kernel/out/msm-waipio-waipio-gki/staging/vendor_dlkm_staging
:
KeyError: 'partition_size'
Could someone advise what are the modifications need to be made in the build.sh to configure the vendor_dlkm to F2FS
Thanks
regards
MHC