diff --git a/pmb/export/__init__.py b/pmb/export/__init__.py
new file mode 100644
index 00000000..bb71f485
--- /dev/null
+++ b/pmb/export/__init__.py
@@ -0,0 +1,21 @@
+"""
+Copyright 2017 Oliver Smith
+
+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 .
+"""
+from pmb.export.frontend import frontend
+from pmb.export.odin import odin
+from pmb.export.symlinks import symlinks
diff --git a/pmb/export/frontend.py b/pmb/export/frontend.py
new file mode 100644
index 00000000..7150d6b6
--- /dev/null
+++ b/pmb/export/frontend.py
@@ -0,0 +1,30 @@
+import logging
+import os
+
+import pmb.helpers.run
+import pmb.helpers.frontend
+import pmb.chroot.initfs
+import pmb.export
+
+
+def frontend(args):
+ # Create the export folder
+ target = args.export_folder
+ if not os.path.exists(target):
+ pmb.helpers.run.user(args, ["mkdir", "-p", target])
+
+ # System image note
+ img_path = "/home/user/rootfs/" + args.device + ".img"
+ if not os.path.exists(args.work + "/chroot_native" + img_path):
+ logging.info("NOTE: To export the system image, run 'pmbootstrap"
+ " install' first (without the 'sdcard' parameter).")
+
+ # Rebuild the initramfs, just to make sure (see #69)
+ flavor = pmb.helpers.frontend._parse_flavor(args)
+ pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device)
+
+ # Do the export, print all files
+ logging.info("Export symlinks to: " + target)
+ if args.odin_flashable_tar:
+ pmb.export.odin(args, flavor, target)
+ pmb.export.symlinks(args, flavor, target)
diff --git a/pmb/flasher/export.py b/pmb/export/odin.py
similarity index 70%
rename from pmb/flasher/export.py
rename to pmb/export/odin.py
index 1766db7d..216ca27c 100644
--- a/pmb/flasher/export.py
+++ b/pmb/export/odin.py
@@ -17,8 +17,6 @@ You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
import logging
-import os
-import glob
import pmb.build
import pmb.chroot.apk
@@ -27,60 +25,7 @@ import pmb.flasher
import pmb.helpers.file
-def export(args, flavor, folder):
- logging.info("Export symlinks to: " + folder)
- if args.odin_flashable_tar:
- odin_flashable_tar(args, flavor, folder)
- symlinks(args, flavor, folder)
-
-
-def symlinks(args, flavor, folder):
- """
- Create convenience symlinks to the system image and boot files.
- """
-
- # File descriptions
- info = {
- "boot.img-" + flavor: "Fastboot compatible boot.img file,"
- " contains initramfs and kernel",
- "initramfs-" + flavor: "Initramfs",
- "uInitrd-" + flavor: "Initramfs, legacy u-boot image format",
- "uImage-" + flavor: "Kernel, legacy u-boot image format",
- "vmlinuz-" + flavor: "Linux kernel",
- args.device + ".img": "System partition",
- "pmos-" + args.device + ".zip": "Android recovery flashable zip",
- }
-
- # Generate a list of patterns
- path_native = args.work + "/chroot_native"
- path_boot = args.work + "/chroot_rootfs_" + args.device + "/boot"
- path_buildroot = args.work + "/chroot_buildroot_" + args.deviceinfo["arch"]
- patterns = [path_boot + "/*-" + flavor,
- path_native + "/home/user/rootfs/" + args.device + ".img",
- path_buildroot +
- "/var/lib/postmarketos-android-recovery-installer/pmos-" +
- args.device + ".zip"]
-
- # Generate a list of files from the patterns
- files = []
- for pattern in patterns:
- files += glob.glob(pattern)
-
- # Iterate through all files
- for file in files:
- basename = os.path.basename(file)
- link = folder + "/" + basename
-
- # Display a readable message
- msg = " * " + basename
- if basename in info:
- msg += " (" + info[basename] + ")"
- logging.info(msg)
-
- pmb.helpers.file.symlink(args, file, link)
-
-
-def odin_flashable_tar(args, flavor, folder):
+def odin(args, flavor, folder):
"""
Create Odin flashable tar file with kernel and initramfs for devices configured with
the flasher method 'heimdall-isorec' and with boot.img for devices with 'heimdall-bootimg'
diff --git a/pmb/export/symlinks.py b/pmb/export/symlinks.py
new file mode 100644
index 00000000..609af82c
--- /dev/null
+++ b/pmb/export/symlinks.py
@@ -0,0 +1,73 @@
+"""
+Copyright 2017 Oliver Smith
+
+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 .
+"""
+import logging
+import os
+import glob
+
+import pmb.build
+import pmb.chroot.apk
+import pmb.config
+import pmb.flasher
+import pmb.helpers.file
+
+
+def symlinks(args, flavor, folder):
+ """
+ Create convenience symlinks to the system image and boot files.
+ """
+
+ # File descriptions
+ info = {
+ "boot.img-" + flavor: "Fastboot compatible boot.img file,"
+ " contains initramfs and kernel",
+ "initramfs-" + flavor: "Initramfs",
+ "uInitrd-" + flavor: "Initramfs, legacy u-boot image format",
+ "uImage-" + flavor: "Kernel, legacy u-boot image format",
+ "vmlinuz-" + flavor: "Linux kernel",
+ args.device + ".img": "System partition",
+ "pmos-" + args.device + ".zip": "Android recovery flashable zip",
+ }
+
+ # Generate a list of patterns
+ path_native = args.work + "/chroot_native"
+ path_boot = args.work + "/chroot_rootfs_" + args.device + "/boot"
+ path_buildroot = args.work + "/chroot_buildroot_" + args.deviceinfo["arch"]
+ patterns = [path_boot + "/*-" + flavor,
+ path_native + "/home/user/rootfs/" + args.device + ".img",
+ path_buildroot +
+ "/var/lib/postmarketos-android-recovery-installer/pmos-" +
+ args.device + ".zip"]
+
+ # Generate a list of files from the patterns
+ files = []
+ for pattern in patterns:
+ files += glob.glob(pattern)
+
+ # Iterate through all files
+ for file in files:
+ basename = os.path.basename(file)
+ link = folder + "/" + basename
+
+ # Display a readable message
+ msg = " * " + basename
+ if basename in info:
+ msg += " (" + info[basename] + ")"
+ logging.info(msg)
+
+ pmb.helpers.file.symlink(args, file, link)
diff --git a/pmb/flasher/__init__.py b/pmb/flasher/__init__.py
index f5e8df18..fed79cef 100644
--- a/pmb/flasher/__init__.py
+++ b/pmb/flasher/__init__.py
@@ -19,4 +19,3 @@ along with pmbootstrap. If not, see .
from pmb.flasher.init import init
from pmb.flasher.run import run
from pmb.flasher.frontend import frontend
-from pmb.flasher.export import export
diff --git a/pmb/flasher/frontend.py b/pmb/flasher/frontend.py
index ae560967..4d8ad77a 100644
--- a/pmb/flasher/frontend.py
+++ b/pmb/flasher/frontend.py
@@ -25,6 +25,7 @@ import pmb.install
import pmb.chroot.apk
import pmb.chroot.initfs
import pmb.chroot.other
+import pmb.export.frontend
import pmb.helpers.frontend
@@ -92,24 +93,6 @@ def sideload(args):
pmb.flasher.run(args, "sideload")
-def export(args):
- # Create the export folder
- if not os.path.exists(args.export_folder):
- pmb.helpers.run.user(args, ["mkdir", "-p", args.export_folder])
-
- # System image note
- img_path = "/home/user/rootfs/" + args.device + ".img"
- if not os.path.exists(args.work + "/chroot_native" + img_path):
- logging.info("NOTE: To export the system image, run 'pmbootstrap"
- " install' first (without the 'sdcard' parameter).")
-
- # Rebuild the initramfs, just to make sure (see #69)
- flavor = pmb.helpers.frontend._parse_flavor(args)
- pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device)
-
- pmb.flasher.export(args, flavor, args.export_folder)
-
-
def frontend(args):
action = args.action_flasher
if action in ["boot", "flash_kernel"]:
@@ -123,4 +106,7 @@ def frontend(args):
if action == "sideload":
sideload(args)
if action == "export":
- export(args)
+ logging.info("WARNING: 'pmbootstrap flasher export' is deprecated and"
+ " will be removed soon. The new syntax is 'pmbootstrap"
+ " export'.")
+ pmb.export.frontend(args)
diff --git a/pmb/helpers/frontend.py b/pmb/helpers/frontend.py
index 14e03dd2..62bb80c8 100644
--- a/pmb/helpers/frontend.py
+++ b/pmb/helpers/frontend.py
@@ -140,6 +140,10 @@ def flasher(args):
pmb.flasher.frontend(args)
+def export(args):
+ pmb.export.frontend(args)
+
+
def menuconfig(args):
pmb.build.menuconfig(args, args.package, args.deviceinfo["arch"])
@@ -174,7 +178,8 @@ def stats(args):
def log(args):
if args.clear_log:
- pmb.helpers.run.user(args, ["truncate", "-s", "0", args.log], log=False)
+ pmb.helpers.run.user(args, ["truncate", "-s", "0", args.log],
+ log=False)
pmb.helpers.run.user(args, ["tail", "-f", args.log, "-n", args.lines],
log=False)
@@ -187,4 +192,5 @@ def log_distccd(args):
def zap(args):
- pmb.chroot.zap(args, packages=args.packages, http=args.http, mismatch_bins=args.mismatch_bins)
+ pmb.chroot.zap(args, packages=args.packages, http=args.http,
+ mismatch_bins=args.mismatch_bins)
diff --git a/pmb/install/install.py b/pmb/install/install.py
index 2f94d99f..583a08a8 100644
--- a/pmb/install/install.py
+++ b/pmb/install/install.py
@@ -212,8 +212,8 @@ def install_system_image(args):
# Export information
logging.info("* If the above steps do not work, you can also create"
- " symlinks to the generated files with 'pmbootstrap flasher"
- " export [export_folder]' and flash outside of pmbootstrap.")
+ " symlinks to the generated files with 'pmbootstrap export'"
+ " and flash outside of pmbootstrap.")
def install_recovery_zip(args):
@@ -231,9 +231,8 @@ def install_recovery_zip(args):
# Export information
logging.info("* If this does not work, you can also create a"
- " symlink to the generated zip with 'pmbootstrap flasher"
- " export --android-recovery-zip [export_folder]' and"
- " flash outside of pmbootstrap.")
+ " symlink to the generated zip with 'pmbootstrap"
+ " export' and flash outside of pmbootstrap.")
def install(args):
diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py
index 13c459e8..b4a3489c 100644
--- a/pmb/parse/arguments.py
+++ b/pmb/parse/arguments.py
@@ -21,6 +21,21 @@ import pmb.config
import pmb.parse.arch
+def arguments_export(subparser):
+ ret = subparser.add_parser("export", help="create convenience symlinks"
+ " to generated image files (system, kernel,"
+ " initramfs, boot.img, ...)")
+
+ ret.add_argument("export_folder", help="export folder, defaults to"
+ " /tmp/postmarketOS-export",
+ default="/tmp/postmarketOS-export", nargs="?")
+ ret.add_argument("--odin", help="odin flashable tar"
+ " (boot.img/kernel+initramfs only)",
+ action="store_true", dest="odin_flashable_tar")
+ ret.add_argument("--flavor", default=None)
+ return ret
+
+
def arguments_flasher(subparser):
ret = subparser.add_parser("flasher", help="flash something to the"
" target device")
@@ -28,29 +43,22 @@ def arguments_flasher(subparser):
ret.add_argument("--method", help="override flash method",
dest="flash_method", default=None)
- # Boot, flash kernel, export
+ # Boot, flash kernel
boot = sub.add_parser("boot", help="boot a kernel once")
boot.add_argument("--cmdline", help="override kernel commandline")
flash_kernel = sub.add_parser("flash_kernel", help="flash a kernel")
- export = sub.add_parser("export", help="create convenience symlinks to the"
- " generated image files (system,"
- " kernel, initramfs, boot.img, ...)")
- for action in [boot, flash_kernel, export]:
+ for action in [boot, flash_kernel]:
action.add_argument("--flavor", default=None)
- # Other
+ # Actions without extra arguments
sub.add_parser("flash_system", help="flash the system partition")
+ sub.add_parser("sideload", help="sideload recovery zip")
sub.add_parser("list_flavors", help="list installed kernel flavors" +
" inside the device rootfs chroot on this computer")
sub.add_parser("list_devices", help="show connected devices")
- sub.add_parser("sideload", help="sideload recovery zip")
- # Export: additional arguments
- export.add_argument("export_folder", help="export folder, defaults to"
- " /tmp/postmarketOS-export",
- default="/tmp/postmarketOS-export", nargs="?")
- export.add_argument("--odin", help="odin flashable tar (boot.img/kernel+initramfs only)",
- action="store_true", dest="odin_flashable_tar")
+ # Deprecated "pmbootstrap flasher export"
+ arguments_export(sub)
return ret
@@ -136,6 +144,7 @@ def arguments():
sub.add_parser("shutdown", help="umount, unregister binfmt")
sub.add_parser("index", help="re-index all repositories with custom built"
" packages (do this after manually removing package files)")
+ arguments_export(sub)
arguments_flasher(sub)
arguments_initfs(sub)