| 1 |
#!/usr/bin/php |
#!/usr/bin/php |
| 2 |
<?php |
<?php |
| 3 |
|
|
| 4 |
// $Id: package-release-nodes.php,v 1.8 2009/02/28 10:07:43 jpetso Exp $ |
// $Id: package-release-nodes.php,v 1.9 2009/03/07 21:58:34 jpetso Exp $ |
| 5 |
|
|
| 6 |
/** |
/** |
| 7 |
* @file |
* @file |
| 32 |
$dest_root = realpath($dest_root); |
$dest_root = realpath($dest_root); |
| 33 |
$tmp_root = realpath($tmp_root); |
$tmp_root = realpath($tmp_root); |
| 34 |
$license = realpath($license); |
$license = realpath($license); |
|
$trans_install = realpath($trans_install); |
|
| 35 |
$dest_root = realpath($dest_root); |
$dest_root = realpath($dest_root); |
| 36 |
|
|
| 37 |
// Check if all required variables are defined. |
// Check if all required variables are defined. |
| 41 |
'site_name' => $site_name, |
'site_name' => $site_name, |
| 42 |
'tmp_root' => $tmp_root, |
'tmp_root' => $tmp_root, |
| 43 |
'license' => $license, |
'license' => $license, |
|
'trans_install' => $trans_install, ///TODO (jpetso): unused? |
|
| 44 |
); |
); |
| 45 |
foreach ($vars as $name => $val) { |
foreach ($vars as $name => $val) { |
| 46 |
if (empty($val)) { |
if (empty($val)) { |
| 185 |
// Fetch the repository where the project is located. |
// Fetch the repository where the project is located. |
| 186 |
$repositories = versioncontrol_get_repositories(array( |
$repositories = versioncontrol_get_repositories(array( |
| 187 |
'repo_ids' => array($release->repo_id), |
'repo_ids' => array($release->repo_id), |
|
'vcs' => array('cvs'), // the script can't do better at the moment |
|
| 188 |
)); |
)); |
| 189 |
if (empty($repositories)) { |
if (empty($repositories)) { |
| 190 |
$num_considered++; |
$num_considered++; |
| 205 |
); |
); |
| 206 |
$label = array( |
$label = array( |
| 207 |
'label_id' => $release->label_id, |
'label_id' => $release->label_id, |
|
'repo_id' => $release->repo_id, |
|
| 208 |
'name' => $release->label_name, |
'name' => $release->label_name, |
| 209 |
'type' => $release->label_type, |
'type' => $release->label_type, |
| 210 |
); |
); |
| 248 |
|
|
| 249 |
function package_release($release_nid, $project, $repository, $version, $label) { |
function package_release($release_nid, $project, $repository, $version, $label) { |
| 250 |
global $tmp_dir, $drupal_root, $dest_root, $dest_rel; |
global $tmp_dir, $drupal_root, $dest_root, $dest_rel; |
| 251 |
global $cvs, $tar, $gzip, $rm, $ln, $mkdir; |
global $tar, $gzip, $rm, $ln, $mkdir; |
| 252 |
global $license, $trans_install; |
global $license; |
| 253 |
|
|
| 254 |
// In Version Control API, item paths start with a slash. Remove that for CVS. |
$project_directory_item = versioncontrol_get_item( |
| 255 |
|
$repository, $project['directory'], array('label' => $label) |
| 256 |
|
); |
| 257 |
|
if (empty($project_directory_item)) { |
| 258 |
|
wd_err('ERROR: Could not retrieve project directory item.'); |
| 259 |
|
} |
| 260 |
|
|
| 261 |
|
// In Version Control API, item paths start with a slash. |
| 262 |
$relative_project_dir = escapeshellcmd(substr($project['directory'], 1)); |
$relative_project_dir = escapeshellcmd(substr($project['directory'], 1)); |
| 263 |
$uri = escapeshellcmd($project['uri']); |
$uri = escapeshellcmd($project['uri']); |
| 264 |
|
|
| 265 |
///TODO: drupal.org specific hack, get rid of it somehow |
///TODO: drupal.org specific hack, get rid of it somehow |
| 266 |
$is_core = ($repository['repo_id'] == 1 && $uri == 'drupal'); |
$is_core = ($site_name == 'drupal.org' && $repository['repo_id'] == 1 && $uri == 'drupal'); |
| 267 |
$is_contrib = ($repository['repo_id'] == 2); |
$is_contrib = ($site_name == 'drupal.org' && $repository['repo_id'] == 2); |
| 268 |
|
|
| 269 |
$id = $uri . '-' . $version; |
$id = $uri . '-' . $version; |
| 270 |
$view_link = l(t('view'), 'node/' . $release_nid); |
$view_link = l(t('view'), 'node/' . $release_nid); |
| 277 |
if ($is_contrib) { ///TODO: drupal.org specific hack, get rid of it somehow |
if ($is_contrib) { ///TODO: drupal.org specific hack, get rid of it somehow |
| 278 |
$export_dir = $tmp_dir . '/' . $relative_project_dir; |
$export_dir = $tmp_dir . '/' . $relative_project_dir; |
| 279 |
} |
} |
| 280 |
|
$success = versioncontrol_export_directory($repository, $project_directory_item, $export_dir); |
| 281 |
|
|
|
// Don't use drupal_exec() or return if this fails, we expect it to be empty. |
|
|
exec("$rm -rf $export_dir"); |
|
|
|
|
|
include_once(drupal_get_path('module', 'versioncontrol_cvs') .'/cvslib/cvslib.inc'); |
|
|
$success = cvslib_export( |
|
|
$export_dir, $repository['root'], $project['directory'], |
|
|
array('revision' => $label['name']) |
|
|
); |
|
| 282 |
if (!$success) { |
if (!$success) { |
| 283 |
wd_err("ERROR: %dir @ !labeltype %labelname could not be exported", array( |
wd_err('ERROR: %dir @ !labeltype %labelname could not be exported', array( |
| 284 |
'%dir' => $export_dir, |
'%dir' => $export_dir, |
| 285 |
'!labeltype' => ($label['type'] == VERSIONCONTROL_OPERATION_BRANCH) |
'!labeltype' => ($label['type'] == VERSIONCONTROL_OPERATION_BRANCH) |
| 286 |
? t('branch') |
? t('branch') |
| 305 |
// Fix any .info files. |
// Fix any .info files. |
| 306 |
foreach ($info_files as $file) { |
foreach ($info_files as $file) { |
| 307 |
if (!fix_info_file_version($file, $uri, $version)) { |
if (!fix_info_file_version($file, $uri, $version)) { |
| 308 |
wd_err("ERROR: Failed to update version in %file, aborting packaging", array('%file' => $file), $view_link); |
wd_err('ERROR: Failed to update version in %file, aborting packaging', |
| 309 |
|
array('%file' => $file), $view_link); |
| 310 |
return FALSE; |
return FALSE; |
| 311 |
} |
} |
| 312 |
} |
} |