| ... | @@ -45,13 +45,16 @@ pub fn main() !void { | ... | @@ -45,13 +45,16 @@ pub fn main() !void { |
| 45 | while (try walker.next()) |entry| { | 45 | while (try walker.next()) |entry| { |
| 46 | if (entry.kind != .file) continue; | 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 | src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, .{}) catch |err| switch (err) { | 48 | src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, .{}) catch |err| switch (err) { |
| 52 | error.FileNotFound => { | 49 | error.FileNotFound => { |
| 53 | std.log.warn("deleting {s}", .{entry.path}); | 50 | const whitelisted = for (whitelist) |item| { |
| 54 | try dest_crt_dir.deleteFile(entry.path); | 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 | else => { | 59 | else => { |
| 57 | std.log.err("unable to copy {s}: {s}", .{ entry.path, @errorName(err) }); | 60 | std.log.err("unable to copy {s}: {s}", .{ entry.path, @errorName(err) }); |
| ... | @@ -105,6 +108,11 @@ pub fn main() !void { | ... | @@ -105,6 +108,11 @@ pub fn main() !void { |
| 105 | return std.process.cleanExit(); | 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 | const ok_exts = [_][]const u8{ | 116 | const ok_exts = [_][]const u8{ |
| 109 | ".def", | 117 | ".def", |
| 110 | ".def.in", | 118 | ".def.in", |