refactored build system

This commit is contained in:
Martchus 2016-04-25 22:30:11 +02:00
parent 74ca6aea8e
commit 9bb47d37f8
54 changed files with 372 additions and 474 deletions

View File

@ -1,89 +1,5 @@
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
# add project files
set(HEADER_FILES
alpm/manager.h
alpm/package.h
alpm/utilities.h
network/server.h
network/connection.h
network/networkaccessmanager.h
alpm/config.h
alpm/resolvebuildorder.h
alpm/mingwbundle.h
network/userrepository.h
alpm/alpmpackage.h
alpm/aurpackage.h
alpm/alpmdatabase.h
alpm/repository.h
alpm/upgradelookup.h
alpm/suggestionslookup.h
alpm/packageinfolookup.h
alpm/packagelookup.h
alpm/packagefinder.h
)
set(SRC_FILES
alpm/manager.cpp
alpm/package.cpp
alpm/utilities.cpp
alpm/config.cpp
alpm/resolvebuildorder.cpp
alpm/mingwbundle.cpp
alpm/alpmpackage.cpp
alpm/aurpackage.cpp
alpm/alpmdatabase.cpp
alpm/repository.cpp
alpm/upgradelookup.cpp
alpm/suggestionslookup.cpp
alpm/packageinfolookup.cpp
alpm/packagelookup.cpp
alpm/packagefinder.cpp
network/server.cpp
network/connection.cpp
network/userrepository.cpp
network/networkaccessmanager.cpp
)
set(CLI_HEADER_FILES
)
set(CLI_SRC_FILES
cli/main.cpp
)
set(GUI_HEADER_FILES
gui/mainwindow.h
gui/webpage.h
gui/webviewprovider.h
)
set(GUI_SRC_FILES
gui/main.cpp
gui/mainwindow.cpp
gui/webpage.cpp
)
set(WEB_FILES
web/3rdparty/jquery-1.11.2/jquery.min.js
web/3rdparty/bootstrap/css/bootstrap-theme.min.css
web/3rdparty/bootstrap/css/bootstrap.min.css
web/3rdparty/bootstrap/fonts/glyphicons-halflings-regular.eot
web/3rdparty/bootstrap/fonts/glyphicons-halflings-regular.svg
web/3rdparty/bootstrap/fonts/glyphicons-halflings-regular.ttf
web/3rdparty/bootstrap/fonts/glyphicons-halflings-regular.woff
web/3rdparty/bootstrap/fonts/glyphicons-halflings-regular.woff2
web/3rdparty/bootstrap/js/bootstrap.min.js
web/3rdparty/bootstrap_dropdowns_enhancement/css/dropdowns-enhancement.min.css
web/css/core.css
web/css/dashboard.css
web/js/client.js
web/js/entrymanagement.js
web/js/expandcollapse.js
web/js/groupmanagement.js
web/js/packagemanagement.js
web/js/pagemanagement.js
web/js/pagination.js
web/js/proto.js
web/js/repomanagement.js
web/js/tabbing.js
web/js/utils.js
)
# meta data
set(META_PROJECT_NAME repoindex)
set(META_APP_NAME "Repository Browser")
@ -94,298 +10,8 @@ set(META_VERSION_MAJOR 0)
set(META_VERSION_MINOR 2)
set(META_VERSION_PATCH 2)
# stringification of meta data
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
set(META_APP_URL_STR "\"${META_APP_URL}\"")
set(META_APP_DESCRIPTION_STR "\"${META_APP_DESCRIPTION}\"")
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
set(META_APP_VERSION_STR "\"${META_APP_VERSION}\"")
# define project
project(${META_PROJECT_NAME})
# add configuration header
configure_file(
"${PROJECT_SOURCE_DIR}/resources/config.h.in"
"${PROJECT_BINARY_DIR}/resources/config.h"
)
include_directories("${PROJECT_BINARY_DIR}")
# insert meta data in index.html
configure_file(
"${PROJECT_SOURCE_DIR}/web/index.html"
"${PROJECT_BINARY_DIR}/web/index.html"
)
# add windows resource file
if(MINGW)
# create windows rc file from template
set(WINDOWS_EXT "exe")
configure_file(
"${PROJECT_SOURCE_DIR}/resources/windows.rc.in"
"${PROJECT_BINARY_DIR}/resources/windows.rc"
)
# set windres as resource compiler
set(RES_FILES "${PROJECT_BINARY_DIR}/resources/windows.rc")
set(CMAKE_RC_COMPILER_INIT windres)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
enable_language(RC)
endif(MINGW)
# read cached variables
set(WEBVIEW_PROVIDER "auto" CACHE STRING "specifies the webview provider: auto, webkit or webengine")
# check required Qt 5 modules
find_package(Qt5Core REQUIRED)
find_package(Qt5Concurrent REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5WebSockets REQUIRED)
find_package(KF5Archive REQUIRED)
# select Qt module providing webview (either Qt WebKit or Qt WebEngine)
if(${WEBVIEW_PROVIDER} STREQUAL "none")
set(WEBVIEW_PROVIDER OFF)
message(STATUS "Webview disabled, not building GUI.")
elseif(${WEBVIEW_PROVIDER} STREQUAL "auto")
find_package(Qt5WebEngineWidgets)
if(Qt5WebEngineWidgets_FOUND)
set(WEBVIEW_PROVIDER Qt5::WebEngineWidgets)
set(WEBVIEW_DEFINITION -DREPOINDEX_USE_WEBENGINE)
message(STATUS "No webview provider explicitely specified, defaulting to Qt WebEngine.")
else()
find_package(Qt5WebKitWidgets REQUIRED)
set(WEBVIEW_PROVIDER Qt5::WebKitWidgets)
message(STATUS "No webview provider explicitely specified, defaulting to Qt WebKit.")
endif()
else()
if(${WEBVIEW_PROVIDER} STREQUAL "webkit")
find_package(Qt5WebKitWidgets REQUIRED)
set(WEBVIEW_PROVIDER Qt5::WebKitWidgets)
message(STATUS "Using Qt WebKit as webview provider.")
elseif(${WEBVIEW_PROVIDER} STREQUAL "webengine")
find_package(Qt5WebEngineWidgets REQUIRED)
set(WEBVIEW_PROVIDER Qt5::WebEngineWidgets)
set(WEBVIEW_DEFINITION -DREPOINDEX_USE_WEBENGINE)
message(STATUS "Using Qt WebEngine as webview provider.")
else()
message(FATAL_ERROR "The specified webview provider '${WEBVIEW_PROVIDER}' is unknown.")
endif()
endif()
# enable moc
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# disable new ABI (can't catch ios_base::failure with new ABI)
add_definitions(
-D_GLIBCXX_USE_CXX11_ABI=0
-DCMAKE_BUILD
${WEBVIEW_DEFINITION}
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEBUG_BUILD)
message(STATUS "Debug build enabled.")
endif()
# executable and linking
add_library(${META_PROJECT_NAME}-lib SHARED ${HEADER_FILES} ${SRC_FILES} ${WEB_FILES})
target_link_libraries(${META_PROJECT_NAME}-lib c++utilities Qt5::Core Qt5::Concurrent Qt5::Network Qt5::WebSockets KF5::Archive)
set_target_properties(${META_PROJECT_NAME}-lib PROPERTIES
VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}
SOVERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}
CXX_STANDARD 11
OUTPUT_NAME ${META_PROJECT_NAME}
)
add_executable(${META_PROJECT_NAME} ${CLI_HEADER_FILES} ${CLI_SRC_FILES})
target_link_libraries(${META_PROJECT_NAME} c++utilities ${META_PROJECT_NAME}-lib Qt5::Core Qt5::Network Qt5::WebSockets)
set_target_properties(${META_PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
)
if(NOT ${WEBVIEW_PROVIDER} STREQUAL "none")
add_executable(${META_PROJECT_NAME}-gui ${GUI_HEADER_FILES} ${GUI_SRC_FILES})
target_link_libraries(${META_PROJECT_NAME}-gui c++utilities qtutilities ${META_PROJECT_NAME}-lib Qt5::Core Qt5::Network Qt5::WebSockets ${WEBVIEW_PROVIDER})
set_target_properties(${META_PROJECT_NAME}-gui PROPERTIES
CXX_STANDARD 11
)
endif()
# add install target for web files / minimizing
# -> don't minimize debug builds
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# find JavaScript/CSS minimizer
find_program(YUI_EXECUTABLE yuicompressor)
if(YUI_EXECUTABLE)
set(JS_MIN_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/jsmin.sh")
endif()
if(NOT JS_MIN_EXECUTABLE)
message(STATUS "YUI compressor not found -> installing JavaScript/CSS files unminimized")
endif()
# find html minimizer
find_program(HTML_MIN_EXECUTABLE htmlmin)
endif()
if(NOT HTML_MIN_EXECUTABLE)
message(STATUS "htmlmin not found -> installing HTML files unminimized")
# install unminimized index.html
install(
FILES "${PROJECT_BINARY_DIR}/web/index.html"
DESTINATION share/${META_PROJECT_NAME}/web
COMPONENT web
)
else()
# minimize index.html
set(MIN_FILE "${PROJECT_BINARY_DIR}/web/index.min/index.html")
add_custom_command(
OUTPUT ${MIN_FILE}
COMMAND "${HTML_MIN_EXECUTABLE}"
ARGS "${HTML_MIN_EXECUTABLE}" "${PROJECT_BINARY_DIR}/web/index.html" "${MIN_FILE}"
)
install(
FILES ${MIN_FILE}
DESTINATION share/${META_PROJECT_NAME}/web
COMPONENT web
)
list(APPEND HTML_MIN_FILES "${MIN_FILE}")
endif()
foreach(WEB_FILE ${WEB_FILES})
# check whether file can be minimized
get_filename_component(WEB_DIR ${WEB_FILE} DIRECTORY)
get_filename_component(WEB_EXT ${WEB_FILE} EXT)
if(JS_MIN_EXECUTABLE AND (${WEB_EXT} STREQUAL ".js" OR ${WEB_EXT} STREQUAL ".css"))
# minimize web file
set(MIN_FILE "${CMAKE_CURRENT_BINARY_DIR}/min/${WEB_FILE}")
add_custom_command(
OUTPUT ${MIN_FILE}
COMMAND "${JS_MIN_EXECUTABLE}"
ARGS "${YUI_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/${WEB_FILE}" "${MIN_FILE}"
)
install(
FILES ${MIN_FILE}
DESTINATION share/${META_PROJECT_NAME}/${WEB_DIR}
COMPONENT web
)
list(APPEND JS_MIN_FILES "${MIN_FILE}")
else()
# install unminimized version of web file
install(
FILES ${WEB_FILE}
DESTINATION share/${META_PROJECT_NAME}/${WEB_DIR}
COMPONENT web
)
endif()
endforeach()
install(
FILES resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg
DESTINATION share/${META_PROJECT_NAME}/web/img
COMPONENT web
)
# add target for minimizing
if(HTML_MIN_FILES)
add_custom_target(htmlmin ALL DEPENDS ${HTML_MIN_FILES})
endif()
if(JS_MIN_FILES)
add_custom_target(jsmin ALL DEPENDS ${JS_MIN_FILES})
endif()
# add install target
foreach(HEADER_FILE ${HEADER_FILES})
get_filename_component(HEADER_DIR ${HEADER_FILE} DIRECTORY)
install(
FILES ${HEADER_FILE}
DESTINATION include/${META_PROJECT_NAME}/${HEADER_DIR}
COMPONENT header
)
endforeach()
install(TARGETS ${META_PROJECT_NAME}
RUNTIME DESTINATION bin
COMPONENT binary
)
if(NOT ${WEBVIEW_PROVIDER} STREQUAL "none")
install(TARGETS ${META_PROJECT_NAME}-gui
RUNTIME DESTINATION bin
COMPONENT binary-gui
)
endif()
install(TARGETS ${META_PROJECT_NAME}-lib
RUNTIME DESTINATION bin
COMPONENT binary
LIBRARY DESTINATION lib
COMPONENT binary
ARCHIVE DESTINATION lib
COMPONENT binary
)
install(FILES resources/systemd/${META_PROJECT_NAME}.service
DESTINATION lib/systemd/system
COMPONENT service
)
install(FILES resources/settings/${META_PROJECT_NAME}.conf.js
DESTINATION share/${META_PROJECT_NAME}/skel
COMPONENT config
)
install(FILES resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg
DESTINATION share/icons/hicolor/scalable/apps
COMPONENT desktop
)
install(FILES resources/desktop/applications/${META_PROJECT_NAME}.desktop
DESTINATION share/applications
COMPONENT desktop
)
if(NOT TARGET install-binary)
add_custom_target(install-binary
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=binary -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
if((NOT ${WEBVIEW_PROVIDER} STREQUAL "none") AND (NOT TARGET install-binary-gui))
set(GUI_INSTALL_TARGET "install-binary-gui")
add_custom_target(install-binary-gui
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=binary-gui -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
if(NOT TARGET install-header)
add_custom_target(install-header
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=header -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
if(NOT TARGET install-service)
add_custom_target(install-service
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=service -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
if(NOT TARGET install-desktop)
add_custom_target(install-desktop
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=desktop -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
if(NOT TARGET install-config)
add_custom_target(install-config
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=config -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
if(NOT TARGET install-web)
add_custom_target(install-web
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=web -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
if(NOT TARGET install-mingw-w64)
add_custom_target(install-mingw-w64
DEPENDS install-binary ${GUI_INSTALL_TARGET} install-header
)
endif()
if(NOT TARGET install-binary-strip)
add_custom_target(install-binary-strip
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_COMPONENT=binary -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
if(NOT TARGET install-mingw-w64-strip)
add_custom_target(install-mingw-w64-strip
DEPENDS install-binary-strip
)
endif()
# add subdirectories
add_subdirectory(web)
add_subdirectory(lib)
add_subdirectory(cli)
add_subdirectory(gui)

52
cli/CMakeLists.txt Normal file
View File

@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
# add source files
set(HEADER_FILES
)
set(SRC_FILES
main.cpp
)
# find c++utilities
find_package(c++utilities 3.3.0 REQUIRED)
use_cpp_utilities()
# find qtutilities
find_package(qtutilities 4.0.0 REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${QT_UTILITIES_MODULE_DIRS})
# need to link against the repoindex lib
list(APPEND LIBRARIES lib${META_PROJECT_NAME})
# include modules to apply configuration
include(BasicConfig)
include(QtGuiConfig)
include(QtConfig)
include(WindowsResources)
include(AppTarget)
# add installs for service and config files
install(FILES resources/systemd/${META_PROJECT_NAME}.service
DESTINATION lib/systemd/system
COMPONENT service
)
install(FILES resources/settings/${META_PROJECT_NAME}.conf.js
DESTINATION share/${META_PROJECT_NAME}/skel
COMPONENT config
)
# add install targets for service and config files
if(NOT TARGET install-service)
add_custom_target(install-service
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=service -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
if(NOT TARGET install-config)
add_custom_target(install-config
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=config -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()

View File

@ -1,10 +1,10 @@
#include "./alpm/manager.h"
#include "./alpm/utilities.h"
#include "./alpm/config.h"
#include "./alpm/resolvebuildorder.h"
#include "./alpm/mingwbundle.h"
#include "../lib/alpm/manager.h"
#include "../lib/alpm/utilities.h"
#include "../lib/alpm/config.h"
#include "../lib/alpm/resolvebuildorder.h"
#include "../lib/alpm/mingwbundle.h"
#include "./network/server.h"
#include "../lib/network/server.h"
#include <c++utilities/application/argumentparser.h>
#include <c++utilities/conversion/stringconversion.h>
@ -73,7 +73,7 @@ int main(int argc, char *argv[])
BuildOrderResolverCli resolver(manager, configArgs.buildOrderArg.values(), configArgs.addSourceOnlyDepsArg.isPresent(), configArgs.requireSourcesArg.isPresent());
return resolver.exec();
} else if(configArgs.mingwBundleArg.isPresent()) {
MingwBundle bundle(manager, configArgs.mingwBundleArg.values(), configArgs.iconThemesArg.values(), configArgs.extraPackagesArg.values());
MingwBundle bundle(manager, configArgs.mingwBundleArg.values(), configArgs.iconThemesArg.values(), configArgs.extraPackagesArg.values(), configArgs.qtPluginsArg.values());
bundle.createBundle(configArgs.targetDirArg.isPresent() ? configArgs.targetDirArg.values().front() : string("."),
configArgs.targetNameArg.values().front(),
configArgs.targetFormatArg.isPresent() ? configArgs.targetFormatArg.values().front() : string("zip"),

45
gui/CMakeLists.txt Normal file
View File

@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
# add project files
set(WIDGETS_HEADER_FILES
mainwindow.h
webpage.h
webviewprovider.h
)
set(WIDGETS_SRC_FILES
main.cpp
mainwindow.cpp
webpage.cpp
)
set(ICON_FILES
resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg
)
# find c++utilities
find_package(c++utilities 3.3.0 REQUIRED)
use_cpp_utilities()
# find qtutilities
find_package(qtutilities 4.0.0 REQUIRED)
use_qt_utilities()
# add Qt modules which can currently not be detected automatically
list(APPEND ADDITIONAL_QT_MODULES Network)
# suffix the target to avoid conflict with cli target
set(TARGET_SUFFIX "-gui")
# need to link against the repoindex lib
list(APPEND LIBRARIES lib${META_PROJECT_NAME})
# include modules to apply configuration
include(BasicConfig)
include(QtGuiConfig)
include(QtConfig)
include(WindowsResources)
include(WebViewProviderConfig)
include(AppTarget)
# create desktop file using previously defined meta data
add_desktop_file()

View File

@ -1,10 +1,10 @@
#include "./alpm/manager.h"
#include "./alpm/utilities.h"
#include "./alpm/config.h"
#include "../lib/alpm/manager.h"
#include "../lib/alpm/utilities.h"
#include "../lib/alpm/config.h"
#include "./network/server.h"
#include "../lib/network/server.h"
#include "./gui/mainwindow.h"
#include "./mainwindow.h"
#include "resources/config.h"

View File

@ -1,7 +1,7 @@
#include "./mainwindow.h"
#include "./webpage.h"
#include "../alpm/manager.h"
#include "../lib/alpm/manager.h"
#include "resources/config.h"

View File

@ -9,6 +9,7 @@
#else
# include <QWebSettings>
# include <QWebView>
# include <QWebFrame>
#endif
namespace RepoIndex {
@ -20,17 +21,21 @@ WebPage::WebPage(WEB_VIEW_PROVIDER *view) :
#ifdef REPOINDEX_USE_WEBENGINE
settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
#else
settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
#endif
if(!m_view) {
// delegate to external browser if no view is assigned
#ifdef REPOINDEX_USE_WEBENGINE
connect(this, &WebPage::urlChanged, this, &WebPage::delegateToExternalBrowser);
#else
connect(this->mainFrame(), &QWebFrame::urlChanged, this, &WebPage::delegateToExternalBrowser);
#endif
m_view = new WEB_VIEW_PROVIDER;
m_view->setPage(this);
}
}
WEB_PAGE_PROVIDER *WebPage::createWindow(QWebEnginePage::WebWindowType type)
WEB_PAGE_PROVIDER *WebPage::createWindow(WEB_PAGE_PROVIDER::WebWindowType type)
{
return new WebPage;
}

62
lib/CMakeLists.txt Normal file
View File

@ -0,0 +1,62 @@
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
# add project files
set(HEADER_FILES
alpm/manager.h
alpm/package.h
alpm/utilities.h
network/server.h
network/connection.h
network/networkaccessmanager.h
alpm/config.h
alpm/resolvebuildorder.h
alpm/mingwbundle.h
network/userrepository.h
alpm/alpmpackage.h
alpm/aurpackage.h
alpm/alpmdatabase.h
alpm/repository.h
alpm/upgradelookup.h
alpm/suggestionslookup.h
alpm/packageinfolookup.h
alpm/packagelookup.h
alpm/packagefinder.h
)
set(SRC_FILES
alpm/manager.cpp
alpm/package.cpp
alpm/utilities.cpp
alpm/config.cpp
alpm/resolvebuildorder.cpp
alpm/mingwbundle.cpp
alpm/alpmpackage.cpp
alpm/aurpackage.cpp
alpm/alpmdatabase.cpp
alpm/repository.cpp
alpm/upgradelookup.cpp
alpm/suggestionslookup.cpp
alpm/packageinfolookup.cpp
alpm/packagelookup.cpp
alpm/packagefinder.cpp
network/server.cpp
network/connection.cpp
network/userrepository.cpp
network/networkaccessmanager.cpp
)
# add Qt/KF modules which can currently not be detected automatically
list(APPEND ADDITIONAL_QT_MODULES Concurrent Network WebSockets)
list(APPEND ADDITIONAL_KF_MODULES Archive)
# find c++utilities
find_package(c++utilities 3.3.0 REQUIRED)
use_cpp_utilities()
# prefix the target to avoid conflict with cli target
set(TARGET_PREFIX "lib")
# include modules to apply configuration
include(BasicConfig)
include(QtConfig)
include(WindowsResources)
include(LibraryTarget)

View File

@ -56,6 +56,7 @@ ConfigArgs::ConfigArgs(ArgumentParser &parser) :
iconThemesArg("icon-packages", "i", "specifies the names of the icon packages to include"),
defaultIconThemeArg("default-icon-theme", string(), "specifies the name of the default icon theme (should be included in --icon-packages)"),
extraPackagesArg("extra-packages", string(), "specifies extra packages to be included"),
qtPluginsArg("qt-plugins", string(), "specifies which Qt plugins to be included"),
cacheDirArg("cache-dir", string(), "specifies the cache directory (default is /var/cache/repoindex)"),
storageDirArg("storage-dir", string(), "specifies the storage directory (default is /var/lib/repoindex)"),
shSyntaxArg("sh-syntax", string(), "prints the output using shell syntax: export REPOINDEX_RESULTS=('res1' 'res2' 'res3') or export REPOINDEX_ERROR='some error message'"),
@ -127,13 +128,16 @@ ConfigArgs::ConfigArgs(ArgumentParser &parser) :
extraPackagesArg.setCombinable(true);
extraPackagesArg.setRequiredValueCount(-1);
extraPackagesArg.setValueNames(pkgValueNames);
qtPluginsArg.setCombinable(true);
qtPluginsArg.setRequiredValueCount(-1);
qtPluginsArg.setValueNames({"plugin 1", "plugin 2"});
shSyntaxArg.setCombinable(true);
repoArg.setRequiredValueCount(1);
repoArg.setValueNames({"repo name"});
serverArg.setSecondaryArguments({&rootdirArg, &dbpathArg, &pacmanConfArg, &reposFromPacmanConfEnabled, &certFileArg, &keyFileArg, &websocketAddrArg, &websocketPortArg, &insecureArg, &aurArg, &shSyntaxArg});
upgradeLookupArg.setSecondaryArguments({&shSyntaxArg});
buildOrderArg.setSecondaryArguments({&aurArg, &addSourceOnlyDepsArg, &requireSourcesArg, &verboseArg, &shSyntaxArg});
mingwBundleArg.setSecondaryArguments({&targetDirArg, &targetNameArg, &targetFormatArg, &iconThemesArg, &defaultIconThemeArg, &extraPackagesArg});
mingwBundleArg.setSecondaryArguments({&targetDirArg, &targetNameArg, &targetFormatArg, &iconThemesArg, &defaultIconThemeArg, &extraPackagesArg, &qtPluginsArg});
cacheDirArg.setCombinable(true);
cacheDirArg.setRequiredValueCount(1);
cacheDirArg.setValueNames(pathValueName);

View File

@ -48,6 +48,7 @@ public:
ApplicationUtilities::Argument iconThemesArg;
ApplicationUtilities::Argument defaultIconThemeArg;
ApplicationUtilities::Argument extraPackagesArg;
ApplicationUtilities::Argument qtPluginsArg;
ApplicationUtilities::Argument cacheDirArg;
ApplicationUtilities::Argument storageDirArg;
ApplicationUtilities::Argument shSyntaxArg;

View File

@ -20,6 +20,7 @@
#include <iostream>
using namespace std;
using namespace ApplicationUtilities;
namespace RepoIndex {
@ -27,9 +28,20 @@ using namespace Utilities;
const string prefix("mingw-w64-");
MingwBundle::MingwBundle(Manager &manager, const ApplicationUtilities::StringVector &packages, const ApplicationUtilities::StringVector &iconPackages, const ApplicationUtilities::StringVector &extraPackages) :
IncludedPackage::IncludedPackage(const Package *package, bool dependencyOnly) :
package(package),
dependencyOnly(dependencyOnly)
{}
bool IncludedPackage::operator==(const Package *package) const
{
return this->package == package;
}
MingwBundle::MingwBundle(Manager &manager, const ApplicationUtilities::StringVector &packages, const ApplicationUtilities::StringVector &iconPackages, const ApplicationUtilities::StringVector &extraPackages, const ApplicationUtilities::StringVector &qtPlugins) :
m_manager(manager),
m_extraPackages(extraPackages)
m_extraPackages(extraPackages),
m_qtPlugins(qtPlugins)
{
cerr << shchar << "Resolving dependencies ..." << endl;
string missing;
@ -37,7 +49,7 @@ MingwBundle::MingwBundle(Manager &manager, const ApplicationUtilities::StringVec
for(const auto &pkgName : packages) {
if(auto *pkg = manager.packageProviding(Dependency(QString::fromLocal8Bit(ConversionUtilities::startsWith(pkgName, prefix) ? pkgName.data() : (prefix + pkgName).data())))) {
if(find(m_packages.cbegin(), m_packages.cend(), pkg) == m_packages.cend()) {
m_packages.emplace_back(pkg);
m_packages.emplace_back(pkg, false);
addDependencies(pkg);
}
} else {
@ -49,7 +61,7 @@ MingwBundle::MingwBundle(Manager &manager, const ApplicationUtilities::StringVec
for(const auto &pkgName : iconPackages) {
if(auto *pkg = manager.packageProviding(Dependency(QString::fromLocal8Bit(pkgName.data())))) {
if(find(m_packages.cbegin(), m_packages.cend(), pkg) == m_packages.cend()) {
m_packages.emplace_back(pkg);
m_packages.emplace_back(pkg, false);
}
} else {
missing.push_back(' ');
@ -60,8 +72,8 @@ MingwBundle::MingwBundle(Manager &manager, const ApplicationUtilities::StringVec
throw runtime_error("The following packages can not be found:" + missing);
} else {
cerr << shchar << "Adding the following packages:";
for(const auto *pkg : m_packages) {
cerr << shchar << ' ' << pkg->name().toLocal8Bit().data();
for(const IncludedPackage &pkg : m_packages) {
cerr << shchar << ' ' << pkg.package->name().toLocal8Bit().data();
}
cerr << shchar << endl;
}
@ -74,7 +86,7 @@ void MingwBundle::addDependencies(const Package *pkg)
if(dep.name.startsWith(QLatin1String("mingw-w64-"), Qt::CaseInsensitive)) {
if(auto *pkg = m_manager.packageProviding(dep)) {
if(find(m_packages.cbegin(), m_packages.cend(), pkg) == m_packages.cend()) {
m_packages.emplace_back(pkg);
m_packages.emplace_back(pkg, true);
addDependencies(pkg);
}
} else {
@ -137,9 +149,11 @@ struct RelevantFile
struct PkgFileInfo
{
PkgFileInfo(const QString &name, const QString &path) :
PkgFileInfo(const QString &name, const QString &path, bool dependencyOnly = false, const StringVector &qtPlugins = StringVector()) :
name(name),
path(path),
dependencyOnly(dependencyOnly),
qtPlugins(qtPlugins),
failure(false)
{}
@ -147,6 +161,8 @@ struct PkgFileInfo
QString path;
unique_ptr<KTar> archive;
list<RelevantFile> relevantFiles;
bool dependencyOnly;
const StringVector &qtPlugins;
bool failure;
};
@ -186,9 +202,10 @@ void getFiles(PkgFileInfo &pkgFileInfo)
if(binEntry && binEntry->isDirectory()) {
const auto *binDir = static_cast<const KArchiveDirectory *>(binEntry);
for(const QString &entryName : binDir->entries()) {
if(entryName.endsWith(QLatin1String(".exe")) || entryName.indexOf(QLatin1String(".dll")) > 0) {
if((!pkgFileInfo.dependencyOnly && entryName.endsWith(QLatin1String(".exe"))) || entryName.indexOf(QLatin1String(".dll")) > 0) {
if(const auto *entry = binDir->entry(entryName)) {
if(entry->isFile()) {
// do only copy files and no symlinks
if(entry->isFile() && entry->symLinkTarget().isEmpty()) {
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(entry), binDir, RelevantFileType::Binary, root.first);
}
}
@ -201,7 +218,7 @@ void getFiles(PkgFileInfo &pkgFileInfo)
if(libEntry && libEntry->isDirectory()) {
// Qt 5 plugins
const auto *libDir = static_cast<const KArchiveDirectory *>(libEntry);
const auto *qtEntry = libDir->entry("qt");
const auto *qtEntry = libDir->entry(QStringLiteral("qt"));
if(qtEntry && qtEntry->isDirectory()) {
const auto *qtDir = static_cast<const KArchiveDirectory *>(qtEntry);
const auto *pluginsEntry = qtDir->entry(QStringLiteral("plugins"));
@ -211,10 +228,19 @@ void getFiles(PkgFileInfo &pkgFileInfo)
const auto *categoryEntry = pluginsDir->entry(pluginCategory);
if(categoryEntry && categoryEntry->isDirectory()) {
const auto *categoryDir = static_cast<const KArchiveDirectory *>(categoryEntry);
for(const auto &entryName : categoryDir->entries()) {
for(const QString &entryName : categoryDir->entries()) {
if(const auto *pluginEntry = categoryDir->entry(entryName)) {
if(pluginEntry->isFile()) {
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(pluginEntry), categoryDir, RelevantFileType::QtPlugin, root.first, categoryDir->name());
if(entryName.endsWith(QLatin1String(".dll"))) {
if(!pkgFileInfo.qtPlugins.empty()) {
string pluginName = entryName.toLocal8Bit().data();
pluginName.resize(pluginName.size() - 4);
if(find(pkgFileInfo.qtPlugins.cbegin(), pkgFileInfo.qtPlugins.cend(), pluginName) == pkgFileInfo.qtPlugins.cend()) {
continue;
}
}
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(pluginEntry), categoryDir, RelevantFileType::QtPlugin, root.first, categoryDir->name());
}
}
}
}
@ -490,7 +516,8 @@ void MingwBundle::createBundle(const string &targetDir, const string &targetName
cerr << shchar << "Gathering relevant files ..." << endl;
// get package files
list<PkgFileInfo> pkgFiles;
for(const Package *pkg : m_packages) {
for(const IncludedPackage &includedPkg : m_packages) {
const Package *pkg = includedPkg.package;
QString pkgFile;
if(!pkg->repository()->packagesDirectory().isEmpty()) {
pkgFile = pkg->repository()->packagesDirectory() % QChar('/') % pkg->fileName();
@ -511,13 +538,13 @@ void MingwBundle::createBundle(const string &targetDir, const string &targetName
} else if(pkgName.endsWith(QLatin1String("-hg"))) {
pkgName = pkgName.mid(0, pkgName.length() - 3);
}
pkgFiles.emplace_back(pkgName.toString(), pkgFile);
pkgFiles.emplace_back(pkgName.toString(), pkgFile, includedPkg.dependencyOnly, m_qtPlugins);
}
for(const auto &pkgFileStdStr : m_extraPackages) {
QString pkgFile = QString::fromLocal8Bit(pkgFileStdStr.data());
if(QFile::exists(pkgFile)) {
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);
pkgFiles.emplace_back(pkg->name().startsWith(QLatin1String("mingw-w64-")) ? pkg->name().mid(10) : pkg->name(), pkgFile, false, m_qtPlugins);
} else {
throw runtime_error("The specified extra package \"" + pkgFileStdStr + "\" can't be found.");
}
@ -537,8 +564,8 @@ void MingwBundle::createBundle(const string &targetDir, const string &targetName
}
// make a list with package info to be included in the target archive
QJsonArray pkgArray;
for(const Package *pkg : m_packages) {
pkgArray << pkg->simpleInfo();
for(const IncludedPackage &pkg : m_packages) {
pkgArray << pkg.package->simpleInfo();
}
QJsonDocument pkgList;
pkgList.setArray(pkgArray);

View File

@ -10,10 +10,19 @@ namespace RepoIndex {
class Manager;
struct IncludedPackage
{
IncludedPackage(const Package *package, bool dependencyOnly);
bool operator==(const Package *package) const;
const Package *package;
bool dependencyOnly;
};
class MingwBundle
{
public:
MingwBundle(Manager &manager, const ApplicationUtilities::StringVector &packages, const ApplicationUtilities::StringVector &iconPackages, const ApplicationUtilities::StringVector &extraPackages);
MingwBundle(Manager &manager, const ApplicationUtilities::StringVector &packages, const ApplicationUtilities::StringVector &iconPackages, const ApplicationUtilities::StringVector &extraPackages, const ApplicationUtilities::StringVector &qtPlugins);
void createBundle(const std::string &targetDir, const std::string &targetName, const std::string &targetFormat, const std::string &defaultIconTheme) const;
@ -21,8 +30,9 @@ private:
void addDependencies(const Package *pkg);
Manager &m_manager;
std::list<const Package *> m_packages;
std::list<IncludedPackage> m_packages;
const ApplicationUtilities::StringVector &m_extraPackages;
const ApplicationUtilities::StringVector &m_qtPlugins;
};
} // namespace PackageManagement

View File

@ -1,9 +0,0 @@
#ifndef APP_METADATA_AVAIL
#define APP_METADATA_AVAIL
#define PROJECT_NAME @META_PROJECT_NAME_STR@
#define APP_NAME @META_APP_NAME_STR@
#define APP_VERSION @META_APP_VERSION_STR@
#define APP_AUTHOR @META_APP_AUTHOR_STR@
#define APP_URL @META_APP_URL_STR@
#define APP_DESCRIPTION @META_APP_DESCRIPTION_STR@
#endif // APP_METADATA_AVAIL

View File

@ -1,40 +0,0 @@
# if defined(UNDER_CE)
# include <winbase.h>
# else
# include <windows.h>
# endif
@WINDOWS_ICON_RC_ENTRY@
VS_VERSION_INFO VERSIONINFO
FILEVERSION @META_VERSION_MAJOR@,@META_VERSION_MINOR@,@META_VERSION_PATCH@,0
PRODUCTVERSION @META_VERSION_MAJOR@,@META_VERSION_MINOR@,@META_VERSION_PATCH@,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "@META_APP_AUTHOR@\0"
VALUE "FileDescription", "@META_APP_DESCRIPTION@.\0"
VALUE "FileVersion", "@META_APP_VERSION@\0"
VALUE "LegalCopyright", "by @META_APP_AUTHOR@\0"
VALUE "OriginalFilename", "@META_PROJECT_NAME@.@WINDOWS_EXT@\0"
VALUE "ProductName", "@META_APP_NAME@\0"
VALUE "ProductVersion", "@META_APP_VERSION@\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1200
END
END
/* End of Version info */

View File

@ -24,6 +24,17 @@
"fromPacmanConfig": true,
"add": [
{"name": "ownstuff-testing",
"ignored": false,
"sourcesDir": "path/to/local/source/dir",
"packagesDir": "/run/media/devel/repo/arch/ownstuff-testing/os/x86_64",
"upgradeSources": ["aur"],
"server": [
"https://localhost/repo/arch/ownstuff-testing/os/x86_64"
],
"maxAge": 3600
},
{"name": "ownstuff",
"sourcesDir": "path/to/local/source/dir",
"packagesDir": "/run/media/devel/repo/arch/ownstuff/os/x86_64",
@ -53,16 +64,6 @@
"https://ftp.fau.de/archlinux/gnome-unstable/os/x86_64"
],
"maxAge": 28800
},
{"name": "ownstuff-testing",
"ignored": true,
"sourcesDir": "path/to/local/source/dir",
"packagesDir": "/run/media/devel/repo/arch/ownstuff-testing/os/x86_64",
"upgradeSources": ["aur"],
"server": [
"https://localhost/repo/arch/ownstuff-testing/os/x86_64"
]
}
]
}

114
web/CMakeLists.txt Normal file
View File

@ -0,0 +1,114 @@
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
# add project files
set(WEB_FILES
3rdparty/jquery-1.11.2/jquery.min.js
3rdparty/bootstrap/css/bootstrap-theme.min.css
3rdparty/bootstrap/css/bootstrap.min.css
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.eot
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.svg
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.ttf
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.woff
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.woff2
3rdparty/bootstrap/js/bootstrap.min.js
3rdparty/bootstrap_dropdowns_enhancement/css/dropdowns-enhancement.min.css
css/core.css
css/dashboard.css
js/client.js
js/entrymanagement.js
js/expandcollapse.js
js/groupmanagement.js
js/packagemanagement.js
js/pagemanagement.js
js/pagination.js
js/proto.js
js/repomanagement.js
js/tabbing.js
js/utils.js
)
# add install target for web files / minimizing
# -> don't minimize debug builds
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# find JavaScript/CSS minimizer
find_program(YUI_EXECUTABLE yuicompressor)
if(YUI_EXECUTABLE)
set(JS_MIN_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/jsmin.sh")
endif()
if(NOT JS_MIN_EXECUTABLE)
message(STATUS "YUI compressor not found -> installing JavaScript/CSS files unminimized")
endif()
# find html minimizer
find_program(HTML_MIN_EXECUTABLE htmlmin)
endif()
if(NOT HTML_MIN_EXECUTABLE)
message(STATUS "htmlmin not found -> installing HTML files unminimized")
# install unminimized index.html
install(
FILES "${PROJECT_BINARY_DIR}/web/index.html"
DESTINATION share/${META_PROJECT_NAME}/web
COMPONENT web
)
else()
# minimize index.html
set(MIN_FILE "${PROJECT_BINARY_DIR}/web/index.min/index.html")
add_custom_command(
OUTPUT ${MIN_FILE}
COMMAND "${HTML_MIN_EXECUTABLE}"
ARGS "${HTML_MIN_EXECUTABLE}" "${PROJECT_BINARY_DIR}/web/index.html" "${MIN_FILE}"
)
install(
FILES ${MIN_FILE}
DESTINATION share/${META_PROJECT_NAME}/web
COMPONENT web
)
list(APPEND HTML_MIN_FILES "${MIN_FILE}")
endif()
foreach(WEB_FILE ${WEB_FILES})
# check whether file can be minimized
get_filename_component(WEB_DIR ${WEB_FILE} DIRECTORY)
get_filename_component(WEB_EXT ${WEB_FILE} EXT)
if(JS_MIN_EXECUTABLE AND (${WEB_EXT} STREQUAL ".js" OR ${WEB_EXT} STREQUAL ".css"))
# minimize web file
set(MIN_FILE "${CMAKE_CURRENT_BINARY_DIR}/min/${WEB_FILE}")
add_custom_command(
OUTPUT ${MIN_FILE}
COMMAND "${JS_MIN_EXECUTABLE}"
ARGS "${YUI_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/${WEB_FILE}" "${MIN_FILE}"
)
install(
FILES ${MIN_FILE}
DESTINATION share/${META_PROJECT_NAME}/${WEB_DIR}
COMPONENT web
)
list(APPEND JS_MIN_FILES "${MIN_FILE}")
else()
# install unminimized version of web file
install(
FILES ${WEB_FILE}
DESTINATION share/${META_PROJECT_NAME}/${WEB_DIR}
COMPONENT web
)
endif()
endforeach()
install(
FILES resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg
DESTINATION share/${META_PROJECT_NAME}/web/img
COMPONENT web
)
# add target for minimizing
if(HTML_MIN_FILES)
add_custom_target(htmlmin ALL DEPENDS ${HTML_MIN_FILES})
endif()
if(JS_MIN_FILES)
add_custom_target(jsmin ALL DEPENDS ${JS_MIN_FILES})
endif()
# add install target
if(NOT TARGET install-web)
add_custom_target(install-web
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=web -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()