Edify script для CWM,TWRP..

Phoenix

Разработчик
Сообщения
2,112
Реакции
1,625
Edify script language - XDA-Developers
Syntax
  • The script file must use UNIX newlines as EOL.
  • Whitespace (space, tab, LF 0x0a, but not CR 0x0d) may be freely used.
  • Comments are any line prefaced with #
  • All commands are terminated with a semicolon. Clauses (in ifelse) may contain any number of commands, each terminated with a semicolon.
  • Strings are usually delimited with double quotation marks.
  • The characters \n, \t, \", and \\ are understood, as are hexadecimal escapes like \x4a
  • Numbers are really just strings and are usually not delimited.
  • Logical values are "t" for true or "" for false.
  • The comparison operators are == (string equal), != (string not equal).
  • The logical operators are || (logical or), && (logical and), ! (logical not).
  • The concatenation operator is +. (Caution: 2+2==22)
  • The conditional keywords if, then, else and endif operate as expected if they are unquoted. The ifelse macro may be used instead.
Functions
Disk operations
  • format(fs_type, partition_type, device, fs_size, mountpoint) - usually use "0" for fs_size (entire partition)
  • mount(fs_type, partition_type, device, mountpoint)
  • unmount(mountpoint)
  • is_mounted(mountpoint)
  • wipe_cache()
Image operations
  • write_raw_image(filename, device)
  • write_firmware_image
File operations
  • package_extract_file(source, destination) - returns "t" on success and "" on failure (e.g. if the file does not exist in the archive)
  • package_extract_dir(source, destination)
  • delete(file) – deletes a file
  • delete_recursive(directory) – completely deletes a directory
  • symlink(target, link0, ...) – create any number of links to a target
  • set_perm(user, group, mode, file) – performs a chown, chmod on a file
  • set_perm_recursive(user, group, mode, directory) – performs a chown, chmod on all contents of a directory
  • getprop(key) – returns a string value of the associated key from the system properties
  • file_getprop(file, key) – returns a string value of the associated key from a specific file
  • sha1_check(file) - return sha1 hash of file
  • sha1_check(file, sha1_hex, [sha1_hex2, ...]) - return the hash which matches or "" if none matches
Patching operations
  • apply_patch(srcfile, tgtfile, tgtsha1, tgtsize, sha1_1, patch_1, ...)
  • apply_patch_check(file, [sha1_1, ...])
  • apply_patch_space(bytes)
  • run_program(program, arg0, ...) - returns the exit code of the program
Control
  • assert(condition0, ...) – aborts and prints on any false condition
  • abort(message)
  • ifelse(condition, trueclause, falseclause) – conditional, falseclause is optional
Predicates
  • is_substring(substring, string) – checks to see if string constains substring anywhere
  • less_than_int(x, y) – checks to see if x<y when considered as integers
  • greater_than_int(x, y) – checks to see if x>y when considered as integers
User feedback
  • show_progress(fraction, seconds) – advance progress bar a fractional amount over a period of seconds
  • set_progress(fraction) – advance progress bar a fractional amount
  • ui_print(message0, ...) – print any number of strings
  • sleep(seconds) – pause a number of seconds
Немного теории о том, как происходит установка Zip-архива из Recovery.
Recovery извлекает из архива с обновлением файл META-INF/com/google/android/update-binary в /tmp, делает ему chmod 777 и запускает передавая три параметра:
1. API level. Это число от 1 до 3.
2. Дескриптор Pipe для обратной связи с Recovery.
3. Полное имя Zip-обновления.

Для облегчения создания пакетов для установки можно использовать замечательное приложение ZIPME
ZIPme – Android Apps on Google Play
ZIPme 1.0 для Android
Это приложение автоматически создаёт пакет выбранных файлов, папок и данных с установкой нужных прав.

ui_print("текст выводимого сообщения");

show_progress(1.000000, 0); # параметры прогресс бара
ui_print("Mounting filesystems...");
run_program("/sbin/busybox", "mount", "/system"); # запуск программы монтирования через busybox
set_progress(0.100000);

ui_print("Extracting files...");
package_extract_dir("system", "/system"); # извлечение/копирование
set_progress(0.300000);

ui_print("Setting permissions...");
set_progress(0.400000); # установка положения прогресс бара
set_progress(0.500000);
set_perm(0, 0, 0644, "/system/etc/hosts"); # установка прав на файл
set_progress(0.700000);

# Unmounting filesystems...
run_program("/sbin/busybox", "umount", "/system"); # запуск программы отмонтирования через busybox
set_progress(0.900000);
set_progress(1.000000);
# тут можно комментировать
Screenshot_2016-12-07-09-06-56.png Screenshot_2016-12-07-09-07-05.png Screenshot_2016-12-07-09-07-19.png

Android update-script - 4PDA
Следует так же отметить, что бинарный файл может работать либо с определённым типом рекавери, либо быть универсальным.
Для поддержки SELinux используется синтаксис TWRP set_metadata, а не set_perm (для установки прав), соответственно бинарник для CWM его не распознает.
PHP:
set_metadata_recursive("/system", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/bin", "uid", 0, "gid", 2000, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
В качествае бинарника может быть шелл скрипт, а udater-script используется как dummy file
PHP:
# this is a dummy file, the magic is in update-binary, which is a shell script
 
Последнее редактирование:
Назад
Сверху Снизу