Use new argument parser API

This commit is contained in:
Martchus 2016-05-26 02:29:56 +02:00
parent 9bb47d37f8
commit bb943cb21b
16 changed files with 110 additions and 95 deletions

View File

@ -8,7 +8,9 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_APP_DESCRIPTION "Repository browser for Arch Linux") set(META_APP_DESCRIPTION "Repository browser for Arch Linux")
set(META_VERSION_MAJOR 0) set(META_VERSION_MAJOR 0)
set(META_VERSION_MINOR 2) set(META_VERSION_MINOR 2)
set(META_VERSION_PATCH 2) set(META_VERSION_PATCH 3)
project(${META_PROJECT_NAME})
# add subdirectories # add subdirectories
add_subdirectory(web) add_subdirectory(web)

View File

@ -26,12 +26,12 @@ include(WindowsResources)
include(AppTarget) include(AppTarget)
# add installs for service and config files # add installs for service and config files
install(FILES resources/systemd/${META_PROJECT_NAME}.service install(FILES ../resources/systemd/${META_PROJECT_NAME}.service
DESTINATION lib/systemd/system DESTINATION lib/systemd/system
COMPONENT service COMPONENT service
) )
install(FILES resources/settings/${META_PROJECT_NAME}.conf.js install(FILES ../resources/settings/${META_PROJECT_NAME}.conf.js
DESTINATION share/${META_PROJECT_NAME}/skel DESTINATION share/${META_PROJECT_NAME}/skel
COMPONENT config COMPONENT config
) )

View File

@ -70,10 +70,10 @@ int main(int argc, char *argv[])
QObject::connect(&server, &Server::closed, &application, &QCoreApplication::quit); QObject::connect(&server, &Server::closed, &application, &QCoreApplication::quit);
return application.exec(); return application.exec();
} else if(configArgs.buildOrderArg.isPresent()) { } else if(configArgs.buildOrderArg.isPresent()) {
BuildOrderResolverCli resolver(manager, configArgs.buildOrderArg.values(), configArgs.addSourceOnlyDepsArg.isPresent(), configArgs.requireSourcesArg.isPresent()); BuildOrderResolverCli resolver(manager, configArgs.packagesArg.values(), configArgs.addSourceOnlyDepsArg.isPresent(), configArgs.requireSourcesArg.isPresent());
return resolver.exec(); return resolver.exec();
} else if(configArgs.mingwBundleArg.isPresent()) { } else if(configArgs.mingwBundleArg.isPresent()) {
MingwBundle bundle(manager, configArgs.mingwBundleArg.values(), configArgs.iconThemesArg.values(), configArgs.extraPackagesArg.values(), configArgs.qtPluginsArg.values()); MingwBundle bundle(manager, configArgs.packagesArg.values(), configArgs.iconThemesArg.values(), configArgs.extraPackagesArg.values(), configArgs.qtPluginsArg.values());
bundle.createBundle(configArgs.targetDirArg.isPresent() ? configArgs.targetDirArg.values().front() : string("."), bundle.createBundle(configArgs.targetDirArg.isPresent() ? configArgs.targetDirArg.values().front() : string("."),
configArgs.targetNameArg.values().front(), configArgs.targetNameArg.values().front(),
configArgs.targetFormatArg.isPresent() ? configArgs.targetFormatArg.values().front() : string("zip"), configArgs.targetFormatArg.isPresent() ? configArgs.targetFormatArg.values().front() : string("zip"),

View File

@ -13,7 +13,7 @@ set(WIDGETS_SRC_FILES
) )
set(ICON_FILES set(ICON_FILES
resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg ../resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg
) )
# find c++utilities # find c++utilities

View File

@ -32,12 +32,12 @@ int main(int argc, char *argv[])
QT_CONFIG_ARGUMENTS qtConfigArgs; QT_CONFIG_ARGUMENTS qtConfigArgs;
ConfigArgs configArgs(parser); ConfigArgs configArgs(parser);
parser.setIgnoreUnknownArguments(false); parser.setIgnoreUnknownArguments(false);
Argument webdirArg("web-dir", string(), "specifies the directory of the web files"); Argument webdirArg("web-dir", '\0', "specifies the directory of the web files");
webdirArg.setCombinable(true); webdirArg.setCombinable(true);
webdirArg.setRequiredValueCount(1); webdirArg.setRequiredValueCount(1);
webdirArg.setValueNames({"path"}); webdirArg.setValueNames({"path"});
for(Argument *arg : initializer_list<Argument *>{&configArgs.rootdirArg, &configArgs.dbpathArg, &configArgs.pacmanConfArg, &configArgs.reposFromPacmanConfEnabled, &configArgs.aurArg}) { for(Argument *arg : initializer_list<Argument *>{&configArgs.rootdirArg, &configArgs.dbpathArg, &configArgs.pacmanConfArg, &configArgs.reposFromPacmanConfEnabled, &configArgs.aurArg}) {
qtConfigArgs.qtWidgetsGuiArg().addSecondaryArgument(arg); qtConfigArgs.qtWidgetsGuiArg().addSubArgument(arg);
} }
parser.setMainArguments({&qtConfigArgs.qtWidgetsGuiArg(), &configArgs.repoindexConfArg, &configArgs.repoindexConfArg, &webdirArg, &configArgs.cacheDirArg, &configArgs.storageDirArg, &configArgs.helpArg}); parser.setMainArguments({&qtConfigArgs.qtWidgetsGuiArg(), &configArgs.repoindexConfArg, &configArgs.repoindexConfArg, &webdirArg, &configArgs.cacheDirArg, &configArgs.storageDirArg, &configArgs.helpArg});
// parse command line arguments // parse command line arguments
@ -63,7 +63,7 @@ int main(int argc, char *argv[])
// find directory with web files // find directory with web files
QString webdir; QString webdir;
if(webdirArg.isPresent()) { if(webdirArg.isPresent()) {
webdir = QString::fromLocal8Bit(webdirArg.values().front().data()); webdir = QString::fromLocal8Bit(webdirArg.values().front());
} else { } else {
webdir = QStringLiteral("/usr/share/" PROJECT_NAME "/web"); webdir = QStringLiteral("/usr/share/" PROJECT_NAME "/web");
} }

View File

@ -52,6 +52,10 @@ list(APPEND ADDITIONAL_KF_MODULES Archive)
find_package(c++utilities 3.3.0 REQUIRED) find_package(c++utilities 3.3.0 REQUIRED)
use_cpp_utilities() use_cpp_utilities()
# find qtutilities
find_package(qtutilities 4.0.0 REQUIRED)
use_qt_utilities()
# prefix the target to avoid conflict with cli target # prefix the target to avoid conflict with cli target
set(TARGET_PREFIX "lib") set(TARGET_PREFIX "lib")

View File

@ -31,50 +31,53 @@ const char *shchar = "";
*/ */
ConfigArgs::ConfigArgs(ArgumentParser &parser) : ConfigArgs::ConfigArgs(ArgumentParser &parser) :
helpArg(parser), helpArg(parser),
buildOrderArg("build-order", "b", "calculates the build order to build the specified packages"), packagesArg("packages", 'p', "specifies the packages"),
addSourceOnlyDepsArg("add-src-only-deps", "a", "adds source-only dependencies to build chain"), buildOrderArg("build-order", 'b', "calculates the build order to build the specified packages"),
requireSourcesArg("require-sources", "q", "requires specified packages to be from a source repository"), addSourceOnlyDepsArg("add-src-only-deps", 'a', "adds source-only dependencies to build chain"),
serverArg("server", "s", "runs a websocket server providing the web interface with information"), requireSourcesArg("require-sources", 'q', "requires specified packages to be from a source repository"),
upgradeLookupArg("upgrade-lookup", "u", "checks available upgrades for the specified repository"), serverArg("server", 's', "runs a websocket server providing the web interface with information"),
mingwBundleArg("mingw-w64-bundle", "m", "creates an archive with the runtime-relevant files from the specified mingw-w64-packages and their dependencies"), repoNameArg("repo", 'r', "specifies the repository"),
repoindexConfArg("repoindex-conf", "c", "specifies the path of the repo index config file (default is /etc/repoindex.conf"), upgradeLookupArg("upgrade-lookup", 'u', "checks available upgrades for the specified repository"),
rootdirArg("root-dir", "r", "specifies the root directory (default is /)"), mingwBundleArg("mingw-w64-bundle", 'm', "creates an archive with the runtime-relevant files from the specified mingw-w64-packages and their dependencies"),
dbpathArg("db-path", "d", "specifies the pacman database path (default is /var/lib/pacman)"), repoindexConfArg("repoindex-conf", 'c', "specifies the path of the repo index config file (default is /etc/repoindex.conf"),
pacmanConfArg("pacman-conf", "p", "specifies the path of the pacman config file (default is /etc/pacman.conf"), rootdirArg("root-dir", 'r', "specifies the root directory (default is /)"),
reposFromPacmanConfEnabled("repos-from-pacman-conf", string(), "enables repositories from the pacman config file"), dbpathArg("db-path", 'd', "specifies the pacman database path (default is /var/lib/pacman)"),
websocketAddrArg("addr", string(), "specifies the listening address for the websocket server, default is 127.0.0.1"), pacmanConfArg("pacman-conf", 'p', "specifies the path of the pacman config file (default is /etc/pacman.conf"),
websocketPortArg("port", string(), "specifies the listening port for the websocket server, default is 1234"), reposFromPacmanConfEnabled("repos-from-pacman-conf", '\0', "enables repositories from the pacman config file"),
certFileArg("cert-file", string(), "specifies the SSL certificate"), websocketAddrArg("addr", '\0', "specifies the listening address for the websocket server, default is 127.0.0.1"),
keyFileArg("key-file", string(), "specifies the private SSL key"), websocketPortArg("port", '\0', "specifies the listening port for the websocket server, default is 1234"),
insecureArg("insecure", string(), "forces the server to run in insecure mode"), certFileArg("cert-file", '\0', "specifies the SSL certificate"),
aurArg("aur", string(), "enables/disables AUR queries"), keyFileArg("key-file", '\0', "specifies the private SSL key"),
verboseArg("verbose", "v", "be verbose"), insecureArg("insecure", '\0', "forces the server to run in insecure mode"),
outputFileArg("output-file", "f", "specifies the output file"), aurArg("aur", '\0', "enables/disables AUR queries"),
targetDirArg("target-dir", "t", "the directory to store the target archive"), verboseArg("verbose", 'v', "be verbose"),
targetNameArg("target-name", "n", "specifies the name of the target archive"), outputFileArg("output-file", 'f', "specifies the output file"),
targetFormatArg("target-format", "e", "specifies the format of the target archive"), targetDirArg("target-dir", 't', "the directory to store the target archive"),
iconThemesArg("icon-packages", "i", "specifies the names of the icon packages to include"), targetNameArg("target-name", 'n', "specifies the name of the target archive"),
defaultIconThemeArg("default-icon-theme", string(), "specifies the name of the default icon theme (should be included in --icon-packages)"), targetFormatArg("target-format", 'e', "specifies the format of the target archive"),
extraPackagesArg("extra-packages", string(), "specifies extra packages to be included"), iconThemesArg("icon-packages", 'i', "specifies the names of the icon packages to include"),
qtPluginsArg("qt-plugins", string(), "specifies which Qt plugins to be included"), defaultIconThemeArg("default-icon-theme", '\0', "specifies the name of the default icon theme (should be included in --icon-packages)"),
cacheDirArg("cache-dir", string(), "specifies the cache directory (default is /var/cache/repoindex)"), extraPackagesArg("extra-packages", '\0', "specifies extra packages to be included"),
storageDirArg("storage-dir", string(), "specifies the storage directory (default is /var/lib/repoindex)"), qtPluginsArg("qt-plugins", '\0', "specifies which Qt plugins to be included"),
shSyntaxArg("sh-syntax", string(), "prints the output using shell syntax: export REPOINDEX_RESULTS=('res1' 'res2' 'res3') or export REPOINDEX_ERROR='some error message'"), cacheDirArg("cache-dir", '\0', "specifies the cache directory (default is /var/cache/repoindex)"),
repoArg("repo", string(), "specifies the repository") storageDirArg("storage-dir", '\0', "specifies the storage directory (default is /var/lib/repoindex)"),
shSyntaxArg("sh-syntax", '\0', "prints the output using shell syntax: export REPOINDEX_RESULTS=('res1' 'res2' 'res3') or export REPOINDEX_ERROR='some error message'")
{ {
const initializer_list<string> pathValueName = {"path"}; const initializer_list<const char *> pathValueName = {"path"};
const initializer_list<string> pkgValueNames = {"package 1", "package 2", "package 3"}; const initializer_list<const char *> pkgValueNames = {"package 1", "package 2", "package 3"};
packagesArg.setRequiredValueCount(-1);
packagesArg.setRequired(true);
packagesArg.setImplicit(true);
packagesArg.setValueNames(pkgValueNames);
buildOrderArg.setDenotesOperation(true); buildOrderArg.setDenotesOperation(true);
buildOrderArg.setRequiredValueCount(-1);
buildOrderArg.setValueNames(pkgValueNames);
requireSourcesArg.setCombinable(true); requireSourcesArg.setCombinable(true);
serverArg.setDenotesOperation(true); serverArg.setDenotesOperation(true);
repoNameArg.setRequiredValueCount(1);
repoNameArg.setRequired(true);
repoNameArg.setImplicit(true);
repoNameArg.setValueNames({"repo"});
upgradeLookupArg.setDenotesOperation(true); upgradeLookupArg.setDenotesOperation(true);
upgradeLookupArg.setRequiredValueCount(1);
upgradeLookupArg.setValueNames({"repo"});
mingwBundleArg.setDenotesOperation(true); mingwBundleArg.setDenotesOperation(true);
mingwBundleArg.setRequiredValueCount(-1);
mingwBundleArg.setValueNames(pkgValueNames);
repoindexConfArg.setCombinable(true); repoindexConfArg.setCombinable(true);
repoindexConfArg.setValueNames(pathValueName); repoindexConfArg.setValueNames(pathValueName);
repoindexConfArg.setRequiredValueCount(1); repoindexConfArg.setRequiredValueCount(1);
@ -131,20 +134,19 @@ ConfigArgs::ConfigArgs(ArgumentParser &parser) :
qtPluginsArg.setCombinable(true); qtPluginsArg.setCombinable(true);
qtPluginsArg.setRequiredValueCount(-1); qtPluginsArg.setRequiredValueCount(-1);
qtPluginsArg.setValueNames({"plugin 1", "plugin 2"}); qtPluginsArg.setValueNames({"plugin 1", "plugin 2"});
addSourceOnlyDepsArg.setCombinable(true);
shSyntaxArg.setCombinable(true); shSyntaxArg.setCombinable(true);
repoArg.setRequiredValueCount(1); serverArg.setSubArguments({&rootdirArg, &dbpathArg, &pacmanConfArg, &reposFromPacmanConfEnabled, &certFileArg, &keyFileArg, &websocketAddrArg, &websocketPortArg, &insecureArg, &aurArg, &shSyntaxArg});
repoArg.setValueNames({"repo name"}); upgradeLookupArg.setSubArguments({&repoNameArg, &shSyntaxArg});
serverArg.setSecondaryArguments({&rootdirArg, &dbpathArg, &pacmanConfArg, &reposFromPacmanConfEnabled, &certFileArg, &keyFileArg, &websocketAddrArg, &websocketPortArg, &insecureArg, &aurArg, &shSyntaxArg}); buildOrderArg.setSubArguments({&packagesArg, &aurArg, &addSourceOnlyDepsArg, &requireSourcesArg, &verboseArg, &shSyntaxArg});
upgradeLookupArg.setSecondaryArguments({&shSyntaxArg}); mingwBundleArg.setSubArguments({&packagesArg, &targetDirArg, &targetNameArg, &targetFormatArg, &iconThemesArg, &defaultIconThemeArg, &extraPackagesArg, &qtPluginsArg});
buildOrderArg.setSecondaryArguments({&aurArg, &addSourceOnlyDepsArg, &requireSourcesArg, &verboseArg, &shSyntaxArg});
mingwBundleArg.setSecondaryArguments({&targetDirArg, &targetNameArg, &targetFormatArg, &iconThemesArg, &defaultIconThemeArg, &extraPackagesArg, &qtPluginsArg});
cacheDirArg.setCombinable(true); cacheDirArg.setCombinable(true);
cacheDirArg.setRequiredValueCount(1); cacheDirArg.setRequiredValueCount(1);
cacheDirArg.setValueNames(pathValueName); cacheDirArg.setValueNames(pathValueName);
storageDirArg.setCombinable(true); storageDirArg.setCombinable(true);
storageDirArg.setRequiredValueCount(1); storageDirArg.setRequiredValueCount(1);
storageDirArg.setValueNames(pathValueName); storageDirArg.setValueNames(pathValueName);
parser.setMainArguments({&buildOrderArg, &upgradeLookupArg, &serverArg, &mingwBundleArg, &repoindexConfArg, &repoindexConfArg, &cacheDirArg, &storageDirArg, &helpArg}); parser.setMainArguments({&helpArg, &buildOrderArg, &upgradeLookupArg, &serverArg, &mingwBundleArg, &repoindexConfArg, &cacheDirArg, &storageDirArg});
} }
/*! /*!
@ -211,7 +213,7 @@ inline void assign(QHostAddress &addr, const QString &val)
inline void assign(QString &str, const Argument &arg) inline void assign(QString &str, const Argument &arg)
{ {
if(arg.isPresent()) { if(arg.isPresent()) {
str = QString::fromLocal8Bit(arg.values().front().data(), arg.values().front().size()); str = QString::fromLocal8Bit(arg.values().front());
} }
} }
@ -285,7 +287,7 @@ void Config::loadFromConfigFile(const QString &configFilePath)
void Config::loadFromConfigFile(const ConfigArgs &args) void Config::loadFromConfigFile(const ConfigArgs &args)
{ {
if(args.repoindexConfArg.isPresent()) { if(args.repoindexConfArg.isPresent()) {
loadFromConfigFile(QString::fromLocal8Bit(args.repoindexConfArg.values().front().data())); loadFromConfigFile(QString::fromLocal8Bit(args.repoindexConfArg.values().front()));
return; return;
} else { } else {
for(const auto &defaultPath : {QStringLiteral("./repoindex.conf"), QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + QStringLiteral("/repoindex.conf"), QStringLiteral("/etc/repoindex.conf")}) { for(const auto &defaultPath : {QStringLiteral("./repoindex.conf"), QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + QStringLiteral("/repoindex.conf"), QStringLiteral("/etc/repoindex.conf")}) {
@ -307,9 +309,9 @@ void Config::loadFromArgs(const ConfigArgs &args)
assign(m_pacmanConfFile, args.pacmanConfArg); assign(m_pacmanConfFile, args.pacmanConfArg);
if(args.aurArg.isPresent()) { if(args.aurArg.isPresent()) {
auto val = args.aurArg.values().front(); auto val = args.aurArg.values().front();
if(val == "enabled") { if(!strcmp(val, "enabled")) {
m_aurEnabled = true; m_aurEnabled = true;
} else if(val == "disabled") { } else if(!strcmp(val, "disabled")) {
m_aurEnabled = false; m_aurEnabled = false;
} else { } else {
cerr << shchar << "Warning: The specified value for the argument --aur-enabled is invalid and will be ignored." << endl; cerr << shchar << "Warning: The specified value for the argument --aur-enabled is invalid and will be ignored." << endl;
@ -320,15 +322,15 @@ void Config::loadFromArgs(const ConfigArgs &args)
assign(m_serverKeyFile, args.keyFileArg); assign(m_serverKeyFile, args.keyFileArg);
assign(m_serverInsecure, args.insecureArg); assign(m_serverInsecure, args.insecureArg);
if(args.websocketAddrArg.isPresent()) { if(args.websocketAddrArg.isPresent()) {
assign(m_websocketServerListeningAddr, QString::fromLocal8Bit(args.websocketAddrArg.values().front().data(), args.websocketAddrArg.values().front().size())); assign(m_websocketServerListeningAddr, QString::fromLocal8Bit(args.websocketAddrArg.values().front()));
} }
m_verbose = args.verboseArg.isPresent(); m_verbose = args.verboseArg.isPresent();
m_runServer = args.serverArg.isPresent(); m_runServer = args.serverArg.isPresent();
if(args.cacheDirArg.isPresent()) { if(args.cacheDirArg.isPresent()) {
m_cacheDir = QString::fromLocal8Bit(args.cacheDirArg.values().front().data()); m_cacheDir = QString::fromLocal8Bit(args.cacheDirArg.values().front());
} }
if(args.storageDirArg.isPresent()) { if(args.storageDirArg.isPresent()) {
m_storageDir = QString::fromLocal8Bit(args.storageDirArg.values().front().data()); m_storageDir = QString::fromLocal8Bit(args.storageDirArg.values().front());
} }
if(args.reposFromPacmanConfEnabled.isPresent()) { if(args.reposFromPacmanConfEnabled.isPresent()) {
m_reposFromPacmanConfEnabled = true; m_reposFromPacmanConfEnabled = true;

View File

@ -23,10 +23,12 @@ class ConfigArgs
public: public:
ConfigArgs(ApplicationUtilities::ArgumentParser &parser); ConfigArgs(ApplicationUtilities::ArgumentParser &parser);
ApplicationUtilities::HelpArgument helpArg; ApplicationUtilities::HelpArgument helpArg;
ApplicationUtilities::Argument packagesArg;
ApplicationUtilities::Argument buildOrderArg; ApplicationUtilities::Argument buildOrderArg;
ApplicationUtilities::Argument addSourceOnlyDepsArg; ApplicationUtilities::Argument addSourceOnlyDepsArg;
ApplicationUtilities::Argument requireSourcesArg; ApplicationUtilities::Argument requireSourcesArg;
ApplicationUtilities::Argument serverArg; ApplicationUtilities::Argument serverArg;
ApplicationUtilities::Argument repoNameArg;
ApplicationUtilities::Argument upgradeLookupArg; ApplicationUtilities::Argument upgradeLookupArg;
ApplicationUtilities::Argument mingwBundleArg; ApplicationUtilities::Argument mingwBundleArg;
ApplicationUtilities::Argument repoindexConfArg; ApplicationUtilities::Argument repoindexConfArg;
@ -52,7 +54,6 @@ public:
ApplicationUtilities::Argument cacheDirArg; ApplicationUtilities::Argument cacheDirArg;
ApplicationUtilities::Argument storageDirArg; ApplicationUtilities::Argument storageDirArg;
ApplicationUtilities::Argument shSyntaxArg; ApplicationUtilities::Argument shSyntaxArg;
ApplicationUtilities::Argument repoArg;
}; };
class Config; class Config;

View File

@ -6,6 +6,7 @@
#include "../network/userrepository.h" #include "../network/userrepository.h"
#include <c++utilities/io/inifile.h> #include <c++utilities/io/inifile.h>
#include <c++utilities/io/catchiofailure.h>
#include <c++utilities/conversion/stringconversion.h> #include <c++utilities/conversion/stringconversion.h>
#include <c++utilities/misc/memory.h> #include <c++utilities/misc/memory.h>
@ -352,7 +353,8 @@ void Manager::addDataBasesFromPacmanConfig()
includedFile.exceptions(ios_base::failbit | ios_base::badbit); includedFile.exceptions(ios_base::failbit | ios_base::badbit);
includedFile.open(path, ios_base::in); includedFile.open(path, ios_base::in);
includedIni.parse(includedFile); includedIni.parse(includedFile);
} catch (const ios_base::failure &) { } catch(...) {
catchIoFailure();
cerr << shchar << "Error: An IO exception occured when parsing the included file \"" << path << "\"." << endl; cerr << shchar << "Error: An IO exception occured when parsing the included file \"" << path << "\"." << endl;
} }
} }
@ -377,8 +379,9 @@ void Manager::addDataBasesFromPacmanConfig()
} }
} }
} }
} catch (const ios_base::failure &) { } catch(...) {
throw ios_base::failure("Error: An IO exception occured when parsing the config file."); catchIoFailure();
throwIoFailure("Error: An IO exception occured when parsing the config file.");
} }
} }

View File

@ -26,7 +26,8 @@ namespace RepoIndex {
using namespace Utilities; using namespace Utilities;
const string prefix("mingw-w64-"); const char *prefix = "mingw-w64-";
size_t prefixLen = 10;
IncludedPackage::IncludedPackage(const Package *package, bool dependencyOnly) : IncludedPackage::IncludedPackage(const Package *package, bool dependencyOnly) :
package(package), package(package),
@ -38,7 +39,7 @@ bool IncludedPackage::operator==(const Package *package) const
return this->package == package; return this->package == package;
} }
MingwBundle::MingwBundle(Manager &manager, const ApplicationUtilities::StringVector &packages, const ApplicationUtilities::StringVector &iconPackages, const ApplicationUtilities::StringVector &extraPackages, const ApplicationUtilities::StringVector &qtPlugins) : MingwBundle::MingwBundle(Manager &manager, const std::vector<const char *> &packages, const std::vector<const char *> &iconPackages, const std::vector<const char *> &extraPackages, const std::vector<const char *> &qtPlugins) :
m_manager(manager), m_manager(manager),
m_extraPackages(extraPackages), m_extraPackages(extraPackages),
m_qtPlugins(qtPlugins) m_qtPlugins(qtPlugins)
@ -46,8 +47,8 @@ MingwBundle::MingwBundle(Manager &manager, const ApplicationUtilities::StringVec
cerr << shchar << "Resolving dependencies ..." << endl; cerr << shchar << "Resolving dependencies ..." << endl;
string missing; string missing;
// add mingw-w64 packages // add mingw-w64 packages
for(const auto &pkgName : packages) { for(const char *pkgName : packages) {
if(auto *pkg = manager.packageProviding(Dependency(QString::fromLocal8Bit(ConversionUtilities::startsWith(pkgName, prefix) ? pkgName.data() : (prefix + pkgName).data())))) { if(auto *pkg = manager.packageProviding(Dependency(QString::fromLocal8Bit(strncmp(pkgName, prefix, prefixLen) ? pkgName : (prefix + string(pkgName)).data())))) {
if(find(m_packages.cbegin(), m_packages.cend(), pkg) == m_packages.cend()) { if(find(m_packages.cbegin(), m_packages.cend(), pkg) == m_packages.cend()) {
m_packages.emplace_back(pkg, false); m_packages.emplace_back(pkg, false);
addDependencies(pkg); addDependencies(pkg);
@ -59,7 +60,7 @@ MingwBundle::MingwBundle(Manager &manager, const ApplicationUtilities::StringVec
} }
// add additional icon packages // add additional icon packages
for(const auto &pkgName : iconPackages) { for(const auto &pkgName : iconPackages) {
if(auto *pkg = manager.packageProviding(Dependency(QString::fromLocal8Bit(pkgName.data())))) { if(auto *pkg = manager.packageProviding(Dependency(QString::fromLocal8Bit(pkgName)))) {
if(find(m_packages.cbegin(), m_packages.cend(), pkg) == m_packages.cend()) { if(find(m_packages.cbegin(), m_packages.cend(), pkg) == m_packages.cend()) {
m_packages.emplace_back(pkg, false); m_packages.emplace_back(pkg, false);
} }
@ -149,7 +150,7 @@ struct RelevantFile
struct PkgFileInfo struct PkgFileInfo
{ {
PkgFileInfo(const QString &name, const QString &path, bool dependencyOnly = false, const StringVector &qtPlugins = StringVector()) : PkgFileInfo(const QString &name, const QString &path, bool dependencyOnly = false, const vector<const char *> &qtPlugins = vector<const char *>()) :
name(name), name(name),
path(path), path(path),
dependencyOnly(dependencyOnly), dependencyOnly(dependencyOnly),
@ -162,7 +163,7 @@ struct PkgFileInfo
unique_ptr<KTar> archive; unique_ptr<KTar> archive;
list<RelevantFile> relevantFiles; list<RelevantFile> relevantFiles;
bool dependencyOnly; bool dependencyOnly;
const StringVector &qtPlugins; const vector<const char *> &qtPlugins;
bool failure; bool failure;
}; };
@ -373,6 +374,11 @@ void getFiles(PkgFileInfo &pkgFileInfo)
} }
} }
} else { } else {
if(pkgFileInfo.archive->device()) {
cerr << shchar << "Error: Unable to open the archive " << pkgFileInfo.path.toLocal8Bit().data() << ": " << pkgFileInfo.archive->device()->errorString().toLocal8Bit().data() << endl;
} else {
cerr << shchar << "Error: Unable to open the archive " << pkgFileInfo.path.toLocal8Bit().data() << ": Device hasn't been created." << endl;
}
pkgFileInfo.failure = true; pkgFileInfo.failure = true;
} }
} }
@ -540,13 +546,13 @@ void MingwBundle::createBundle(const string &targetDir, const string &targetName
} }
pkgFiles.emplace_back(pkgName.toString(), pkgFile, includedPkg.dependencyOnly, m_qtPlugins); pkgFiles.emplace_back(pkgName.toString(), pkgFile, includedPkg.dependencyOnly, m_qtPlugins);
} }
for(const auto &pkgFileStdStr : m_extraPackages) { for(const char *pkgFileRawStr : m_extraPackages) {
QString pkgFile = QString::fromLocal8Bit(pkgFileStdStr.data()); QString pkgFile = QString::fromLocal8Bit(pkgFileRawStr);
if(QFile::exists(pkgFile)) { if(QFile::exists(pkgFile)) {
const auto pkg = make_unique<AlpmPackage>(pkgFile); // do not catch the exception here const auto pkg = make_unique<AlpmPackage>(pkgFile); // do not catch the exception here
pkgFiles.emplace_back(pkg->name().startsWith(QLatin1String("mingw-w64-")) ? pkg->name().mid(10) : pkg->name(), pkgFile, false, m_qtPlugins); pkgFiles.emplace_back(pkg->name().startsWith(QLatin1String("mingw-w64-")) ? pkg->name().mid(10) : pkg->name(), pkgFile, false, m_qtPlugins);
} else { } else {
throw runtime_error("The specified extra package \"" + pkgFileStdStr + "\" can't be found."); throw runtime_error("The specified extra package \"" + string(pkgFileRawStr) + "\" can't be found.");
} }
} }
// get relevant files from packages // get relevant files from packages

View File

@ -22,7 +22,7 @@ struct IncludedPackage
class MingwBundle class MingwBundle
{ {
public: public:
MingwBundle(Manager &manager, const ApplicationUtilities::StringVector &packages, const ApplicationUtilities::StringVector &iconPackages, const ApplicationUtilities::StringVector &extraPackages, const ApplicationUtilities::StringVector &qtPlugins); MingwBundle(Manager &manager, const std::vector<const char *> &packages, const std::vector<const char *> &iconPackages, const std::vector<const char *> &extraPackages, const std::vector<const char *> &qtPlugins);
void createBundle(const std::string &targetDir, const std::string &targetName, const std::string &targetFormat, const std::string &defaultIconTheme) const; void createBundle(const std::string &targetDir, const std::string &targetName, const std::string &targetFormat, const std::string &defaultIconTheme) const;
@ -31,8 +31,8 @@ private:
Manager &m_manager; Manager &m_manager;
std::list<IncludedPackage> m_packages; std::list<IncludedPackage> m_packages;
const ApplicationUtilities::StringVector &m_extraPackages; const std::vector<const char *> &m_extraPackages;
const ApplicationUtilities::StringVector &m_qtPlugins; const std::vector<const char *> &m_qtPlugins;
}; };
} // namespace PackageManagement } // namespace PackageManagement

View File

@ -612,15 +612,15 @@ void BuildOrderResolver::requestDependenciesToBeRequested()
/*! /*!
* \brief Creates a new BuildOrderResolverCli for the specified \a packages using the specified \a manager. * \brief Creates a new BuildOrderResolverCli for the specified \a packages using the specified \a manager.
*/ */
BuildOrderResolverCli::BuildOrderResolverCli(Manager &manager, const StringVector &packages, bool addSourceOnlyDeps, bool requireSources) : BuildOrderResolverCli::BuildOrderResolverCli(Manager &manager, const std::vector<const char *> &packages, bool addSourceOnlyDeps, bool requireSources) :
BuildOrderResolver(manager, addSourceOnlyDeps, requireSources) BuildOrderResolver(manager, addSourceOnlyDeps, requireSources)
{ {
cerr << shchar << "Getting package information ..." << endl; cerr << shchar << "Getting package information ..." << endl;
tasks().clear(); tasks().clear();
tasks().reserve(packages.size() * 2); tasks().reserve(packages.size() * 2);
// add a task for each specified package // add a task for each specified package
for(const auto &pkgName : packages) { for(const char *pkgName : packages) {
tasks() << new TaskInfo(QString::fromLocal8Bit(pkgName.data())); tasks() << new TaskInfo(QString::fromLocal8Bit(pkgName));
} }
} }

View File

@ -98,7 +98,7 @@ class BuildOrderResolverCli : public BuildOrderResolver
{ {
Q_OBJECT Q_OBJECT
public: public:
BuildOrderResolverCli(Manager &manager, const ApplicationUtilities::StringVector &packages, bool addSourceOnlyDeps = false, bool requireSources = true); BuildOrderResolverCli(Manager &manager, const std::vector<const char *> &packages, bool addSourceOnlyDeps = false, bool requireSources = true);
int exec(); int exec();
}; };

View File

@ -1,9 +0,0 @@
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Repository Browser
Comment=An Arch Linux repository browser.
Exec=sh -c "repoindex-gui --repos-from-pacman-conf --cache-dir \\"\\$HOME/.cache/Martchus/Repository Browser\\" --storage-dir \\"\\$HOME/.config/Martchus/Repository Browser\\""
Icon=repoindex
Terminal=false
Type=Application
Categories=Utility;

View File

@ -25,7 +25,7 @@
"add": [ "add": [
{"name": "ownstuff-testing", {"name": "ownstuff-testing",
"ignored": false, "ignored": true,
"sourcesDir": "path/to/local/source/dir", "sourcesDir": "path/to/local/source/dir",
"packagesDir": "/run/media/devel/repo/arch/ownstuff-testing/os/x86_64", "packagesDir": "/run/media/devel/repo/arch/ownstuff-testing/os/x86_64",
"upgradeSources": ["aur"], "upgradeSources": ["aur"],

View File

@ -27,6 +27,12 @@ set(WEB_FILES
js/utils.js js/utils.js
) )
# insert meta data in index.html
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/index.html"
"${CMAKE_BINARY_DIR}/web/index.html"
)
# add install target for web files / minimizing # add install target for web files / minimizing
# -> don't minimize debug builds # -> don't minimize debug builds
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
@ -78,7 +84,7 @@ foreach(WEB_FILE ${WEB_FILES})
) )
install( install(
FILES ${MIN_FILE} FILES ${MIN_FILE}
DESTINATION share/${META_PROJECT_NAME}/${WEB_DIR} DESTINATION share/${META_PROJECT_NAME}/web/${WEB_DIR}
COMPONENT web COMPONENT web
) )
list(APPEND JS_MIN_FILES "${MIN_FILE}") list(APPEND JS_MIN_FILES "${MIN_FILE}")
@ -86,13 +92,13 @@ foreach(WEB_FILE ${WEB_FILES})
# install unminimized version of web file # install unminimized version of web file
install( install(
FILES ${WEB_FILE} FILES ${WEB_FILE}
DESTINATION share/${META_PROJECT_NAME}/${WEB_DIR} DESTINATION share/${META_PROJECT_NAME}/web/${WEB_DIR}
COMPONENT web COMPONENT web
) )
endif() endif()
endforeach() endforeach()
install( install(
FILES resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg FILES ../resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg
DESTINATION share/${META_PROJECT_NAME}/web/img DESTINATION share/${META_PROJECT_NAME}/web/img
COMPONENT web COMPONENT web
) )