| ... | ... | @@ -45,13 +45,16 @@ pub fn main() !void { |
| 45 | 45 | while (try walker.next()) |entry| { |
| 46 | 46 | if (entry.kind != .file) continue; |
| 47 | 47 | |
| 48 | | // Special exception to keep the copyright file. |
| 49 | | if (std.mem.eql(u8, entry.path, "COPYING")) continue; |
| 50 | | |
| 51 | 48 | src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, .{}) catch |err| switch (err) { |
| 52 | 49 | error.FileNotFound => { |
| 53 | | std.log.warn("deleting {s}", .{entry.path}); |
| 54 | | try dest_crt_dir.deleteFile(entry.path); |
| 50 | const whitelisted = for (whitelist) |item| { |
| 51 | if (std.mem.eql(u8, entry.path, item)) break true; |
| 52 | } else false; |
| 53 | |
| 54 | if (!whitelisted) { |
| 55 | std.log.warn("deleting {s}", .{entry.path}); |
| 56 | try dest_crt_dir.deleteFile(entry.path); |
| 57 | } |
| 55 | 58 | }, |
| 56 | 59 | else => { |
| 57 | 60 | std.log.err("unable to copy {s}: {s}", .{ entry.path, @errorName(err) }); |
| ... | ... | @@ -105,6 +108,11 @@ pub fn main() !void { |
| 105 | 108 | return std.process.cleanExit(); |
| 106 | 109 | } |
| 107 | 110 | |
| 111 | const whitelist = [_][]const u8{ |
| 112 | "COPYING", |
| 113 | "include" ++ std.fs.path.sep_str ++ "config.h", |
| 114 | }; |
| 115 | |
| 108 | 116 | const ok_exts = [_][]const u8{ |
| 109 | 117 | ".def", |
| 110 | 118 | ".def.in", |