blob: 015a6286e663a9cf64062da72aec3518fdce45a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// file : bpkg/pkg-update.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#include <bpkg/pkg-update>
#include <bpkg/types>
#include <bpkg/package>
#include <bpkg/package-odb>
#include <bpkg/utility>
#include <bpkg/database>
#include <bpkg/diagnostics>
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<package> p (db.find<package> (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;
}
}
|