flasher: Partition blacklisting (!1759)

It is dangerous to flash the boot partition on the Ouya. Doing so can
result in a bricked device. Allow deviceinfo to blacklist partitions from
ever being flashed.
This commit is contained in:
Robert Yang 2019-02-16 14:53:22 -05:00 committed by Oliver Smith
parent 2634bbea95
commit fa40873de2
4 changed files with 17 additions and 0 deletions

View File

@ -267,6 +267,7 @@ deviceinfo_attributes = [
"rootfs_image_sector_size",
"sd_embed_firmware",
"sd_embed_firmware_step_size",
"partition_blacklist",
# weston
"weston_pixman_type",

View File

@ -18,5 +18,6 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
from pmb.flasher.init import init
from pmb.flasher.run import run
from pmb.flasher.run import check_partition_blacklist
from pmb.flasher.variables import variables
from pmb.flasher.frontend import frontend

View File

@ -20,6 +20,17 @@ import pmb.flasher
import pmb.chroot.initfs
def check_partition_blacklist(args, key, value):
if not key.startswith("$PARTITION_"):
return
name = args.deviceinfo["name"]
if value in args.deviceinfo["partition_blacklist"].split(","):
raise RuntimeError("'" + value + "'" + " partition is blacklisted " +
"from being flashed! See the " + name + " device " +
"wiki page for more information.")
def run(args, action, flavor=None):
pmb.flasher.init(args)
@ -48,6 +59,7 @@ def run(args, action, flavor=None):
" action " + action + " for method " + method + ","
" but the value for this variable is None! Is that"
" missing in your deviceinfo?")
check_partition_blacklist(args, key, value)
command[i] = command[i].replace(key, value)
# Run the action

View File

@ -40,6 +40,9 @@ def create_zip(args, suffix):
logging.info("(" + suffix + ") create recovery zip")
for key in vars:
pmb.flasher.check_partition_blacklist(args, key, vars[key])
# Create config file for the recovery installer
options = {
"DEVICE": args.device,