From ed0bc109e13bd8d08e71a915a28686121f59493b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 27 Oct 2011 19:59:53 +0000 Subject: [PATCH] - up to 0.41; fix-paths-handling.patch, warning-fixes.patch, rrdmove-fixes.patch applied upstream Changed files: cacti-plugin-rrdclean.spec -> 1.13 fix-paths-handling.patch -> 1.2 rrdmove-fixes.patch -> 1.2 warning-fixes.patch -> 1.3 --- cacti-plugin-rrdclean.spec | 33 +++++++++------- fix-paths-handling.patch | 28 ------------- rrdmove-fixes.patch | 81 -------------------------------------- warning-fixes.patch | 22 ----------- 4 files changed, 18 insertions(+), 146 deletions(-) delete mode 100644 fix-paths-handling.patch delete mode 100644 rrdmove-fixes.patch delete mode 100644 warning-fixes.patch diff --git a/cacti-plugin-rrdclean.spec b/cacti-plugin-rrdclean.spec index 93ce7d5..f780352 100644 --- a/cacti-plugin-rrdclean.spec +++ b/cacti-plugin-rrdclean.spec @@ -1,20 +1,21 @@ %define plugin rrdclean +%define php_min_version 5.0.0 +%include /usr/lib/rpm/macros.php Summary: Cacti RRD File Cleaner Name: cacti-plugin-%{plugin} -Version: 0.40 -Release: 0.7 +Version: 0.41 +Release: 1 License: GPL v2 Group: Applications/WWW Source0: http://docs.cacti.net/_media/plugin:rrdclean-v%{version}.tgz -# Source0-md5: afd7ae246482fbee883485e0430041e8 +# Source0-md5: e9dd1eeea27003ebb5239a1fa08b73ef Patch0: paths.patch -Patch1: fix-paths-handling.patch -Patch2: warning-fixes.patch -Patch3: rrdmove-fixes.patch URL: http://docs.cacti.net/plugin:rrdclean -Requires: cacti >= 0.8.6j -Requires: php-common >= 3:4.3.0 -Provides: cacti(pia) >= 2.8 +Requires: cacti >= 0.8.7 +Requires: cacti(pia) >= 2.4 +Requires: php-common >= 4:%{php_min_version} +Requires: php-date +Requires: php-pcre BuildArch: noarch BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) @@ -28,17 +29,19 @@ files. %prep %setup -qc -mv %{plugin}/* .; rmdir %{plugin} +cd %{plugin} %patch0 -p1 -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 +cd .. + +mv %{plugin}/{README,LICENSE} . + +# cleanup backups after patching +find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f %install rm -rf $RPM_BUILD_ROOT install -d $RPM_BUILD_ROOT{%{plugindir},%{rradir}/{backup,archive}} -cp -a . $RPM_BUILD_ROOT%{plugindir} -%{__rm} $RPM_BUILD_ROOT%{plugindir}/{README,LICENSE} +cp -a %{plugin}/* $RPM_BUILD_ROOT%{plugindir} %clean rm -rf $RPM_BUILD_ROOT diff --git a/fix-paths-handling.patch b/fix-paths-handling.patch deleted file mode 100644 index 4155919..0000000 --- a/fix-paths-handling.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- cacti-plugin-rrdclean-0.40/rrdmove.php 2010-06-19 17:24:22.000000000 +0300 -+++ cacti-plugin-rrdclean-0.40/rrdmove.php 2010-12-14 09:28:27.185477958 +0200 -@@ -117,7 +116,7 @@ - cacti_log("RRDClean is now running on " . sizeof($file_array) . " items", true, "RRDCLEAN"); - - /* determine the location of the RRA files */ -- if (isset ($config["path_rra"])) { -+ if (isset($config["rra_path"])) { - $rra_path = $config["rra_path"]; - } else { - $rra_path = $config["base_path"] . "/rra"; -@@ -128,12 +127,12 @@ - $rrd_archive = read_config_option("rrd_archive", TRUE); - - if ($rrd_backup == "") -- $rrd_backup = $rra_path . "/backup/"; -+ $rrd_backup = $rra_path . "/backup"; - if ($rrd_archive == "") -- $rrd_archive = $rra_path . "/archive/"; -+ $rrd_archive = $rra_path . "/archive"; - -- rrdclean_create_path($rra_path . "/backup/"); -- rrdclean_create_path($rra_path . "/archive/"); -+ rrdclean_create_path($rrd_backup); -+ rrdclean_create_path($rrd_archive); - - /* now scan the files */ - foreach ($file_array as $file) { diff --git a/rrdmove-fixes.patch b/rrdmove-fixes.patch deleted file mode 100644 index cf87b69..0000000 --- a/rrdmove-fixes.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- cacti-plugin-rrdclean-0.40/rrdmove.php~ 2010-12-14 10:10:59.431054842 +0200 -+++ cacti-plugin-rrdclean-0.40/rrdmove.php 2010-12-14 10:32:23.984260340 +0200 -@@ -137,31 +137,36 @@ - - /* now scan the files */ - foreach ($file_array as $file) { -+ $source_file = $rra_path . "/" . $file["name"]; - switch ($file['action']) { - case "1" : -- if (unlink($rra_path . "/" . $file["name"])) { -+ if (unlink($source_file)) { - cacti_log("Deleted: " . $file["name"], true, "RRDCLEAN"); - } else { - cacti_log($file["name"] . " Error: unable to delete from $rra_path!", true, "RRDCLEAN"); - } - break; - case "2" : -- if (!is_dir(dirname($rrd_backup . "/" . $file["name"]))) { -- rrdclean_create_path(dirname($rrd_backup . "/" . $file["name"])); -+ $target_file = $rrd_backup . "/" . $file["name"]; -+ $target_dir = dirname($target_file); -+ if (!is_dir($target_dir)) { -+ rrdclean_create_path($target_dir); - } - -- if (copy($rra_path . "/" . $file["name"], $rrd_backup . "/" . $file["name"])) { -+ if (copy($source_file, $target_file)) { - cacti_log("Copied: " . $file["name"] . " to: " . $rrd_backup, true, "RRDCLEAN"); - } else { - cacti_log($file["name"] . " Error: unable to save to $rrd_backup!", true, "RRDCLEAN"); - } - break; - case "3" : -- if (!is_dir(dirname($rrd_archive . "/" . $file["name"]))) { -- rrdclean_create_path(dirname($rrd_archive . "/" . $file["name"])); -+ $target_file = $rrd_archive . "/" . $file["name"]; -+ $target_dir = dirname($target_file); -+ if (!is_dir($target_dir)) { -+ rrdclean_create_path($target_dir); - } - -- if (rename($rra_path . "/" . $file["name"], $rrd_archive . "/" . $file["name"])) { -+ if (rename($source_file, $target_file)) { - cacti_log("Moved: " . $file["name"] . " to: " . $rrd_archive, true, "RRDCLEAN"); - } else { - cacti_log($file["name"] . " Error: unable to move to $rrd_archive!", true, "RRDCLEAN"); -@@ -224,25 +229,24 @@ - function rrdclean_create_path($path) { - global $config; - -- if (!is_dir(dirname($path))) { -- if (mkdir(dirname($path), 0775)) { -+ if (!is_dir($path)) { -+ if (mkdir($path, 0775)) { - if ($config["cacti_server_os"] != "win32") { - $owner_id = fileowner($config["rra_path"]); - $group_id = filegroup($config["rra_path"]); - -- if ((chown(dirname($path), $owner_id)) && -- (chgrp(dirname($path), $group_id))) { -- return TRUE; -- }else{ -- cacti_log("ERROR: Unable to set directory permissions for '" . dirname($path) . "'", FALSE); -- } -+ // NOTE: chown/chgrp fails for non-root users, checking their -+ // result is therefore irrevelevant -+ @chown($path, $owner_id); -+ @chgrp($path, $group_id); - } - }else{ -- cacti_log("ERROR: Unable to create directory '" . dirname($path) . "'", FALSE); -+ cacti_log("ERROR: Unable to create directory '" . $path . "'", FALSE); - } - } - -- return FALSE; -+ // if path existed, we can return true -+ return is_dir($path) && is_writable($path); - } - - /* diff --git a/warning-fixes.patch b/warning-fixes.patch deleted file mode 100644 index 744a23b..0000000 --- a/warning-fixes.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- cacti-plugin-rrdclean-0.40/rrdcleaner.php 2010-05-18 23:56:45.000000000 +0300 -+++ cacti-plugin-rrdclean-0.40/rrdcleaner.php 2010-12-14 09:38:38.595416928 +0200 -@@ -301,7 +301,7 @@ - $files_db[] = substr(strchr($entry["data_source_path"], "/"),1); - } - -- if(function_exists(glob)) { //needed because this function is not available on all systems -+ if(function_exists('glob')) { //needed because this function is not available on all systems - chdir($rra_path); - /* get all rrdfiles in two passes */ - $files_on_hd = glob("*/*.rrd"); //simply pull all .rrd files out of the directory.. ---- cacti-plugin-rrdclean-0.40/rrdmove.php~ 2010-12-14 09:49:03.068688201 +0200 -+++ cacti-plugin-rrdclean-0.40/rrdmove.php 2010-12-14 10:09:54.997728344 +0200 -@@ -27,7 +27,7 @@ - /* let PHP run just as long as it has to */ - ini_set("max_execution_time", "0"); - --error_reporting('E_ALL'); -+error_reporting(E_ALL); - $dir = dirname(__FILE__); - chdir($dir); - -- 2.43.0