Rev 9370 | Rev 9374 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9370 | Rev 9373 | ||
---|---|---|---|
Line 52... | Line 52... | ||
52 | if __name__ == "__main__": |
52 | if __name__ == "__main__": |
53 | program_files = build.build() |
53 | program_files = build.build() |
Line 54... | Line 54... | ||
54 | 54 | ||
Line 55... | Line 55... | ||
55 | os.makedirs("workspace", exist_ok = True) |
55 | os.makedirs("workspace", exist_ok = True) |
56 | 56 | ||
57 | if not os.path.exists("workspace/kolibri.img"): |
57 | if not os.path.exists("workspace/kolibri.unmodified.img"): |
- | 58 | img_url = "http://builds.kolibrios.org/eng/data/data/kolibri.img" |
|
- | 59 | download(img_url, "workspace/kolibri.unmodified.img") |
|
- | 60 | ||
Line 58... | Line 61... | ||
58 | img_url = "http://builds.kolibrios.org/eng/data/data/kolibri.img" |
61 | # Create a copy of IMG |
59 | download(img_url, "workspace/kolibri.img") |
62 | shutil.copyfile("workspace/kolibri.unmodified.img", "workspace/kolibri.img") |
60 | 63 | ||
61 | # Open the IMG |
64 | # Open the IMG |
Line 70... | Line 73... | ||
70 | 73 | ||
71 | log("Moving program files into kolibri image... ", end = "") |
74 | log("Moving program files into kolibri image... ", end = "") |
72 | for file_name in program_files: |
75 | for file_name in program_files: |
73 | with open(file_name, "rb") as file: |
76 | with open(file_name, "rb") as file: |
74 | file_data = file.read() |
77 | file_data = file.read() |
75 | if not img.add_file_path(file_name, file_data): |
78 | if not img.add_file_path(file_name.upper(), file_data): |
76 | print(f"Coudn't move {file_name} into IMG") |
- | |
77 | img.save("workspace/kolibri.img") |
79 | print(f"Coudn't move {file_name} into IMG") |
Line -... | Line 80... | ||
- | 80 | log("Done") |
|
- | 81 | ||
- | 82 | # TODO: Figure out which of compiled files is a program executable and only run it |
|
- | 83 | log("Adding program to autorun.dat", end = "") |
|
- | 84 | lines_to_add = b"" |
|
- | 85 | for file_name in program_files: |
|
- | 86 | lines_to_add += bytes(f"\r\n/SYS/{file_name.upper()}\t\t""\t0\t# Your program", "ascii") |
|
- | 87 | autorun_dat = img.extract_file_path("SETTINGS\AUTORUN.DAT") |
|
78 | log("Done") |
88 | place_for_new_lines = autorun_dat.index(b"\r\n/SYS/@TASKBAR")# b"\r\n### Hello, ASM World! ###") |
- | 89 | autorun_dat = autorun_dat[:place_for_new_lines] + lines_to_add + autorun_dat[place_for_new_lines:] |
|
- | 90 | print(autorun_dat) |
|
- | 91 | img.delete_path("SETTINGS\AUTORUN.DAT") |
|
- | 92 | img.add_file_path("SETTINGS\AUTORUN.DAT", autorun_dat) |
|
- | 93 | log("Done") |
|
- | 94 | ||
79 | 95 | img.save("workspace/kolibri.img") |