summaryrefslogtreecommitdiffhomepage
path: root/tooling/mk_img.py
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-21 08:47:04 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-21 08:47:04 +0200
commit00e314410e6049c2ddbcb4861c04af6b06eeeea3 (patch)
treebe4ee060de121ac0b825b5b0263deb3a0ac74619 /tooling/mk_img.py
parentf00211b6023ad406553a6bf9208092f834a44cdd (diff)
dev, kernel, tools, tooling, tex: add mk_app tool, see details.
- Patch HeFS implementation file, working on a allocation function now. - Generated LaTeX specs from source code. - Add mk.{hefs, nefs} tools for future formatting (with diutil first) - Add python tool to generate user apps for NeKernel. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'tooling/mk_img.py')
-rwxr-xr-xtooling/mk_img.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tooling/mk_img.py b/tooling/mk_img.py
new file mode 100755
index 00000000..253e5a6c
--- /dev/null
+++ b/tooling/mk_img.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+import subprocess
+import glob
+
+def copy_to_fat(image_path, source_dir):
+ if not os.path.isfile(image_path):
+ print(f"Error: FAT32 image {image_path} does not exist.")
+ sys.exit(1)
+
+ if not os.path.isdir(source_dir):
+ print(f"Error: {source_dir} is not a valid directory.")
+ sys.exit(1)
+
+ try:
+ files_to_copy = glob.glob(os.path.join(source_dir, "*"))
+ # Now build the command
+ command = ["mcopy", "-spom", "-i", image_path] + files_to_copy + ["::"]
+ subprocess.run(command, check=True)
+
+ print(f"Successfully copied contents of '{source_dir}' into '{image_path}'")
+ except FileNotFoundError:
+ print("Error: mcopy is not installed. Please install mtools.")
+ sys.exit(1)
+ except subprocess.CalledProcessError as e:
+ print(f"Error: mcopy failed with error code {e.returncode}.")
+ sys.exit(1)
+ except Exception as e:
+ print(f"mcopy failed: {e}")
+ sys.exit(1)
+
+if __name__ == "__main__":
+ if len(sys.argv) != 3:
+ print("Usage: mk_img.py <fat32_image> <source_directory>")
+ sys.exit(1)
+
+ image_path = sys.argv[1]
+ source_dir = sys.argv[2]
+
+ copy_to_fat(image_path, source_dir) \ No newline at end of file