在PC端利用F-Droid开放仓库一键部署和备份Android应用程序, 可替代钛备份 - Deploy and backup Android applications from F-Droid repository in PC side
Go to file
2022-07-11 16:14:04 +08:00
completion Rename project name from deplaydroid to deployidroid 2022-07-11 16:14:04 +08:00
example Rename project name from deplaydroid to deployidroid 2022-07-11 16:14:04 +08:00
include adb_utils: Add todo comment for adb_push 2022-01-06 16:33:19 +08:00
test Rename project name from deplaydroid to deployidroid 2022-07-11 16:14:04 +08:00
.gitignore test: Add test for list command 2020-09-06 10:07:28 +08:00
deployidroid Rename project name from deplaydroid to deployidroid 2022-07-11 16:14:04 +08:00
gencode.sh Rename project name from deplaydroid to deployidroid 2022-07-11 16:14:04 +08:00
LICENSE Add README, LICENSE 2019-05-13 22:33:34 +08:00
Makefile test: Move to test dir 2020-09-05 21:34:55 +08:00
README_cn.org Rename project name from deplaydroid to deployidroid 2022-07-11 16:14:04 +08:00
README.org Rename project name from deplaydroid to deployidroid 2022-07-11 16:14:04 +08:00
usage.org Rename project name from deplaydroid to deployidroid 2022-07-11 16:14:04 +08:00

English | 简体中文

Description: Deploy and backup Android applications from F-Droid repository in computer side.

Keywords: shell, android, fdroid, package-manager, deploy, backup, root, titanium-backup

Features

  • Support download and install Android application from F-Droid repository
  • Support upgrade applications to latest version in device if possible
  • Support shell completion
  • Support multiple users in Android
  • Support backup and restore applications
  • Support backup special data, such as accounts, WiFi access-points
  • Support increment backup, the data files that timestamp not changed will be ignored
  • Support create profile files for different devices
  • Provide methods to encrypt user data
  • Try to fix compatibility issue when restore applications to different Android version
  • Works fine for Android 4.0+ (API level 14+). And the older versions should works, too, but need more testing work

Requirement

Command dependents in computer side:

  • bash >=4.0
  • curl
  • xmlstarlet
  • sha1sum
  • sha256sum
  • tar
  • gzip
  • adb
  • openssl (optional, only need for --password argument)

And in Android side:

  • sha1sum
  • find
  • tar
  • gzip
  • gunzip (if missing just install busybox)
  • Enable debug mode
  • Root permission in adb shell, either adb root works or su command exists will be fine
  • Enough free space in device temporary directory (default is /data/local/tmp, and could special it with argument --device-tmpdir)

Quick start

# download deployidroid
wget https://gitea.com/fasheng/deployidroid/raw/branch/master/deployidroid
chmod +x deployidroid

# enable command completion for bash
source <(./deployidroid complete --bash)

# fetch F-Droid repository index.xml file
./deployidroid update

# install applications
./deployidroid install org.fdroid.fdroid com.nextcloud.client
./deployidroid install org.fdroid.fdroid=1007051

# upgrade applications
./deployidroid upgrade

# backup applications
./deployidroid backup org.fdroid.fdroid com.nextcloud.client

# restore applications
./deployidroid restore org.fdroid.fdroid com.nextcloud.client

# deploy nextcloud from profile
./deployidroid deploy --profile example/deploy-nextcloud.sh

Usage

  1. Enable command completion

    • for bash

      source <(deployidroid complete --bash)
    • for fish

      source <(deployidroid complete --fish | psub)
  2. Update F-Droid repository index.xml file before operations

    deployidroid update
  3. List applications in repositories

    • List all applications, could use --cat, --desc, --ver to show category, description and available versions

      deployidroid list
      deployidroid list --cat --desc --ver
    • List applications with matched keyword, the keyword support awk regexp syntax. And if use --cat, --desc, --ver, will search text in the related fields

      deployidroid list fdroid
      deployidroid list --cat --desc --ver fdroid
    • List applications in category "System"

      deployidroid list --cat System
    • List applications with special application ID

      deployidroid list --appid org.fdroid.fdroid org.fdroid.fdroid.privileged
    • List applications in special repository

      deployidroid list --repo fdroid
    • Show application suggest version, the result will be different if different adb device connected

      deployidroid list --sug --appid org.fdroid.fdroid com.jereksel.libresubstratum
  4. Download and install application to device

    • Install the suggest latest stable version

      deployidroid install org.fdroid.fdroid
    • Install the suggest version, include unstable version

      deployidroid install --allow-unstable org.fdroid.fdroid
    • Install special version

      deployidroid install org.fdroid.fdroid=1007051
    • Install to special users

      deployidroid adb list-users
      deployidroid install --user 0 --user 10 org.fdroid.fdroid
  5. Uninstall application from device

    deployidroid uninstall --user cur org.fdroid.fdroid
  6. Upgrade applications

    • List all upgrade-able applications

      deployidroid upgrade --list
    • Upgrade all applications if possible

      deployidroid upgrade
  7. Deploy and cleanup applications in profile

    • deploy microg

      deployidroid deploy --profile example/deploy-microg.sh
      deployidroid cleanup --profile example/deploy-microg.sh
    • deploy nextcloud

      deployidroid deploy --profile example/deploy-nextcloud.sh
      deployidroid cleanup --profile example/deploy-nextcloud.sh
    • deploy without profile

      deployidroid deploy 'org.fdroid.fdroid' 'user_10:com.nextcloud.client:allow_unstable=1'
      deployidroid cleanup 'org.fdroid.fdroid' 'user_10:com.nextcloud.client:allow_unstable=1'
    • backup and cleanup useless services in Samsung devices

      deployidroid backup --profile ./example/cleanup-samsung.sh
      deployidroid cleanup --profile ./example/cleanup-samsung.sh
  8. Backup & Restore applications

    1. Ensure root permission for adb shell works firstly, there are two methods:

      1. su coommand works

        adb shell su -c "id -u -r"
      2. adb root works

        adb root
        adb shell "id -u -r"
    2. Backup apps and restore later

      deployidroid backup user_0:com.pkg1.name user_0:com.pkg2.name
      deployidroid restore --user cur user_0:com.pkg1.name user_0:com.pkg2.name
    3. Backup or restore with the appinfo.sh file

      deployidroid backup --options 'type=app+data' ./data/default/user_0/com.pkg.name/appinfo.sh
      deployidroid restore --options 'type=app+data' ./data/default/user_0/com.pkg.name/appinfo.sh
    4. Clone apps to another device or user, will create user automatically, but if failed please ensure user exists at first

      deployidroid backup user_cur:com.pkg.name
      deployidroid restore --user 10 --user 11 ./data/default/user_0/com.pkg.name/appinfo.sh
      deployidroid restore --user 10 --user 11 user_0:com.pkg.name
    5. Backup special user data, such as accounts and saved WiFi access points

      deployidroid backup @user.accounts @wifi
    6. Create backup profile, so flashing roms work will be easy

      deployidroid new --3rd-app --3rd-data --freq-data --spec-data --profile test.sh
      deployidroid backup --profile test.sh
      deployidroid restore --profile test.sh
    7. Encrypt the user data

      1. Use --password argument set the archive password, if value is "-", will read password from input

        deployidroid backup --password - com.pkg.name
        deployidroid restore --password - com.pkg.name
      2. Use encfs or similar tools encrypt the full data directory

        encfs .data data
  9. Special Android device with ANDROID_SERIAL environment or --serial argument, useful when multiple devices connected

    env ANDROID_SERIAL=xxxx deployidroid <commands>
    deployidroid --serial xxxx <commands>

Configuration file of deployidroid

Just customize F-Droid repository sources and other variables in ~/.config/deployidroid/config.sh, here is an example:

fdroid_opt_cache_dir="${HOME}/.cache/deployidroid"
fdroid_opt_download_cmd="wget -c '%s'"
adb_opt_device_tmpdir='/data/local/tmp'
repos=(
  ["fdroid"]="https://f-droid.org/repo"
  ["izzy"]="https://apt.izzysoft.de/fdroid/repo"
  ["retroarch"]="https://fdroid.libretro.com/repo"
  ["microg"]="https://microg.org/fdroid/repo"
  ["nethunter"]="https://store.nethunter.com/repo"
)

Backup directory structure

├── profile.sh
├── app
│   ├── com.pkg.name-1.0-10.apk
└── data
    └── profile-name
        └── user_0
        │   ├── com.pkg.name
        │   │   ├── com.pkg.name.tar.gz
        │   │   └── appinfo.sh
        │   └── @user.wallpaper
        │       ├── appinfo.sh
        │       └── @user.wallpaper.tar.gz
        └── user_system
            ├── @bluetooth
            │   ├── @bluetooth.tar.gz
            │   └── appinfo.sh
            └── @wifi
                ├── appinfo.sh
                └── @wifi.tar.gz
backup/restore profile.sh example
version='0.9.5'

# profile name
name='test'

appdir='./app'
datadir='./data/test'
android_version='6.0.1'
android_api_level=23

users=(system 0)
system_apps=(
  # spec system data
  '@datausage' # network data usage
  '@bluetooth' # bluetooth pair data
  '@wifi'      # wifi connection data
  # system apps
  'com.google.android.gms:type=app' # microG Services Core
)

user_apps=(
  # spec user data
  '@user.accounts'  # accounts data
  '@user.wallpaper' # wallpaper
  # system apps data
  'com.google.android.gms:type=data' # microG Services Core
  # 3rd apps
  'org.fdroid.fdroid:type=app+data'  # F-Droid
)
deploy/cleanup profile.sh example
version='0.9.5'

# profile name
name='test'

fdroid_repos=(
  ["fdroid"]="https://f-droid.org/repo"
  ["microg"]="https://microg.org/fdroid/repo"
)
fdroid_opt_allow_unstable=

users=(system 0)
system_apps=(
  'com.google.android.gms:type=app;repo=microg;version_code=19420020;install_path=/system/priv-app' # microG Services Core
)

user_apps=(
  'org.fdroid.fdroid:type=app+data;allow_unstable=1'  # F-Droid
)
appinfo.sh example
id='org.fdroid.fdroid'
version_name='1.6'
version_code='1006050'
android_api_level='23'  # android 6.0.1
is_system=''
is_encrypted=''
install_path='/vendor/app'
data_timestamp='1552435308'

Run tests

Install bats and run:

make test

License

GNU General Public License, Version 3.0+