[HD2 Android Q&A, Help & Troubleshooting and Genera] HypoTurtle:
Yea I see what you mean, in the haret stuff (startup, haret , clrcad) will be taken from the Rom_Zip and if there's none there, then from /tmp (where /sdcard/bins is copied to), do you know if there's any variation in startup.txt other than the rel_path. If there isn't I'll generate in in the script.

Not sure why that's happening with the updater-script - try the attached (it should generate a run.log file on the sdcard)

#!/sbin/sh
set -u
testing() {
busybox printf "%s\n" "TESTING MODE" | tee /tmp/${0}run.log
sdpart=/dev/block/mmcblk0p1
types="NAND DataOnExt NativeSD DirectSD porta "
options="m ins mr fb "
m="mount partitions"; ins="install system"; mr="modify the ramdisk"; fb="andthis"; runn="runn"
if [ $# -gt 0 ]; then
typecheck=` echo "$types" | grep "$1 " ` | tee -a /tmp/${0}run.log
if [ -z "${typecheck}" ]; then
echo "$1 is not a valid type - choices are $types" | tee -a /tmp/${0}run.log
echo "checking if $1 is a command" | tee -a /tmp/${0}run.log
optioncheck=` echo "$options" | grep "$1 " `
if [ -z ${optioncheck} ]; then
busybox printf "%s\n" "${1} is not a valid option - choices are:"
for i in ${options}
do
busybox printf "%s" "$i to "
eval echo "\$${i}"
done
cp /tmp/${0}run.log /sdcard/${0}run.log
exit 0
else
typecheck=` echo "$types" | grep "$2 " `
if [ -n "${typecheck}" ] || [ -n "${optioncheck}" ]; then
type=${2}
ROM_NAME=${3}
data_NAME=${4:-$ROM_NAME}
install_type=` expr index "Axvrp" "${type}" `
systemunzip=${5:-n}
if [ ${type} = "porta" ]; then
systemunzip=y
fi
echo "TYPE is $type
RomName is $ROM_NAME
DataName is $data_NAME
install no is $install_type
system install is $systemunzip" | tee -a /tmp/${0}run.log
m="mntstuff"; ins="installsystem"; mr="modifyramdisk"; fb="andthis"; runn="runn"
eval \$${1} ${type:-NativeSD} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type:-3} ${systemunzip}
fi
fi
else
type=${1}
ROM_NAME=${2}
data_NAME=${3:-$ROM_NAME}
install_type=` expr index "Axvrp" "${type}" `
systemunzip=${4:-n}
runn ${type:-NativeSD} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type:-3} ${systemunzip}
fi
else
busybox printf "%s\n" "no commands sent to script
checking /sdcard/installtype.prop" | tee -a /tmp/${0}run.log
getpropfile
systemunzip=${4:-n}
runn ${type:-NativeSD} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type:-3} ${systemunzip}
cp /tmp/${0}run.log /sdcard/${0}run.log
exit 0
fi
}
#terminalvars() {
#m="mntstuff"; is="orthis"; mr="maybethis"; fb="andthis"; runn="runn";
#for i in $@;
#do
#	eval \$$i ${type:-NativeSD} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type:-3} ${systemunzip:-n}
#	if [ $? = "127" ]; then
#	##eval \$$i ${type:-NativeSD} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type:-3}
#	TMP="VAR${t:-1}"
#	printf "%s\n" ${TMP}=$i
#	eval "${TMP}=$i"
#	t=$((t+1))
#	type=$VAR1
#	ROM_NAME=$VAR2
#	data_NAME=$VAR3
#	install_type=` expr index "Axvr" "${type}" `
#	printf "%s\n" install type is $type
#	printf "%s\n" ROM_NAME is $ROM_NAME
#	printf "%s\n" data_NAME is $data_NAME
#	printf "%s\n" install no. is $install_type
#	fi
#done
#}
#optionscheck() {
#### Options ###
#terminalvars $@
#options="m is mr fb $ROM_NAME $type ${data_NAME:-$ROM_NAME} $install_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
#	printf "%s\n" "$i is not a valid option - choices are:"
#	for t in $options
#	do
#	printf "%s" "$t to "
#	eval echo \$${t}
#	#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 umountloop.sh
}
partnames() {
firstpart=/dev/block/mmcblk0p2
secondpart=/dev/block/mmcblk0p3
busybox printf "%s\n" "setting partitions with ` echo ${firstpart} | cut -d "/" -f "4" ` format" | tee -a /tmp/${0}run.log
}
looppartnames() {
firstpart=/dev/block/loop1
secondpart=/dev/block/loop2
thirdpart=/dev/block/loop3
busybox printf "%s\n" "setting partitions with ` echo ${firstpart} | cut -d "/" -f "4" ` format" | tee -a /tmp/${0}run.log
}
mkloopdev() {
echo "" >> /sdcard/porta.txt
fls=` cat /sdcard/porta.txt | cut -d " " -f "1" `
dd if=/dev/zero of=/sdcard/${ROM_NAME}/system.${fls:-ext4} bs=4096 count=${romsize}
dd if=/dev/zero of=/sdcard/${ROM_NAME}/data.${fls:-ext4} bs=4096 count=256000
dd if=/dev/zero of=/sdcard/${ROM_NAME}/cache.${fls:-ext4} bs=4096 count=32000
losetup ${firstpart} /sdcard/${ROM_NAME}/system.${fls:-ext4}
losetup ${secondpart} /sdcard/${ROM_NAME}/data.${fls:-ext4}
losetup ${thirdpart} /sdcard/${ROM_NAME}/cache.${fls:-ext4}
busybox mke2fs -T ${fls:-ext4} -O has_journal,ext_attr,resize_inode,filetype,extent,sparse_super,large_file,uninit_bg -I 256 ${firstpart}
busybox mke2fs -T ${fls:-ext4} -O has_journal,ext_attr,resize_inode,filetype,extent,sparse_super,large_file,uninit_bg -I 256 ${secondpart}
busybox mke2fs -T ${fls:-ext4} -O has_journal,ext_attr,resize_inode,filetype,extent,sparse_super,large_file,uninit_bg -I 256 ${thirdpart}
tune2fs -o journal_data_writeback ${secondpart}
tune2fs -o journal_data_writeback ${thirdpart}
}
mountloop() {
mount ${firstpart} /system
mount ${secondpart} /data
mount ${thirdpart} /cache
echo "#!/sbin/sh
losetup -d ${firstpart}
losetup -d ${secondpart}
losetup -d ${thirdpart}
" > /tmp/umountloop.sh
}
getpropfile() {
mkdir -p /tmp/sdcard > /dev/null
mount ${sdpart} /tmp/sdcard
if [ -f "/tmp/sdcard/installtype.prop" ]; then
busybox printf "%s\n" "installtype.prop found on sdcard" | tee -a /tmp/${0}run.log
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
install_type=` expr index "Axvrp" "${type}" `
else
busybox printf "%s\n" "no installtype.prop on sdcard - exitting
no type or ROM name specified
usage sh hytmb.sh {options} [type] [ROM_NAME]
type can be ${types},
ROM_NAME to be taken from ROM_NAMEqweasd1234.zip" | tee -a /tmp/${0}run.log
for i in ${options}
do
busybox printf "%s" "$i to "
eval echo "\$${i}"
done
cp /tmp/${0}run.log /sdcard/${0}run.log
exit 0
fi
umount /tmp/sdcard
}
bootloadercheck() {
busybox printf "%s\n" "checking bootloader" | tee -a /tmp/${0}run.log
bootloader=MAGLDR
output=`grep -i "clk" /proc/cmdline`
if [ -n "${output}" ]; then
bootloader=cLK
fi
output=`grep -i "haret" /proc/cmdline`
if [ -n "${output}" ]; then
bootloader=haret
fi
####For testing
#bootloader=haret
}
bootloader() {
bootloader=cLK
}
mkdirs() {
busybox printf "%s\n" "creating directories" | tee -a /tmp/${0}run.log
mkdir -p /NativeSD > /dev/null
mkdir -p /DirectSD > /dev/null
mkdir -p /boot_dir > /dev/null
mkdir -p /boot > /dev/null
mkdir -p /system > /dev/null
mkdir -p /data > /dev/null
mkdir -p /sdcard/NativeSD/"${2}" > /dev/null
mkdir -p /sdcard/NativeSD/"${2}"_"${1}" > /dev/null
}
mountpart() {
busybox printf "%s\n" "mounting files" | tee -a /tmp/${0}run.log
if [ -b "${firstpart}" ]; then
mount -t auto ${firstpart} /NativeSD
if [ ${1} = "NativeSD" ] || [ ${1} = "DataOnExt" ]; then
mkdir -p /NativeSD/${2}/data > /dev/null
mount --bind /NativeSD/${3}/data /data
fi
if [ ${install_type} -gt '2' ]; then
mkdir -p /NativeSD/${2}/system > /dev/null
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}_${1} /boot
if [ -b "${secondpart}" ]; then
mount -t auto ${secondpart} /DirectSD
if [ ${1} = "DirectSD" ]; then
mkdir -p /DirectSD/${3}/data > /dev/null
mount --bind /DirectSD/${3}/data /data
fi
fi
}
bootorig() {
busybox printf "%s\n" "saving original boot.img to boot-orig folder" | tee -a /tmp/${0}run.log
mkdir /boot_dir/boot-orig/
#chmod 0777 /tmp/dump_image
/tmp/dump_image boot /boot/boot-orig/boot.img
}
systeminstall() {
##cp /tmp/inc.lst /inc.lst > /dev/null
##cp /tmp/exc.lst /exc.lst > /dev/null
busybox printf "%s\n" "installing system" | tee -a /tmp/${0}run.log
cd /
# rm -rf /system/*
local systemlocat=` mount | grep /system | cut -d ' ' -f '1' `
local datalocat=` mount | grep /data | cut -d ' ' -f '1' `
echo "system mounted at ... ${systemlocat}" | tee -a /tmp/${0}run.log
echo "data mounted at ... ${datalocat}" | tee -a /tmp/${0}run.log
if [ -n "$systemlocat" ]; then
local romzip="/sdcard/${2}*.zip"
echo ROM zip found is at ... ${romzip} | tee -a /tmp/${0}run.log
cp ${romzip} /sdcard/${2}_${1}.zip
chmod 0777 /tmp/7za
echo META-INF/*aroma* > exc.lst
echo "initrd.gz
zImage
boot.img" > inc.lst
###### Including haret stuff ###
if [ ${bootloader} = "haret" ]; then
echo "haret.exe
clrcad.exe
startup.txt" >> inc.lst
fi
/tmp/7za x /sdcard/${2}_${1}.zip META-INF -oMEI '-xr@exc.lst' -y > /dev/null
/tmp/7za x /sdcard/${2}_${1}.zip '-ir@inc.lst' -oramds -y > /dev/null
if [ ${5} = "y" ]; then
echo "installing system" | tee -a /tmp/${0}run.log
if [ ${type} = "porta" ]; then
echo "creating system, data and cache blocks on /sdcard first"
romsize=` /tmp/7za -l /sdcard/${2}_${1}.zip | tail -1 | awk '{print $(NF-5)}'/4096 `
mkloopdev
mountloop
fi
/tmp/7za x /sdcard/${2}_${1}.zip data -y >> /tmp/${0}run.log
/tmp/7za x /sdcard/${2}_${1}.zip system -y >> /tmp/${0}run.log
fi
local ubi=` find MEI -name update-binary-installer -print0 `
local ub=` find MEI -name update-binary -print0 `
local ups=` find MEI -name updater-script -print0 `
echo "UBI location is ${ubi:-$ub} UPS is ${ups}" | tee -a /tmp/${0}run.log
mkdir -p /META-INF/com/google/android
cp /${ubi:-$ub} /META-INF/com/google/android/update-binary
##echo "package_extract_file(\"multi.sh\", \"/tmp/multi.sh\");
##set_perm(0, 0, 0777, \"/tmp/multi.sh\");
##run_program(\"/tmp/multi.sh\", \"m\" \"${type}\" \"${ROM_NAME}\" \"${data_NAME}\" > /META-INF/com/google/android/updater-script
if [ ${type} = "porta" ]; then
cat /$ups | sed -e '/^symlink/,/);/!d' > /META-INF/com/google/android/updater-script
else
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
fi
cat /$ups | sed -e '/^set_perm/,/);/!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 "unmount (\"/NativeSD\");
unmount (\"/DirectSD\");
unmount (\"/system\");
unmount (\"/data\");
unmount (\"/boot\");
unmount (\"/boot_dir\");
" >> /META-INF/com/google/android/updater-script
if [ ${type} = "porta" ]; then
echo "run_program("/tmp/umountloop.sh");
" >> /META-INF/com/google/android/updater-script
fi
/tmp/7za u /sdcard/${2}_${1}.zip META-INF/ | tee -a /tmp/${0}run.log
#dd if=$0 of=multi.sh
#/tmp/7za a /sdcard/${2}_${1}.zip multi.sh
else
echo "system isn't mounted" | tee -a /tmp/${0}run.log
fi
}
bootingred() {
busybox printf "%s\n" "obtaining an initrd.gz and zImage to work with" | tee -a /tmp/${0}run.log
###### Copying zImage and initrd.gz from /boot_dir when one wasn't in the zip
if [ ! -e "ramds/boot.img" ]; then
local nandinitrd=` find ramds -name initrd.gz -print0 | xargs -0 ls -s | sort -nr | awk '{print $(NF)}' | tail -n 1 `
local zImagelocat=` find ramds -name zImage `
echo "nand ramdisk is at ... $nandinitrd" | tee -a /tmp/${0}run.log
echo "zImage is at ... $zImagelocat" | tee -a /tmp/${0}run.log
cp /${zImagelocat} /tmp/
cp /${nandinitrd} /tmp/initrd.gz
else
chmod 0777 /tmp/unmkbootimg
cp /ramds/boot.img /tmp/boot.img
mkdir -p /tmp/boot 2> /dev/null
cd /tmp
./unmkbootimg /tmp/boot.img /tmp/boot
cd /
cp /tmp/boot/boot.img-ramdisk.gz /tmp/initrd.gz
cp /tmp/boot/boot.img-zImage /tmp/zImage
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 /tmp/dump_image
/tmp/dump_image boot /tmp/boot.img
/tmp/unpackbootimg /tmp/boot.img /tmp > /tmp/bootimg.txt
cp /tmp/boot.img-ramdisk.gz /tmp/initrd.gz
cp /tmp/boot.img-zImage /tmp/zImage
}
mkmountfsloop() {
echo "#!/bin/busybox sh
while [ ! -b ${sdpart} ]; do
/bin/busybox sleep 5
done
/bin/busybox sleep 2
/bin/e2fsck -p /sdcard/${ROM_NAME}/system.${fls:-ext4} > e2fsck.log
/bin/e2fsck -p /sdcard/${ROM_NAME}/data.${fls:-ext4} >> e2fsck.log
/bin/e2fsck -p /sdcard/${ROM_NAME}/cache.${fls:-ext4} >> e2fsck.log
losetup ${firstpart} /sdcard/${ROM_NAME}/system.${fls:-ext4}
losetup ${secondpart} /sdcard/${ROM_NAME}/data.${fls:-ext4}
losetup ${thirdpart} /sdcard/${ROM_NAME}/cache.${fls:-ext4}
/bin/busybox mount ${firstpart} /system
/bin/busybox mount ${secondpart} /data
/bin/busybox mount ${thirdpart} /cache" > /tmp/mountfs-"${1}".sh
if [ ${fls:-ext4} = "ext4" ]; then
echo "tune2fs -O dir_index,has_journal,uninit_bg ${firstpart}
echo tune2fs -O dir_index,has_journal,uninit_bg ${secondpart}
echo tune2fs -O dir_index,has_journal,uninit_bg ${thirdpart}" >> /tmp/mountfs-"${1}".sh
else
echo "tune2fs -o journal_data_writeback ${secondpart}
tune2fs -o journal_data_writeback ${thirdpart}" >> /tmp/mountfs-"${1}".sh
fi
echo "# cleanup - delete /bin to free ram
/bin/busybox rm -rf /bin
" >> mountfs-${1}.sh
}
mkmountfs() {
busybox printf "%s\n" "creating mountfs.sh" | tee -a /tmp/${0}run.log
if [ "${4}" -gt '1' ]; then
echo "#!/bin/busybox sh
while [ ! -b ${firstpart} ]; do
/bin/busybox sleep 5
done
/bin/busybox sleep 2" > /tmp/mountfs-"${1}".sh
if [ ${1} = DirectSD ]; then
echo "Modifying for ${type}"
echo "while [ ! -b ${secondpart} ]; do
/bin/busybox sleep 5
done
/bin/busybox sleep 2" >> /tmp/mountfs-"${1}".sh
fi
mt1=` blkid ${firstpart} | cut -d '"' -f '4' `
mt2="${mt1}"
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} > /e2fsck2.log" >> /tmp/mountfs-"${1}".sh
else
echo "# check the f2fs fs
/bin/fsck.f2fs -p ${secondpart} > /fsckf2fs2.log" >> /tmp/mountfs-"${1}".sh
fi
fi
echo "/bin/busybox mkdir -p /NativeSD
/bin/busybox mount -t ${mt1:-f2fs} -o noatime,nodiratime,barrier=0 ${firstpart} /NativeSD
# mount the data 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 "##/system/bin/logcat -d -f /sdcard/logcat.log *:V
# cleanup
# delete /bin to free ram
### /bin/busybox rm -rf /bin" >> /tmp/mountfs-"${1}".sh
fi
}
mkinitrd() {
busybox printf "%s\n" "modifying ramdisk" | tee -a /tmp/${0}run.log
###### 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 /tmp/busybox /tmp/work/bin/busybox
cp /tmp/e2fsck /tmp/work/bin/e2fsck
cp /tmp/mountfs-${1}.sh /tmp/work/mountfs-${1}.sh

if [ ${mt1:-f2fs} = f2fs ] || [ ${mt2:-f2fs} = f2fs ]; then
busybox printf "%s\n" "copying fsck for f2fs"
cp /tmp/fsck.f2fs /tmp/work/bin/fsck.f2fs
chmod 0777 /tmp/work/bin/fsck.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
/tmp/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 /tmp/busybox bin/busybox
cp /tmp/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() {
busybox printf "%s\n" "copying ramdisk" | tee -a /tmp/${0}run.log
###### 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 /tmp/initrd.gz
else
cp /tmp/initrd-done.gz /tmp/initrd.gz
fi
cp /tmp/initrd.gz /boot/initrd.gz; cp /tmp/zImage /boot/zImage; cp /tmp/initrd.gz /boot_dir/initrd.gz; cp /tmp/zImage /boot_dir/zImage
cd /
}
bootflash() {
busybox printf "%s\n" "flashing boot" | tee -a /tmp/${0}run.log
chmod 0755 /tmp/mkbootimg
base=` cat /tmp/boot.img-base `
base=${base:-0x11800000}
cd /tmp
./mkbootimg --base "${base}" --cmdline "`cat /tmp/boot.img-cmdline`" --kernel /boot/zImage --ramdisk /boot/initrd.gz -o /tmp/boot.img
cd /
cp /tmp/boot.img /sdcard/NativeSD/"${2}"_"${1}"/
#if [ ${install_type} -gt '2' ] && [ -b /sboot ]; then
# boot=sboot
#else
# boot=boot
#fi
#chmod 0777 /tmp/flash_image
#/tmp/flash_image "${boot}" /tmp/boot.img
}
revertinitrd() {
busybox printf "%s\n" "reverting ramdisk in /tmp" | tee -a /tmp/${0}run.log
cp /tmp/initrd-"${ROM_NAME}".gz /tmp/initrd.gz
}
showresult() {
busybox printf "%s\n" "Ramdisk successfully modified for ${ROM_NAME} running as ${type} on ${mt1:-f2fs} with data on ${mt2:-f2fs}
The install folder is ${ROM_NAME}_${type}" | tee -a /tmp/${0}run.log
if [ -f tmp/zI.txt ]; then
if grep -q 00003f80 tmp/zI.txt; then
busybox printf "%s\n" "Kernel used is a 3.0.x kernel" | tee -a /tmp/${0}run.log
else
busybox printf "%s\n" "Kernel used is a 2.x kernel" | tee -a /tmp/${0}run.log
fi
fi
if [ -f /sdcard/tempy/test.zip ]; then
busybox printf "%s\n" "Please flash ${2}_${1}.zip in recovery" | tee -a /tmp/${0}run.log
fi
}
exiterr() {
echo "command failed"; exit 1;
}
runn() {
cleanup || exiterr
if [ ${type} = "porta" ]; then
looppartnames || exiterr
else
partnames || exiterr
fi
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 [ "$bootloader" = "haret" ]; then
###not sure on this ###
haretstuff < clrcad.exe haret.exe startup.txt || exiterr
fi
if [ ! -f /tmp/initrd.gz ]; then
bootingred "$@" || exiterr
fi
if [ ! -f /tmp/mountfs-"${1}".sh ]; then
echo "making mountfs.sh for $type"
if [ ${type} = "porta" ]; then
mkmountfsloop "$@" || exiterr
else
mkmountfs "$@" || exiterr
fi
fi
mkinitrd "$@" || exiterr
initrdcp || exiterr
if [ ${bootloader} = cLK ]; then
bootflash
fi
# revertinitrd || exiterr
showresult || exiterr
}
#vb() {
#local q=""
#local e="> /dev/null"
#local r="2> /dev/null"
#local l="2> /sdcard/univlog.txt"
#local b="2&> /sdcard/univlog.txt"
#export verb=`eval \$${1} `
#}
mntstuff() {
##getpropfile $@
mkdirs $@
if [ ${type} != "porta" ]; then
partnames $@
mountpart $@
else
looppartnames $@
mountloop
fi
}
modifyramdisk() {
mntstuff $@
install_type=` expr index "Axvrp" "${type}" `
bootingred $@
mkmountfs $@
mkinitrd $@
initrdcp $@
}
flashbootpart() {
bootingred $@
bootflash $@
}
findit() {
find $1 -name $2
}
remtxt() {
currdir=$(pwd)
rmfile=` cat /tmp/removerc.txt | awk '{print $(NF)}' `
startrm=` cat /tmp/removerc.txt | awk '{print $(NF-1)}' `
endrm=` cat /tmp/removerc.txt | awk '{print $(NF-2)}' `
grep -lrIZ $p $currdir/$rmfile | xargs -0 sed --in-place "/$startrm/,/$endrm/d"
}
haretstuff() {
for i in $@; do zz=`findit ramds $i`; sdsd=`findit tmp $i`
hrtstff=${zz:-$sdsd}
if [ -n ${hrtstff} ]; then
cp ${hrtstff} /boot_dir
fi
done
bootloader=MAGLDR
}
installsystem() {
systemunzip="y"
systeminstall ${type} ${ROM_NAME} ${data_NAME:-$ROM_NAME} ${install_type} ${systemunzip:-n}
}
cp /sdcard/bins/* /tmp 2> /dev/null
testing "$@" || exiterr
cp /tmp/${0}run.log /sdcard/${0}run.log
exit 0