60 require_once
"FIXMETOBERELATIVE/pathinclude.php";
63 require_once(
"$LIBDIR/lib_projxml.h.php");
64 require_once(
"$INCLUDEDIR/fm-paths.php");
67 Usage:
get-projects [-h] -f <file>
68 Where <file> is an uncompressed XML file, fully qualified
69 -h displays
this usage.
73 $XML_input_file = NULL;
75 for ($i = 1; $i < $argc; $i++) {
79 if (isset($argv[$i])) {
80 $XML_input_file = $argv[$i];
83 die(
"ERROR: Must specify an uncompressed filename after -f");
91 die(
"ERROR: Unknown argument: $argv[$i]\n$usage");
111 $yyyymmdd = date(
'Y-m-d');
112 $golden =
'/golden.' .
"$yyyymmdd" .
'/';
113 $dest_dir .= $golden;
114 $wget_logs = $dest_dir .
'wget-logs/';
115 $log_data = $dest_dir .
'Logs-Data/';
116 $input_files = $dest_dir .
'Input-files/';
119 if (! is_dir(
"$dest_dir")){
120 exec(
"mkdir -p $dest_dir", $dummy, $rval);
122 echo
"ERROR: can't create output directory: $dest_dir";
126 if (! is_dir($wget_logs)){
127 exec(
"mkdir -p $wget_logs", $dummy, $rval);
129 echo
"ERROR: can't create output directory: $wget_logs\n";
133 if (! is_dir($log_data)){
134 exec(
"mkdir -p $log_data", $dummy, $rval);
136 echo
"ERROR: can't create output directory: $log_data\n";
140 if (! is_dir($input_files)){
141 exec(
"mkdir -p $input_files", $dummy, $rval);
143 echo
"ERROR: can't create output directory: $input_files\n";
149 if (is_null($XML_input_file)){
150 echo
"Error: null input file\n";
159 $last = strrchr($XML_input_file,
".");
175 echo
"Processing Xml file $XML_input_file\n";
179 $fm_projects = array();
180 $fm_projects = read_pfile($XML_input_file);
185 $projects_skipped = 0;
186 foreach($fm_projects as $rank => $key){
187 foreach ($key as $name => $values){
196 $release_version_date
198 # echo "We got:NAME:$name\nTG:$url_tgz\nBZ:$url_bz2\nZ:$url_zip\nHM:$homepage\nDesc:$short_desc\nRV:$release_version\nVID:$release_version_id\nVD:$release_version_date\n\n"; 201 if (($url_tgz ==
"") and ($url_bz2 ==
"") and ($url_zip ==
"")) {
202 $NoUrls = fopen(
"{$log_data}skipped_fmprojects",
'w') or
203 die("Can't open: $php_errormsg");
205 fwrite($NoUrls, "$rank $name $homepage $release_version\n")){
206 die(
"Can't write: $php_errormsg");
209 unset($fm_projects[
"$rank"]);
222 $skipped_uploads = array();
225 $uploads_scheduled = 0;
226 foreach ($fm_projects as $pkg_rank => $nkey){
227 foreach ($nkey as $pkg_name => $pkg_data){
242 $common_data = array (
255 echo
"Trying project #$pkg_rank $pkg_name at:\n";
256 if ($tgz_url !=
"") {
257 $cnt = array_unshift($common_data,$tgz_url);
258 $tupload = wget_url($pkg_rank, $pkg_name, $gzip, $common_data, $mode);
260 elseif ($bz2_url !=
"") {
261 $cnt = array_unshift($common_data,$bz2_url);
262 $tupload = wget_url($pkg_rank, $pkg_name, $bzip2, $common_data, $mode);
264 elseif ($zip_url !=
"") {
265 $cnt = array_unshift($common_data,$zip_url);
266 $tupload = wget_url($pkg_rank, $pkg_name, $zip1, $common_data, $mode);
268 if(is_null($tupload[
'Null'])){
269 echo
"Warning! There may have been an undetected error in the wget of $pkg_name\n";
270 echo
"Check the wget logs in $wget_logs\n";
272 if(!(is_null($tupload[
'Compressed']))){
273 $uploads[] = $tupload[
'Compressed'];
274 $uploads_scheduled++;
275 echo
"#$pkg_rank $pkg_name was downloaded and can be scheduled for an upload\n";
277 elseif(!(is_null($tupload[
'Uncompressed']))){
278 echo
"WARNING! did not get a compressed archive from wget\n";
279 echo
"Will Not upload $pkg_name\n";
280 $skipped_uploads[] = $tupload[
'Uncompressed'];
290 $skipped_up = count($skipped_uploads);
291 if ($skipped_up != 0){
292 echo
"Saving skipped uploads (downloaded files that were not compressed)\n";
294 "There were $skipped_up skipped uploads, see $log_data/skipped_uploads for details\n";
296 $SUP = fopen(
"$log_data/skipped_uploads",
'w')
297 or die("Can't open $log_data/skipped_uploads, $php_errormsg\n");
298 foreach($skipped_uploads as $skipped){
299 fwrite($SUP,
"$skipped\n")
300 or die("Can't write to $log_data/skipped_uploads, $php_errormsg\n");
309 create_cp2foss_ifile($uploads, "{$input_files}Freshmeat_to_Upload
"); 331 function create_cp2foss_ifile($uploads, $filename){ 333 $UPLOAD = fopen($filename, 'w') or 334 die("ERROR: can
't open $filename, $php_errormsg\n"); 335 $upload_count = count($uploads); 336 for ($uc=0; $uc<$upload_count; $uc++){ 337 $parms = parse_fm_input($uploads[$uc]); 349 // don't write an entry that has no archive path (wget either returned
351 if(!(isset($archive_path))){
355 $folder_path =
'-p Freshmeat';
357 $name =
"-n '$name-$version'";
359 $cp2foss_input =
"$folder_path $name -a $archive_path -d '$description' $alpha\n";
361 fwrite($UPLOAD, $cp2foss_input) or
362 die("Errors: can't write $php_error_msg\n");
378 function report($output_dir){
380 global $projects_skipped;
381 global $uploads_scheduled;
384 $skipped_path =
"{$output_dir}skipped_fmprojects";
386 if ($uploads_scheduled){
387 printf(
"There were %d projects scheduled for uploading\nSee the {$input_files}Freshmeat_to_Upload\nfile for details\n\n", $uploads_scheduled);
391 printf(
"There were %d projects downloaded\nSee the $output_dir for details\n\n", $uploads_scheduled);
393 if ($projects_skipped != 0){
395 "There were %d skipped projects for this run\nSee the {$output_dir}skipped_fmprojects file for details\n", $projects_skipped);
398 printf(
"There were %d skipped projects for this run\n", $projects_skipped);
399 echo (
"Skipped projects are projects that had no compressed downloadable archives\n");
401 echo
"To upload the files into the data-base run cp2foss using the Freshmeat_to_Upload file\n";
424 function wget_url($project_rank, $project_name, $ark_type, $proj_data, $mode){
441 $log_path =
"$wget_logs" .
"log.$project_name-" .
"$project_rank";
443 $wCmd .=
"$proxy" .
"wget -P $dest_dir -o $log_path $url ";
448 $lastline = system(
"$wCmd", $retval);
454 $upload[
'Compressed'] = NULL;
455 $upload[
'Null'] = NULL;
456 $upload[
'Uncompressed'] = NULL;
457 exec(
"$wCmd", $dummy, $retval);
459 $WGF = fopen (
"{$log_data}failed-wgets",
'a') or
460 die("Can't open: $php_errormsg\n");
461 if (-1 == fwrite($WGF, "$project_rank $project_name $url\n")) {
462 die(
"Can't write: $php_errormsg");
469 elseif ($retval == 0){
470 $archive_path = _getfmpath($log_path);
471 if (is_null($archive_path)){
472 echo
"Warning! returning NULL for an archive path\n";
479 $type = exec(
"file -b $archive_path", $dummy , $ret_val);
480 if (ereg(
'compressed data', $type)){
481 $upload[
'Compressed'] =
482 "'$project_rank' '$project_name' '$archive_path' '$short_desc' '$ver' '$ver_id' '$ver_date'";
483 $upload[
'Null'] = True;
486 $upload[
'Uncompressed'] =
"'$project_name' '$archive_path'";
487 $upload[
'Null'] = True;
511 function _getfmpath($path){
518 $contents = file($path);
519 $size = count($contents);
520 $stat_line = $contents[$size-2];
521 if(ereg(
'^Removed ',$stat_line)){
524 $stat_line = $contents[$size-1];
529 if (ereg(
'ERROR 404:', $stat_line)){
530 echo
"ERROR 404 found in file $dir_entry\n";
531 echo
"Line was:\n$stat_line\n";
532 return($path_wanted);
534 elseif (ereg(
'ERROR 502:', $stat_line)){
535 echo
"ERROR 502 found in file $dir_entry\n$stat_line\n";
536 echo
"Line was:\n$stat_line\n";
537 return($path_wanted);
539 elseif (ereg(
'ERROR 503:', $stat_line)){
540 echo
"ERROR 503 found in file $dir_entry\n$stat_line\n";
541 echo
"Line was:\n$stat_line\n";
542 return($path_wanted);
544 elseif (ereg(
'ERROR 400:', $stat_line)){
545 echo
"ERROR 400 found in file $dir_entry\n$stat_line\n";
546 echo
"Line was:\n$stat_line\n";
547 return($path_wanted);
549 elseif (ereg(
'--no-check-certificate', $stat_line)){
551 "ERROR Secure connect to sourceforge.net needed: in file $dir_entry\n";
552 echo
"Line was:\n$stat_line\n";
553 return($path_wanted);
557 $chunks = explode(
' ', $stat_line);
560 $stmp = ltrim($chunks[4],
'`');
562 $path_wanted = rtrim($stmp,
'\'');
565 return($path_wanted);
if(!preg_match("/\s$projectGroup\s/", $groups)&&(posix_getgid()!=$gInfo['gid']))
get monk license list of one specified uploadtree_id
Usage()
Print Usage statement.
list_t type structure used to keep various lists. (e.g. there are multiple lists).
FUNCTION void usage(char *name)