2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-12-01 07:15:24 +00:00
bazel-lib/lib/private/modify_mtree.awk

33 lines
842 B
Awk

# Edits mtree files. See the modify_mtree macro in /lib/tar.bzl.
{
if (strip_prefix != "") {
if ($1 == strip_prefix) {
# this line declares the directory which is now the root. It may be discarded.
next;
} else if (index($1, strip_prefix) == 1) {
# this line starts with the strip_prefix
sub("^" strip_prefix "/", "");
} else {
# this line declares some path under a parent directory, which will be discarded
next;
}
}
if (mtime != "") {
sub(/time=[0-9\.]+/, "time=" mtime);
}
if (owner != "") {
sub(/uid=[0-9\.]+/, "uid=" owner)
}
if (ownername != "") {
sub(/uname=[^ ]+/, "uname=" ownername)
}
if (package_dir != "") {
sub(/^/, package_dir "/")
}
print;
}