aboutsummaryrefslogtreecommitdiff
path: root/bpkg/rep-fetch.hxx
blob: 1ed6a224e54c235be2b3e200c866453dd9164372 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// file      : bpkg/rep-fetch.hxx -*- C++ -*-
// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#ifndef BPKG_REP_FETCH_HXX
#define BPKG_REP_FETCH_HXX

#include <libbpkg/manifest.hxx>

#include <bpkg/types.hxx>
#include <bpkg/forward.hxx> // database
#include <bpkg/utility.hxx>

#include <bpkg/rep-fetch-options.hxx>

namespace bpkg
{
  int
  rep_fetch (const rep_fetch_options&, cli::scanner& args);

  // Fetch and authenticate repositories and packages manifests.
  //
  // If conf is NULL, then assume not running in a bpkg configuration. If it
  // is empty, then check if the bpkg configuration exists in the current
  // working directory.
  //
  class certificate;

  struct rep_fetch_data
  {
    struct fragment
    {
      // Empty for fragment-less repositories.
      //
      string id;
      string friendly_name; // User-friendly fragment name (e.g, tag, etc).

      vector<repository_manifest> repositories;
      vector<package_manifest>    packages;
    };

    vector<fragment> fragments;

    // For pkg repositories (can be nullopt/NULL).
    //
    optional<string> certificate_pem;
    shared_ptr<const bpkg::certificate> certificate; // Authenticated.
  };

  // If requested, expand the file-referencing package manifest values
  // (description, changes, etc), setting them to the contents of files they
  // refer to and set the potentially absent description-type value to the
  // effective description type (see libbpkg/manifest.hxx). Note that for pkg
  // repositories such values are expanded at the repository creation time.
  //
  rep_fetch_data
  rep_fetch (const common_options&,
             const dir_path* conf,
             const repository_location&,
             bool ignore_unknown,
             bool expand_values);

  // Add (or update) repository locations to the configuration and fetch
  // them. If shallow is true, then don't fetch their prerequisite and/or
  // complements unless the respective sets have changed. On failure clean up
  // the configuration (see rep_remove_clean() for details). Note that it
  // should be called in session.
  //
  // If reason is absent, then don't print the "fetching ..." progress line.
  //
  void
  rep_fetch (const common_options&,
             const dir_path& conf,
             database&,
             const vector<repository_location>&,
             bool shallow,
             const optional<string>& reason);
}

#endif // BPKG_REP_FETCH_HXX