}
$pkgdir = substr($file, 0, $pos);
*/
- $dp = opendir($tmpdir);
- do {
- $pkgdir = readdir($dp);
- } while ($pkgdir{0} == '.');
- $descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
+ // ----- Look for existing package file
+ $descfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml';
+
+ // ==> XXX This part should be removed later on
+ $flag_old_format = false;
+ if (!is_file($descfile)) {
+ // ----- Look for old package .tgz archive format
+ // In this format the package.xml file was inside the package directory name
+ $dp = opendir($tmpdir);
+ do {
+ $pkgdir = readdir($dp);
+ } while ($pkgdir{0} == '.');
+
+ $descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
+ $flag_old_format = true;
+ $this->log(0, "warning : you are using an archive with an old format");
+ }
+ // <== XXX This part should be removed later on
if (!is_file($descfile)) {
chdir($oldcwd);
return $this->raiseError("no script destination directory\n",
null, PEAR_ERROR_DIE);
}
- $tmp_path = dirname($descfile);
+
+ // don't want strange characters
+ $pkgname = ereg_replace ('[^a-zA-Z0-9._]', '_', $pkginfo['package']);
+ $pkgversion = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $pkginfo['version']);
+ $tmp_path = dirname($descfile) . DIRECTORY_SEPARATOR . $pkgname . '-' . $pkgversion;
+
+ // ==> XXX This part should be removed later on
+ if ($flag_old_format) {
+ $tmp_path = dirname($descfile);
+ }
+ // <== XXX This part should be removed later on
+
foreach ($pkginfo['filelist'] as $file => $atts) {
$this->_installFile($file, $atts, $tmp_path);
}
$filelist = array();
$i = 0;
- // ----- Add the package XML file
- $filelist[$i++] = $pkgfile;
-
// Copy files -----------------------------------------------
foreach ($pkginfo['filelist'] as $fname => $atts) {
if (!file_exists($fname)) {
$dest_package = $this->orig_pwd . DIRECTORY_SEPARATOR . "{$pkgver}.tgz";
$tar = new Archive_Tar($dest_package, true);
$tar->setErrorHandling(PEAR_ERROR_PRINT);
- if (!$tar->createModify($filelist, $pkgver)) {
+ // ----- Creates with the package.xml file
+ if (!$tar->create($pkgfile)) {
+ return $this->raiseError('an error ocurred during package creation');
+ }
+ // ----- Add the content of the package
+ if (!$tar->addModify($filelist, $pkgver)) {
return $this->raiseError('an error ocurred during package creation');
}
+
$this->log(1, "Package $dest_package done");
return $dest_package;
}