From 12516da3dc01774d029761a5e5efe703ba405897 Mon Sep 17 00:00:00 2001 From: Rick Sayre Date: Sun, 17 May 2015 17:18:54 -0700 Subject: [PATCH] Patched in changes to 1.28.1 to allow OmniOS/Illumos to build and work haven't attempted to build yet, there are some changes --- configure.ac | 5 +++++ scripts/zmdc.pl.in | 2 ++ scripts/zmpkg.pl.in | 16 +++++++++++++--- scripts/zmupdate.pl.in | 14 +++++++------- src/zm.h | 4 ++++ src/zm_box.h | 4 ++++ src/zm_comms.cpp | 4 ++++ src/zm_ffmpeg_camera.cpp | 6 ++++++ src/zm_image.cpp | 4 ++++ src/zm_logger.cpp | 3 +++ src/zm_monitor.cpp | 5 +++++ src/zm_poly.cpp | 4 ++++ src/zm_remote_camera_http.cpp | 4 ++++ src/zm_thread.h | 15 +++++++++++++++ src/zm_timer.h | 4 ++++ web/includes/config.php.in | 9 +++++++-- zm.conf.in | 3 +++ 17 files changed, 94 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 35e0e7fb9..707cd4629 100644 --- a/configure.ac +++ b/configure.ac @@ -34,6 +34,11 @@ case $host_os in HOST_OS='BSD' AC_DEFINE(BSD,1,"This is a BSD system") ;; + *solaris*) + # Do something specific for Solaris + HOST_OS='solaris' + AC_DEFINE(SOLARIS,1,"We are running a Solaroid OS [tested on OmniOS]") + ;; *) #Default Case AC_MSG_ERROR([Your platform is not currently supported]) diff --git a/scripts/zmdc.pl.in b/scripts/zmdc.pl.in index 5a0ce9eef..981f7364e 100644 --- a/scripts/zmdc.pl.in +++ b/scripts/zmdc.pl.in @@ -834,6 +834,8 @@ sub killAll if ( '@HOST_OS@' eq 'BSD' ) { $killall = 'killall -'; + } elsif ( '@HOST_OS@' eq 'solaris' ) { + $killall = 'pkill -'; } else { $killall = 'killall -q -s '; } diff --git a/scripts/zmpkg.pl.in b/scripts/zmpkg.pl.in index 5686f2596..d696bb0d0 100644 --- a/scripts/zmpkg.pl.in +++ b/scripts/zmpkg.pl.in @@ -189,7 +189,7 @@ if ( $command =~ /^(?:start|restart)$/ ) if ( $status eq "stopped" ) { if ( $Config{ZM_DYN_DB_VERSION} - and ( $Config{ZM_DYN_DB_VERSION} ne ZM_VERSION ) + and ( $Config{ZM_DYN_DB_VERSION} ne $Config{ZM_VERSION} ) ) { Fatal( "Version mismatch, system is version ".ZM_VERSION @@ -294,7 +294,12 @@ sub systemdRunning { my $result = 0; - my $output = qx(ps -o comm="" 1); + my $output; + if ( '@HOST_OS@' eq 'solaris' ) { + $output = qx(ps -o comm="" -p 1); + } else { + $output = qx(ps -o comm="" 1); + } chomp( $output ); if ($output =~ /systemd/) { @@ -309,7 +314,12 @@ sub calledBysystem my $result = 0; my $ppid = getppid(); - my $output = qx(ps -o comm="" $ppid); + my $output; + if ( '@HOST_OS@' eq 'solaris' ) { + $output = qx(ps -o comm="" -p $ppid); + } else { + $output = qx(ps -o comm="" $ppid); + } chomp( $output ); if ($output =~ /^(?:systemd|init)$/) { diff --git a/scripts/zmupdate.pl.in b/scripts/zmupdate.pl.in index 75ac52fa0..6ffd00e4c 100644 --- a/scripts/zmupdate.pl.in +++ b/scripts/zmupdate.pl.in @@ -82,7 +82,7 @@ use constant EVENT_PATH => ($Config{ZM_DIR_EVENTS}=~m|/|)?$Config{ZM_DIR_EVENTS} $| = 1; -$ENV{PATH} = '/bin:/usr/bin:/usr/local/bin'; +$ENV{PATH} = '/bin:/usr/bin:/usr/local/bin:/opt/local/bin'; $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; @@ -165,7 +165,7 @@ if ( $check && $Config{ZM_CHECK_FOR_UPDATES} ) use LWP::UserAgent; my $ua = LWP::UserAgent->new; - $ua->agent( "ZoneMinder Update Agent/".ZM_VERSION ); + $ua->agent( "ZoneMinder Update Agent/".$Config{ZM_VERSION} ); if ( $Config{ZM_UPDATE_CHECK_PROXY} ) { $ua->proxy( "http", $Config{ZM_UPDATE_CHECK_PROXY} ); } @@ -374,13 +374,13 @@ if ( $version ) my ( $detaint_version ) = $version =~ /^([\w.]+)$/; $version = $detaint_version; - if ( ZM_VERSION eq $version ) + if ( $Config{ZM_VERSION} eq $version ) { print( "\nDatabase already at version $version, update aborted.\n\n" ); exit( 0 ); } - print( "\nInitiating database upgrade to version ".ZM_VERSION." from version $version\n" ); + print( "\nInitiating database upgrade to version ".$Config{ZM_VERSION}." from version $version\n" ); if ( $interactive ) { if ( $Config{ZM_DYN_DB_VERSION} && $Config{ZM_DYN_DB_VERSION} ne $version ) @@ -489,7 +489,7 @@ if ( $version ) } - print( "\nUpgrading database to version ".ZM_VERSION."\n" ); + print( "\nUpgrading database to version ".$Config{ZM_VERSION}."\n" ); # Update config first of all loadConfigFromDB(); @@ -1050,7 +1050,7 @@ if ( $version ) if ( $cascade ) { - my $installed_version = ZM_VERSION; + my $installed_version = $Config{ZM_VERSION}; my $sql = "update Config set Value = ? where Name = ?"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute( "$installed_version", "ZM_DYN_DB_VERSION" ) or die( "Can't execute: ".$sth->errstr() ); @@ -1061,7 +1061,7 @@ if ( $version ) zmDbDisconnect(); die( "Can't find upgrade from version '$version'" ); } - print( "\nDatabase upgrade to version ".ZM_VERSION." successful.\n\n" ); + print( "\nDatabase upgrade to version ".$Config{ZM_VERSION}." successful.\n\n" ); } zmDbDisconnect(); exit( 0 ); diff --git a/src/zm.h b/src/zm.h index 38af33bf6..be2882f8d 100644 --- a/src/zm.h +++ b/src/zm.h @@ -25,6 +25,10 @@ #define ZM_H #include "zm_config.h" +#ifdef SOLARIS +#undef DEFAULT_TYPE // pthread defines this which breaks StreamType DEFAULT_TYPE +#include // define strerror() and friends +#endif #include "zm_logger.h" #include diff --git a/src/zm_box.h b/src/zm_box.h index 8a18b8847..8aa341d73 100644 --- a/src/zm_box.h +++ b/src/zm_box.h @@ -23,7 +23,11 @@ #include "zm.h" #include "zm_coord.h" +#ifndef SOLARIS #include +#else +#include +#endif // // Class used for storing a box, which is defined as a region diff --git a/src/zm_comms.cpp b/src/zm_comms.cpp index c42b7bd17..a109019bd 100644 --- a/src/zm_comms.cpp +++ b/src/zm_comms.cpp @@ -36,6 +36,10 @@ #include #include +#ifdef SOLARIS +#include // define FIONREAD +#endif + int CommsBase::readV( int iovcnt, /* const void *, int, */ ... ) { va_list arg_ptr; diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 225d9ec66..09d39ab53 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -27,6 +27,12 @@ #define AV_ERROR_MAX_STRING_SIZE 64 #endif +#ifdef SOLARIS +#include // for ESRCH +#include +#include +#endif + FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( p_id, FFMPEG_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ), mPath( p_path ), diff --git a/src/zm_image.cpp b/src/zm_image.cpp index eb7510cf5..21e190ffb 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -1580,7 +1580,11 @@ Image *Image::Highlight( unsigned int n_images, Image *images[], const Rgb thres { uint8_t *psrc = images[j]->buffer+c; +#ifndef SOLARIS if ( (unsigned)abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) ) +#else + if ( (unsigned)std::abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) ) +#endif { count++; } diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index df3bdde4d..f6cc9523b 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -542,7 +542,10 @@ void Logger::logPrint( bool hex, const char * const file, const int line, const if ( (syscall(SYS_thr_self, &tid)) < 0 ) // Thread/Process id # else + // SOLARIS doesn't have SYS_gettid; don't assume + #ifdef SYS_gettid if ( (tid = syscall(SYS_gettid)) < 0 ) // Thread/Process id + #endif // SYS_gettid #endif #endif // HAVE_SYSCALL #endif diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index f2ae97215..f990bf320 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -55,6 +55,11 @@ #include #endif // ZM_MEM_MAPPED +// SOLARIS - we don't have MAP_LOCKED on openSolaris/illumos +#ifndef MAP_LOCKED +#define MAP_LOCKED 0 +#endif + //============================================================================= std::vector split(const std::string &s, char delim) { std::vector elems; diff --git a/src/zm_poly.cpp b/src/zm_poly.cpp index eef5dd56a..4eee73f46 100644 --- a/src/zm_poly.cpp +++ b/src/zm_poly.cpp @@ -20,7 +20,11 @@ #include "zm.h" #include "zm_poly.h" +#ifndef SOLARIS #include +#else +#include +#endif void Polygon::calcArea() { diff --git a/src/zm_remote_camera_http.cpp b/src/zm_remote_camera_http.cpp index fdbfd69a6..c6de64aed 100644 --- a/src/zm_remote_camera_http.cpp +++ b/src/zm_remote_camera_http.cpp @@ -26,6 +26,10 @@ #include #include +#ifdef SOLARIS +#include // FIONREAD and friends +#endif + RemoteCameraHttp::RemoteCameraHttp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : RemoteCamera( p_id, "http", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture ) { diff --git a/src/zm_thread.h b/src/zm_thread.h index 54190547c..615bec6aa 100644 --- a/src/zm_thread.h +++ b/src/zm_thread.h @@ -35,6 +35,7 @@ class ThreadException : public Exception { private: +#ifndef SOLARIS pid_t pid() { pid_t tid; #ifdef __FreeBSD__ @@ -50,6 +51,9 @@ pid_t pid() { #endif return tid; } +#else +pthread_t pid() { return( pthread_self() ); } +#endif public: ThreadException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)pid() ) ) { } @@ -213,7 +217,11 @@ protected: Mutex mThreadMutex; Condition mThreadCondition; +#ifndef SOLARIS pid_t mPid; +#else + pthread_t mPid; +#endif bool mStarted; bool mRunning; @@ -221,6 +229,7 @@ protected: Thread(); virtual ~Thread(); +#ifndef SOLARIS pid_t id() const { pid_t tid; @@ -238,6 +247,12 @@ protected: #endif return tid; } +#else + pthread_t id() const + { + return( pthread_self() ); + } +#endif void exit( int status = 0 ) { //INFO( "Exiting" ); diff --git a/src/zm_timer.h b/src/zm_timer.h index f7f74aa7d..7afe0a647 100644 --- a/src/zm_timer.h +++ b/src/zm_timer.h @@ -33,6 +33,7 @@ private: class TimerException : public Exception { private: +#ifndef SOLARIS pid_t pid() { pid_t tid; #ifdef __FreeBSD__ @@ -48,6 +49,9 @@ private: #endif return tid; } +#else + pthread_t pid() { return( pthread_self() ); } +#endif public: TimerException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)pid() ) ) { diff --git a/web/includes/config.php.in b/web/includes/config.php.in index fbcb0e7b3..54257fc16 100644 --- a/web/includes/config.php.in +++ b/web/includes/config.php.in @@ -22,8 +22,6 @@ // This section contains options substituted by the zmconfig.pl utility, do not edit these directly // define( "ZM_CONFIG", "@ZM_CONFIG@" ); // Path to config file -// Define, and override any given in config file -define( "ZM_VERSION", "@VERSION@" ); // Version $configFile = ZM_CONFIG; $localConfigFile = basename($configFile); @@ -48,6 +46,13 @@ while ( !feof($cfg) ) define( $matches[1], $matches[2] ); } fclose( $cfg ); + +// Define, and override any given in config file +// to override, must be done AFTER asignment, cripes +// @VERSION@ hasn't been defined in tests, perhaps configure.ac needs fix? +if (!defined("ZM_VERSION")) { // avoid double definition warning + define( "ZM_VERSION", "@VERSION@" ); // Version +} // // This section is options normally derived from other options or configuration diff --git a/zm.conf.in b/zm.conf.in index 9cc3d42de..f3bdb0471 100644 --- a/zm.conf.in +++ b/zm.conf.in @@ -48,3 +48,6 @@ ZM_DB_PASS=@ZM_DB_PASS@ # Host of this machine ZM_SERVER_HOST= + +# Version of zoneminder - must be set +ZM_VERSION=1.28.1