|
12 | 12 | -- |
13 | 13 | -- Copyright (C) 2023-2023 RT-Thread Development Team |
14 | 14 | -- |
15 | | --- @author xqyjlj |
| 15 | +-- @author xqyjlj |
16 | 16 | -- @file on_run.lua |
17 | 17 | -- |
18 | 18 | -- Change Logs: |
@@ -50,17 +50,40 @@ function make_fat(size, output, rootfs) |
50 | 50 | local fatdisk_exec |
51 | 51 | local fatdisk_dir = path.absolute("../../../fatdisk", os.scriptdir()) |
52 | 52 |
|
53 | | - if not os.host() == "linux" then |
| 53 | + if os.host() == "windows" then |
| 54 | + fatdisk_exec = path.join(fatdisk_dir, "fatdisk.exe") |
| 55 | + elseif os.host() == "linux" then |
| 56 | + if os.is_arch("x86_64", "x86", "x64") then |
| 57 | + fatdisk_exec = path.join(fatdisk_dir, "fatdisk-x86") |
| 58 | + else |
| 59 | + os.raise("not support arch '%s'", os.arch()) |
| 60 | + end |
| 61 | + else |
54 | 62 | os.raise("not support host '%s'", os.host()) |
55 | 63 | end |
56 | 64 |
|
57 | | - if os.arch() == "x86_64" then |
58 | | - fatdisk_exec = path.join(fatdisk_dir, "fatdisk-x86") |
| 65 | + os.vrunv(fatdisk_exec, {"--disk_size=" .. size, "--output=" .. output, "--input=" .. rootfs}) |
| 66 | +end |
| 67 | + |
| 68 | +function make_cromfs(output, rootfs) |
| 69 | + local target |
| 70 | + local rootfs_dir |
| 71 | + local cromfs_exec |
| 72 | + local cromfs_dir = path.absolute("../../../cromfs", os.scriptdir()) |
| 73 | + |
| 74 | + if os.host() == "windows" then |
| 75 | + cromfs_exec = path.join(cromfs_dir, "cromfs-tool.exe") |
| 76 | + elseif os.host() == "linux" then |
| 77 | + if os.is_arch("x86_64", "x86", "x64") then |
| 78 | + cromfs_exec = path.join(cromfs_dir, "cromfs-tool-x86") |
| 79 | + else |
| 80 | + os.raise("not support arch '%s'", os.arch()) |
| 81 | + end |
59 | 82 | else |
60 | | - os.raise("not support arch '%s'", os.arch()) |
| 83 | + os.raise("not support host '%s'", os.host()) |
61 | 84 | end |
62 | 85 |
|
63 | | - os.vrunv(fatdisk_exec, {"--disk_size=" .. size, "--output=" .. output, "--input=" .. rootfs}) |
| 86 | + os.vrunv(cromfs_exec, {rootfs, output}) |
64 | 87 | end |
65 | 88 |
|
66 | 89 | function main() |
@@ -93,6 +116,8 @@ function main() |
93 | 116 | make_ext4(size, output, rootfs) |
94 | 117 | elseif format == "fat" then |
95 | 118 | make_fat(size, output, rootfs) |
| 119 | + elseif format == "cromfs" then |
| 120 | + make_cromfs(output, rootfs) |
96 | 121 | else |
97 | 122 | os.raise("unsupport format '%s'", format) |
98 | 123 | end |
|
0 commit comments