DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
oks_clone_repository.cxx
Go to the documentation of this file.
1// DUNE DAQ modification notice:
2// This file has been modified from the original ATLAS oks source for the DUNE DAQ project.
3// Fork baseline commit: oks-08-03-04 (2022-04-14).
4// Renamed since fork: yes (from bin/oks_clone_repository.cpp to apps/oks_clone_repository.cxx).
5
12
13#include "oks/kernel.hpp"
14
15#include <stdlib.h>
16#include <string.h>
17
18#include <boost/program_options.hpp>
19
20using namespace dunedaq::oks;
21
22int
23main(int argc, char** argv)
24{
25 std::string config_version, user_dir, branch_name;
26 bool verbose = false;
27
28 try {
29 boost::program_options::options_description desc(
30 "Clone and checkout oks repository.\n\n"
31 "By default the master branch is checkout. The \"branch\" command line option can be used to specify particular "
32 "one. A branch will be created, if does not exist yet.\n"
33 "TDAQ_DB_VERSION process environment variable or \"version\" command line option can be used to specify "
34 "particular version.\n"
35 "The output directory can be specified via command line, otherwise temporal directory will be created and its "
36 "name will be reported.\n"
37 "If TDAQ_DB_USER_REPOSITORY process environment variable is set, the utility makes no effect.\n\n"
38 "The command line options are");
39
40 std::vector<std::string> app_types_list;
41 std::vector<std::string> segments_list;
42
43 desc.add_options()(
44 "branch,b", boost::program_options::value<std::string>(&branch_name), "checkout or create given branch name")(
45 "version,e",
46 boost::program_options::value<std::string>(&config_version),
47 "oks config version in type:value format, where type is \"hash\", \"date\" or \"tag\"")(
48 "output-directory,o",
49 boost::program_options::value<std::string>(&user_dir),
50 "output directory; if not defined, create temporal")("verbose,v",
51 "print verbose information")("help,h", "print help message");
52
53 boost::program_options::variables_map vm;
54 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
55
56 if (vm.count("help")) {
57 std::cout << desc << std::endl;
58 return EXIT_SUCCESS;
59 }
60
61 if (vm.count("verbose"))
62 verbose = true;
63
64 boost::program_options::notify(vm);
65 } catch (std::exception& ex) {
66 std::cerr << "Command line parsing errors occurred:\n" << ex.what() << std::endl;
67 return EXIT_FAILURE;
68 }
69
70 if (!getenv("TDAQ_DB_USER_REPOSITORY")) {
71 if (!user_dir.empty())
72 setenv("TDAQ_DB_USER_REPOSITORY_PATH", user_dir.c_str(), 1);
73
74 OksKernel k(user_dir.empty() && !verbose,
75 verbose,
76 false,
77 true,
78 config_version.empty() ? nullptr : config_version.c_str(),
79 branch_name);
80
81 if (!k.get_user_repository_root().empty()) {
83
84 if (user_dir.empty())
85 std::cout << k.get_user_repository_root() << std::endl;
86 }
87 }
88
89 return EXIT_SUCCESS;
90}
Provides interface to the OKS kernel.
Definition kernel.hpp:615
const std::string & get_user_repository_root() const
Get user OKS repository root.
Definition kernel.cpp:335
void unset_repository_created()
Set repository created flag to false to avoid created repository removal in destructor;.
Definition kernel.cpp:4716
int main(int argc, char *argv[])