import tarfile
import tempfile
-__version__ = "1.0.2"
+__version__ = "1.0.3"
Format = False
Device = ""
binaries[f] = i + 1
return binaries
- def get_partition_index(self, binary):
+ def get_partition_index_list(self, binary):
if hasattr(self, 'update'):
logging.error("You have requested to update the {} partition set. "
"This target does not support A/B partition sets."
.format(self.update.upper()))
sys.exit(1)
- return self.binaries.get(binary, None)
+ return [self.binaries.get(binary, None)]
params = ()
def initialize_parameters(self):
super().__init__(device, ltype)
self.binaries_b = self._get_binaries('binaries_b')
- def get_partition_index(self, binary):
+ def get_partition_index_list(self, binary):
if self.update == 'b':
- return self.binaries_b.get(binary, None)
- return self.binaries.get(binary, None)
+ return [self.binaries_b.get(binary, None)]
+ elif self.update == 'ab':
+ return [self.binaries.get(binary, None), self.binaries_b.get(binary, None)]
+
+ return [self.binaries.get(binary, None)]
class InitParams:
def initialize_parameters(self):
return None
def do_fuse_file(f, name, target):
- idx = target.get_partition_index(name)
- if idx is None:
+ indexes = target.get_partition_index_list(name)
+ if len(indexes) == 0:
logging.info(f"No partition defined for {name}, skipping.")
return
- pdevice = "/dev/" + get_partition_device(Device, idx)
- argv = ['dd', 'bs=4M',
- 'oflag=direct',
- 'iflag=fullblock',
- 'conv=nocreat',
- 'status=progress',
- f"of={pdevice}"]
- logging.debug(" ".join(argv))
- proc_dd = subprocess.Popen(argv,
- bufsize=(4 << 20),
- stdin=subprocess.PIPE,
- stdout=None, stderr=None)
- logging.notice(f"Writing {name} to {pdevice}")
- buf = f.read(4 << 20)
- while len(buf) > 0:
- proc_dd.stdin.write(buf)
+ for idx in indexes:
+ if idx is None:
+ logging.info(f"No partition defined for {name}, skipping.")
+ continue
+ pdevice = "/dev/" + get_partition_device(Device, idx)
+ argv = ['dd', 'bs=4M',
+ 'oflag=direct',
+ 'iflag=fullblock',
+ 'conv=nocreat',
+ 'status=progress',
+ f"of={pdevice}"]
+ logging.debug(" ".join(argv))
+ proc_dd = subprocess.Popen(argv,
+ bufsize=(4 << 20),
+ stdin=subprocess.PIPE,
+ stdout=None, stderr=None)
+ logging.notice(f"Writing {name} to {pdevice}")
buf = f.read(4 << 20)
- proc_dd.communicate()
- logging.info("Done")
- #TODO: verification
+ while len(buf) > 0:
+ proc_dd.stdin.write(buf)
+ buf = f.read(4 << 20)
+ proc_dd.communicate()
+ logging.info("Done")
+ #TODO: verification
#TODO: functions with the target argument should probably
# be part of some class
parser.add_argument("-t", "--target", required=True,
help="Target device model. Use `--target list`"
" to show supported devices.")
- parser.add_argument("--update", choices=['a', 'b'], default=None,
- help="Choose partition set to update: a or b.")
+ parser.add_argument("--update", choices=['a', 'b', 'ab'], default=None,
+ help="Choose partition set to update: a or b or ab.")
parser.add_argument("--version", action="version",
version=f"%(prog)s {__version__}")
parser.add_argument("--YES", action="store_true",