Skip to content

Commit

Permalink
Improve replacement tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Oct 17, 2017
1 parent e91ba37 commit 79e10ed
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
33 changes: 22 additions & 11 deletions lib/Horde/Pear/Package/Contents/Role/HordeApplication.php
Expand Up @@ -67,22 +67,33 @@ public function getReplace($file, $root)
$basedir = array_shift($elements);
switch ($basedir) {
case 'bin':
if (strpos(file_get_contents($root . '/' . $file), '#!/usr/bin/env php') === 0) {
return array(array(
$contents = file_get_contents($root . '/' . $file);
$replace = array();
if (strpos($contents, '#!/usr/bin/env php') === 0) {
$replace[] = array(
'from' => '/usr/bin/env php',
'to' => 'php_bin',
'type' => 'pear-config'
));
);
}
if (strpos($contents, '@php_dir@')) {
$replace[] = array(
'from' => '@php_dir@',
'to' => 'php_dir',
'type' => 'pear-config'
);
}
break;
return $replace;
}
$file = array_pop($elements);
if ($file == 'Translation.php') {
return array(array(
'from' => '@data_dir@',
'to' => 'data_dir',
'type' => 'pear-config'
));
$basename = array_pop($elements);
if ($basename == 'Translation.php') {
if (strpos(file_get_contents($root . '/' . $file), '@data_dir@')) {
return array(array(
'from' => '@data_dir@',
'to' => 'data_dir',
'type' => 'pear-config'
));
}
}
return array();
}
Expand Down
33 changes: 22 additions & 11 deletions lib/Horde/Pear/Package/Contents/Role/HordeComponent.php
Expand Up @@ -74,22 +74,33 @@ public function getReplace($file, $root)
$basedir = array_shift($elements);
switch ($basedir) {
case 'bin':
if (strpos(file_get_contents($root . '/' . $file), '#!/usr/bin/env php') === 0) {
return array(array(
$contents = file_get_contents($root . '/' . $file);
$replace = array();
if (strpos($contents, '#!/usr/bin/env php') === 0) {
$replace[] = array(
'from' => '/usr/bin/env php',
'to' => 'php_bin',
'type' => 'pear-config'
));
);
}
if (strpos($contents, '@php_dir@')) {
$replace[] = array(
'from' => '@php_dir@',
'to' => 'php_dir',
'type' => 'pear-config'
);
}
break;
return $replace;
}
$file = array_pop($elements);
if ($file == 'Translation.php') {
return array(array(
'from' => '@data_dir@',
'to' => 'data_dir',
'type' => 'pear-config'
));
$basename = array_pop($elements);
if ($basename == 'Translation.php') {
if (strpos(file_get_contents($root . '/' . $file), '@data_dir@')) {
return array(array(
'from' => '@data_dir@',
'to' => 'data_dir',
'type' => 'pear-config'
));
}
}
return array();
}
Expand Down
5 changes: 4 additions & 1 deletion lib/Horde/Pear/Package/Xml/Element/File.php
Expand Up @@ -155,11 +155,14 @@ public function insert(DOMNode $point = null)
array(
"\n " . str_repeat(" ", $this->_level),
'tasks:replace' => $replace,
"\n " . str_repeat(" ", $this->_level),
),
$this->_file
);
}
$this->_xml->append(
array("\n " . str_repeat(" ", $this->_level)),
$this->_file
);
}
}

Expand Down

0 comments on commit 79e10ed

Please sign in to comment.