Is this really EngProd or RulesServer?  That's a trick question, all package building should be a separate project and not part of Bazel itself.

That aside. I think the least cost way to get there is to add a depends_file attribute. Implement just like version/version_file.

- the user still needs a genrule to get the depends file from VERSION, so maybe ugly.
- we can mitigate that by creating a rule set that does easy template expansion. Imagine 
 ```
expand_template(
        name="x",
        srcs = ["//:VERSION"],
        template = "A ($(content //:VERSION))" 
     )
```
$(content label) is like the $(location label) syntax in a genrule, but expands the content.
someone could spend months making this. It would be a huge boon for cross platform tooling,
because we would not have to assume a whole bunch of unix tools on windows.

I would be happy to review a PR for adding @depends_file. I'm not going to have a lot of time to do it myself 

I would also be happy to review a proposal to move packaging rules to a new repo. They need a lot of work for performance and portability. We could innovate better if this was shared by the community rather than part of core bazel.


pkg_deb should support a way of embedding version into control fields
### Description of the problem / feature request:

Cannot add `pkg_deb`'s version from `version_file` into Debian control field (i.e. `Depends:`)

### Feature requests: what underlying problem are you trying to solve with this feature?

I have several dependent packages (say, `A` and `B` depending on `A`) which I'm building at once. I want to specify dependency from `B` (of version `$version`) to `A` (of same `$version`). However, as I'm using `version_file` to specify version, I'm not able to specify `depends` = [`A (=<$version — how would I get it?>)`]

### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

```
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_deb")

pkg_deb(package = "A", version_file = "//:VERSION")
pkg_deb(package = "B", version_file = "//:VERSION", depends=["A (=version)"]) # <-- how can I make `A` the same version as in `//:VERSION` here?
```

### What operating system are you running Bazel on?

macOS Mojave 10.14.4

### What's the output of `bazel info release`?

`release 0.23.0`

###  Have you found anything relevant by searching the web?

#7474 is probably relevant

tools/build_defs/pkg/make_deb.py tools/build_defs/pkg/pkg.bzl
tools/build_defs/pkg/make_deb.py tools/build_defs/pkg/pkg.bzl
diff --git a/tools/build_defs/pkg/make_deb.py b/tools/build_defs/pkg/make_deb.py
index 47056754a16e35..f58e920654f5ee 100644
--- a/tools/build_defs/pkg/make_deb.py
+++ b/tools/build_defs/pkg/make_deb.py
@@ -329,7 +329,7 @@ def main(unused_argv):
       maintainer=FLAGS.maintainer,
       section=FLAGS.section,
       architecture=FLAGS.architecture,
-      depends=FLAGS.depends,
+      depends=GetFlagValues(FLAGS.depends),
       suggests=FLAGS.suggests,
       enhances=FLAGS.enhances,
       preDepends=FLAGS.pre_depends,
diff --git a/tools/build_defs/pkg/pkg.bzl b/tools/build_defs/pkg/pkg.bzl
index 1e1391cff24cf8..2ff0779d2c4775 100644
--- a/tools/build_defs/pkg/pkg.bzl
+++ b/tools/build_defs/pkg/pkg.bzl
@@ -184,6 +184,14 @@ def _pkg_deb_impl(ctx):
     elif ctx.attr.built_using:
         args += ["--built_using=" + ctx.attr.built_using]
 
+    if ctx.attr.depends_file:
+        if ctx.file.depends:
+            fail("Both depends and depends_file attributes were specified")
+        args += ["--depends=@" + ctx.attr.depends_file.path]
+        files += [ctx.file.depends_file]
+    elif ctx.attr.depends:
+        args += ["--depends=" + d for d in ctx.attr.depends]
+
     if ctx.attr.priority:
         args += ["--priority=" + ctx.attr.priority]
     if ctx.attr.section:
@@ -193,7 +201,6 @@ def _pkg_deb_impl(ctx):
 
     args += ["--distribution=" + ctx.attr.distribution]
     args += ["--urgency=" + ctx.attr.urgency]
-    args += ["--depends=" + d for d in ctx.attr.depends]
     args += ["--suggests=" + d for d in ctx.attr.suggests]
     args += ["--enhances=" + d for d in ctx.attr.enhances]
     args += ["--conflicts=" + d for d in ctx.attr.conflicts]
@@ -299,6 +306,7 @@ _pkg_deb = rule(
         "section": attr.string(),
         "homepage": attr.string(),
         "depends": attr.string_list(default = []),
+        "depends_file": attr.label(allow_single_file=True),
         "suggests": attr.string_list(default = []),
         "enhances": attr.string_list(default = []),
         "conflicts": attr.string_list(default = []),
