278 lines
7.0 KiB
Bash
Executable File
278 lines
7.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
VER=2.5.1
|
|
ROM=Froyo_Sense_Revolution
|
|
|
|
BUILD1_NAME=${ROM}_${VER}_CWM
|
|
BUILD2_NAME=${ROM}_${VER}_DFT
|
|
BUILD3_NAME=${ROM}_${VER}_LK
|
|
BUILD1=/tmp/${BUILD1_NAME}
|
|
BUILD2=/tmp/${BUILD2_NAME}
|
|
BUILD3=/tmp/${BUILD3_NAME}
|
|
TOOLS=${PWD}/../tools
|
|
MKYAFFS=${TOOLS}/mkyaffs2image
|
|
UNYAFFS=${TOOLS}/unyaffs
|
|
MAIN=${PWD}
|
|
|
|
syncDirs()
|
|
{
|
|
mkdir -p ${BUILD1}
|
|
echo -n "Synchronising the build ... "
|
|
rsync --exclude ".svn" -az ${MAIN}/../build/* ${BUILD1}/.
|
|
echo "DONE"
|
|
rm -rf ${BUILD1}/boot/initrd
|
|
|
|
# Change the version number in build.prop
|
|
sed -i s/ro.product.version=.*/ro.product.version=${VER}/g ${BUILD1}/system/build.prop
|
|
sed -i s/ro.build.description=.*/ro.build.description=${ROM}/g ${BUILD1}/system/build.prop
|
|
}
|
|
|
|
set_perm_recursive()
|
|
{
|
|
file=`echo $5 | sed -E 's/\///'`
|
|
chown -R $1:$2 $file
|
|
find $file -type d -exec chmod $3 {} \;
|
|
find $file -type f -exec chmod $4 {} \;
|
|
}
|
|
|
|
set_perm()
|
|
{
|
|
file=`echo $4 | sed -E 's/\///'`
|
|
chown $1:$2 $file
|
|
chmod $3 $file
|
|
}
|
|
|
|
doFiles()
|
|
{
|
|
# create symlinks for busybox
|
|
pushd ${BUILD1}/system/xbin > /dev/null 2>&1
|
|
for file in `cat ${TOOLS}/busybox`
|
|
do
|
|
ln -sf busybox $file
|
|
done
|
|
popd > /dev/null 2>&1
|
|
|
|
# create symlinks for toolbox
|
|
pushd ${BUILD1}/system/bin > /dev/null 2>&1
|
|
for file in `cat ${TOOLS}/toolbox`
|
|
do
|
|
ln -sf toolbox $file
|
|
done
|
|
popd > /dev/null 2>&1
|
|
|
|
# create symlink for su
|
|
pushd ${BUILD1}/system/bin > /dev/null 2>&1
|
|
ln -sf ../xbin/su
|
|
popd > /dev/null 2>&1
|
|
|
|
# To enable a2sd+ by default
|
|
# app, app-private and dalvik-cache
|
|
pushd ${BUILD1}/data > /dev/null 2>&1
|
|
ln -s /sd-ext/app
|
|
ln -s /sd-ext/app-private
|
|
ln -s /sd-ext/dalvik-cache
|
|
touch .dalvikcache
|
|
popd > /dev/null 2>&1
|
|
|
|
# To enable datasd uncomment the lines below
|
|
#pushd ${BUILD1}/data > /dev/null 2>&1
|
|
#ln -s /sd-ext/data
|
|
#touch .datasd
|
|
#popd > /dev/null 2>&1
|
|
|
|
pushd ${BUILD1}/system/etc/init.d > /dev/null 2>&1
|
|
mv dtapp 04apps2sd
|
|
popd > /dev/null 2>&1
|
|
|
|
# change permissions
|
|
pushd ${BUILD1} > /dev/null 2>&1
|
|
set_perm_recursive 0 0 0755 0644 "/system"
|
|
set_perm_recursive 0 2000 0755 0755 "/system/bin"
|
|
set_perm 0 3003 02750 "/system/bin/netcfg"
|
|
set_perm 0 3004 02755 "/system/bin/ping"
|
|
set_perm 0 2000 06750 "/system/bin/run-as"
|
|
set_perm_recursive 1002 1002 0755 0440 "/system/etc/bluetooth"
|
|
set_perm 0 0 0755 "/system/etc/bluetooth"
|
|
set_perm 1000 1000 0640 "/system/etc/bluetooth/auto_pairing.conf"
|
|
set_perm 3002 3002 0444 "/system/etc/bluetooth/blacklist.conf"
|
|
set_perm 1002 1002 0440 "/system/etc/dbus.conf"
|
|
set_perm 1014 2000 0550 "/system/etc/dhcpcd/dhcpcd-run-hooks"
|
|
set_perm_recursive 0 2000 0755 0750 "/system/etc/init.d"
|
|
set_perm 0 0 0755 "/system/etc/init.d"
|
|
set_perm 0 2000 0550 "/system/etc/init.goldfish.sh"
|
|
#set_perm 0 0 0544 "/system/etc/install-recovery.sh"
|
|
set_perm_recursive 0 0 0755 0555 "/system/etc/ppp"
|
|
set_perm_recursive 0 2000 0755 0755 "/system/xbin"
|
|
set_perm 0 0 06755 "/system/xbin/hcitool"
|
|
set_perm 0 0 06755 "/system/xbin/librank"
|
|
set_perm 0 0 06755 "/system/xbin/procmem"
|
|
set_perm 0 0 06755 "/system/xbin/procrank"
|
|
set_perm 0 0 06755 "/system/xbin/su"
|
|
set_perm 0 0 06755 "/system/xbin/tcpdump"
|
|
set_perm 0 0 04755 "/system/bin/pppd"
|
|
popd > /dev/null 2>&1
|
|
}
|
|
|
|
createDFT()
|
|
{
|
|
syncDirs
|
|
pushd ${BUILD1} > /dev/null 2>&1
|
|
rm -rf ../${BUILD2_NAME}.7z
|
|
rm -rf ${BUILD2}
|
|
mkdir ${BUILD2}
|
|
popd > /dev/null 2>&1
|
|
|
|
doFiles
|
|
|
|
# create images
|
|
echo -n "Creating DFT img files ... "
|
|
pushd ${BUILD1} > /dev/null 2>&1
|
|
[ -d system ] && echo -n "system ... " && ${MKYAFFS} system ${BUILD2}/system.img > /dev/null 2>&1
|
|
[ -d boot ] && echo -n "boot ... " && ${MKYAFFS} boot ${BUILD2}/boot.img > /dev/null 2>&1
|
|
[ -d data ] && echo -n "data ... " && ${MKYAFFS} data ${BUILD2}/data.img > /dev/null 2>&1
|
|
[ -d recovery ] && echo -n "recovery ... " && ${MKYAFFS} recovery ${BUILD2}/recovery.img > /dev/null 2>&1
|
|
popd > /dev/null 2>&1
|
|
echo "DONE"
|
|
|
|
cp ${TOOLS}/DFT/* ${BUILD2}/.
|
|
pushd ${BUILD2}/.. > /dev/null 2>&1
|
|
echo -n "Creating DFT archive ... "
|
|
7zr a ${BUILD2_NAME}.7z ${BUILD2_NAME} > /dev/null 2>&1
|
|
echo "DONE"
|
|
popd > /dev/null 2>&1
|
|
}
|
|
|
|
|
|
createCWM()
|
|
{
|
|
syncDirs
|
|
pushd ${BUILD1} > /dev/null 2>&1
|
|
rsync --exclude ".svn" -az ${TOOLS}/META-INF .
|
|
pushd ${BUILD1}/boot > /dev/null 2>&1
|
|
|
|
if [[ "$1" == "LK" ]] ; then
|
|
genInitrd LK
|
|
${TOOLS}/mkbootimg --kernel zImage --ramdisk initrd.gz --cmdline "console=null" --base 0x11800000 -o ${BUILD1}/boot.img
|
|
popd > /dev/null 2>&1
|
|
rm -rf boot
|
|
cp META-INF/com/google/android/updater-script.lk META-INF/com/google/android/updater-script
|
|
touch system/ppp
|
|
rm -rf ../${BUILD1_NAME}_LK.zip
|
|
echo -n "Creating CWM LK zip file ... "
|
|
zip -9Dry -q ../${BUILD1_NAME}_LK.zip *
|
|
echo "DONE"
|
|
rm -rf system/ppp
|
|
else
|
|
genInitrd
|
|
popd > /dev/null 2>&1
|
|
cp META-INF/com/google/android/updater-script.std META-INF/com/google/android/updater-script
|
|
rm -rf system/app/ROMManager.apk
|
|
rm -rf ../${BUILD1_NAME}.zip
|
|
echo -n "Creating CWM zip file ... "
|
|
zip -9Dry -q ../${BUILD1_NAME}.zip *
|
|
echo "DONE"
|
|
fi
|
|
|
|
rm -rf META-INF
|
|
popd > /dev/null 2>&1
|
|
}
|
|
|
|
createLK()
|
|
{
|
|
syncDirs
|
|
pushd ${BUILD1} > /dev/null 2>&1
|
|
rm -rf ../${BUILD3_NAME}.7z
|
|
rm -rf ${BUILD3}
|
|
mkdir ${BUILD3}
|
|
popd > /dev/null 2>&1
|
|
|
|
doFiles
|
|
touch ${BUILD1}/system/ppp
|
|
genInitrd LK
|
|
|
|
pushd ${BUILD1}/boot > /dev/null 2>&1
|
|
${TOOLS}/mkbootimg --kernel zImage --ramdisk initrd.gz --cmdline "console=null" --base 0x11800000 -o ${BUILD3}/boot.img
|
|
popd > /dev/null 2>&1
|
|
|
|
pushd ${BUILD1} > /dev/null 2>&1
|
|
[ -d system ] && ${MKYAFFS} system ${BUILD3}/system.img > /dev/null 2>&1
|
|
[ -d data ] && ${MKYAFFS} data ${BUILD3}/data.img > /dev/null 2>&1
|
|
popd
|
|
|
|
cp ${TOOLS}/fastboot* ${BUILD3}/.
|
|
cp ${TOOLS}/recovery_lk.img ${BUILD3}/recovery.img
|
|
pushd ${BUILD3}/.. > /dev/null 2>&1
|
|
echo -n "Creating LK archive ... "
|
|
7zr a ${BUILD3_NAME}.7z ${BUILD3_NAME} > /dev/null 2>&1
|
|
echo "DONE"
|
|
popd > /dev/null 2>&1
|
|
|
|
rm -rf ${BUILD1}/system/ppp
|
|
}
|
|
|
|
genInitrd()
|
|
{
|
|
|
|
mkdir -p ${BUILD1}/boot/initrd
|
|
rsync --exclude ".svn" -az ${MAIN}/../build/boot/initrd/ ${BUILD1}/boot/initrd
|
|
echo -n "Creating initrd ... "
|
|
pushd ${BUILD1}/boot/initrd > /dev/null 2>&1
|
|
chmod 770 bin/*
|
|
|
|
# if [[ "$1" == "LK" ]] ; then
|
|
# mv init.android init
|
|
# pushd sbin > /dev/null 2>&1
|
|
# ln -sf ../init ueventd
|
|
# popd > /dev/null 2>&1
|
|
# fi
|
|
|
|
find .|cpio --quiet -H newc -o|gzip -9 -c - > ../initrd.gz
|
|
|
|
popd > /dev/null 2>&1
|
|
|
|
rm -rf ${BUILD1}/boot/initrd
|
|
echo "DONE"
|
|
|
|
if [[ `echo $0 | grep createInitrd.sh` ]]; then
|
|
|
|
cp ${BUILD1}/boot/initrd.gz /tmp/initrd.gz.$$
|
|
rm -rf ${BUILD1}
|
|
mkdir ${BUILD1}
|
|
cp /tmp/initrd.gz.$$ ${BUILD1}/initrd.gz
|
|
ls -lh ${BUILD1}/initrd.gz
|
|
exit 0
|
|
|
|
fi
|
|
}
|
|
|
|
echo Build started on `date`
|
|
echo
|
|
|
|
if [[ `echo $0 | grep createInitrd.sh` ]]; then
|
|
|
|
#if [[ "$1" == "LK" ]] ; then
|
|
# genInitrd LK
|
|
#else
|
|
genInitrd
|
|
#fi
|
|
|
|
fi
|
|
|
|
syncDirs
|
|
|
|
createCWM
|
|
createCWM LK
|
|
#createDFT
|
|
#createLK
|
|
|
|
rm -rf ${BUILD1}
|
|
rm -rf ${BUILD2}
|
|
rm -rf ${BUILD3}
|
|
|
|
echo "your files are here"
|
|
echo ""
|
|
ls -lh /tmp/${ROM}_${VER}*
|
|
|
|
echo
|
|
echo Build finished on `date`
|