Skip to content

Commit

Permalink
Compatibility with Ubuntu 18.04
Browse files Browse the repository at this point in the history
- Remove restriction on ubuntu version in basex install script
- Fix requirements hook so it checks for both basex and zorba
  before complaining.
  • Loading branch information
Matthieu Hughes committed Nov 28, 2019
1 parent 20246eb commit e751457
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
34 changes: 34 additions & 0 deletions includes/utilities.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,37 @@ function islandora_xquery_get_zorba_version($executable_path = NULL) {
}
return FALSE;
}

/**
* Gets the versions of the given basex executable.
*
* @param string $executable_path
* The absolute path to the basex executable. If not provided the
* "islandora_xquery_basex" variable will be used instead.
*
* @return bool
* Whether the basex executable exists at the given path.
*/
function islandora_xquery_get_basex_version($executable_path = NULL) {
$executable_path = $executable_path ? $executable_path : variable_get('islandora_xquery_basex', ISLANDORA_XQUERY_BASEX_DEFAULT_LOCATION);
if (is_executable($executable_path)) {
$ret = -1;
$output = array();
$command = "$executable_path -h 2>&1";
exec($command, $output, $ret);
if ($ret == 1 && $output) {
// There might be some warnings before the line with version info, so
// loop through the output.
foreach ($output as $line) {
// Example output: "BaseX 8.5.1 [Standalone]".
if (strpos($line, 'BaseX') === 0) {
$matches = array();
if (preg_match('/\d\.\d\.\d/', $line, $matches)) {
return array_pop($matches);
}
}
}
}
}
return FALSE;
}
30 changes: 19 additions & 11 deletions islandora_xquery.install
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,19 @@ function islandora_xquery_requirements($phase) {
switch ($phase) {
case 'runtime':
$zorba_version = islandora_xquery_get_zorba_version();
if ($zorba_version === FALSE) {
$requirements['zorba'] = array(
'title' => $t('Zorba'),
'value' => $t('Zorba could not be found. Islandora XQuery requires Zorba %version.', array('%version' => ISLANDORA_XQUERY_ZORBA_REQUIRED_VERSION)),
$basex_version = islandora_xquery_get_basex_version();

if ($basex_version === FALSE && $zorba_version === FALSE) {
$requirements['xquery_processor'] = array(
'title' => $t('XQuery Processor'),
'value' => $t('Processor could not be found. Islandora XQuery requires Zorba %version or BaseX.', array('%version' => ISLANDORA_XQUERY_ZORBA_REQUIRED_VERSION)),
'severity' => REQUIREMENT_ERROR,
);
}
elseif (version_compare($zorba_version, ISLANDORA_XQUERY_ZORBA_REQUIRED_VERSION, '!=')) {
$requirements['zorba'] = array(
'title' => $t('Zorba'),
'value' => $t('Islandora XQuery requires Zorba %required_version. Version %version is currently installed.', array(
elseif ($basex_version === FALSE && version_compare($zorba_version, ISLANDORA_XQUERY_ZORBA_REQUIRED_VERSION, '!=')) {
$requirements['xquery_processor'] = array(
'title' => $t('XQuery Processor'),
'value' => $t('Islandora XQuery requires BaseX or Zorba %required_version. Zorba version %version is currently installed.', array(
'%required_version' => ISLANDORA_XQUERY_ZORBA_REQUIRED_VERSION,
'%version' => $zorba_version,
)
Expand All @@ -206,9 +208,15 @@ function islandora_xquery_requirements($phase) {
);
}
else {
$requirements['zorba'] = array(
'title' => $t('Zorba'),
'value' => $zorba_version,
if ($basex_version !== FALSE) {
$value = "BaseX " . $basex_version;
}
else {
$value = "Zorba " . $zorba_version;
}
$requirements['xquery_processor'] = array(
'title' => $t('XQuery Processor'),
'value' => $value,
'severity' => REQUIREMENT_OK,
);
}
Expand Down
1 change: 1 addition & 0 deletions islandora_xquery.module
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

define('ISLANDORA_XQUERY_ZORBA_REQUIRED_VERSION', '3.0.0');
define('ISLANDORA_XQUERY_ZORBA_DEFAULT_LOCATION', '/usr/bin/zorba');
define('ISLANDORA_XQUERY_BASEX_DEFAULT_LOCATION', '/usr/bin/basex');

define('ISLANDORA_XQUERY_STATUS_PENDING', 'PENDING');
define('ISLANDORA_XQUERY_STATUS_OBJECT_LOAD_FAIL', 'OBJECT LOAD FAIL');
Expand Down
2 changes: 1 addition & 1 deletion resources/install_islandora_xquery_with_basex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sanityCheck()
{
test -d $drupalRoot
checkSafe $? "$drupalRoot does not exist!"
if [ "$myOS" = "Ubuntu" -a "$majorRelease" -lt "18" ] || [ "$myOS" = "Redhat" -a "$majorRelease" -lt "7" ]; then
if [ "$myOS" = "Redhat" -a "$majorRelease" -lt "7" ]; then
checkSafe $majorRelease "This script won't work on this version of $myOS"
fi
}
Expand Down

0 comments on commit e751457

Please sign in to comment.