aboutsummaryrefslogtreecommitdiff
path: root/bpkg/system-package-manager.cxx
blob: aa9bed8a16352bf558ea533b228ff7736727bfed (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
// file      : bpkg/system-package-manager.cxx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

#include <bpkg/system-package-manager.hxx>

#include <bpkg/diagnostics.hxx>

namespace bpkg
{
  system_package_manager::
  ~system_package_manager ()
  {
    // vtable
  }

  unique_ptr<system_package_manager>
  make_system_package_manager (const target_triplet& host,
                               const string& name)
  {
    unique_ptr<system_package_manager> r;

    if (optional<os_release> osr = host_os_release (host))
    {
      if (host.class_ == "linux")
      {
        if (osr->name_id == "debian" ||
            osr->name_id == "ubuntu" ||
            find_if (osr->like_ids.begin (), osr->like_ids.end (),
                     [] (const string& n)
                     {
                       return n == "debian" || n == "ubuntu";
                     }) != osr->like_ids.end ())
        {
          // @@ TODO: verify name if specified.

          //r.reset (new system_package_manager_debian (move (*osr)));
        }
      }
    }

    if (r == nullptr)
    {
      if (!name.empty ())
        fail << "unsupported package manager '" << name << "' for host "
             << host;
    }

    return r;
  }
}