summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-10-20 16:10:54 -0200
committerRenato Botelho <renato@netgate.com>2015-10-20 16:19:50 -0200
commit8df1877b704f9d5cd788def274ff7ffa5349dc23 (patch)
tree5ae5a36aa9e4a7788a015df332776f9b399648ce /src
parentcd51e4f60e706e2c0e13f50935ca4c006898677a (diff)
downloadpfsense-8df1877b704f9d5cd788def274ff7ffa5349dc23.zip
pfsense-8df1877b704f9d5cd788def274ff7ffa5349dc23.tar.gz
Add pkg_version_compare()
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/pkg-utils.inc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/etc/inc/pkg-utils.inc b/src/etc/inc/pkg-utils.inc
index fee93fd..147d550 100644
--- a/src/etc/inc/pkg-utils.inc
+++ b/src/etc/inc/pkg-utils.inc
@@ -283,6 +283,26 @@ function pkg_exec($params, &$stdout, &$stderr) {
return proc_close($process);
}
+/* Compare 2 pkg versions and return:
+ * '=' - versions are the same
+ * '>' - $v1 > $v2
+ * '<' - $v1 < $v2
+ * '?' - Error
+ */
+function pkg_version_compare($v1, $v2) {
+ if (empty($v1) || empty($v2)) {
+ return '?';
+ }
+
+ $rc = pkg_exec("version -t '{$v1}' '{$v2}'", $stdout, $stderr);
+
+ if ($rc != 0) {
+ return '?';
+ }
+
+ return str_replace("\n", "", $stdout);
+}
+
/* Check if package is installed */
function is_pkg_installed($pkg_name) {
global $g;
OpenPOWER on IntegriCloud