在PC端利用F-Droid开放仓库一键部署和备份Android应用程序, 可替代钛备份 - Deploy and backup Android applications from F-Droid repository in PC side
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Xu Fasheng 2033290ff4 Fix head tail command args 1 year ago
completion adb_utils: Add arg -vv to control if show adb_shell error msg 1 year ago
example example: Update cleanup-samsung-9.0 1 year ago
include Fix head tail command args 1 year ago
test test: Add test case for override options 2 years ago
.gitignore test: Add test for list command 2 years ago
LICENSE Add README, LICENSE 3 years ago
Makefile test: Move to test dir 2 years ago
README.org readme: Fix typo 2 years ago
README_cn.org readme: Update quick start 2 years ago
deplaydroid Fix head tail command args 1 year ago
gencode.sh gencode: Generate usage.org 2 years ago
usage.org adb_utils: Add arg -vv to control if show adb_shell error msg 1 year ago

README.org

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 deplaydroid
wget https://gitea.com/fasheng/deplaydroid/raw/branch/master/deplaydroid
chmod +x deplaydroid

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

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

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

# upgrade applications
./deplaydroid upgrade

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

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

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

Usage

  1. Enable command completion

    • for bash

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

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

    deplaydroid update
  3. List applications in repositories

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

      deplaydroid list
      deplaydroid 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

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

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

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

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

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

    • Install the suggest latest stable version

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

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

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

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

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

    • List all upgrade-able applications

      deplaydroid upgrade --list
    • Upgrade all applications if possible

      deplaydroid upgrade
  7. Deploy and cleanup applications in profile

    • deploy microg

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

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

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

      deplaydroid backup --profile ./example/cleanup-samsung.sh
      deplaydroid 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

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

      deplaydroid backup --options 'type=app+data' ./data/default/user_0/com.pkg.name/appinfo.sh
      deplaydroid 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

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

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

      deplaydroid new --3rd-app --3rd-data --freq-data --spec-data --profile test.sh
      deplaydroid backup --profile test.sh
      deplaydroid 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

        deplaydroid backup --password - com.pkg.name
        deplaydroid 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 deplaydroid <commands>
    deplaydroid --serial xxxx <commands>

Configuration file of deplaydroid

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

fdroid_opt_cache_dir="${HOME}/.cache/deplaydroid"
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+