aboutsummaryrefslogtreecommitdiff
path: root/bpkg/rep-remove.hxx
blob: ac39f7afec0337fa447546282f65755bb91e5707 (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
// file      : bpkg/rep-remove.hxx -*- C++ -*-
// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#ifndef BPKG_REP_REMOVE_HXX
#define BPKG_REP_REMOVE_HXX

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

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

namespace bpkg
{
  int
  rep_remove (const rep_remove_options&, cli::scanner& args);

  // Remove a repository if it is not reachable from the root (and thus is not
  // required by any user-added repository), also removing its unused
  // repository fragments.
  //
  void
  rep_remove (const dir_path& conf,
              transaction&,
              const shared_ptr<repository>&);

  // Remove a repository fragment if it is not referenced by any repository,
  // also removing its unreachable complements and prerequisites.
  //
  void
  rep_remove_fragment (const dir_path& conf,
                       transaction&,
                       const shared_ptr<repository_fragment>&);

  // Bring the configuration to the clean state as if repositories were added
  // but never fetched. Leave selected packages intact.
  //
  // Specifically:
  //
  // - Clean prerequisite and complement repository sets for the top-level
  //   repositories.
  //
  // - Remove all repositories except the top-level ones and the root.
  //
  // - Remove all repository fragments except the root.
  //
  // - Remove all repository state directories (regardless of whether they
  //   actually relate to any existing repositories).
  //
  // - Remove all available packages.
  //
  void
  rep_remove_clean (const common_options&,
                    const dir_path& conf,
                    database&,
                    bool quiet = true);

  // Remove a repository fragment from locations of the available packages it
  // contains. Remove packages that come from only this repository fragment.
  //
  void
  rep_remove_package_locations (transaction&, const string& fragment_name);
}

#endif // BPKG_REP_REMOVE_HXX