From: Gunnar Wrobel
Date: Tue, 12 Oct 2010 18:32:30 +0000 (+0200)
Subject: Allow keeping "replace" tasks in the content section of the package.xml.
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7e4375c68c63c8bcad31a8de4f53cf3b81c27a3d;p=horde.git
Allow keeping "replace" tasks in the content section of the package.xml.
Great, no more manual fixing after the update :)
---
diff --git a/components/lib/Components/Pear/Package.php b/components/lib/Components/Pear/Package.php
index 8b93d124f..05de3bdc9 100644
--- a/components/lib/Components/Pear/Package.php
+++ b/components/lib/Components/Pear/Package.php
@@ -203,15 +203,84 @@ class Components_Pear_Package
return $this->_getPackageFile()->getDescription();
}
- private function _getUpdatedPackageFile()
+ /**
+ * Update the content listing of the provided package.
+ *
+ * @param PEAR_PackageFileManager2 $package The package to update.
+ *
+ * @return NULL
+ */
+ private function _updateContents(PEAR_PackageFileManager2 $package)
{
- $package = $this->_getPackageRwFile();
+ $contents = $package->getContents();
+ $contents = $contents['dir']['file'];
+ $taskfiles = array();
+ foreach ($contents as $file) {
+ $atts = $file['attribs'];
+ unset($file['attribs']);
+ if (count($file)) {
+ $taskfiles[$atts['name']] = $file;
+ }
+ }
+
/**
* @todo: Looks like this throws away any tags we have in
* the content list. Needs to be fixed.
*/
$package->generateContents();
+ $updated = $package->getContents();
+ $updated = $updated['dir']['file'];
+ foreach ($updated as $file) {
+ if (isset($taskfiles[$file['attribs']['name']])) {
+ foreach ($taskfiles[$file['attribs']['name']] as $tag => $raw) {
+ $taskname = $package->getTask($tag) . '_rw';
+ if (!class_exists($taskname)) {
+ throw new Components_Exception(
+ sprintf('Read/write task %s is missing!', $taskname)
+ );
+ }
+ $logger = new stdClass;
+ $task = new $taskname(
+ $package,
+ $this->getEnvironment()->getPearConfig(),
+ $logger,
+ ''
+ );
+ switch ($tag) {
+ case 'replace':
+ $task->setInfo(
+ $raw['attribs']['from'],
+ $raw['attribs']['to'],
+ $raw['attribs']['type']
+ );
+ break;
+ default:
+ throw new Components_Exceptions(
+ sprintf('Unsupported task type %s!', $tag)
+ );
+ }
+ $task->init(
+ $raw,
+ $file['attribs']
+ );
+ $package->addTaskToFile($file['attribs']['name'], $task);
+ }
+ }
+ }
+ }
+
+ /**
+ * Return an updated package description.
+ *
+ * @return PEAR_PackageFileManager2 The updated package.
+ */
+ private function _getUpdatedPackageFile()
+ {
+ $package = $this->_getPackageRwFile();
+
+ $this->_updateContents($package);
+
/**
* This is required to clear the
* section.
@@ -277,5 +346,6 @@ class Components_Pear_Package
public function writeUpdatedPackageFile()
{
$this->_getUpdatedPackageFile()->writePackageFile();
+ $this->_output->ok('Successfully updated ' . $this->_package_xml_path);
}
}
diff --git a/components/package.xml b/components/package.xml
index 0f5679cff..ac9c96434 100644
--- a/components/package.xml
+++ b/components/package.xml
@@ -24,8 +24,8 @@
jan@horde.org
yes
- 2010-10-03
-
+ 2010-10-12
+
0.0.1
0.0.1
@@ -48,6 +48,7 @@
+
@@ -62,18 +63,21 @@
+
+
+
-
+
@@ -85,7 +89,7 @@
-
+
@@ -96,17 +100,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -175,6 +214,7 @@
+
@@ -183,11 +223,14 @@
+
+
+
@@ -196,10 +239,21 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -214,7 +268,7 @@
alpha
alpha
- 2010-10-03
+ 2010-10-12
LGPL
* Initial release