forked from Mirror/pmbootstrap
Recovery installer zip (#404)
Supports flashing with TWRP and other Android recovery OS through adb sideload, as well as exporting a generated recovery zip file. See also: https://github.com/postmarketOS/pmbootstrap/wiki/deviceinfo_flash_methods#recovery-mode-adb
This commit is contained in:
parent
28fa7eeaf0
commit
fbe968f1ab
17 changed files with 552 additions and 54 deletions
61
pmb/install/recovery.py
Normal file
61
pmb/install/recovery.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
"""
|
||||
Copyright 2017 Attila Szollosi
|
||||
|
||||
This file is part of pmbootstrap.
|
||||
|
||||
pmbootstrap is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
pmbootstrap is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import logging
|
||||
|
||||
import pmb.chroot
|
||||
|
||||
|
||||
def create_zip(args, suffix):
|
||||
"""
|
||||
Create android recovery compatible installer zip.
|
||||
"""
|
||||
zip_root = "/var/lib/postmarketos-android-recovery-installer/"
|
||||
rootfs = "/mnt/rootfs_" + args.device
|
||||
|
||||
# Install recovery installer package in buildroot
|
||||
pmb.chroot.apk.install(args,
|
||||
["postmarketos-android-recovery-installer"],
|
||||
suffix)
|
||||
|
||||
logging.info("(" + suffix + ") create recovery zip")
|
||||
|
||||
# Create config file for the recovery installer
|
||||
with open(args.work + "/chroot_" + suffix + "/tmp/install_options",
|
||||
"w") as install_options:
|
||||
install_options.write(
|
||||
"\n".join(['DEVICE="{}"'.format(args.device),
|
||||
'FLASH_BOOTIMG="{}"'.format(
|
||||
str(args.recovery_flash_bootimg).lower()),
|
||||
'INSTALL_PARTITION="{}"'.format(
|
||||
args.recovery_install_partition),
|
||||
'CIPHER="{}"'.format(args.cipher),
|
||||
'FDE="{}"'.format(
|
||||
str(args.full_disk_encryption).lower())]))
|
||||
|
||||
commands = [
|
||||
# Move config file from /tmp/ to zip root
|
||||
["mv", "/tmp/install_options", "install_options"],
|
||||
# Copy boot.img to zip root
|
||||
["cp", rootfs + "/boot/boot.img-" + args.device, "boot.img"],
|
||||
# Create tar archive of the rootfs
|
||||
["tar", "-pczf", "rootfs.tar.gz", "--exclude", "./home/user/*",
|
||||
"-C", rootfs, "."],
|
||||
["build-recovery-zip"]]
|
||||
for command in commands:
|
||||
pmb.chroot.root(args, command, suffix, working_dir=zip_root)
|
Loading…
Add table
Add a link
Reference in a new issue