mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-02-16 16:40:55 +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
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
if (APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
# Mac OS X does not have fopen64()
|
||||
# and several related functions as the standard fopen()
|
||||
# calls are 64bit
|
||||
|
|
|
@ -117,7 +117,10 @@ if(APPLE)
|
|||
endif()
|
||||
|
||||
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()
|
||||
|
||||
if (WIN32)
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
#define PLATFORM_LINUX
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define PLATFORM_FREEBSD
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define PLATFORM_WINDOWS
|
||||
#include <windows.h>
|
||||
|
@ -18,7 +22,7 @@
|
|||
#define PLATFORM_MAC
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_MAC)
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_MAC) || defined(PLATFORM_FREEBSD)
|
||||
#define PLATFORM_UNIX
|
||||
#endif
|
||||
|
||||
|
@ -27,4 +31,4 @@
|
|||
#define PLATFORM_PID pid_t
|
||||
#else
|
||||
#define PLATFORM_PID DWORD
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_FREEBSD
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_MAC
|
||||
#include <Security/Security.h>
|
||||
#include <mach-o/dyld.h>
|
||||
|
@ -87,7 +92,7 @@ int ProcessUtils::runElevated(const std::string& executable,
|
|||
#elif defined(PLATFORM_MAC)
|
||||
(void)task;
|
||||
return runElevatedMac(executable,args);
|
||||
#elif defined(PLATFORM_LINUX)
|
||||
#elif defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||
return runElevatedLinux(executable,args,task);
|
||||
#endif
|
||||
}
|
||||
|
@ -122,7 +127,7 @@ bool ProcessUtils::waitForProcess(PLATFORM_PID pid)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_LINUX
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||
int ProcessUtils::runElevatedLinux(const std::string& executable,
|
||||
const std::list<std::string>& args,
|
||||
const std::string& _task)
|
||||
|
@ -477,7 +482,23 @@ int ProcessUtils::runWindows(const std::string& _executable,
|
|||
|
||||
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");
|
||||
LOG(Info,"Current process path " + path);
|
||||
return path;
|
||||
|
|
|
@ -34,7 +34,7 @@ std::string StandardDirs::homeDir()
|
|||
std::string StandardDirs::appDataPath(const std::string& organizationName,
|
||||
const std::string& appName)
|
||||
{
|
||||
#ifdef PLATFORM_LINUX
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||
std::string xdgDataHome = notNullString(getenv("XDG_DATA_HOME"));
|
||||
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
|
||||
// the installation directory
|
||||
|
||||
#ifdef PLATFORM_LINUX
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||
// the main binary is in lib/mendeleydesktop/libexec,
|
||||
// go up 3 levels
|
||||
installDir = FileUtils::canonicalPath((value + "/../../../").c_str());
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "tinythread.h"
|
||||
|
||||
#if defined(PLATFORM_LINUX)
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||
#include "UpdateDialogGtkFactory.h"
|
||||
#include "UpdateDialogAscii.h"
|
||||
#endif
|
||||
|
@ -176,7 +176,7 @@ UpdateDialog* createUpdateDialog()
|
|||
return new UpdateDialogWin32();
|
||||
#elif defined(PLATFORM_MAC)
|
||||
return new UpdateDialogCocoa();
|
||||
#elif defined(PLATFORM_LINUX)
|
||||
#elif defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||
UpdateDialog* dialog = UpdateDialogGtkFactory::createDialog();
|
||||
if (!dialog)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ void TestUpdaterOptions::testOldFormatArgs()
|
|||
// CurrentDir is the path to the directory containing the main
|
||||
// Mendeley Desktop binary, on Linux and Mac this differs from
|
||||
// the root of the install directory
|
||||
#ifdef PLATFORM_LINUX
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||
appDir = "/tmp/path-to-app/lib/mendeleydesktop/libexec/";
|
||||
FileUtils::mkpath(appDir);
|
||||
#elif defined(PLATFORM_MAC)
|
||||
|
@ -41,7 +41,7 @@ void TestUpdaterOptions::testOldFormatArgs()
|
|||
options.parse(argc,argv);
|
||||
|
||||
TEST_COMPARE(options.mode,UpdateInstaller::Setup);
|
||||
#ifdef PLATFORM_LINUX
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
||||
TEST_COMPARE(options.installDir,"/tmp/path-to-app");
|
||||
#elif defined(PLATFORM_MAC)
|
||||
// /tmp is a symlink to /private/tmp on Mac
|
||||
|
|
Loading…
Reference in a new issue