Fix to pkg_tar(mtime=N). The code never worked.

See: https://github.com/bazelbuild/bazel/pull/7482

Wow. This testing scheme is fragile. Someone shoudld rewrite it with a
golden test scheme so the expected tar content can be put in the BUILD
file and each pkg can have a distinct test.

RELNOTES: None
PiperOrigin-RevId: 243187745
diff --git a/tools/build_defs/pkg/build_test.sh b/tools/build_defs/pkg/build_test.sh
index f07b729..ad1b8f4 100755
--- a/tools/build_defs/pkg/build_test.sh
+++ b/tools/build_defs/pkg/build_test.sh
@@ -164,6 +164,10 @@
 drwxrwxrwx 0/0               0 2000-01-01 00:00 ./tmp/
 drwxrwxrwx 0/0               0 2000-01-01 00:00 ./pmt/" \
       "$(get_tar_verbose_listing test-tar-empty_dirs.tar)"
+  check_eq \
+    "drwxr-xr-x 0/0               0 1999-12-31 23:59 ./
+-r-xr-xr-x 0/0               2 1999-12-31 23:59 ./nsswitch.conf" \
+    "$(get_tar_verbose_listing test-tar-mtime.tar)"
 }
 
 function test_deb() {
diff --git a/tools/build_defs/pkg/pkg.bzl b/tools/build_defs/pkg/pkg.bzl
index 051061c..8ef8c1a 100644
--- a/tools/build_defs/pkg/pkg.bzl
+++ b/tools/build_defs/pkg/pkg.bzl
@@ -50,7 +50,7 @@
     if ctx.attr.mtime != -1:  # Note: Must match default in rule def.
         if ctx.attr.portable_mtime:
             fail("You may not set both mtime and portable_mtime")
-        args.append("--mtime=" + ctx.attr.mtime)
+        args.append("--mtime=%d" % ctx.attr.mtime)
     if ctx.attr.portable_mtime:
         args.append("--mtime=portable")