name; $a['description'] = $json->description; $a['version'] = $json->{'dist-tags'}->latest; if (property_exists($json->versions->$a['version'],"license")) { if (property_exists($json->versions->$a['version']->license,"type")) { $a['license'] = $json->versions->$a['version']->license->type; } else { $a['license'] = $json->versions->$a['version']->license; } } $a['repo'] = $json->versions->$a['version']->repository->url; if (property_exists($json->versions->$a['version'],"files")) { $a['files'] = $json->versions->$a['version']->files; } $a['tarball'] = $json->versions->$a['version']->dist->tarball; echo print_r($a,true)."\n"; if(file_exists("/home/jsmith/Git/nodejs-$fixed_name/")) { die("Directory already exists!\n"); } else { mkdir("/home/jsmith/Git/nodejs-$fixed_name"); } chdir("/home/jsmith/Git/nodejs-$fixed_name"); if (!file_exists("/home/jsmith/Git/nodejs-$fixed_name/nodejs-$fixed_name.spec")) { exec("/usr/bin/rpmdev-newspec -t nodejs -o nodejs-$fixed_name.spec"); } // fix up repo urls that don't start with https or http $scheme = parse_url($a['repo'],PHP_URL_SCHEME); $host = parse_url($a['repo'],PHP_URL_HOST); if ($scheme != 'https' && $scheme != 'http' && $host == 'github.com') { $url_parts = parse_url($a['repo']); #echo print_r($url_parts,true)."\n\n"; $new_url = "https://".$url_parts['host'].$url_parts['path']; echo "Fixing URL: $new_url\n"; $a['repo'] = $new_url; } $user = parse_url($a['repo'],PHP_URL_USER); $spec = file_get_contents("/home/jsmith/Git/nodejs-$fixed_name/nodejs-$fixed_name.spec"); $name_regex = '/%global packagename /'; $output = preg_replace($name_regex,"%global packagename $package",$spec); $version_regex = '/Version:/'; $output = preg_replace($version_regex,"Version:\t".$a['version'],$output); $summary_regex = '/Summary:\t/'; $output = preg_replace($summary_regex,"Summary:\t".$a['description'],$output,-1,$count); $license_regex = '/License:/'; $output = preg_replace($license_regex,"License:\t".$a['license'],$output,-1,$count); $url_regex = '/URL:/'; $output = preg_replace($url_regex,"URL:\t\t".$a['repo'],$output,-1,$count); $desc_regex = '/%description/'; $output = preg_replace($desc_regex,"%description\n".$a['description'],$output,-1,$count); if ($count) echo $output; else echo "No match\n"; file_put_contents("/home/jsmith/Git/nodejs-$fixed_name/nodejs-$fixed_name.spec",$output); exec("spectool -g /home/jsmith/Git/nodejs-$fixed_name/nodejs-$fixed_name.spec"); if (preg_match('|/sindresorhus/|',$a['repo'])) { exec("sh /home/jsmith/Build/SOURCES/dl-testjs.sh"); } elseif (preg_match('|/babel/|',$a['repo'])) { copy("/home/jsmith/Build/SOURCES/dl-babel-files.sh","/home/jsmith/Git/nodejs-$fixed_name/dl-babel-files.sh"); } else { exec("sh /home/jsmith/Build/SOURCES/dl-tests.sh"); } } ?>