Flavor instead of device name when creating recovery zip (#491)
* Flavor instead of device name when creating recovery zip. * Move parse_flavor_arg function
This commit is contained in:
parent
54d8010af1
commit
c6fe6e134a
|
@ -25,34 +25,12 @@ import pmb.install
|
||||||
import pmb.chroot.apk
|
import pmb.chroot.apk
|
||||||
import pmb.chroot.initfs
|
import pmb.chroot.initfs
|
||||||
import pmb.chroot.other
|
import pmb.chroot.other
|
||||||
|
import pmb.helpers.frontend
|
||||||
|
|
||||||
def parse_flavor_arg(args):
|
|
||||||
"""
|
|
||||||
Verify the flavor argument if specified, or return a default value.
|
|
||||||
"""
|
|
||||||
# Make sure, that at least one kernel is installed
|
|
||||||
suffix = "rootfs_" + args.device
|
|
||||||
pmb.chroot.apk.install(args, ["device-" + args.device], suffix)
|
|
||||||
|
|
||||||
# Parse and verify the flavor argument
|
|
||||||
flavor = args.flavor
|
|
||||||
flavors = pmb.chroot.other.kernel_flavors_installed(args, suffix)
|
|
||||||
if flavor:
|
|
||||||
if flavor not in flavors:
|
|
||||||
raise RuntimeError("No kernel installed with flavor " + flavor + "!" +
|
|
||||||
" Run 'pmbootstrap flasher list_flavors' to get a list.")
|
|
||||||
return flavor
|
|
||||||
if not len(flavors):
|
|
||||||
raise RuntimeError(
|
|
||||||
"No kernel flavors installed in chroot " + suffix + "! Please let"
|
|
||||||
" your device package depend on a package starting with 'linux-'.")
|
|
||||||
return flavors[0]
|
|
||||||
|
|
||||||
|
|
||||||
def kernel(args):
|
def kernel(args):
|
||||||
# Rebuild the initramfs, just to make sure (see #69)
|
# Rebuild the initramfs, just to make sure (see #69)
|
||||||
flavor = parse_flavor_arg(args)
|
flavor = pmb.helpers.frontend._parse_flavor(args)
|
||||||
pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device)
|
pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device)
|
||||||
|
|
||||||
# Generate the paths and run the flasher
|
# Generate the paths and run the flasher
|
||||||
|
@ -126,7 +104,7 @@ def export(args):
|
||||||
" install' first (without the 'sdcard' parameter).")
|
" install' first (without the 'sdcard' parameter).")
|
||||||
|
|
||||||
# Rebuild the initramfs, just to make sure (see #69)
|
# Rebuild the initramfs, just to make sure (see #69)
|
||||||
flavor = parse_flavor_arg(args)
|
flavor = pmb.helpers.frontend._parse_flavor(args)
|
||||||
pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device)
|
pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device)
|
||||||
|
|
||||||
pmb.flasher.export(args, flavor, args.export_folder)
|
pmb.flasher.export(args, flavor, args.export_folder)
|
||||||
|
|
|
@ -39,6 +39,29 @@ import pmb.parse
|
||||||
import pmb.qemu
|
import pmb.qemu
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_flavor(args):
|
||||||
|
"""
|
||||||
|
Verify the flavor argument if specified, or return a default value.
|
||||||
|
"""
|
||||||
|
# Make sure, that at least one kernel is installed
|
||||||
|
suffix = "rootfs_" + args.device
|
||||||
|
pmb.chroot.apk.install(args, ["device-" + args.device], suffix)
|
||||||
|
|
||||||
|
# Parse and verify the flavor argument
|
||||||
|
flavor = args.flavor
|
||||||
|
flavors = pmb.chroot.other.kernel_flavors_installed(args, suffix)
|
||||||
|
if flavor:
|
||||||
|
if flavor not in flavors:
|
||||||
|
raise RuntimeError("No kernel installed with flavor " + flavor + "!" +
|
||||||
|
" Run 'pmbootstrap flasher list_flavors' to get a list.")
|
||||||
|
return flavor
|
||||||
|
if not len(flavors):
|
||||||
|
raise RuntimeError(
|
||||||
|
"No kernel flavors installed in chroot " + suffix + "! Please let"
|
||||||
|
" your device package depend on a package starting with 'linux-'.")
|
||||||
|
return flavors[0]
|
||||||
|
|
||||||
|
|
||||||
def _parse_suffix(args):
|
def _parse_suffix(args):
|
||||||
if args.rootfs:
|
if args.rootfs:
|
||||||
return "rootfs_" + args.device
|
return "rootfs_" + args.device
|
||||||
|
|
|
@ -19,6 +19,7 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pmb.chroot
|
import pmb.chroot
|
||||||
|
import pmb.helpers.frontend
|
||||||
|
|
||||||
|
|
||||||
def create_zip(args, suffix):
|
def create_zip(args, suffix):
|
||||||
|
@ -27,6 +28,7 @@ def create_zip(args, suffix):
|
||||||
"""
|
"""
|
||||||
zip_root = "/var/lib/postmarketos-android-recovery-installer/"
|
zip_root = "/var/lib/postmarketos-android-recovery-installer/"
|
||||||
rootfs = "/mnt/rootfs_" + args.device
|
rootfs = "/mnt/rootfs_" + args.device
|
||||||
|
flavor = pmb.helpers.frontend._parse_flavor(args)
|
||||||
|
|
||||||
# Install recovery installer package in buildroot
|
# Install recovery installer package in buildroot
|
||||||
pmb.chroot.apk.install(args,
|
pmb.chroot.apk.install(args,
|
||||||
|
@ -52,7 +54,7 @@ def create_zip(args, suffix):
|
||||||
# Move config file from /tmp/ to zip root
|
# Move config file from /tmp/ to zip root
|
||||||
["mv", "/tmp/install_options", "install_options"],
|
["mv", "/tmp/install_options", "install_options"],
|
||||||
# Copy boot.img to zip root
|
# Copy boot.img to zip root
|
||||||
["cp", rootfs + "/boot/boot.img-" + args.device, "boot.img"],
|
["cp", rootfs + "/boot/boot.img-" + flavor, "boot.img"],
|
||||||
# Create tar archive of the rootfs
|
# Create tar archive of the rootfs
|
||||||
["tar", "-pczf", "rootfs.tar.gz", "--exclude", "./home/user/*",
|
["tar", "-pczf", "rootfs.tar.gz", "--exclude", "./home/user/*",
|
||||||
"-C", rootfs, "."],
|
"-C", rootfs, "."],
|
||||||
|
|
|
@ -192,6 +192,9 @@ def arguments():
|
||||||
" added to the rootfs (e.g. 'vim,gcc')")
|
" added to the rootfs (e.g. 'vim,gcc')")
|
||||||
install.add_argument("--no-fde", help="do not use full disk encryption",
|
install.add_argument("--no-fde", help="do not use full disk encryption",
|
||||||
action="store_false", dest="full_disk_encryption")
|
action="store_false", dest="full_disk_encryption")
|
||||||
|
install.add_argument("--flavor",
|
||||||
|
help="Specify kernel flavor to include in recovery"
|
||||||
|
" flashable zip", default=None)
|
||||||
install.add_argument("--android-recovery-zip",
|
install.add_argument("--android-recovery-zip",
|
||||||
help="generate TWRP flashable zip",
|
help="generate TWRP flashable zip",
|
||||||
action="store_true", dest="android_recovery_zip")
|
action="store_true", dest="android_recovery_zip")
|
||||||
|
|
Loading…
Reference in New Issue