Select the types of activity you want to include in your feed.
feat: add ocaml-initramfs package, use it in space and uniboot
Extract initramfs building into a standalone package with Dir, File, and Tree entry types. Replaces duplicated cpio logic in space/lib/build.ml and uniboot/lib/uniboot.ml.
···142142 Log.info (fun m ->
143143 m "Building initramfs from %d paths" (List.length paths));
144144 let entries =
145145- List.concat_map
145145+ List.map
146146 (fun path ->
147147- if Sys.is_directory path then begin
148148- (* Add directory and its contents recursively *)
149149- let entries = ref [] in
150150- let rec walk prefix dir =
151151- let items = Sys.readdir dir |> Array.to_list in
152152- List.iter
153153- (fun name ->
154154- let full = Filename.concat dir name in
155155- let cpio_name = Filename.concat prefix name in
156156- if Sys.is_directory full then begin
157157- entries :=
158158- Cpio.directory ~perm:0o755 cpio_name :: !entries;
159159- walk cpio_name full
160160- end
161161- else
162162- let data =
163163- let ic = open_in_bin full in
164164- let len = in_channel_length ic in
165165- let s = Bytes.create len in
166166- really_input ic s 0 len;
167167- close_in ic;
168168- Bytes.unsafe_to_string s
169169- in
170170- let perm =
171171- let st = Unix.stat full in
172172- st.Unix.st_perm
173173- in
174174- entries :=
175175- Cpio.regular ~perm ~name:cpio_name data :: !entries)
176176- items
177177- in
178178- let base = Filename.basename path in
179179- entries := Cpio.directory ~perm:0o755 base :: !entries;
180180- walk base path;
181181- List.rev !entries
182182- end
183183- else
184184- let data =
185185- let ic = open_in_bin path in
186186- let len = in_channel_length ic in
187187- let s = Bytes.create len in
188188- really_input ic s 0 len;
189189- close_in ic;
190190- Bytes.unsafe_to_string s
191191- in
192192- let name = Filename.basename path in
193193- let perm =
194194- let st = Unix.stat path in
195195- st.Unix.st_perm
196196- in
197197- [ Cpio.regular ~perm ~name data ])
147147+ if Sys.is_directory path then Initramfs.Tree path
148148+ else Initramfs.File { name = Filename.basename path; path })
198149 paths
199150 in
200200- let archive = Cpio.to_string entries in
151151+ let archive = Initramfs.build entries in
201152 let archive_len = String.length archive in
202153 Log.info (fun m ->
203154 m "Initramfs: %d entries, %d bytes" (List.length entries) archive_len);