|
14 | 14 | """This tool build tar files from a list of inputs.""" |
15 | 15 |
|
16 | 16 | from contextlib import contextmanager |
| 17 | +import gflags |
17 | 18 | import gzip |
18 | 19 | import io |
19 | 20 | import json |
|
25 | 26 | import tarfile |
26 | 27 | import tempfile |
27 | 28 |
|
28 | | -from absl import flags |
29 | 29 | from rules_pkg import archive |
30 | 30 |
|
| 31 | +gflags.DEFINE_string('output', None, 'The output file, mandatory') |
| 32 | +gflags.MarkFlagAsRequired('output') |
31 | 33 |
|
32 | | -flags.DEFINE_string('output', None, 'The output file, mandatory') |
33 | | -flags.mark_flag_as_required('output') |
| 34 | +gflags.DEFINE_multistring('file', [], 'A file to add to the layer') |
34 | 35 |
|
35 | | -flags.DEFINE_multi_string('file', [], 'A file to add to the layer') |
| 36 | +gflags.DEFINE_string('manifest', None, 'JSON manifest of contents to add to the layer') |
36 | 37 |
|
37 | | -flags.DEFINE_string('manifest', None, 'JSON manifest of contents to add to the layer') |
| 38 | +gflags.DEFINE_multistring('empty_file', [], 'An empty file to add to the layer') |
38 | 39 |
|
39 | | -flags.DEFINE_multi_string('empty_file', [], 'An empty file to add to the layer') |
| 40 | +gflags.DEFINE_multistring('empty_dir', [], 'An empty dir to add to the layer') |
40 | 41 |
|
41 | | -flags.DEFINE_multi_string('empty_dir', [], 'An empty dir to add to the layer') |
42 | | - |
43 | | -flags.DEFINE_string( |
| 42 | +gflags.DEFINE_string( |
44 | 43 | 'mode', None, 'Force the mode on the added files (in octal).') |
45 | 44 |
|
46 | | -flags.DEFINE_string( |
| 45 | +gflags.DEFINE_string( |
47 | 46 | 'mtime', None, 'Set mtime on tar file entries. May be an integer or the' |
48 | 47 | ' value "portable", to get the value 2000-01-01, which is' |
49 | 48 | ' usable with non *nix OSes.') |
50 | 49 |
|
51 | | -flags.DEFINE_bool( |
| 50 | +gflags.DEFINE_bool( |
52 | 51 | 'enable_mtime_preservation', False, 'Preserve file mtimes from input tar file.') |
53 | 52 |
|
54 | | -flags.DEFINE_multi_string( |
| 53 | +gflags.DEFINE_multistring( |
55 | 54 | 'empty_root_dir', |
56 | 55 | [], |
57 | 56 | 'An empty root directory to add to the layer. This will create a directory that' |
58 | 57 | 'is a peer of "root_directory". "empty_dir" creates an empty directory inside of' |
59 | 58 | '"root_directory"') |
60 | 59 |
|
61 | | -flags.DEFINE_multi_string('tar', [], 'A tar file to add to the layer') |
| 60 | +gflags.DEFINE_multistring('tar', [], 'A tar file to add to the layer') |
62 | 61 |
|
63 | | -flags.DEFINE_multi_string('deb', [], 'A debian package to add to the layer') |
| 62 | +gflags.DEFINE_multistring('deb', [], 'A debian package to add to the layer') |
64 | 63 |
|
65 | | -flags.DEFINE_multi_string( |
| 64 | +gflags.DEFINE_multistring( |
66 | 65 | 'link', [], |
67 | 66 | 'Add a symlink a inside the layer ponting to b if a:b is specified') |
68 | | -flags.register_validator( |
| 67 | +gflags.RegisterValidator( |
69 | 68 | 'link', |
70 | 69 | lambda l: all(value.find(':') > 0 for value in l), |
71 | 70 | message='--link value should contains a : separator') |
72 | 71 |
|
73 | | -flags.DEFINE_string( |
| 72 | +gflags.DEFINE_string( |
74 | 73 | 'directory', None, 'Directory in which to store the file inside the layer') |
75 | 74 |
|
76 | | -flags.DEFINE_string( |
| 75 | +gflags.DEFINE_string( |
77 | 76 | 'compression', None, 'Compression (`gz` or `bz2`), default is none.') |
78 | 77 |
|
79 | | -flags.DEFINE_multi_string( |
| 78 | +gflags.DEFINE_multistring( |
80 | 79 | 'modes', None, |
81 | 80 | 'Specific mode to apply to specific file (from the file argument),' |
82 | 81 | ' e.g., path/to/file=0o455.') |
83 | 82 |
|
84 | | -flags.DEFINE_multi_string('owners', None, |
| 83 | +gflags.DEFINE_multistring('owners', None, |
85 | 84 | 'Specify the numeric owners of individual files, ' |
86 | 85 | 'e.g. path/to/file=0.0.') |
87 | 86 |
|
88 | | -flags.DEFINE_string('owner', '0.0', |
| 87 | +gflags.DEFINE_string('owner', '0.0', |
89 | 88 | 'Specify the numeric default owner of all files,' |
90 | 89 | ' e.g., 0.0') |
91 | 90 |
|
92 | | -flags.DEFINE_string('owner_name', None, |
| 91 | +gflags.DEFINE_string('owner_name', None, |
93 | 92 | 'Specify the owner name of all files, e.g. root.root.') |
94 | 93 |
|
95 | | -flags.DEFINE_multi_string('owner_names', None, |
| 94 | +gflags.DEFINE_multistring('owner_names', None, |
96 | 95 | 'Specify the owner names of individual files, e.g. ' |
97 | 96 | 'path/to/file=root.root.') |
98 | 97 |
|
99 | | -flags.DEFINE_string( |
| 98 | +gflags.DEFINE_string( |
100 | 99 | 'root_directory', './', 'Default root directory is named "."' |
101 | 100 | 'Windows docker images require this be named "Files" instead of "."') |
102 | 101 |
|
103 | | -flags.DEFINE_string('xz_path', None, |
| 102 | +gflags.DEFINE_string('xz_path', None, |
104 | 103 | 'Specify the path to xz as a fallback when the Python ' |
105 | 104 | 'lzma module is unavailable.') |
106 | 105 |
|
107 | | -FLAGS = flags.FLAGS |
| 106 | +FLAGS = gflags.FLAGS |
108 | 107 |
|
109 | 108 |
|
110 | 109 | class TarFile(object): |
|
0 commit comments