From 9f162f1c93009f3a8139c4b3e72d6bbd0c1c4dce Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Sep 2021 08:07:07 +0200 Subject: Add pkg-build --rebuild-checksum option --- bpkg/pkg-build.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'bpkg/pkg-build.cxx') diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index 76625e1..6661109 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -9,6 +9,7 @@ #include // strlen() #include // cout +#include #include #include @@ -6432,9 +6433,13 @@ namespace bpkg // --plan, then we print it as long as it is not empty. // string plan; + sha256 csum; bool need_prompt (false); - if (o.print_only () || !o.yes () || o.plan_specified ()) + if (!o.yes () || + o.print_only () || + o.plan_specified () || + o.rebuild_checksum_specified ()) { bool first (true); // First entry in the plan. @@ -6543,6 +6548,12 @@ namespace bpkg string rb; if (!p.user_selection ()) { + // Note: if we are ever tempted to truncate this, watch out for + // the --rebuild-checksum functionality which uses this. But then + // it's not clear this information is actually important: can a + // dependent-dependency structure change without any of the + // package versions changing? Doesn't feel like it should. + // for (const config_package& cp: p.required_by) rb += (rb.empty () ? " " : ", ") + cp.string (); @@ -6579,9 +6590,20 @@ namespace bpkg // Print indented for better visual separation. // plan += (plan.empty () ? " " : "\n ") + act; + + if (o.rebuild_checksum_specified ()) + csum.append (act); } } + if (o.rebuild_checksum_specified ()) + { + cout << csum.string () << endl; + + if (o.rebuild_checksum () == csum.string ()) + return o.noop_exit_specified () ? o.noop_exit () : 0; + } + if (o.print_only ()) return 0; -- cgit v1.1