[HD2 Android Q&A, Help & Troubleshooting and Genera] HypoTurtle:
Yip all seems fine there (unless you're trying to use a 3.0x kernel as the offset isn't being reported as being changed), have you ran the test.zip yet?

#!/sbin/sh
set -u
testing() {
echo "TESTING MODE"
types="NAND DataOnExt NativeSD DirectSD "
typecheck=` echo "$types" | grep "$1 " `
if [ -z "${typecheck}" ]; then
echo "$1 is not a valid type - choices are $types"
exit 0
fi
if [ -z "$2" ]; then
echo "no type or ROM name specified"
echo "usage sh multiboot.sh [type] [ROM_NAME]"
echo "type can be ${types}, ROM_NAME to be taken from ROM_NAMEqweasd1234.zip"
exit 0
fi
}
terminalvars() {
m="mntstuff"; is="orthis"; mr="maybethis"; fb="andthis"; runn="runn";
for i in $@;
do
##if -!
eval \$$i ${type:-NativeSD} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type:-3}; then
if [ $? = "127" ]; then
##eval \$$i ${type:-NativeSD} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type:-3}
TMP="VAR${t:-1}"
echo ${TMP}=$i
eval "${TMP}=$i"
t=2
type=$VAR1
ROM_NAME=$VAR2
fi
shift
done
}
optionscheck() {
### Options ###
options="m is mr fb $ROM_NAME $type"
m="mount partitions"; is="install system"; mr="modify ramdisk"; fb="flash boot partition"; runn="run all"
for i in $@
do
optioncheck=` echo "$options " | grep "$i " `
if [ -z "${optioncheck}" ]; then
echo "$i is not a valid option - choices are:"
for t in $options
do
echo -n "$t to "
eval echo \$${t}
done
exit 0
fi
done
}
cleanup() {
echo "cleaning"
rm -rf zI.txt bootimg.txt updater-script test.zip META-INF MEI ramds
}
partnames() {
sdpart=/dev/block/mmcblk0p1
firstpart=/dev/block/mmcblk0p2
secondpart=/dev/block/mmcblk0p3
echo "setting partitions with ${firstpart} format"
}
looppartnames() {
sdpart=/dev/block/platform/msm_sdcc.1/by-name/userdata/media/0
#sdpart=/sdcard
firstpart=/dev/block/loop1
secondpart=/dev/block/loop2
thirdpart=/dev/block/loop3
systemblock=/dev/block/mtd4
echo "setting partitions with ${firstpart} format"
}
mkloopdev() {
dd if=/dev/zero of=${sdpart}/${ROM_NAME}/system.ext4 bs=4096 count=128000
dd if=/dev/zero of=${sdpart}/${ROM_NAME}/data.ext4 bs=4096 count=256000
dd if=/dev/zero of=${sdpart}/${ROM_NAME}/cache.ext4 bs=4096 count=32000
losetup ${firstpart} ${sdpart}/${ROM_NAME}/system.ext4
losetup ${secondpart} ${sdpart}/${ROM_NAME}/data.ext4
losetup ${thirdpart} ${sdpart}/${ROM_NAME}/cache.ext4
UU=` blkid ${systemblock} | cut -d '"' -f '2' `
mke2fs -T ext4 -O has_journal,ext_attr,resize_inode,filetype,extent, sparse_super,large_file,uninit_bg -U ${UU} -I 256 ${firstpart}
mke2fs -T ext4 -O has_journal,ext_attr,resize_inode,filetype,extent, sparse_super,large_file,uninit_bg -U ${UU} -I 256 ${secondpart}
mke2fs -T ext4 -O has_journal,ext_attr,resize_inode,filetype,extent, sparse_super,large_file,uninit_bg -U ${UU} -I 256 ${thirdpart}
tune2fs -o journal_data_writeback ${secondpart}
tune2fs -o journal_data_writeback ${thirdpart}
losetup -d ${firstpart}
losetup -d ${secondpart}
losetup -d ${thirdpart}
}
getpropfile() {
if [ ! -d /tmp/sdcard ]; then
mkdir /tmp/sdcard
fi
mount ${sdpart} /tmp/sdcard
if [ -f "/tmp/sdcard/installtype.prop" ]; then
if [ -z "`cut -d ' ' -f '3' /tmp/sdcard/installtype.prop`" ]; then
type=` cat /tmp/sdcard/installtype.prop | awk '{print $(NF)}' | sed 's/\(\[\|\]\)//g' `
ROM_NAME=` cat /tmp/sdcard/installtype.prop | awk '{print $(NF-1)}' | sed 's/\(\[\|\]\)//g' `
data_NAME=${ROM_NAME}
else
data_NAME=` cat /tmp/sdcard/installtype.prop | awk '{print $(NF)}' | sed 's/\(\[\|\]\)//g' `
type=` cat /tmp/sdcard/installtype.prop | awk '{print $(NF-1)}' | sed 's/\(\[\|\]\)//g' `
ROM_NAME=` cat /tmp/sdcard/installtype.prop | awk '{print $(NF-2)}' | sed 's/\(\[\|\]\)//g' `
fi
else
echo "no installtype.prop on sdcard - exitting"
exit 0
fi
umount /tmp/sdcard
}
bootloadercheck() {
echo "checking bootloader"
bootloader=MAGLDR
output=`grep -i "clk" /proc/cmdline`
if [ -n "${output}" ]; then
bootloader=cLK
fi
}
bootloader() {
bootloader=cLK
}
mkdirs() {
echo "creating directories"
if [ ! -d /NativeSD ]; then
mkdir -p /NativeSD
fi
if [ ! -d /DirectSD ]; then
mkdir -p /DirectSD
fi
if [ ! -d /boot_dir ]; then
mkdir -p /boot_dir
fi
if [ ! -d /boot ]; then
mkdir -p /boot
fi
if [ ! -d /system ]; then
mkdir -p /system
fi
if [ ! -d /data ]; then
mkdir -p /data
fi
if [ ! -d /sdcard/NativeSD/"${2}" ]; then
mkdir -p /sdcard/NativeSD/"${2}"
fi
if [ ! -d /sdcard/NativeSD/"${2}"-new ]; then
mkdir -p /sdcard/NativeSD/"${2}"-new
fi
}
mountpart() {
echo "mounting files"
if [ -b "${firstpart}" ]; then
mount -t auto ${firstpart} /NativeSD
if [ ${1} = NativeSD ] || [ ${1} = DataOnExt ]; then
if [ ! -d /NativeSD/${2}/data ]; then
mkdir -p /NativeSD/${2}/data
fi
mount --bind /NativeSD/${3}/data /data
fi
if [ ${install_type} -gt '2' ]; then
if [ ! -d /NativeSD/${2}/system ]; then
mkdir -p /NativeSD/${2}/system
fi
mount --bind /NativeSD/${2}/system /system
fi
fi
sdmounted=`mount | grep "${sdpart} on /sdcard"`
if [ -z "${sdmounted}" ]; then
mount -t auto ${sdpart} /sdcard
fi
mount --bind /sdcard/NativeSD /boot_dir
mount --bind /sdcard/NativeSD/${2}-new /boot
if [ -b "${secondpart}" ]; then
mount -t auto ${secondpart} /DirectSD
if [ ${1} = DirectSD ]; then
if [ ! -d /DirectSD/${3}/data ]; then
mkdir -p /DirectSD/${3}/data
fi
mount --bind /DirectSD/${3}/data /data
fi
fi
}
bootorig() {
echo "saving original boot.img to boot-orig folder"
mkdir /boot_dir/boot-orig/
chmod 0777 /sbin/dump_image
/sbin/dump_image boot /boot/boot-orig/boot.img
}
systeminstall() {
echo "installing system"
cd /
# rm -rf /system/*
systemlocat=` mount | grep /system | cut -d ' ' -f '1' `
datalocat=` mount | grep /data | cut -d ' ' -f '1' `
echo "system mounted at ${systemlocat}"
echo "data mounted at ${datalocat}"
if [ -n "$systemlocat" ]; then
romzip="/sdcard/${2}*.zip"
echo ROM zip found is at ... ${romzip}
if [ ! -d /sdcard/tempy ]; then
mkdir /sdcard/tempy
fi
cp ${romzip} /sdcard/tempy/test.zip
chmod 0777 /sbin/7za
echo META-INF/*aroma* > exc.lst
echo "initrd.gz
zImage" > inc.lst
/sbin/7za x /sdcard/tempy/test.zip META-INF -oMEI '-xr@exc.lst' -y
/sbin/7za x /sdcard/tempy/test.zip '-ir@inc.lst' -oramds -y
ubi=` find MEI -name 'update-binary-installer' `
ups=` find MEI -name 'updater-script' `
echo "UBI location is ${ubi} UPS is ${ups}"
mkdir -p /META-INF/com/google/android
cp /$ubi /META-INF/com/google/android/update-binary
echo "package_extract_dir("system", "/system");
package_extract_dir("data", "/data");" > /META-INF/com/google/android/updater-script
cat /$ups | sed -e '/symlink(/,/);/!d' >> /META-INF/com/google/android/updater-script
cat /$ups | sed -e '/setmetadata(/,/);/!d' >> /META-INF/com/google/android/updater-script
echo "modifying updater-script"
echo "umount /NativeSD
umount /DirectSD
umount /system
umount /data
umount /boot
umount /system
umount /boot_dir" >> /META-INF/com/google/android/updater-script
/sbin/7za u /sdcard/tempy/test.zip META-INF/
else
cat "system not mounted"
fi
}
bootingred() {
echo "obtaining an initrd.gz and zImage to work with"
###### Copying zImage and initrd.gz from /boot_dir when one wasn't in the zip
if [ ! -e "boot.img" ]; then
nandinitrd=` find ramds -name 'initrd.gz' -print0 | xargs -0 ls -s | sort -nr | awk '{print $(NF)}' | tail -n 1 `
zImagelocat=` find ramds -name 'zImage' `
cp /${zImagelocat} /tmp/zImage
cp /${nandinitrd} /tmp/initrd.gz
else
chmod 0777 /sbin/unpackbootimg
cp boot.img /tmp/boot.img
/sbin/unpackbootimg /tmp/boot.img /tmp > /tmp/bootimg.txt
cp /tmp/boot.img-ramdisk.gz /tmp/initrd.gz
fi
if [ -f "/sdcard/zImage" ]; then
cp /sdcard/zImage /tmp/zImage
cp /sdcard/modules/* /system/lib/modules/ 2> /dev/null
fi
if [ -f "/sdcard/initrd.gz" ]; then
cp /sdcard/initrd.gz /tmp/initrd.gz
fi
}
usecurrentboot() {
chmod 0777 /sbin/dump_image
/sbin/dump_image boot /tmp/boot.img
/sbin/unpackbootimg /tmp/boot.img /tmp > /tmp/bootimg.txt
cp /tmp/boot.img-ramdisk.gz /tmp/initrd.gz
cp /tmp/boot.img-zImage /tmp/zImage
}
mkmountfs() {
echo "creating mountfs.sh"
if [ "${4}" -gt '1' ]; then
echo "#!/bin/busybox sh
# wait for 2nd partition ready
wait ${firstpart}
wait ${firstpart}
wait ${firstpart}
wait ${firstpart}
wait ${firstpart}" > /tmp/mountfs-"${1}".sh
if [ ${1} = DirectSD ]; then
echo "Modifying for ${type}"
echo "# wait for 3rd partition ready
wait ${secondpart}
wait ${secondpart}
wait ${secondpart}
wait ${secondpart}
wait ${secondpart}" >> /tmp/mountfs-"${1}".sh
fi
mt1=` blkid ${firstpart} | cut -d '"' -f '4' `
if [ ${mt1:-f2fs} = ext4 ]; then
echo "# check the ext4 fs
/bin/e2fsck -p ${firstpart} > /e2fsck.log" >> /tmp/mountfs-"${1}".sh
else
echo "# check the f2fs fs
/bin/fsck.f2fs -p ${firstpart} > /fsckf2fs.log" >> /tmp/mountfs-"${1}".sh
fi
if [ ${1} = DirectSD ]; then
if [ -b ${secondpart} ]; then
mt2=` blkid ${secondpart} | cut -d '"' -f '4' `
else
echo "No 2nd ext partition present, format one and run script again"
fi
if [ ${mt2:-f2fs} = ext4 ]; then
echo "# check the ext4 fs
/bin/e2fsck -p ${secondpart} > /e2fsck.log" >> /tmp/mountfs-"${1}".sh
else
echo "# check the f2fs fs
/bin/fsck.f2fs -p ${secondpart} > /fsckf2fs.log" >> /tmp/mountfs-"${1}".sh
fi
fi
echo "/bin/busybox mkdir -p /NativeSD
/bin/busybox mount -t ${mt1:-f2fs} -o ro,noatime,nodiratime,barrier=0 ${firstpart} /NativeSD
# mount the system data app dir" >> /tmp/mountfs-"${1}".sh
if [ ${1} = DataOnExt ]; then
echo "Modifying for ${1}"
echo "/bin/busybox mount --bind /NativeSD/${2}/data /data" >> /tmp/mountfs-"${1}".sh
fi
if [ ${4} -gt '2' ]; then
echo "/bin/busybox mount --bind /NativeSD/${2}/system /system" >> /tmp/mountfs-"${1}".sh
if [ ${1} = NativeSD ]; then
echo "Modifying for ${1}"
echo "/bin/busybox mount --bind /NativeSD/${3}/data /data" >> /tmp/mountfs-"${1}".sh
else
echo "/bin/busybox mkdir -p /DirectData
/bin/busybox mount -t ${mt2:-f2fs} -o noatime,nodiratime,nosuid,nodev,discard ${secondpart} /DirectData
/bin/busybox mount --bind /DirectData/${3}/data /data" >> /tmp/mountfs-"${1}".sh
fi
fi
echo "# cleanup
# delete /bin to free ram
### /bin/busybox rm -rf /bin" >> /tmp/mountfs-"${1}".sh
fi
}
mkinitrd() {
echo "modifying ramdisk"
###### Setting up working directory
cp /tmp/initrd.gz /tmp/initrd-${2}.gz
mkdir -p /tmp/work
cd /tmp/work

###### Unzipping nand kernel
gzip -d -c ../initrd-${2}.gz | cpio -i -d
if [ ! -d bin ]; then
mkdir bin
fi
cp /sbin/busybox /tmp/work/bin/busybox
cp /sbin/e2fsck /tmp/work/bin/e2fsck
cp /tmp/mountfs-${1}.sh /tmp/work/mountfs-${1}.sh

if [ ${mt1:-f2fs} = f2fs ] || [ ${mt2:-f2fs} = f2fs ]; then
echo "copying fsck for f2fs"
cp /sbin/fsck.f2fs /tmp/work/bin/fsck.f2fs
chmod 0777 /tmp/work/bin/fsck.f2fs
cp /sbin/dump.f2fs /tmp/work/bin/dump.f2fs
chmod 0777 /tmp/work/bin/dump.f2fs
fi
chmod 0777 /tmp/work/mountfs-${1}.sh
chmod 0777 /tmp/work/bin/busybox
chmod 0777 /tmp/work/bin/e2fsck

###### Modifying ramdisk to not use yaffs, and use sd partitions instead.
if [ "${4}" -gt '2' ]; then
sed -i '/mtd@misc/s/^/#/' /tmp/work/ueventd.*.rc
sed -i '/mount yaffs2/s/^/#/
s/# #/# /g' /tmp/work/*.rc
fi
###### Checking for anything other than nand is to be installed
if [ "${4}" -gt '1' ]; then
sed -i "/on fs/ a exec /mountfs-${1}.sh/" /tmp/work/*.rc
chmod 0750 /tmp/work/init*.rc
chmod 0644 /tmp/work/ueventd.*.rc
fi
###### Building new ramdisk
find . | cpio -o -H newc | gzip -9 > /tmp/initrd-done.gz
}
mkinitrdduo() {
mkdir -p /tmp/work/ing
mkdir -p /tmp/work/ramd
/sbin/unpackbootimg /tmp/boot.img /tmp/work/
## Setting up working directory
cp /tmp/boot.img-ramdisk.gz /tmp/work/initrd.gz
## Unzipping nand kernel
gzip -d -c ../initrd.gz | cpio -i -d
chmod 777 sbin
chmod 777 sbin/ramdisk.cpio
cp /tmp/work/ing/sbin/ramdisk.cpio /tmp/work/ramd
cd /tmp/work/ramd
cpio -i -d < ramdisk.cpio
rm ramdisk.cpio
mkdir bin
cp /sbin/busybox bin/busybox
cp /sbin/e2fsck bin/e2fsck
cp /tmp/mountfs.sh /tmp/work/ramd/
chmod 0777 mountfs.sh
chmod 0777 bin/busybox
chmod 0777 bin/e2fsck
## Modifying ramdisk to not use fstab, and use mountfs.sh instead.
sed -i '/mount_all/s/^/#/' init*.rc
sed -i "s/rOm/$ROM_NAME/g" mountfs-${type}.sh
sed -i '/on fs/ a exec /mountfs.sh' init*.rc
chmod 0750 init*.rc
find .| cpio -o -H newc > newramdisk.cpio
cp /tmp/ramd/newramdisk.cpio /tmp/work/ing/sbin/ramdisk.cpio
chmod 750 /tmp/work/ing/sbin/ramdisk.cpio
chmod 750 /tmp/work/ing/sbin
cd /tmp/work/ing
# Building new ramdisk
find .| cpio -o -H newc | gzip -9 > ../boot.img-ramd.gz
}
initrdcp() {
echo "copying ramdisk"
###### Checking bootloader
cd /tmp
if [ ${bootloader} != cLK ]; then
###### Checking zImage type
if [ -f zImage ]; then
hexdump -C zImage | grep '1f 8b 08' > zI.txt
if grep -q 00003f80 "zI.txt"; then
dd if=/dev/zero of=/tmp/6MB bs=1M count=6
fi
fi
cat /tmp/initrd-done.gz >> 6MB
cp 6MB /boot_dir/"${ROM_NAME}"-new/initrd.gz
cp zImage /boot_dir/"${ROM_NAME}"-new/zImage
else
cp /tmp/initrd-done.gz /tmp/initrd.gz
if [ "${install_type}" -gt '2' ]; then
cp /tmp/initrd.gz /boot/initrd.gz
cp /tmp/zImage /boot/zImage
fi
fi
}
bootflash() {
echo "flashing boot"
cd /tmp
chmod 0755 mkbootimg
base=` cat /tmp/bootimg.txt | grep 'base' | cut -d ' ' -f '9' ` 2> /dev/null
base=${base:-0x11800000}
/sbin/mkbootimg --base "${base}" --cmdline "`cat /tmp/boot.img-cmdline`" --kernel /boot_dir/${ROM_NAME}-new/zImage --ramdisk /boot_dir/${ROM_NAME}-new/initrd.gz -o /tmp/boot.img
if [ ${install_type} -gt '2' ] && [ -b /sboot ]; then
boot=sboot
else
boot=boot
fi
chmod 0777 /sbin/flash_image
/sbin/flash_image "${boot}" /tmp/boot.img
}
revertinitrd() {
echo "reverting ramdisk in /tmp"
cd /
cp /tmp/initrd-"${ROM_NAME}".gz /tmp/initrd.gz
}
showresult() {
echo "Ramdisk successfully modified for ${ROM_NAME} running as ${type} on ${mt1:-f2fs}"
if [ -n "$mt2:-f2fs" ]; then
echo "with data on ${mt2:-f2fs}"
fi
echo "The install folder is ${ROM_NAME}-new"
if [ -f tmp/zI.txt ]; then
if grep -q 00003f80 tmp/zI.txt; then
echo "kernel used is a 3.0.x kernel"
else
echo "kernel used is a 2.x kernel"
fi
fi
if [ -f /sdcard/tempy/test.zip ]; then
echo "Please flash testy/test.zip in recovery"
fi
}
exiterr() {
echo "command failed"; exit 1;
}
runn() {
cleanup || exiterr
partnames || exiterr
bootloadercheck || exiterr
mkdirs "$@" || exiterr
if [ "${4}" -gt '1' ]; then
mountpart "$@" || exiterr
fi
if [ "${bootloader}" = cLK ]; then
bootorig || exiterr
fi
installsystem=`find '/sdcard' -name '*.zip' | grep ${2}`
if [ -n "${installsystem}" ]; then
systeminstall "$@" || exiterr
fi
if [ ! -f /tmp/initrd.gz ]; then
bootingred "$@" || exiterr
fi
if [ ! -f /tmp/mountfs-"${1}".sh ]; then
mkmountfs "$@" || exiterr
fi
mkinitrd "$@" || exiterr
initrdcp || exiterr
if [ ${bootloader} = cLK ]; then
bootflash
fi
# revertinitrd || exiterr
showresult || exiterr
}
##${verbose:-""}
##verbose="> /dev/null"
##verbose="2> /dev/null"
##verbose="2> /sdcard/univlog.txt"
##verbose="2&> /sdcard/univlog.txt"
###
mntstuff(){
##getpropfile $@
partnames $@
mkdirs $@
mountpart $@
}
modifyramdisk(){
mntstuff $@
install_type=` expr index "Axvr" "${type}" `
bootingred $@
mkmountfs $@
mkinitrd $@
initrdcp $@
}
flashbootpart(){
bootingred $@
bootflash $@
}
########
scnm=` echo $0 | grep univ `
if [ -n "$scnm" ]; then
cp /sdcard/bins/* /sbin 2> /dev/null
type=${1}
ROM_NAME=${2}
if [ -n $1 ]; then
testing "$@" || exiterr
else
getpropfile || exiterr
fi
install_type=` expr index "Axvr" "${1}" `
echo "install_no=$install_type"
runn ${type:-NativeSD} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type:-3}
cp /tmp/mountfs-"${type}".sh /sdcard/testrun.txt
cat /tmp/work/init.rc >> /sdcard/testrun.txt
fi
########
scnm2=` echo $0 | grep dothis `
if [ -n "$scnm2" ]; then
cp /sdcard/bins/* /sbin 2> /dev/null
optionscheck
echo "opt check"
m="mntstuff"; is="install system"; mr="modifyramdisk"; fb="flash boot partition"
#for i in $@
#do
#eval \$$i ${type:-NativeSD} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type:-3}
#done
fi
########
exit 0

Not 100% sure what 'symlink("../bin/fsck.f2fs", "/system/bin/dump.f2fs");' is mean to symlink from I believe it symlinks from the boot.img bin folder - so ##'ed the rm bin from mountfs.sh (in the script fsck "and now dump" are taken from the sbin in recovery - ROM 'should' run without them, but to be sure they are included you'll need to be running f2fs recovery).

Edit have modified to dump /sdcard/bins/ to /sbin.

With the above script running "sh dothis.sh DirectSD PixelDroid_Liquid m" should mount the partitions (scriptname needs to have 'dothis' in it)

I think we are ready for this (the functions part) to be added into a recovery