mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2024-11-10 06:31:49 +00:00
Add support for FreeBSD
This commit is contained in:
parent
373caf74a7
commit
a8755f9464
8 changed files with 41 additions and 13 deletions
2
external/minizip/CMakeLists.txt
vendored
2
external/minizip/CMakeLists.txt
vendored
|
@ -18,7 +18,7 @@ set (HEADERS
|
||||||
zip.h
|
zip.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||||
# Mac OS X does not have fopen64()
|
# Mac OS X does not have fopen64()
|
||||||
# and several related functions as the standard fopen()
|
# and several related functions as the standard fopen()
|
||||||
# calls are 64bit
|
# calls are 64bit
|
||||||
|
|
|
@ -117,7 +117,10 @@ if(APPLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
target_link_libraries(updatershared pthread dl)
|
target_link_libraries(updatershared pthread)
|
||||||
|
if(SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
target_link_libraries(updatershared dl)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
#define PLATFORM_LINUX
|
#define PLATFORM_LINUX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#define PLATFORM_FREEBSD
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define PLATFORM_WINDOWS
|
#define PLATFORM_WINDOWS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -18,7 +22,7 @@
|
||||||
#define PLATFORM_MAC
|
#define PLATFORM_MAC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_MAC)
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_MAC) || defined(PLATFORM_FREEBSD)
|
||||||
#define PLATFORM_UNIX
|
#define PLATFORM_UNIX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -27,4 +31,4 @@
|
||||||
#define PLATFORM_PID pid_t
|
#define PLATFORM_PID pid_t
|
||||||
#else
|
#else
|
||||||
#define PLATFORM_PID DWORD
|
#define PLATFORM_PID DWORD
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PLATFORM_FREEBSD
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PLATFORM_MAC
|
#ifdef PLATFORM_MAC
|
||||||
#include <Security/Security.h>
|
#include <Security/Security.h>
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
|
@ -87,7 +92,7 @@ int ProcessUtils::runElevated(const std::string& executable,
|
||||||
#elif defined(PLATFORM_MAC)
|
#elif defined(PLATFORM_MAC)
|
||||||
(void)task;
|
(void)task;
|
||||||
return runElevatedMac(executable,args);
|
return runElevatedMac(executable,args);
|
||||||
#elif defined(PLATFORM_LINUX)
|
#elif defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||||
return runElevatedLinux(executable,args,task);
|
return runElevatedLinux(executable,args,task);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -122,7 +127,7 @@ bool ProcessUtils::waitForProcess(PLATFORM_PID pid)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PLATFORM_LINUX
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||||
int ProcessUtils::runElevatedLinux(const std::string& executable,
|
int ProcessUtils::runElevatedLinux(const std::string& executable,
|
||||||
const std::list<std::string>& args,
|
const std::list<std::string>& args,
|
||||||
const std::string& _task)
|
const std::string& _task)
|
||||||
|
@ -477,7 +482,23 @@ int ProcessUtils::runWindows(const std::string& _executable,
|
||||||
|
|
||||||
std::string ProcessUtils::currentProcessPath()
|
std::string ProcessUtils::currentProcessPath()
|
||||||
{
|
{
|
||||||
#ifdef PLATFORM_LINUX
|
#if defined(PLATFORM_FREEBSD)
|
||||||
|
static char cmdline[PATH_MAX];
|
||||||
|
int mib[4];
|
||||||
|
|
||||||
|
mib[0] = CTL_KERN;
|
||||||
|
mib[1] = KERN_PROC;
|
||||||
|
mib[2] = KERN_PROC_ARGS;
|
||||||
|
mib[3] = getpid();
|
||||||
|
|
||||||
|
size_t len = sizeof(cmdline);
|
||||||
|
if (sysctl(mib, 4, &cmdline, &len, NULL, 0) == -1)
|
||||||
|
{
|
||||||
|
LOG(Error, "Could not get command line path!");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return std::string(cmdline);
|
||||||
|
#elif defined(PLATFORM_LINUX)
|
||||||
std::string path = FileUtils::canonicalPath("/proc/self/exe");
|
std::string path = FileUtils::canonicalPath("/proc/self/exe");
|
||||||
LOG(Info,"Current process path " + path);
|
LOG(Info,"Current process path " + path);
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -34,7 +34,7 @@ std::string StandardDirs::homeDir()
|
||||||
std::string StandardDirs::appDataPath(const std::string& organizationName,
|
std::string StandardDirs::appDataPath(const std::string& organizationName,
|
||||||
const std::string& appName)
|
const std::string& appName)
|
||||||
{
|
{
|
||||||
#ifdef PLATFORM_LINUX
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||||
std::string xdgDataHome = notNullString(getenv("XDG_DATA_HOME"));
|
std::string xdgDataHome = notNullString(getenv("XDG_DATA_HOME"));
|
||||||
if (xdgDataHome.empty())
|
if (xdgDataHome.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ void UpdaterOptions::parseOldFormatArgs(int argc, char** argv)
|
||||||
// binary. On Mac and Linux this differs from the root of
|
// binary. On Mac and Linux this differs from the root of
|
||||||
// the installation directory
|
// the installation directory
|
||||||
|
|
||||||
#ifdef PLATFORM_LINUX
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||||
// the main binary is in lib/mendeleydesktop/libexec,
|
// the main binary is in lib/mendeleydesktop/libexec,
|
||||||
// go up 3 levels
|
// go up 3 levels
|
||||||
installDir = FileUtils::canonicalPath((value + "/../../../").c_str());
|
installDir = FileUtils::canonicalPath((value + "/../../../").c_str());
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "tinythread.h"
|
#include "tinythread.h"
|
||||||
|
|
||||||
#if defined(PLATFORM_LINUX)
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||||
#include "UpdateDialogGtkFactory.h"
|
#include "UpdateDialogGtkFactory.h"
|
||||||
#include "UpdateDialogAscii.h"
|
#include "UpdateDialogAscii.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -176,7 +176,7 @@ UpdateDialog* createUpdateDialog()
|
||||||
return new UpdateDialogWin32();
|
return new UpdateDialogWin32();
|
||||||
#elif defined(PLATFORM_MAC)
|
#elif defined(PLATFORM_MAC)
|
||||||
return new UpdateDialogCocoa();
|
return new UpdateDialogCocoa();
|
||||||
#elif defined(PLATFORM_LINUX)
|
#elif defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||||
UpdateDialog* dialog = UpdateDialogGtkFactory::createDialog();
|
UpdateDialog* dialog = UpdateDialogGtkFactory::createDialog();
|
||||||
if (!dialog)
|
if (!dialog)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ void TestUpdaterOptions::testOldFormatArgs()
|
||||||
// CurrentDir is the path to the directory containing the main
|
// CurrentDir is the path to the directory containing the main
|
||||||
// Mendeley Desktop binary, on Linux and Mac this differs from
|
// Mendeley Desktop binary, on Linux and Mac this differs from
|
||||||
// the root of the install directory
|
// the root of the install directory
|
||||||
#ifdef PLATFORM_LINUX
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||||
appDir = "/tmp/path-to-app/lib/mendeleydesktop/libexec/";
|
appDir = "/tmp/path-to-app/lib/mendeleydesktop/libexec/";
|
||||||
FileUtils::mkpath(appDir);
|
FileUtils::mkpath(appDir);
|
||||||
#elif defined(PLATFORM_MAC)
|
#elif defined(PLATFORM_MAC)
|
||||||
|
@ -41,7 +41,7 @@ void TestUpdaterOptions::testOldFormatArgs()
|
||||||
options.parse(argc,argv);
|
options.parse(argc,argv);
|
||||||
|
|
||||||
TEST_COMPARE(options.mode,UpdateInstaller::Setup);
|
TEST_COMPARE(options.mode,UpdateInstaller::Setup);
|
||||||
#ifdef PLATFORM_LINUX
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||||
TEST_COMPARE(options.installDir,"/tmp/path-to-app");
|
TEST_COMPARE(options.installDir,"/tmp/path-to-app");
|
||||||
#elif defined(PLATFORM_MAC)
|
#elif defined(PLATFORM_MAC)
|
||||||
// /tmp is a symlink to /private/tmp on Mac
|
// /tmp is a symlink to /private/tmp on Mac
|
||||||
|
|
Loading…
Reference in a new issue