1

Here's exactly what I'm looking for - I need an 'update.zip' file that can copy a file (example):

/system/framework/file-to-copy.apk

to another folder:

/system/

and then it would rename the 'file-to-copy.apk' in the 'system' folder to:

renamed-file.apk

and copy it back to:

/system/framework/

It would have to overwrite an already existing 'renamed-file.apk' in 'system/framework' folder.

Note: The permissions can NOT change.

Is it even possible to do this?

Any help would be appreciated!

1
  • To tell the truth, I just need the correct commands and syntax for update-script or updater-script.
    – Key-Six
    Commented Dec 18, 2012 at 10:30

3 Answers 3

4

Actually you can do that by using the run_program syntax in updater-script to execute a shell script that moves/copies/pastes files while in recovery. But of course, you must extract the files that are to be pasted in somewhere (/tmp for instance).

Part of the updater-script:

package_extract_dir("stuff", "/tmp/stuff");
set_perm(0, 0, 0755, "/tmp/stuff/movefiles.sh");
run_program("/tmp/stuff/movefiles.sh");

The sample shell script can be like this (named movefiles.sh in this case):

#!/sbin/sh
# Backup files
cp /system/framwork/something.apk /path/you/want

# Paste files
cp /tmp/somethingssss.apk /system/framework/something.apk

# Set back permissions (the copied file has the same permissons, but the new ones does not)
chmod 644 /system/framework/something.apk

But remember, the EOL of updater-script and the shell script must be the same, in UNIX format, or else it won't work.

2

Copy a file (-p preserves permissions and ownership):

run_program("/sbin/cp", "-p", "/system/framework/file-to-copy.apk", "/system/file-to-copy.apk");

Rename a file (-f forces overwriting the existing file):

run_program("/sbin/mv", "-f", "/system/file-to-copy.apk", "/system/renamed-file.apk");

For reference, the syntax for Edify scripts (that's what they're called) is here: Edify syntax

2
  • I know this is a couple years old but I wanted to comment on @bmaupin above. The run_program method works great, but the rename method doesn't seem to be recognized by Edify. I can't find any other sources which specify that this method exists. I don't know if it did 2-3 years ago, but if you are looking to do this now, use the run_program.
    – BenH
    Commented May 24, 2018 at 1:19
  • Good catch! I've been doing most of my work on Motorola devices, and apparently rename is specific to Motorola. I'll update my answer to reflect that.
    – bmaupin
    Commented May 24, 2018 at 12:08
-1

You cannot execute zip files.

You can move/delete/rename a file in /system/ via adb but you must remount /system/ as writable.

1
  • Actually, you can 'execute' .zip files via the recovery mode. I cannot use ADB because my device is half-bricked and the USB debugging isn't enabled.
    – Key-Six
    Commented Dec 17, 2012 at 20:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .