need help to translate MIUI V4 (ICS) - Android Q&A, Help & Troubleshooting

Hi,
i tried to translate a MIUI for Galaxy Nexus rom into french (can also be an other language)
i wrote an unix script to automate the process.
What i do is quite simple:
i get a specific MIUI V4 version for my device and the same translated version for the nexus S (because the nexus S has a french version)
i decompile each apk from the french rom, an put the french files into to decompile galaxy nexus directories
i recompile each apk
and i copy the compiled resources into the origin galaxy nexus apks
and i build the new ROM
but i get a bootloop any ideas ?
here is my script
if there are any part of this script that isn't clear, i could try to explain them.
of course this script could also be used on other device or other translation with some changes.
Thanks in advance .
Code:
#!/bin/bash
# MIUI-FRENCH TRANSLATE SCRIPT FOR GNEX V1.0 By Alain57
BASE_DIR=$PWD
FRENCH_DIR=$BASE_DIR/french_rom
ORIGINAL_DIR=$BASE_DIR/original_rom
OUTPUT_ROM_DIR=$BASE_DIR/output_rom
OUT_DIR=$BASE_DIR/out
WORK_DIR=$BASE_DIR/workdir
ORIGIN_APK_DIR=$WORK_DIR/origin
TRANSLATION_DIR=$WORK_DIR/translation
DECODED_APK_DIR=$WORK_DIR/decoded
LOG_FILE=$BASE_DIR/log.txt
TEMP_DIR=$BASE_DIR/temp
# clean the log file and create the missing directories if they don't exist (for exemple on first run)
function cleanLog(){
rm -fr $LOG_FILE
ARRAY_DIR=( $FRENCH_DIR $ORIGINAL_DIR $OUTPUT_ROM_DIR $OUT_DIR $WORK_DIR $ORIGIN_APK_DIR $TRANSLATION_DIR $DECODED_APK_DIR $TEMP_DIR )
echo "creating missing directoriesi if needed"
for DIR in ${ARRAY_DIR[@]}; do
if [ ! -d $DIR ]; then
mkdir $DIR
fi
done
}
# configure apktool to use framework-res and framework-miui-res
function setFramework(){
cd $FRENCH_DIR
echo "<- apktool if system/framework/framework-res.apk ->" >> $LOG_FILE
apktool if framework-res.apk >> $LOG_FILE 2>&1
echo "<- apktool if system/framework/framework-miui-res.apk ->" >> $LOG_FILE
apktool if framework-miui-res.apk >> $LOG_FILE 2>&1
}
#decompile all apk file from the english Gnex miui rom
function decompileOriginFiles(){
cd $ORIGINAL_DIR
COUNT_ORIGINAL_ZIP=`ls . | grep '.zip' | wc -l`
if [ "$COUNT_ORIGINAL_ZIP" -eq "1" ]; then
mv *.zip en.zip
echo "unzip the original rom"
unzip -q -o en.zip
echo "copy the apks to the origin dir"
cp -a system/framework/*.apk $ORIGIN_APK_DIR
cp -a system/app/*apk $ORIGIN_APK_DIR
cd $ORIGIN_APK_DIR
for F in *.apk; do
echo "decompiling origianl file $F ..." | tee -a $LOG_FILE
apktool d $F $DECODED_APK_DIR/${F%.apk} >> $LOG_FILE 2>&1
done
else
echo "there need to be ONE zip file in the original directory"
exit
fi
}
# decompile all apk files from the french Nexus S ROM
function decompileTranslatedFiles(){
cd $FRENCH_DIR
COUNT_FRENCH_ZIP=`ls . | grep '.zip' | wc -l`
if [ "$COUNT_FRENCH_ZIP" -eq "1" ]; then
mv *.zip fr.zip
echo "unzip the french rom"
unzip -q -o fr.zip
setFramework
echo "copy the apks to the working dir"
cp -a system/framework/*.apk $WORK_DIR
cp -a system/app/*.apk $WORK_DIR
cd $WORK_DIR
for F in *.apk; do
echo "decompiling french file $F ..." | tee -a $LOG_FILE
apktool d $F $TRANSLATION_DIR/${F%.apk} >> $LOG_FILE 2>&1
done
else
echo "there neeed to be ONE zip file in the french directory"
exit
fi
}
# Delete the given directory, because it is not needed
function deleteDirectoryWithoutTranslation(){
echo " ---> directory useless, removed"
cd $TRANSLATION_APK_DIR
rm -fr $1
}
# delete all useless data from the french apks
function cleanTranslatedFiles(){
cd $TRANSLATION_DIR
for d in *; do
echo "cleaning the directory $d"
cd $TRANSLATION_DIR/$d
if [ -d "res" ]; then
ls . | grep -v res | xargs -o rm -fr
cd "res"
CONTAINS_FRENCH_TRANSLATION=`ls .| grep '\-fr' | wc -l`
if [ "$CONTAINS_FRENCH_TRANSLATION" -eq "0" ]; then
deleteDirectoryWithoutTranslation $d
else
echo "---> transltation here, clean it"
ls . | grep -v '\-fr\|\./\|\.\./' | xargs -o rm -fr
fi
else
echo "no res directory"
deleteDirectoryWithoutTranslation $d
fi
if [ ! -f $ORIGIN_APK_DIR/$d.apk ];then
echo "directory not in original rom $d"
deleteDirectoryWithoutTranslation $d
fi
done
}
# merge the decoded translation in the decoded english files
function mergeTranslations(){
cd $DECODED_APK_DIR
mv $TRANSLATION_DIR/* .
cd $WORK_DIR
rm -f *.apk
}
# compile new apks including french files
function compileApk(){
cd $ORIGIN_APK_DIR
for f in *.apk; do
echo "compiling $f"
echo "apktool b $DECODED_APK_DIR/${f%.apk} $WORK_DIR/$f"
apktool b $DECODED_APK_DIR/${f%.apk} $WORK_DIR/$f >> $LOG_FILE 2>&1
done
}
# delete apk in work directory and put the original apks there
function deleteWorkFileAndCopyOriginalApk(){
cd $WORK_DIR
rm -f *.apk
cp -a $ORIGIN_APK_DIR/*.apk .
}
# put the compiled modified files in the original apk files
function finalMerge(){
cd $DECODED_APK_DIR
for F in *.apk; do
echo "doing final build $F"
cd $TEMP_DIR
rm -fr *
unzip -q $DECODED_DIR/$F
ls . | grep -v 'res\|classes.dex\|resources.arsc\|\./\|\.\./' | xargs -o rm -fr
if [ -d res ]; then
cd res
ls . | grep -v '\-fr\|\./\|\.\./' | xargs -o rm -fr
HAS_FR=`ls . | grep '\-fr' | wc -l`
if [ "$HAS_FR" -eq "0" ]; then
cd ..
rm -fr res
else
cd ..
fi
fi
zip -r $WORK_DIR/$F *
done
}
#replace the english apk files with the new french apk files, change the build.prop value and create an unsigned zip that can be flashed
function createRom(){
cd $OUTPUT_ROM_DIR
mv $ORIGINAL_DIR/system $ORIGINAL_DIR/boot.img $ORIGINAL_DIR/META-INF .
mv $WORK_DIR/*.apk system/app
mv system/app/framework*.apk system/framework
mv system/build.prop build.prop
sed 's/=en/=fr/g' build.prop > build1.prop
rm -f build.prop
sed 's/=US/=FR/g' build1.prop > system/build.prop
rm -f build1.prop
zip -r $BASE_DIR/new_rom.zip *
}
cleanLog
decompileTranslatedFiles
decompileOriginFiles
cleanTranslatedFiles
mergeTranslations
compileApk
deleteWorkFileAndCopyOriginalApk
finalMerge
createRom

Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums & Read the Forum Rules
Moving to Q&A

Related

Two versions of the same app

Is it possible to install two versions of the same app without overwriting the previous one??
i have tried to decompile the app and change the app name in package field of manif
est.xml, i was successful in installing the apps but the one with unedited manifest.xml works whereas the other force closes
This is possible, but you will need to adjust the folders containing the smali files (after using apktool), as well as (not sure about this bit) changing the class declaration names in each smali file.
It's complex, but it is possible to do and you're on the right tracks with the package name
is there any automated tool to do all that?
keyboardcowboy said:
is there any automated tool to do all that?
Click to expand...
Click to collapse
Unlikely
10 char
I have seen Brut's modified Google maps, it can be installed beside original app...How did he do it?
keyboardcowboy said:
is there any automated tool to do all that?
Click to expand...
Click to collapse
Someone could make a script. I'll post my solution to give that person a head start.
Code:
apktool d -f base_MYAPP.apk base_MYAPP
mv base_MYAPP/smali/com/MYCOMPANY/MYAPP base_MYAPP/smali/com/MYCOMPANY/NEW_MYAPP
find base_MYAPP/smali/com/MYCOMPANY/NEW_MYAPP -name "*.smali" -print | xargs sed -i -e 's/MYAPP/NEW_MYAPP/g'
sed -i -e 's/MYAPP/NEW_MYAPP/g' base_MYAPP/AndroidManifest.xml
sed -i -e 's/APP NAME/APP NAME NEW/g' base_MYAPP/res/values/strings.xml
rm -f base_MYAPP/res/values/strings.xml-e base_MYAPP/AndroidManifest.xml-e
find base_MYAPP/smali/com/MYCOMPANY/NEW_MYAPP -name "*.smali-e" -print | xargs rm -f
apktool b base_MYAPP NEW_MYAPP-unaligned.apk
jarsigner -keystore my.keystore -storepass pass1 -keypass pass2 NEW_MYAPP-unaligned.apk alias
zipalign -f -v 4 NEW_MYAPP-unaligned.apk NEW_MYAPP.apk
Something like that. I need to go home. =)
awesome
Try something like this:
Code:
#!/bin/bash
##### Constants
APK_NAME="My App"
PACKAGE="My_App"
PACKAGE_PATH=com/my_company/
KEYSTORE="my.keystore"
KEYSTORE_PASS="keystore_pass"
ALIAS="alias_name"
ALIAS_PASS="alias_pass"
##### Functions
function copy_apk
{
# Parameters
base_file=$1
new_package=$2
new_apk_name=$3
input_dir=base/
file_modification_date=$(stat -f "%Sm" -t "%Y%m%d" $input_dir/$base_file)
file_modification_time=$(stat -f "%Sm" -t "%H%M%S" $input_dir/$base_file)
output_dir=$file_modification_date/
# Variables
file_name=$(echo "$base_file" | cut -d'.' -f1)
file_extension=$(echo "$base_file" | cut -d'.' -f2)
new_file_name_unaligned="${file_name}-unaligned.${file_extension}"
new_file_name_aligned="${file_name}_${file_modification_date}_${file_modification_time}.${file_extension}"
work_directory=$input_dir$file_name/
smali_directory=$work_directory/smali/$PACKAGE_PATH/
# Function Body
mkdir -p $input_dir
mkdir -p $output_dir
apktool d -f $input_dir$base_file $work_directory
mv $smali_directory/$PACKAGE $smali_directory/$new_package
find $smali_directory/ -name "*.smali" -print | xargs sed -i -e "s/$PACKAGE/$new_package/g"
find $smali_directory/ -name "*.smali-e" -print | xargs rm -f
find $work_directory/ -name "*.xml" -print | xargs sed -i -e "s/$PACKAGE/$new_package/g"
sed -i -e "s/$APK_NAME/$new_apk_name/g" $work_directory/res/values/strings.xml
find $work_directory/ -name "*.xml-e" -print | xargs rm -f
apktool b $work_directory $input_dir/$new_file_name_unaligned
jarsigner -keystore $KEYSTORE -storepass $KEYSTORE_PASS -keypass $ALIAS_PASS $input_dir/$new_file_name_unaligned $ALIAS
zipalign -f 4 "$input_dir/$new_file_name_unaligned" "$output_dir/$new_file_name_aligned"
}
function apk_version
{
# Parameters
base_file=$1
package_extension=$2
# Variables
new_package="${PACKAGE}_${package_extension}"
new_apk_name="${APK_NAME} $package_extension"
# Function Body
$(copy_apk "$base_file" "$new_package" "$new_apk_name")
}
##### Main
$(apk_version my_app_sandbox.apk Sandbox)
$(apk_version my_app_release.apk Release)
sgeos said:
Try something like this:
Code:
#!/bin/bash
##### Constants
APK_NAME="My App"
PACKAGE="My_App"
PACKAGE_PATH=com/my_company/
KEYSTORE="my.keystore"
KEYSTORE_PASS="keystore_pass"
ALIAS="alias_name"
ALIAS_PASS="alias_pass"
##### Functions
function copy_apk
{
# Parameters
base_file=$1
new_package=$2
new_apk_name=$3
input_dir=base/
file_modification_date=$(stat -f "%Sm" -t "%Y%m%d" $input_dir/$base_file)
file_modification_time=$(stat -f "%Sm" -t "%H%M%S" $input_dir/$base_file)
output_dir=$file_modification_date/
# Variables
file_name=$(echo "$base_file" | cut -d'.' -f1)
file_extension=$(echo "$base_file" | cut -d'.' -f2)
new_file_name_unaligned="${file_name}-unaligned.${file_extension}"
new_file_name_aligned="${file_name}_${file_modification_date}_${file_modification_time}.${file_extension}"
work_directory=$input_dir$file_name/
smali_directory=$work_directory/smali/$PACKAGE_PATH/
# Function Body
mkdir -p $input_dir
mkdir -p $output_dir
apktool d -f $input_dir$base_file $work_directory
mv $smali_directory/$PACKAGE $smali_directory/$new_package
find $smali_directory/ -name "*.smali" -print | xargs sed -i -e "s/$PACKAGE/$new_package/g"
find $smali_directory/ -name "*.smali-e" -print | xargs rm -f
find $work_directory/ -name "*.xml" -print | xargs sed -i -e "s/$PACKAGE/$new_package/g"
sed -i -e "s/$APK_NAME/$new_apk_name/g" $work_directory/res/values/strings.xml
find $work_directory/ -name "*.xml-e" -print | xargs rm -f
apktool b $work_directory $input_dir/$new_file_name_unaligned
jarsigner -keystore $KEYSTORE -storepass $KEYSTORE_PASS -keypass $ALIAS_PASS $input_dir/$new_file_name_unaligned $ALIAS
zipalign -f 4 "$input_dir/$new_file_name_unaligned" "$output_dir/$new_file_name_aligned"
}
function apk_version
{
# Parameters
base_file=$1
package_extension=$2
# Variables
new_package="${PACKAGE}_${package_extension}"
new_apk_name="${APK_NAME} $package_extension"
# Function Body
$(copy_apk "$base_file" "$new_package" "$new_apk_name")
}
##### Main
$(apk_version my_app_sandbox.apk Sandbox)
$(apk_version my_app_release.apk Release)
Click to expand...
Click to collapse
this is fun, but I am not sure how to runt he script on my phone.

[Q] Repurpose Eris?

I have two of these devices sitting around and I was wondering how people were repurposing them. I just picked up a Raspberry Pi with the intention of setting up a home automation system. Isn't the Eris also an ARMv6 processor? Could they be used as smart WiIP video security cameras? Is there a Linux distro somewhere? Anyone have any experience?
Greetings! There's a thread here you might be interested in. http://forum.xda-developers.com/showthread.php?t=823564&highlight=linux
roirraW "edor" ehT said:
Greetings! There's a thread here you might be interested in. http://forum.xda-developers.com/showthread.php?t=823564&highlight=linux
Click to expand...
Click to collapse
http://www.4shared.com/zip/uiPl7NhN/ubuntu.html Link to Ubuntu.img
to mount you can use this:
linuxboot.sh
#option if you wish to load a different file than the rc_enter just replace the rc_enter.sh with the script file you want to run
# i.e init.sh below this script I will post the initl.ls if you wan to replace the rc_enter.sh
Code:
#!/system/bin/sh
(
# If $BINDS does not exist, then done of the others are set iether.
if [ -z "$BINDS" ]; then
export DIST="debian squeeze"
export FILESYSTEM=/sdcard/ubuntu.img
export MOUNTPOINT=/sdcard/linux
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
export USER=root
export LOGNAME=root
export UID=0
export SHELL=bash
export FS=ext3
export busybox="/data/data/com.galoula.LinuxInstall/bin/busybox"
export BINDS="1"
unset TMPDIR
fi
createLinuxBoot() {
if $busybox [ -d "$FILESYSTEM" ]
then
echo "I: Directory chroot !"
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/proc")" ]; then
# If the loop device is already mounted, we do nothing.
echo "W: $DIST is already mounted. Entering chroot..."
else
echo "I: Mounting device for $DIST..."
# Bind some Android dirs to the linux filesystem
if $busybox [ $BINDS -eq 1 ]
then
# Create mtab
echo > "${MOUNTPOINT}/etc/mtab"
$busybox cat /proc/mounts > "${MOUNTPOINT}/etc/mtab"
# for i in `$busybox cat /proc/mounts | $busybox cut -d " " -f 2`
for i in $( $busybox cat /proc/mounts | $busybox awk '{print $2}' )
do
$busybox mkdir -p "${MOUNTPOINT}/$i" 2> /dev/null
$busybox mount -o bind "${i}" "${MOUNTPOINT}/${i}" 2> /dev/null
#echo "${i}" >> "${MOUNTPOINT}/etc/mtab"
done
fi
fi
else
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# If the loop device is already mounted, we do nothing.
echo "W: $DIST is already mounted. Entering chroot..."
else
echo "I: Mounting device for $DIST..."
if $busybox [ ! -d $MOUNTPOINT ]; then
# Create the mount point if it does not already exist
$busybox mkdir -p $MOUNTPOINT 2> /dev/null
if $busybox [ ! -d $MOUNTPOINT ]; then
echo "F: It was not possible to create the missing mount location ($MOUNTPOINT)"
return 0
fi
fi
if $busybox [ -f "$FILESYSTEM" ]
then
# Android places loop devices in /dev/block/ instead of root /dev/
# If there are none in /dev/ we create links between /dev/loopX and /dev/block/loopX so that losetup will work as it should.
if $busybox [ ! -e /dev/block/loop0 ]; then
i=0
while [ $i -le 8 ]
do
$busybox mknod /dev/block/loop$i b 7 $i
let i=1+$i
done
fi
# Locate the current loop device file
if $busybox [ ! -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
# If the filesystem file is already attached to an loop device, we get the path to the device file.
loblk=$($busybox losetup | $busybox grep "$FILESYSTEM" | $busybox cut -d ":" -f 1)
else
# If the filesystem file is not yet attached, we attach it.
loblk=$($busybox losetup -f)
$busybox losetup $loblk $FILESYSTEM 2> /dev/null
# Make sure that the device was successfully attached to a loop device file
if $busybox [ -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
echo "F: It was not possible to attach the device to a loop device file"
return 0
fi
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
loblk=$FILESYSTEM
fi
# Mount the filesystem
$busybox mount -t $FS $loblk $MOUNTPOINT 2> /dev/null
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# Bind some Android dirs to the linux filesystem
if $busybox [ $BINDS -eq 1 ]
then
# Create mtab
echo > "${MOUNTPOINT}/etc/mtab"
$busybox cat /proc/mounts > "${MOUNTPOINT}/etc/mtab"
# for i in `$busybox cat /proc/mounts | $busybox cut -d " " -f 2`
for i in $( $busybox cat /proc/mounts | $busybox awk '{print $2}' )
do
# /sdcard/Mon mount/Linux
$busybox mkdir -p "${MOUNTPOINT}/$i" 2> /dev/null
$busybox mount -o bind "${i}" "${MOUNTPOINT}/${i}" 2> /dev/null
#echo "${i}" >> "${MOUNTPOINT}/etc/mtab"
done
fi
#for i in $BINDS
#do
# # Bind the dirs if they are not already binded
# if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
# # Create any missing dirs in the mountpoint
# if $busybox [ ! -d $MOUNTPOINT/$i ]; then
# $busybox mkdir -p $MOUNTPOINT/$i
# fi
# $busybox mount -o bind $i $MOUNTPOINT$i
# fi
#done
else
echo "F: It was not possible to mount $DIST at the specified location ($MOUNTPOINT)"
return 0
fi
fi
fi
# FIX the "stdin: is not a tty" error in direct hadware case.
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox mount -t devpts devpts $MOUNTPOINT/dev/pts
fi
# For the network.
#sysctl -w net.ipv4.ip_forward=1
echo 1 > /proc/sys/net/ipv4/ip_forward
# Cleanup tmp folder.
$busybox rm -rf $MOUNTPOINT/tmp/*
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_mount.sh ]; then
# Execute the mount init file, if it exists
echo "I: Executing /etc/init.android/rc_mount.sh"
$busybox chroot $MOUNTPOINT /etc/init.android/rc_mount.sh
fi
echo "I: Entering chroot..."
return 1
}
removeLinuxBoot() {
if $busybox [ -d "$FILESYSTEM" ]
then
echo "I: Directory chroot !"
# Unmount pts
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox umount $MOUNTPOINT/dev/pts 2> /dev/null
fi
for i in $BINDS
do
# Unmount all binding dirs
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
$busybox umount $MOUNTPOINT/$i
fi
done
for i in `$busybox cat /proc/mounts | $busybox tac | $busybox grep -v "$MOUNTPOINT " | $busybox grep "$MOUNTPOINT" | $busybox cut -d " " -f 2`;do umount $i 2> /dev/null;done
else
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# If linux is not mounted, then do nothing.
echo "W: $DIST is already unmounted"
else
echo "I: Unmounting $DIST..."
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_unmount.sh ]; then
echo "I: Executing /etc/init.android/rc_unmount.sh"
# Execute the unmount init script, if it exist.
$busybox chroot $MOUNTPOINT /etc/init.android/rc_unmount.sh
fi
sync
# Make sure that we have an loop device file to use
if $busybox [ -f "$FILESYSTEM" ]
then
if $busybox [ ! -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
# Get the loop device file
loblk=$($busybox losetup | $busybox grep "$FILESYSTEM" | $busybox cut -d ":" -f 1)
else
echo "E: Could not locate the loop device file. $DIST was not unmounted successfully"
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
loblk=$FILESYSTEM
fi
# Unmount pts
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox umount $MOUNTPOINT/dev/pts
fi
for i in `$busybox cat /proc/mounts | $busybox tac | $busybox grep -v "$MOUNTPOINT " | $busybox grep "$MOUNTPOINT" | $busybox cut -d " " -f 2`;do umount $i 2> /dev/null;done
for i in $BINDS
do
# Unmount all binding dirs
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
$busybox umount $MOUNTPOINT/$i
fi
done
sync && sleep 1
# Unmount the device
$busybox umount $MOUNTPOINT 2> /dev/null && sleep 1
# If the device could not be unmounted
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
echo "E: $DIST could not be unmounted. Trying to kill attached processes..."
# Try to kill all processes holding the device
for i in `$busybox grep "$MOUNTPOINT" /proc/*/maps 2> /dev/null | $busybox cut -d":" -f 1 | $busybox sort | $busybox uniq | $busybox cut -d "/" -f 3`; do kill $i 2> /dev/null; echo; done
fuser -k -9 $MOUNTPOINT
for i in `$busybox grep "$MOUNTPOINT" /proc/*/maps 2> /dev/null | $busybox cut -d":" -f 1 | $busybox sort | $busybox uniq | $busybox cut -d "/" -f 3`; do kill -9 $i 2> /dev/null; echo; done
# Use umount with the -l option to take care of the rest
$busybox umount -l $MOUNTPOINT 2> /dev/null && sleep 1
fi
# Make sure the device has been successfully unmounted
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
if $busybox [ -f "$FILESYSTEM" ]
then
# Try to detach the device from the loop device file
$busybox losetup -d $loblk 2> /dev/null
# Make sure that the device was successfully detached
if $busybox [ -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
echo "I: $DIST has been successfully unmounted"
else
echo "E: $DIST has been unmounted, but could not detach the loop device"
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
echo "I: $DIST has been successfully unmounted"
else
echo "E: $DIST has been unmounted, but could not detach the loop device"
fi
fi
else
echo "E: $DIST could not be unmounted successfully"
fi
fi
fi
}
if $busybox [ "$1" = "unmount" ]; then
removeLinuxBoot
else
createLinuxBoot
if $busybox [ $? -eq 1 ]; then
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_enter.sh ]; then
echo "I: Executing /etc/init.android/rc_enter.sh"
$busybox chroot $MOUNTPOINT /etc/init.android/rc_enter.sh
else
echo "I: To run command when enterring Linux create executable file at /etc/init.android/rc_enter.sh"
fi
$busybox chroot $MOUNTPOINT /bin/bash -i
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_leave.sh ]; then
echo "I: Executing /etc/init.android/rc_leave.sh ..."
$busybox chroot $MOUNTPOINT /etc/init.android/rc_leave.sh
else
echo "I: To run command when leaving Linux create executable file at /etc/init.android/rc_leave.sh"
fi
echo "Q: Do you want to unmount the $DIST environment, or leave it as is ? Y will kill all process as required; any other key will leave services running."
read REPLY
if $busybox [ "y$REPLY" = "yy" ] || $busybox [ "y$REPLY" = "yY" ]; then
removeLinuxBoot
fi
fi
fi
)
or you can mount it with this linuxboot.sh:
Code:
# Check Permissions
if [ $(whoami) != root ]; then
echo "This script must be run as root."
exit
fi
# Script Variables
NAME=ubuntu
PATH=$(dirname $0)
# Enviroment Variables
export BIN=/system/bin
export HOME=/root
export MOUNT=/data/local/mnt/$NAME
export PATH=$BIN:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export TERM=linux
export USER=root
# Change Directory
cd $PATH
# Create Mount Point
mkdir -p $MOUNT
# Remount System Read/Write
mount -o remount,rw /system
# Check Loop Block Device
if [ ! -b /dev/block/loop_$NAME ]; then
# Create Loop Block Device
mknod /dev/block/loop_$NAME b 7 255
fi
# Setup Loop Block Device
losetup /dev/block/loop_$NAME $NAME.img
# Mount Loop Block Device To Mount Point
mount -t ext3 /dev/block/loop_$NAME $MOUNT
# Add Mount Points
mount -o bind /dev $MOUNT/dev
mount -o bind /dev/pts $MOUNT/dev/pts
mount -o bind /dev/shm $MOUNT/dev/shm
mount -o bind /sdcard $MOUNT/media
mount -t proc none $MOUNT/proc
mount -t sysfs none $MOUNT/sys
# Set Options
echo "127.0.0.1 localhost" > $MOUNT/etc/hosts
echo "nameserver 8.8.4.4" > $MOUNT/etc/resolv.conf
echo "nameserver 8.8.8.8" >> $MOUNT/etc/resolv.conf
rm -rf $MOUNT/lost+found
sysctl -w net.ipv4.ip_forward=1 > /dev/null
sysctl -w net.ipv6.conf.all.forwarding=1 > /dev/null
# Enter Linux
chroot $MOUNT /bin/bash -c "source /etc/profile; bash"
# Remove Mount Points
umount $MOUNT/sys
umount $MOUNT/proc
umount $MOUNT/media
umount $MOUNT/dev/shm
umount $MOUNT/dev/pts
umount $MOUNT/dev
# Clean Up
umount $MOUNT
losetup -d /dev/block/loop_$NAME
rm /dev/block/loop_$NAME
rmdir $MOUNT
this is not the init.sh.
the init.sh is iniside the ubuntu.img so to boot using the init.sh you can edit the rc_enter.sh to start init.sh like so:
./init.sh
you can also start a service like so:
service hostname start

[Q] Can someone please help me run this script?

Hi everyone
I am trying to run a script on my android that extracts asec files back to apk's on my phone. The scripts works fine when i put in every line manually into terminal though obviously that is a pain in the ass. So i put it into a .sh file and put the .sh file in system root for ease of execution..
i then do:
su
sh deasec.sh
though it returns:
unexpected syntax error: do
can someone tell me what i am doing wrong? - thank you kindly! (will press thanks!)
Code is below
Code:
#!/system/xbin/sh
LD_LIBRARY_PATH="/system/lib"
PATH="/system/xbin:/system/sbin:/system/bin"
for ASEC in $(find /data/app-asec/ -name '*.asec')
do
echo "Deasec $ASEC"
PKG=$(basename $ASEC|cut -d'-' -f1)
echo "Package name $PKG"
if [ -d /mnt/asec/$PKG*/lib ]
then
echo "Relocate libs"
find /data/data/$PKG/ -type l -name lib -exec rm {} \;
cp -r /mnt/asec/$PKG*/lib /data/data/$PKG/
echo "Fix libs permissions"
chown -R system:system /data/data/$PKG/lib
chmod -R 755 /data/data/$PKG/lib
fi
APK=$(pm path $PKG|cut -d':' -f2)
echo "APK location $APK"
cp $APK /data/local/tmp/pkg.apk
chmod 644 /data/local/tmp/pkg.apk
pm install -r -f /data/local/tmp/pkg.apk && rm /data/local/tmp/pkg.apk
done
Have you done the script under Windows, you don't? You need to write the script under Linux. You can also write the script directly in your phone:
Open Terminal Emulator, and write the lines one by one this way:
Code:
echo line1 >> /sdcard/script.sh
echo line2 >> /sdcard/script.sh
echo line3 >> /sdcard/script.sh
...
Then move the script to its final location, and give it permissions (if needed).
nice one mate Thankyou

[Q] How to use string array in init.d script?

I want to make app symlinks to sd-ext on booting.
I made a short init.d script, And It correctly worked on JB based rom.
But after I downgraded to GB, It doesn't work anymore.
I founded that pure bone shell doesn't support arrays.
The script uses string array to declare apk list I want to symlink.
So is there a way to use string array or make similar effect?
Here is my script.
Code:
#!/system/bin/sh
if [ -z "$SD_EXT_DIRECTORY" ]; then SD_EXT_DIRECTORY=/sd-ext; fi
SYSBLOCK=`mount | grep system | cut -f 1 -d ' '`
sysapp2sd=("BackupRestoreConfirmation.apk" "BasicDreams.apk" "Bluetooth.apk" "CertInstaller.apk" "Calculator.apk" "CMFileManager.apk" "CMScreenshot.apk" "DSPManager.apk" "DrmProvider.apk" "Email.apk" "Email2.apk" "Exchange.apk" "Exchange2.apk" "Gmail.apk" "GoogleBackupTransport.apk" "InputDevices.apk" "Music.apk" "OneTimeInitializer.apk" "PhotoTable.apk" "PicoTts.apk" "SamsungTTS.apk" "SharedStorageBackup.apk" "SoundRecorder.apk" "Talk.apk" "ThemeChooser.apk" "ThemeManager.apk" "Torch.apk" "VpnDialogs.apk" "WAPPushManager.apk")
app2sd_exception=("com.UCMobile" "com.adobe.flashplayer" "com.android.lmt" "com.fiberthemax.OpQ2keyboard" "com.fiberthemax.OpQ2keyboard.dict.ko" "com.google.android.gms" "com.google.android.googlequicksearchbox" "com.jungsup.thecall" "com.mobint.hololauncher" "com.mobint.hololauncherplus" "com.mobitobi.android.gentlealarm" "com.myhome.mytheme" "com.rs.autorun" "com.teslacoilsw.launcher" "com.vladlee.callconfirm.free" "eu.chainfire.supersu" "kz.mek.DialerOne" "me.dennis.weather.naver" "net.dinglisch.android.taskerm" "net.everythingandroid.smspopup" )
# make sure $SD_EXT_DIRECTORY is actually mounted
if ! awk -vDIR="$SD_EXT_DIRECTORY" '$2 == DIR { exit 1; }' /proc/mounts ; then
mount -rw -o remount SYSBLOCK /system
mkdir -p /sd-ext/symlink/system/app
# /system/app/ -> /sd-ext/symlink/system/app/
FILES=`find /system/app -maxdepth 1 -type f`
for file in $FILES; do
filename=`basename $file`
for pattern in ${sysapp2sd[@]}; do
if [[ $filename == $pattern ]]; then
cp /system/app/$filename /sd-ext/symlink/system/app/
rm -f /system/app/$filename
ln -s /sd-ext/symlink/system/app/$filename /system/app/$filename
fi
done
done
# /data/app/ -> /sd-ext/symlink/data/app/
FILES=`find /data/app -maxdepth 1 -type f`
for file in $FILES; do
filename=`basename $file`
match=false
for pattern in ${app2sd_exception[@]}; do
if [[ $filename == $pattern* ]]; then
match=true
fi
done
if ! $match; then
cp /data/app/$filename /sd-ext/symlink/data/app/
rm -f /data/app/$filename
ln -s /sd-ext/symlink/data/app/$filename /data/app/$filename
fi
done
mount -r -o remount SYSBLOCK /system
fi
You can use echo or cat command to wrap list and grab it with awk.
and add another for loop over for loop for getting the counted numbers to be used on awk...

[Q] How to use "grep" to search the "build.prop"

Hey guys!
I am new to this forum, and needed some extra help
I am trying to add a line of text to "Build.prop" from a file Test.sh
Code:
echo "#Test" >> /system/build.prop
But if you run the code again, the same line is created
I'm trying to do it this way, but does not give any results
Code:
if [ $(grep "#Test" /system/build.prop) ]; then
sed -i '/Test/d' /system/build.prop;
else
echo "#Test" >> /system/build.prop;
fi
Code:
if [ -f /system/build.prop ]; then
cp /system/build.prop /system/build.prop.bak;
else
rm -rf /system/build.prop;
cp /system/build.prop.bak /system/build.prop
fi
if [ $(grep "#Test" /system/build.prop) ]; then
sed -i '/Test/d' /system/build.prop;
else
echo "#Test" >> /system/build.prop;
fi
Can someone help me solve this problem?
Please help me!

Categories

Resources