mirror of
https://gitlab.com/prpl-foundation/prplmesh/prplMesh.git
synced 2025-12-20 01:21:22 +08:00
By default, isort doesn't sort alphabetically within each section. Make it do so, and fix the existing imports in 'tools/deploy_firmware.py' and in 'tools/device/turris_rdk_b.py'. Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
88 lines
3.1 KiB
Python
Executable File
88 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
###############################################################
|
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
# SPDX-FileCopyrightText: 2020-2022 the prplMesh contributors (see AUTHORS.md)
|
|
# This code is subject to the terms of the BSD+Patent license.
|
|
# See LICENSE file for more details.
|
|
###############################################################
|
|
|
|
# Standard library
|
|
import argparse
|
|
import sys
|
|
|
|
# Third party
|
|
from device.axepoint import Axepoint
|
|
from device.glinet_b1300 import GlinetB1300
|
|
from device.prplos import GenericPrplOS
|
|
from device.turris_prplos import TurrisPrplOS
|
|
from device.turris_rdk_b import TurrisRdkb
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(prog=sys.argv[0],
|
|
description="""Update a prplOS device, either through u-boot
|
|
or using sysupgrade, depending on the target device.""")
|
|
parser.add_argument('-d', '--device',
|
|
help="""Device to upgrade. Currently supported targets are: nec-wx3000hp
|
|
glinet-b1300 turris-omnia axepoint""", required=True)
|
|
parser.add_argument(
|
|
'-t',
|
|
'--target-name',
|
|
help="Name of the target to upgrade (make sure it's reachable through ssh).", required=True)
|
|
|
|
parser.add_argument(
|
|
'-i',
|
|
'--image',
|
|
help="Name of the image to use for the upgrade (should exist in the artifacts folder).",
|
|
required=True)
|
|
|
|
parser.add_argument(
|
|
'-k',
|
|
'--kernel',
|
|
help="Kernel for RDKB type of image.")
|
|
parser.add_argument(
|
|
'-f',
|
|
'--full',
|
|
action='store_true',
|
|
help="Always flash the full image (even if it's not required).")
|
|
|
|
args = parser.parse_args()
|
|
|
|
if args.device in ["axepoint", "nec-wx3000hp"]:
|
|
dev = Axepoint(args.device, args.target_name, args.image)
|
|
elif args.device == "turris-omnia-rdk":
|
|
dev = TurrisRdkb(args.device, args.target_name, args.image, args.kernel)
|
|
elif args.device == "turris-omnia":
|
|
dev = TurrisPrplOS(args.device, args.target_name, args.image)
|
|
elif args.device == "glinet-b1300":
|
|
dev = GlinetB1300(args.device, args.target_name, args.image)
|
|
else:
|
|
# if no device matched, try the generic prplOS (sysupgrade)
|
|
dev = GenericPrplOS(args.device, args.target_name, args.image)
|
|
|
|
def do_upgrade(dev):
|
|
try:
|
|
dev.sysupgrade()
|
|
except NotImplementedError:
|
|
dev.upgrade_bootloader()
|
|
print("Checking if the device was properly updated")
|
|
if dev.needs_upgrade():
|
|
print("Something went wrong with the update!")
|
|
sys.exit(1)
|
|
print("Done")
|
|
|
|
if args.full:
|
|
print("--full was provided, the device {} will be upgraded".format(dev.name))
|
|
do_upgrade(dev)
|
|
else:
|
|
print("Checking if the device needs to be upgraded")
|
|
if dev.needs_upgrade():
|
|
print("The device {} will be upgraded".format(dev.name))
|
|
do_upgrade(dev)
|
|
else:
|
|
print("The device is already using the same version, no upgrade will be done.")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|