From cae11509203061e894e6310c35ea50ae818af3a7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Sep 2015 06:59:28 +0200 Subject: Implement pkg-update command --- bpkg/pkg-update.cxx | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 bpkg/pkg-update.cxx (limited to 'bpkg/pkg-update.cxx') diff --git a/bpkg/pkg-update.cxx b/bpkg/pkg-update.cxx new file mode 100644 index 0000000..015a628 --- /dev/null +++ b/bpkg/pkg-update.cxx @@ -0,0 +1,64 @@ +// file : bpkg/pkg-update.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace butl; + +namespace bpkg +{ + void + pkg_update (const pkg_update_options& o, cli::scanner& args) + { + tracer trace ("pkg_update"); + + const dir_path& c (o.directory ()); + level4 ([&]{trace << "configuration: " << c;}); + + if (!args.more ()) + fail << "package name argument expected" << + info << "run 'bpkg help pkg-update' for more information"; + + string n (args.next ()); + + database db (open (c, trace)); + + transaction t (db.begin ()); + shared_ptr p (db.find (n)); + t.commit (); + + if (p == nullptr) + fail << "package " << n << " does not exist in configuration " << c; + + if (p->state != state::configured) + fail << "package " << n << " is " << p->state << + info << "expected it to be configured"; + + level4 ([&]{trace << p->name << " " << p->version;}); + + assert (p->out_root); // Should be present since configured. + dir_path out_root (c / *p->out_root); // Always relative. + level4 ([&]{trace << "out_root: " << out_root;}); + + // Form the buildspec. + // + string bspec ("update(" + out_root.string () + "/)"); + level4 ([&]{trace << "buildspec: " << bspec;}); + + // Update. + // + run_b (bspec); + + if (verb) + text << "updated " << p->name << " " << p->version; + } +} -- cgit v1.1