From 02fea26156ad67db5ff5f408d0ea87afe3c7174f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 26 May 2016 21:13:04 +0100 Subject: Add an update util for triggering database updates --- gentoobrowse-api/Jamfile.jam | 5 ++++- gentoobrowse-api/util/Jamfile.jam | 9 +++++++++ gentoobrowse-api/util/update.cpp | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 gentoobrowse-api/util/Jamfile.jam create mode 100644 gentoobrowse-api/util/update.cpp diff --git a/gentoobrowse-api/Jamfile.jam b/gentoobrowse-api/Jamfile.jam index 1766a46..e5607ec 100644 --- a/gentoobrowse-api/Jamfile.jam +++ b/gentoobrowse-api/Jamfile.jam @@ -17,6 +17,7 @@ lib dbppcore : : : : /usr/include/dbpp ; build-project client ; build-project service ; build-project unittests ; +build-project util ; package.install install-libs : : : api//gentoobrowse-api @@ -27,7 +28,9 @@ package.install install-client : install-libs : client//gbcli ; -package.install install-service : install-libs : : +package.install install-service : install-libs : + util//gbdbupdate + : service//gentoobrowse-service ; diff --git a/gentoobrowse-api/util/Jamfile.jam b/gentoobrowse-api/util/Jamfile.jam new file mode 100644 index 0000000..cb06c61 --- /dev/null +++ b/gentoobrowse-api/util/Jamfile.jam @@ -0,0 +1,9 @@ +lib boost_program_options ; + +exe gbdbupdate : update.cpp : + ..//adhocutil + ..//boost_system + boost_program_options + ../api//gentoobrowse-api + ../api//gentoobrowse-api + ; diff --git a/gentoobrowse-api/util/update.cpp b/gentoobrowse-api/util/update.cpp new file mode 100644 index 0000000..43f894a --- /dev/null +++ b/gentoobrowse-api/util/update.cpp @@ -0,0 +1,35 @@ +#include +#include +#include + +namespace po = boost::program_options; + +int +main(int c, char ** v) +{ + std::string endpoint; + po::options_description opts("Gentoo Browse Util::Update options"); + opts.add_options() + ("endpoint", po::value(&endpoint)->default_value("tcp -p 9001"), "Service endpoint") + ("help,h", "Show help") + ; + + po::variables_map vm; + po::store(po::command_line_parser(c, v).options(opts).run(), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cerr << opts << std::endl; + exit(1); + } + + auto ic = Ice::initialize(c, v); + auto m = Gentoo::MaintenancePrx::checkedCast(ic->stringToProxy("maintenance:" + endpoint)); + m->ice_ping(); + + m->refreshPackageTree(); + + ic->destroy(); + return 0; +} + -- cgit v1.2.3