aboutsummaryrefslogtreecommitdiffstats
path: root/backend
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2023-08-01 15:48:46 +0200
committerPapoteur <papoteur@mageia.org>2023-08-01 15:49:11 +0200
commit67f456e3cf9a802111ce0158f140ffc302b459e2 (patch)
tree850a06e7941361c22d037af9f6713e7d89f33021 /backend
parent9d8775f70069e22fed33bfa9e6397394494b6db5 (diff)
downloadisodumper-67f456e3cf9a802111ce0158f140ffc302b459e2.tar
isodumper-67f456e3cf9a802111ce0158f140ffc302b459e2.tar.gz
isodumper-67f456e3cf9a802111ce0158f140ffc302b459e2.tar.bz2
isodumper-67f456e3cf9a802111ce0158f140ffc302b459e2.tar.xz
isodumper-67f456e3cf9a802111ce0158f140ffc302b459e2.zip
Add the code for creating any type of partition after writing ISO image
Diffstat (limited to 'backend')
-rwxr-xr-xbackend/magiback5
-rwxr-xr-xbackend/raw_write.py43
2 files changed, 38 insertions, 10 deletions
diff --git a/backend/magiback b/backend/magiback
index 108618a..5c55307 100755
--- a/backend/magiback
+++ b/backend/magiback
@@ -43,6 +43,7 @@ class Isodumper(raw_write.Dumper):
<arg type='s' name='target' direction='in'/>
<arg type='s' name='label' direction='in'/>
<arg type='s' name='key' direction='in'/>
+ <arg type='s' name='fs_type' direction='in'/>
</method>
<method name='set_backup_mode'>
<arg type='x' name='uid' direction='in'/>
@@ -102,10 +103,10 @@ class Isodumper(raw_write.Dumper):
logging.debug(self.return_message)
self.finished.set()
- def do_persistence(self, target, label, key):
+ def do_persistence(self, target, label, key, fs_type):
self.finished.clear()
if self.writing_perm and self.writing_target == target:
- self.thread = threading.Thread(target=self._do_persistence, args=(target, label, key))
+ self.thread = threading.Thread(target=self._do_persistence, args=(target, label, key, fs_type))
self.thread.start()
logging.info("Persistence thread started")
else:
diff --git a/backend/raw_write.py b/backend/raw_write.py
index d46fe1e..fe21046 100755
--- a/backend/raw_write.py
+++ b/backend/raw_write.py
@@ -198,9 +198,16 @@ class Dumper(object):
return False
return True
- def _do_persistence(self, target, label, key):
+ def _do_persistence(self, target, label, key, fs_type):
logging.debug("Start doing persistence partition")
p = Popen(["fdisk", target], stdin=PIPE, stderr=PIPE)
+ # commands:
+ # n : new
+ # p : primary partition
+ # 3 : partition number (1-4)
+ # default first sector
+ # default last sector
+ # w : write and quit
outs, errs = p.communicate(input=b"n\np\n3\n\n\nw\n")
working = True
while working:
@@ -250,15 +257,35 @@ class Dumper(object):
logging.debug("New partition created")
self._progress = 25
- # Wait for propagation of the info of new partition table
- if not self.udev_wait("creating a new partition table"):
- return
+ ## Wait for propagation of the info of new partition table
+ #if not self.udev_wait("creating a new partition table"):
+ #logging.error("Timeout")
+ #self.return_state = False
+ #self.finished.set()
+ #return
if key == "":
# example mkfs.ext4 -L mgalive-persist /dev/sdf3
- self.return_message = _("Persistent partition added. Formatting...")
- process = Popen(
- ["mkfs.ext4", "-q", "-F", "-L", label, target + "3"], stderr=PIPE
- )
+ self.return_message = _("Additional partition added. Formatting...")
+ path = target + "3"
+ # Format partition according to the fs_type specified
+ fs_type = fs_type.lower()
+ if fs_type == "fat32":
+ cmd = ["mkdosfs", "-F", "32", "-n", label.upper()[:11], path]
+ elif fs_type == "exfat":
+ cmd = ["mkfs.exfat", "-n", label.upper()[:11], path]
+ elif fs_type == "ntfs":
+ cmd = ["mkntfs", "-f", "-L", label, path]
+ elif fs_type == "ext4":
+ cmd = [
+ "mkfs.ext4",
+ "-q",
+ "-F",
+ "-L",
+ label,
+ path,
+ ]
+ logging.info(f"Executing {' '.join(cmd)}")
+ process = Popen(cmd, stderr=PIPE)
outs, errs = process.communicate()
working = True
while working: