13
13
# limitations under the License.
14
14
"""Rules for making .tar files."""
15
15
16
+ load ("@aspect_bazel_lib//lib:expand_make_vars.bzl" , "expand_variables" )
16
17
load ("//pkg:providers.bzl" , "PackageVariablesInfo" )
17
18
load (
18
19
"//pkg/private:pkg_files.bzl" ,
@@ -104,7 +105,8 @@ def _pkg_tar_impl(ctx):
104
105
args .add ("--mtime" , "portable" )
105
106
if ctx .attr .modes :
106
107
for key in ctx .attr .modes :
107
- args .add ("--modes" , "%s=%s" % (_quote (key ), ctx .attr .modes [key ]))
108
+ expanded_key = expand_variables (ctx , key )
109
+ args .add ("--modes" , "%s=%s" % (_quote (expanded_key ), ctx .attr .modes [key ]))
108
110
if ctx .attr .owners :
109
111
for key in ctx .attr .owners :
110
112
args .add ("--owners" , "%s=%s" % (_quote (key ), ctx .attr .owners [key ]))
@@ -119,8 +121,14 @@ def _pkg_tar_impl(ctx):
119
121
120
122
# Now we begin processing the files.
121
123
path_mapper = None
124
+ expanded_remap_paths = {}
122
125
if ctx .attr .remap_paths :
123
- path_mapper = lambda path : _remap (ctx .attr .remap_paths , path )
126
+ for prefix , replacement in ctx .attr .remap_paths .items ():
127
+ expanded_prefix = expand_variables (ctx , prefix )
128
+ expanded_replacement = expand_variables (ctx , replacement )
129
+ expanded_remap_paths [expanded_prefix ] = expanded_replacement
130
+
131
+ path_mapper = lambda path : _remap (expanded_remap_paths , path )
124
132
125
133
mapping_context = create_mapping_context_from_ctx (
126
134
ctx ,
0 commit comments