aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-02-22 11:36:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-02-22 11:36:49 +0200
commit7afd8609b8080e04825565d77072b46e90001c4e (patch)
tree90cfea4d9d2e43fdb954679c1b9ed6c1d9699f35
parent5837974ede1f489fe1e65cb10188f776fb6d1974 (diff)
WIP
-rw-r--r--bpkg/system-package-manager-debian.cxx74
1 files changed, 68 insertions, 6 deletions
diff --git a/bpkg/system-package-manager-debian.cxx b/bpkg/system-package-manager-debian.cxx
index 3d9b5d5..1eb317e 100644
--- a/bpkg/system-package-manager-debian.cxx
+++ b/bpkg/system-package-manager-debian.cxx
@@ -2644,16 +2644,78 @@ namespace bpkg
fail << "unable to write to " << rules << ": " << e;
}
- // Call dpkg-buildpackage.
+ // Run dpkg-buildpackage.
+ //
+ // Note that there doesn't seem to be any way to control its verbosity or
+ // progress.
//
- // @@ Pass our --jobs as --jobs=N.
// @@ Buildinfo stuff fuzzy.
//
- // --no-sign
- // --target-arch
+ // @@ Why does stuff keep recompiling on every run (e.g., byacc)? Running
+ // the same commands from the command line does not trigger rebuild.
+ // Could dpkg-buildpackage somehow forcing rebuild? Via environment?
+ //
//
- // cd src/
- // dpkg-buildpackage --no-sign --build=binary
+ cstrings args {
+ "dpkg-buildpackage",
+ "--build=binary", // Only build binary packages.
+ "--no-sign", // Do not sign anything.
+ "--target-arch", arch.c_str ()};
+
+ // Pass our --jobs value, if any.
+ //
+ string jobs_arg;
+ if (size_t n = ops_->jobs_specified () ? ops_->jobs () : 0)
+ {
+ // Note: only accepts the --jobs=N form.
+ //
+ args.push_back ((jobs_arg = "--jobs=" + to_string (n)).c_str ());
+ }
+
+ args.push_back (nullptr);
+
+ try
+ {
+ process_path pp (process::path_search (args[0]));
+ process_env pe (pp, src /* cwd */);
+
+ // There is going to be quite a bit of diagnostics so print the command
+ // line unless quiet.
+ //
+ if (verb >= 1)
+ print_process (pe, args);
+
+ // Redirect stdout to stderr since half of dpkg-buildpackage diagnostics
+ // goes there. For good measure also redirect stdin to /dev/null to make
+ // sure there are no prompts of any kind.
+ //
+ process pr (pp,
+ args,
+ -2 /* stdin */,
+ 2 /* stdout */,
+ 2 /* stderr */,
+ pe.cwd->string ().c_str (),
+ pe.vars);
+
+ if (!pr.wait ())
+ {
+ // Let's repeat the command line even if it was printed at the
+ // beginning to save the user a rummage through the logs.
+ //
+ diag_record dr (fail);
+ dr << args[0] << " exited with non-zero code" <<
+ info << "command line: "; print_process (dr, pe, args);
+ }
+ }
+ catch (const process_error& e)
+ {
+ error << "unable to execute " << args[0] << ": " << e;
+
+ if (e.child)
+ exit (1);
+
+ throw failed ();
+ }
// Cleanup intermediate files unless requested not to.
//