File scripts/worker.php changed (mode: 100644) (index f1da158..5f0db32) |
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
370 |
370 |
. 'export job_id=' . escapeshellarg($job['id']) . "\n" |
. 'export job_id=' . escapeshellarg($job['id']) . "\n" |
371 |
371 |
. 'export repo_username=' . escapeshellarg(isset($job['repo_username']) ? $job['repo_username'] : '') . "\n" |
. 'export repo_username=' . escapeshellarg(isset($job['repo_username']) ? $job['repo_username'] : '') . "\n" |
372 |
372 |
. 'export job_uid=' . (isset($job['uid']) ? $job['uid'] : '') . "\n" |
. 'export job_uid=' . (isset($job['uid']) ? $job['uid'] : '') . "\n" |
|
373 |
|
. 'export job_url=' . (isset($job['url']) ? $job['url'] : '') . "\n" |
|
374 |
|
. 'export job_head=' . (isset($job['head']) ? $job['head'] : '') . "\n" |
373 |
375 |
. 'export env=' . escapeshellarg($job['env']) . "\n" |
. 'export env=' . escapeshellarg($job['env']) . "\n" |
374 |
376 |
. 'export env_distro=' . escapeshellarg($job['env_distro']) . "\n" |
. 'export env_distro=' . escapeshellarg($job['env_distro']) . "\n" |
375 |
377 |
. 'export env_major=' . escapeshellarg($job['env_major']) . "\n" |
. 'export env_major=' . escapeshellarg($job['env_major']) . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
558 |
560 |
. ' xecho "rg_extract_rpm_info: dir=${dir} [`date`]"' . "\n" |
. ' xecho "rg_extract_rpm_info: dir=${dir} [`date`]"' . "\n" |
559 |
561 |
. ' spec_file=`find "${dir}" -type f -iname \'*.spec\' | head -n1`' . "\n" |
. ' spec_file=`find "${dir}" -type f -iname \'*.spec\' | head -n1`' . "\n" |
560 |
562 |
. ' if [ "${spec_file}" = "" ]; then' . "\n" |
. ' if [ "${spec_file}" = "" ]; then' . "\n" |
561 |
|
. ' xecho " Cannot find any .spec file in ${dir}!" > ~/rg_op.err' . "\n" |
|
|
563 |
|
. ' xecho " Cannot find any .spec file in ${dir}!"' . "\n" |
|
564 |
|
. ' ls -l "${dir}"' . "\n" |
562 |
565 |
. ' return' . "\n" |
. ' return' . "\n" |
563 |
566 |
. ' fi' . "\n" |
. ' fi' . "\n" |
564 |
567 |
. "\n" |
. "\n" |
|
... |
... |
function start_worker($job) |
1288 |
1291 |
|
|
1289 |
1292 |
// Creating build.sh file |
// Creating build.sh file |
1290 |
1293 |
// TODO: document how a user can add labels in configure or make |
// TODO: document how a user can add labels in configure or make |
1291 |
|
$s = '#!/bin/bash' . "\n"; |
|
|
1294 |
|
$s = '#!/bin/bash' . "\n\n"; |
1292 |
1295 |
$s .= 'export RG_LABELS=/mnt/status/RG_LABELS' . "\n\n"; |
$s .= 'export RG_LABELS=/mnt/status/RG_LABELS' . "\n\n"; |
1293 |
|
$s .= "\n"; |
|
1294 |
1296 |
|
|
1295 |
1297 |
// build.sh: secrets |
// build.sh: secrets |
1296 |
1298 |
if (isset($job['secrets']) && !empty($job['secrets'])) { |
if (isset($job['secrets']) && !empty($job['secrets'])) { |
|
... |
... |
function start_worker($job) |
1306 |
1308 |
|
|
1307 |
1309 |
$s .= 'cd /mnt/target' . "\n\n"; |
$s .= 'cd /mnt/target' . "\n\n"; |
1308 |
1310 |
|
|
1309 |
|
if (isset($job['url'])) { |
|
1310 |
|
$s .= 'git branch -f rgw ' . escapeshellarg($job['head']) . " &>/mnt/status/git.branch.log\n\n"; |
|
1311 |
|
$s .= 'git checkout rgw' . " &>/mnt/status/git.checkout.log\n\n"; |
|
1312 |
|
} |
|
|
1311 |
|
// To be able to run 'configure' without './' |
|
1312 |
|
$s .= 'export PATH="${PATH}:."' . "\n\n"; |
1313 |
1313 |
|
|
1314 |
1314 |
if (!isset($job['cmds'])) |
if (!isset($job['cmds'])) |
1315 |
1315 |
$job['cmds'] = array(); |
$job['cmds'] = array(); |
|
... |
... |
function start_worker($job) |
1335 |
1335 |
. ' >>/mnt/status/RG_LABELS' . "\n"; |
. ' >>/mnt/status/RG_LABELS' . "\n"; |
1336 |
1336 |
|
|
1337 |
1337 |
$s .= 'date +%s > ' . $prefix . '.start' . "\n" |
$s .= 'date +%s > ' . $prefix . '.start' . "\n" |
1338 |
|
. '# i: ' . json_encode($i) . "\n" |
|
1339 |
1338 |
. 'echo "Executing [' . $i['cmd'] . ']"' . "\n" |
. 'echo "Executing [' . $i['cmd'] . ']"' . "\n" |
1340 |
1339 |
. '(' . $i['cmd'] . ') &>' . $prefix . '.log' . "\n" |
. '(' . $i['cmd'] . ') &>' . $prefix . '.log' . "\n" |
1341 |
1340 |
. 'E=${?}' . "\n" |
. 'E=${?}' . "\n" |
|
... |
... |
function start_worker($job) |
1405 |
1404 |
// TODO: we should not wait for net forever |
// TODO: we should not wait for net forever |
1406 |
1405 |
$r = @file_put_contents($job['main'] . '/root/rg.sh', |
$r = @file_put_contents($job['main'] . '/root/rg.sh', |
1407 |
1406 |
'#!/bin/bash' . "\n" |
'#!/bin/bash' . "\n" |
|
1407 |
|
. "\n" |
1408 |
1408 |
. 'echo "This is the rg.sh script..."' . "\n" |
. 'echo "This is the rg.sh script..."' . "\n" |
1409 |
1409 |
. "\n" |
. "\n" |
1410 |
1410 |
. 'source /mnt/build_tools.sh' . "\n" |
. 'source /mnt/build_tools.sh' . "\n" |
|
... |
... |
function start_worker($job) |
1461 |
1461 |
. 'fi' . "\n" |
. 'fi' . "\n" |
1462 |
1462 |
. "\n" |
. "\n" |
1463 |
1463 |
. 'while [ "${ERR}" = "" ]; do' . "\n" |
. 'while [ "${ERR}" = "" ]; do' . "\n" |
1464 |
|
. ' echo; echo "`date`: Running build.sh script"' . "\n" |
|
1465 |
|
. ' date +%s > /mnt/status/build.sh.start' . "\n" // TODO: not read and not exposed? |
|
1466 |
|
. ' su - build -c "bash /mnt/build.sh" &>/mnt/status/build.log' . "\n" |
|
1467 |
|
. ' E=${?}' . "\n" |
|
1468 |
|
. ' date +%s > /mnt/status/build.sh.stop' . "\n" // TODO: not read and not exposed? |
|
1469 |
|
. ' if [ "${E}" != "0" ]; then' . "\n" |
|
1470 |
|
. ' echo "`date`: DEBUG: build.sh exited with code ${E}"' . "\n" |
|
1471 |
|
. ' ERR="build.sh returned ${E}"' . "\n" |
|
1472 |
|
. ' break' . "\n" |
|
|
1464 |
|
. ' if [ "${job_url}" != "" ]; then' . "\n" |
|
1465 |
|
. ' echo; echo "`date`: Checkout"' . "\n" |
|
1466 |
|
. ' su - build -c "cd /mnt/target && git branch -f rgw ${job_head} && git checkout rgw"' . "\n" |
|
1467 |
|
. ' if [ "${?}" != "0" ]; then' . "\n" |
|
1468 |
|
. ' ERR="cannot checkout"' . "\n" |
|
1469 |
|
. ' break' . "\n" |
|
1470 |
|
. ' fi' . "\n" |
1473 |
1471 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1474 |
1472 |
. "\n" |
. "\n" |
1475 |
|
. ' # Now we may have the .spec file, we can try to extract info' . "\n" |
|
1476 |
|
. ' rg_extract_rpm_info /mnt/target || break' . "\n" |
|
|
1473 |
|
. ' # Extract .spec file info' . "\n" |
|
1474 |
|
. ' rg_extract_rpm_info /mnt/target' . "\n" |
1477 |
1475 |
. ' if [ "${spec_deps}" != "" ]; then' . "\n" |
. ' if [ "${spec_deps}" != "" ]; then' . "\n" |
1478 |
1476 |
. ' echo; echo "`date`: Installing dependencies [${spec_deps}]"' . "\n" |
. ' echo; echo "`date`: Installing dependencies [${spec_deps}]"' . "\n" |
1479 |
1477 |
. ' export DEBIAN_FRONTEND=noninteractive' . "\n" |
. ' export DEBIAN_FRONTEND=noninteractive' . "\n" |
|
... |
... |
function start_worker($job) |
1485 |
1483 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1486 |
1484 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1487 |
1485 |
. "\n" |
. "\n" |
|
1486 |
|
. ' echo; echo "`date`: Running build.sh script"' . "\n" |
|
1487 |
|
. ' date +%s > /mnt/status/build.sh.start' . "\n" // TODO: not read and not exposed? |
|
1488 |
|
. ' su - build -c "bash /mnt/build.sh" &>/mnt/status/build.log' . "\n" |
|
1489 |
|
. ' E=${?}' . "\n" |
|
1490 |
|
. ' date +%s > /mnt/status/build.sh.stop' . "\n" // TODO: not read and not exposed? |
|
1491 |
|
. ' if [ "${E}" != "0" ]; then' . "\n" |
|
1492 |
|
. ' echo "`date`: DEBUG: build.sh exited with code ${E}"' . "\n" |
|
1493 |
|
. ' ERR="build.sh returned ${E}"' . "\n" |
|
1494 |
|
. ' break' . "\n" |
|
1495 |
|
. ' fi' . "\n" |
|
1496 |
|
. "\n" |
1488 |
1497 |
. ' echo; echo "`date`: Running build_rpms.sh script"' . "\n" |
. ' echo; echo "`date`: Running build_rpms.sh script"' . "\n" |
1489 |
1498 |
. ' date +%s > /mnt/T_RPMS_START' . "\n" |
. ' date +%s > /mnt/T_RPMS_START' . "\n" |
1490 |
1499 |
. ' su - build -c "bash /mnt/build_rpms.sh" &>/mnt/status/build_rpms.log' . "\n" |
. ' su - build -c "bash /mnt/build_rpms.sh" &>/mnt/status/build_rpms.log' . "\n" |