Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
build: ignore empty files
Do not error out on empty files, just ignore them.

This can be easily reproduced by touch'ing an empty file in the
directory of an appliance created with --prepare.
  • Loading branch information
ptoscano committed Dec 3, 2018
1 parent bece55d commit 52172bd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mode_build.ml
Expand Up @@ -46,6 +46,7 @@ and file_content =
| Packages
| Hostfiles
| Excludefiles
| Empty

let rec string_of_file_type = function
| GZip c -> sprintf "gzip %s" (string_of_file_content c)
Expand All @@ -56,6 +57,7 @@ and string_of_file_content = function
| Packages -> "packages"
| Hostfiles -> "hostfiles"
| Excludefiles -> "excludefiles"
| Empty -> "empty"

let rec build debug
(copy_kernel, format, host_cpu,
Expand Down Expand Up @@ -250,6 +252,8 @@ and read_appliance debug basedir appliance = function
(* Depending on the file type, read or unpack the file. *)
let appliance =
match file_type with
| Uncompressed Empty | GZip Empty | XZ Empty ->
appliance
| Uncompressed ((Packages|Hostfiles|Excludefiles) as t) ->
let chan = open_in file in
let lines = input_all_lines chan in
Expand Down Expand Up @@ -294,7 +298,7 @@ and update_appliance appliance lines = function
String.sub path 1 (n-1)
) lines in
{ appliance with excludefiles = appliance.excludefiles @ lines }
| Base_image -> assert false
| Base_image | Empty -> assert false

(* Determine the [file_type] of [file], or exit with an error. *)
and get_file_type file =
Expand Down Expand Up @@ -331,6 +335,7 @@ and get_file_content file buf len =
else if len >= 2 && buf.[0] = '/' then Hostfiles
else if len >= 2 && buf.[0] = '-' then Excludefiles
else if len >= 1 && isalnum buf.[0] then Packages
else if len = 0 then Empty
else error "%s: unknown file type in supermin directory" file

and get_compressed_file_content zcat file =
Expand Down

0 comments on commit 52172bd

Please sign in to comment.