aboutsummaryrefslogtreecommitdiff
path: root/bpkg/host-os-release.test.cxx
blob: e65c3ca4dffecdadf2c1672a3f5240df7dce3649 (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
// file      : bpkg/host-os-release.test.cxx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

#include <bpkg/host-os-release.hxx>

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

#include <iostream>

#undef NDEBUG
#include <cassert>

using namespace std;

namespace bpkg
{
  extern os_release
  host_os_release_linux (path f = {});

  int
  main (int argc, char* argv[])
  {
    assert (argc >= 2); // <host-target-triplet>

    target_triplet host (argv[1]);

    os_release r;
    if (host.class_ == "linux")
    {
      assert (argc == 3); // <host-target-triplet> <file-path>
      r = host_os_release_linux (path (argv[2]));
    }
    else
      assert (false);

    cout << r.name_id << '\n';
    for (auto b (r.like_ids.begin ()), i (b); i != r.like_ids.end (); ++i)
      cout << (i != b ? "|" : "") << *i;
    cout << '\n'
         << r.version_id << '\n'
         << r.variant_id << '\n'
         << r.name << '\n'
         << r.version_codename << '\n'
         << r.variant << '\n';

    return 0;
  }
}

int
main (int argc, char* argv[])
{
  return bpkg::main (argc, argv);
}