49 require_once
"FIXMETOBERELATIVE/pathinclude.php";
52 require_once(
"$LIBDIR/lib_projxml.h.php");
53 require_once(
"$INCLUDEDIR/fm-paths.php");
56 Usage:
get-projects [-h] -f <file>
57 Where <file> is an uncompressed XML file, fully qualified
58 -h displays
this usage.
62 $XML_input_file = NULL;
64 for ($i = 1; $i < $argc; $i++) {
68 if (isset($argv[$i])) {
69 $XML_input_file = $argv[$i];
72 die(
"ERROR: Must specify an uncompressed filename after -f");
79 die(
"ERROR: Unknown argument: $argv[$i]\n$usage");
98 $yyyymmdd = date(
'Y-m-d');
99 $golden =
'/golden.' .
"$yyyymmdd" .
'/';
100 $dest_dir .= $golden;
101 $wget_logs = $dest_dir .
'wget-logs/';
102 $log_data = $dest_dir .
'Logs-Data/';
103 $input_files = $dest_dir .
'Input-files/';
106 if (! is_dir(
"$dest_dir")){
107 exec(
"mkdir -p $dest_dir", $dummy, $rval);
109 echo
"ERROR: can't create output directory: $dest_dir";
113 if (! is_dir($wget_logs)){
114 exec(
"mkdir -p $wget_logs", $dummy, $rval);
116 echo
"ERROR: can't create output directory: $wget_logs\n";
120 if (! is_dir($log_data)){
121 exec(
"mkdir -p $log_data", $dummy, $rval);
123 echo
"ERROR: can't create output directory: $log_data\n";
127 if (! is_dir($input_files)){
128 exec(
"mkdir -p $input_files", $dummy, $rval);
130 echo
"ERROR: can't create output directory: $input_files\n";
136 if (is_null($XML_input_file)){
137 echo
"Error: null input file\n";
146 $last = strrchr($XML_input_file,
".");
159 echo
"Processing Xml file $XML_input_file\n";
163 $fm_projects = array();
164 $fm_projects = read_pfile($XML_input_file);
169 $projects_skipped = 0;
170 foreach($fm_projects as $rank => $key){
171 foreach ($key as $name => $values){
180 $release_version_date
182 # 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";
185 if (($url_tgz ==
"") and ($url_bz2 ==
"") and ($url_zip ==
"")) {
186 $NoUrls = fopen(
"{$log_data}skipped_fmprojects",
'w') or
187 die("Can't open: $php_errormsg");
189 fwrite($NoUrls, "$rank $name $homepage $release_version\n")){
190 die(
"Can't write: $php_errormsg");
193 unset($fm_projects[
"$rank"]);
206 $skipped_uploads = array();
209 $uploads_scheduled = 0;
210 foreach ($fm_projects as $pkg_rank => $nkey){
211 foreach ($nkey as $pkg_name => $pkg_data){
226 $common_data = array (
239 echo
"Trying project #$pkg_rank $pkg_name at:\n";
240 if ($tgz_url !=
"") {
241 $cnt = array_unshift($common_data,$tgz_url);
242 $tupload = wget_url($pkg_rank, $pkg_name, $gzip, $common_data, $mode);
244 elseif ($bz2_url !=
"") {
245 $cnt = array_unshift($common_data,$bz2_url);
246 $tupload = wget_url($pkg_rank, $pkg_name, $bzip2, $common_data, $mode);
248 elseif ($zip_url !=
"") {
249 $cnt = array_unshift($common_data,$zip_url);
250 $tupload = wget_url($pkg_rank, $pkg_name, $zip1, $common_data, $mode);
252 if(is_null($tupload[
'Null'])){
253 echo
"Warning! There may have been an undetected error in the wget of $pkg_name\n";
254 echo
"Check the wget logs in $wget_logs\n";
256 if(!(is_null($tupload[
'Compressed']))){
257 $uploads[] = $tupload[
'Compressed'];
258 $uploads_scheduled++;
259 echo
"#$pkg_rank $pkg_name was downloaded and can be scheduled for an upload\n";
261 elseif(!(is_null($tupload[
'Uncompressed']))){
262 echo
"WARNING! did not get a compressed archive from wget\n";
263 echo
"Will Not upload $pkg_name\n";
264 $skipped_uploads[] = $tupload[
'Uncompressed'];
274 $skipped_up = count($skipped_uploads);
275 if ($skipped_up != 0){
276 echo
"Saving skipped uploads (downloaded files that were not compressed)\n";
278 "There were $skipped_up skipped uploads, see $log_data/skipped_uploads for details\n";
280 $SUP = fopen(
"$log_data/skipped_uploads",
'w')
281 or die("Can't open $log_data/skipped_uploads, $php_errormsg\n");
282 foreach($skipped_uploads as $skipped){
283 fwrite($SUP,
"$skipped\n")
284 or die("Can't write to $log_data/skipped_uploads, $php_errormsg\n");
293 create_cp2foss_ifile($uploads, "{$input_files}Freshmeat_to_Upload
");
315 function create_cp2foss_ifile($uploads, $filename){
317 $UPLOAD = fopen($filename, 'w') or
318 die("ERROR: can
't open $filename, $php_errormsg\n");
319 $upload_count = count($uploads);
320 for ($uc=0; $uc<$upload_count; $uc++){
321 $parms = parse_fm_input($uploads[$uc]);
333 // don't write an entry that has no archive path (wget either returned
335 if(!(isset($archive_path))){
339 $folder_path =
'-p Freshmeat';
341 $name =
"-n '$name-$version'";
343 $cp2foss_input =
"$folder_path $name -a $archive_path -d '$description' $alpha\n";
345 fwrite($UPLOAD, $cp2foss_input) or
346 die(
"Errors: can't write $php_error_msg\n");
362 function report($output_dir){
364 global $projects_skipped;
365 global $uploads_scheduled;
368 $skipped_path =
"{$output_dir}skipped_fmprojects";
370 if ($uploads_scheduled){
371 printf(
"There were %d projects scheduled for uploading\nSee the {$input_files}Freshmeat_to_Upload\nfile for details\n\n", $uploads_scheduled);
375 printf(
"There were %d projects downloaded\nSee the $output_dir for details\n\n", $uploads_scheduled);
377 if ($projects_skipped != 0){
379 "There were %d skipped projects for this run\nSee the {$output_dir}skipped_fmprojects file for details\n", $projects_skipped);
382 printf(
"There were %d skipped projects for this run\n", $projects_skipped);
383 echo (
"Skipped projects are projects that had no compressed downloadable archives\n");
385 echo
"To upload the files into the data-base run cp2foss using the Freshmeat_to_Upload file\n";
408 function wget_url($project_rank, $project_name, $ark_type, $proj_data, $mode){
425 $log_path =
"$wget_logs" .
"log.$project_name-" .
"$project_rank";
427 $wCmd .=
"$proxy" .
"wget -P $dest_dir -o $log_path $url ";
432 $lastline = system(
"$wCmd", $retval);
438 $upload[
'Compressed'] = NULL;
439 $upload[
'Null'] = NULL;
440 $upload[
'Uncompressed'] = NULL;
441 exec(
"$wCmd", $dummy, $retval);
443 $WGF = fopen (
"{$log_data}failed-wgets",
'a') or
444 die("Can't open: $php_errormsg\n");
445 if (-1 == fwrite($WGF, "$project_rank $project_name $url\n")) {
446 die(
"Can't write: $php_errormsg");
453 elseif ($retval == 0){
454 $archive_path = _getfmpath($log_path);
455 if (is_null($archive_path)){
456 echo
"Warning! returning NULL for an archive path\n";
463 $type = exec(
"file -b $archive_path", $dummy , $ret_val);
464 if (ereg(
'compressed data', $type)){
465 $upload[
'Compressed'] =
466 "'$project_rank' '$project_name' '$archive_path' '$short_desc' '$ver' '$ver_id' '$ver_date'";
469 $upload[
'Uncompressed'] =
"'$project_name' '$archive_path'";
471 $upload[
'Null'] =
true;
494 function _getfmpath($path){
501 $contents = file($path);
502 $size = count($contents);
503 $stat_line = $contents[$size-2];
504 if(ereg(
'^Removed ',$stat_line)){
507 $stat_line = $contents[$size-1];
512 if (ereg(
'ERROR 404:', $stat_line)){
513 echo
"ERROR 404 found in file $dir_entry\n";
514 echo
"Line was:\n$stat_line\n";
515 return($path_wanted);
517 elseif (ereg(
'ERROR 502:', $stat_line)){
518 echo
"ERROR 502 found in file $dir_entry\n$stat_line\n";
519 echo
"Line was:\n$stat_line\n";
520 return($path_wanted);
522 elseif (ereg(
'ERROR 503:', $stat_line)){
523 echo
"ERROR 503 found in file $dir_entry\n$stat_line\n";
524 echo
"Line was:\n$stat_line\n";
525 return($path_wanted);
527 elseif (ereg(
'ERROR 400:', $stat_line)){
528 echo
"ERROR 400 found in file $dir_entry\n$stat_line\n";
529 echo
"Line was:\n$stat_line\n";
530 return($path_wanted);
532 elseif (ereg(
'--no-check-certificate', $stat_line)){
533 echo
"ERROR Secure connect to sourceforge.net needed: in file $dir_entry\n";
534 echo
"Line was:\n$stat_line\n";
535 return($path_wanted);
539 $chunks = explode(
' ', $stat_line);
542 $stmp = ltrim($chunks[4],
'`');
544 $path_wanted = rtrim($stmp,
'\'');
547 return($path_wanted);
Usage()
Print Usage statement.
FUNCTION void usage(char *name)
if(!preg_match("/\s$projectGroup\s/", $groups) &&(posix_getgid() !=$gInfo[ 'gid']))
get monk license list of one specified uploadtree_id
list_t type structure used to keep various lists. (e.g. there are multiple lists).