summaryrefslogtreecommitdiffhomepage
path: root/tooling
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-20 16:47:35 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-20 16:47:35 +0200
commitbc97b2b790eb06d8f9adb8ef8fa41874d7d19770 (patch)
treea6929db78467c2b07877abb9d9aad579d77139bb /tooling
parent699e395505a602f4a731c481646233d87f87a85c (diff)
kernel, dev: python script to make an ESP from files.
- Started implementing the wrt_* APIs (Wide string functions) - Make user.sys link now, need to implement more syscalls. - Tiny HEFS refactors too. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'tooling')
-rwxr-xr-xtooling/copy_to_fat32.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tooling/copy_to_fat32.py b/tooling/copy_to_fat32.py
new file mode 100755
index 00000000..ea0cb1b9
--- /dev/null
+++ b/tooling/copy_to_fat32.py
@@ -0,0 +1,44 @@
+#!/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: python3 copy_to_fat32.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