Working schema and app installation detection.

master
Melroy van den Berg 2021-03-29 01:22:34 +02:00
parent 0602abef71
commit 760f11c52f
4 changed files with 17 additions and 19 deletions

View File

@ -1,4 +1,3 @@
# Example: https://github.com/MariaDB/server/tree/10.5/cmake
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LibreWeb Browser - Decentralized Web-Browser")
set(CPACK_PACKAGE_VENDOR "Melroy van den Berg")
@ -9,7 +8,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_TARGET}-${CPACK_PACKAGE_VERSION}")
set(CPACK_DEBIAN_PACKAGE_SECTION "web")
set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-v${CPACK_PACKAGE_VERSION}") # Without '-Linux' suffix
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND EXISTS "/etc/os-release")

View File

@ -2,10 +2,13 @@
# By: Melroy van den Berg
# Description: Release production build + create Debian package file (.deb),
# RPM [Red Hat] Package Manager (.rpm) and compressed file (.tgz/.tar.gz)
#
# Installs into /usr folder (prefix)
rm -rf build_prod
mkdir build_prod
cd build_prod
cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..
cmake -GNinja -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=Release ..
ninja &&
echo "INFO: Building packages...";
cpack -G "TGZ;DEB;RPM"

View File

@ -54,7 +54,9 @@ MainWindow::MainWindow()
// Change schema directory when browser is not installed
if (!this->isInstalled())
{
Glib::setenv("GSETTINGS_SCHEMA_DIR", "/media/melroy/Data/Projects/browser/build/src/gsettings", true);
std::string schemaDir = std::string(BINARY_DIR) + "/gsettings";
std::cout << "INFO: Use settings from: " << schemaDir << std::endl;
Glib::setenv("GSETTINGS_SCHEMA_DIR", schemaDir);
}
// Load schema settings file
m_settings = Gio::Settings::create("org.libreweb.browser");
@ -394,18 +396,14 @@ MainWindow::MainWindow()
// timer will do the updates later
this->update_connection_status();
if (this->isInstalled())
{
std::cout << "INFO: App installed!" << std::endl;
// Show homepage
// Show homepage if debugging is disabled
#ifdef NDEBUG
go_home();
}
else
{
std::cout << "INFO: App NOT installed.." << std::endl;
#else
std::cout << "INFO: Running as Debug mode, opening test.md." << std::endl;
// Load test file when developing
doRequest("file://../../test.md", true);
}
#endif
}
/**
@ -851,8 +849,8 @@ void MainWindow::refresh()
}
/**
* \brief Determing run-time if the application is installed or running from build
* \return true if the current running process is installed (to the install prefix path)
* \brief Determing if browser is installed from current binary path, at runtime
* \return true if the current running process is installed (to the installed prefix path)
*/
bool MainWindow::isInstalled()
{
@ -860,15 +858,12 @@ bool MainWindow::isInstalled()
memset(pathbuf, 0, sizeof(pathbuf));
if (readlink("/proc/self/exe", pathbuf, sizeof(pathbuf) - 1) > 0)
{
std::cout << "Current dir: " << pathbuf << std::endl;
std::cout << "Prefix dir: " << INSTALL_PREFIX << std::endl;
// If current binary path starts with the install prefix, it's installed
return (strncmp(pathbuf, INSTALL_PREFIX, strlen(INSTALL_PREFIX)) == 0);
}
else
{
return true; // fallback
return true; // fallback; always installed
}
}

View File

@ -8,5 +8,6 @@
#define PROJECT_VER_PATCH "@PROJECT_VERSION_PATCH@"
#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#define BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@"
#endif // PROJECT_CONFIG_H