File scripts/worker.php changed (mode: 100644) (index f7790f9..85e16eb) |
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
527 |
527 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
528 |
528 |
. ' local pkg_list_file=${1}; shift' . "\n" |
. ' local pkg_list_file=${1}; shift' . "\n" |
529 |
529 |
. "\n" |
. "\n" |
530 |
|
. ' rg_notify "rg_rpm_sign: pkg_list_file=${pkg_list_file} key=repo_id-${pkg_repo_id} dir=${dir} [`date`]"' . "\n" |
|
|
530 |
|
. ' rg_notify "rg_rpm_sign: pkg_list_file=${pkg_list_file} key=repo_id-${pkg_repo_id} dir=${dir}"' . "\n" |
531 |
531 |
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
532 |
532 |
. ' rg_notify " No packages available."' . "\n" |
. ' rg_notify " No packages available."' . "\n" |
533 |
533 |
. ' return 0' . "\n" |
. ' return 0' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
600 |
600 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
601 |
601 |
. ' local pkg_list_file=${1}; shift' . "\n" |
. ' local pkg_list_file=${1}; shift' . "\n" |
602 |
602 |
. "\n" |
. "\n" |
603 |
|
. ' rg_notify "rg_deb_sign: pkg_list_file=${pkg_list_file} key=repo_id-${pkg_repo_id} dir=${dir} [`date`]"' . "\n" |
|
|
603 |
|
. ' rg_notify "rg_deb_sign: pkg_list_file=${pkg_list_file} key=repo_id-${pkg_repo_id} dir=${dir}"' . "\n" |
604 |
604 |
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
605 |
605 |
. ' rg_notify " No packages available."' . "\n" |
. ' rg_notify " No packages available."' . "\n" |
606 |
606 |
. ' return 0' . "\n" |
. ' return 0' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
626 |
626 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
627 |
627 |
. ' local pkg_list_file=${1}; shift' . "\n" |
. ' local pkg_list_file=${1}; shift' . "\n" |
628 |
628 |
. "\n" |
. "\n" |
629 |
|
. ' rg_notify "rg_rpm_create_list: pkg_list_file=${pkg_list_file} dir=${dir} [`date`]"' . "\n" |
|
|
629 |
|
. ' rg_notify "rg_rpm_create_list: pkg_list_file=${pkg_list_file} dir=${dir}"' . "\n" |
630 |
630 |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
631 |
631 |
. ' rg_notify_err " Dir ${dir} not found."' . "\n" |
. ' rg_notify_err " Dir ${dir} not found."' . "\n" |
632 |
632 |
. ' return 0' . "\n" |
. ' return 0' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
644 |
644 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
645 |
645 |
. ' local pkg_list_file=${1}; shift' . "\n" |
. ' local pkg_list_file=${1}; shift' . "\n" |
646 |
646 |
. "\n" |
. "\n" |
647 |
|
. ' rg_notify "rg_deb_create_deb_list: pkg_list_file=${pkg_list_file} dir=${dir} [`date`]"' . "\n" |
|
|
647 |
|
. ' rg_notify "rg_deb_create_deb_list: pkg_list_file=${pkg_list_file} dir=${dir}"' . "\n" |
648 |
648 |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
649 |
649 |
. ' rg_notify " Dir ${dir} not found."' . "\n" |
. ' rg_notify " Dir ${dir} not found."' . "\n" |
650 |
650 |
. ' return 0' . "\n" |
. ' return 0' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
662 |
662 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
663 |
663 |
. ' local file=${1}; shift' . "\n" |
. ' local file=${1}; shift' . "\n" |
664 |
664 |
. "\n" |
. "\n" |
665 |
|
. ' rg_notify "rg_create_list: file=${file} dir=${dir} [`date`]"' . "\n" |
|
|
665 |
|
. ' rg_notify "rg_create_list: file=${file} dir=${dir}"' . "\n" |
666 |
666 |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
667 |
667 |
. ' rg_notify " Dir ${dir} not found."' . "\n" |
. ' rg_notify " Dir ${dir} not found."' . "\n" |
668 |
668 |
. ' return 0' . "\n" |
. ' return 0' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
682 |
682 |
. ' local pkg_list_file=${1}; shift' . "\n" |
. ' local pkg_list_file=${1}; shift' . "\n" |
683 |
683 |
. ' local oldpackagedirs=${1}; shift' . "\n" |
. ' local oldpackagedirs=${1}; shift' . "\n" |
684 |
684 |
. "\n" |
. "\n" |
685 |
|
. ' rg_notify "rg_rpm_createrepo dir=${dir} pkg_list_file=${pkg_list_file} oldpackagedirs=${oldpackagedirs} [`date`]"' . "\n" |
|
|
685 |
|
. ' rg_notify "rg_rpm_createrepo dir=${dir} pkg_list_file=${pkg_list_file} oldpackagedirs=${oldpackagedirs}"' . "\n" |
686 |
686 |
. ' rm -rf "${dir}/.repodata"' . "\n" |
. ' rm -rf "${dir}/.repodata"' . "\n" |
687 |
687 |
. "\n" |
. "\n" |
688 |
688 |
. ' local extra_paras=""' . "\n" |
. ' local extra_paras=""' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
713 |
713 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
714 |
714 |
. "\n" |
. "\n" |
715 |
715 |
. ' rg_notify "Extracting .spec info"' . "\n" |
. ' rg_notify "Extracting .spec info"' . "\n" |
716 |
|
. ' rg_notify "rg_rpm_extract_info: dir=${dir} [`date`]"' . "\n" |
|
|
716 |
|
. ' rg_notify "rg_rpm_extract_info: dir=${dir}"' . "\n" |
717 |
717 |
. ' spec_file=`find "${dir}" -iname \'*.spec\' -type f -printf "%d %p\n" | sort -n | head -n1 | awk \'{print $2}\'`' . "\n" |
. ' spec_file=`find "${dir}" -iname \'*.spec\' -type f -printf "%d %p\n" | sort -n | head -n1 | awk \'{print $2}\'`' . "\n" |
718 |
718 |
. ' if [ "${spec_file}" = "" ]; then' . "\n" |
. ' if [ "${spec_file}" = "" ]; then' . "\n" |
719 |
719 |
. ' rg_notify " Cannot find any .spec file in ${dir}!"' . "\n" |
. ' rg_notify " Cannot find any .spec file in ${dir}!"' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
856 |
856 |
. ' break' . "\n" |
. ' break' . "\n" |
857 |
857 |
. ' done' . "\n" |
. ' done' . "\n" |
858 |
858 |
. ' cd "${old_dir}"' . "\n" |
. ' cd "${old_dir}"' . "\n" |
859 |
|
. ' xecho "Done E=${E}"' . "\n" |
|
|
859 |
|
. ' rg_notify "Done E=${E}"' . "\n" |
860 |
860 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
861 |
861 |
. ' return ${E}' . "\n" |
. ' return ${E}' . "\n" |
862 |
862 |
. '}' . "\n" |
. '}' . "\n" |
|
... |
... |
function start_worker($job) |
1712 |
1712 |
. ' >>/mnt/status/RG_LABELS' . "\n"; |
. ' >>/mnt/status/RG_LABELS' . "\n"; |
1713 |
1713 |
|
|
1714 |
1714 |
$s .= 'date +%s > ' . $prefix . '.start' . "\n" |
$s .= 'date +%s > ' . $prefix . '.start' . "\n" |
1715 |
|
. 'echo "Executing [' . $i['cmd'] . ']"' . "\n" |
|
|
1715 |
|
. 'rg_notify "Executing [' . $i['cmd'] . ']"' . "\n" |
1716 |
1716 |
. '(' . $i['cmd'] . ') &>' . $prefix . '.log' . "\n" |
. '(' . $i['cmd'] . ') &>' . $prefix . '.log' . "\n" |
1717 |
1717 |
. 'E=${?}' . "\n" |
. 'E=${?}' . "\n" |
1718 |
1718 |
. 'echo ${E} > ' . $prefix . ".status\n" |
. 'echo ${E} > ' . $prefix . ".status\n" |
1719 |
1719 |
. 'date +%s > ' . $prefix . '.done' . "\n" |
. 'date +%s > ' . $prefix . '.done' . "\n" |
1720 |
1720 |
. 'if [ "${E}" != "0" ]; then' . "\n" |
. 'if [ "${E}" != "0" ]; then' . "\n" |
1721 |
|
. ' echo "Command failed with code ${E}"' . "\n" |
|
|
1721 |
|
. ' rg_notify "Command failed with code ${E}"' . "\n" |
1722 |
1722 |
. $lnok |
. $lnok |
1723 |
1723 |
. ($i['abort'] ? ' exit ${E}' . "\n" : '') |
. ($i['abort'] ? ' exit ${E}' . "\n" : '') |
1724 |
1724 |
. 'else' . "\n" |
. 'else' . "\n" |
|
... |
... |
function start_worker($job) |
1834 |
1834 |
. 'sysctl kernel.dmesg_restrict=1' . "\n" |
. 'sysctl kernel.dmesg_restrict=1' . "\n" |
1835 |
1835 |
. "\n" |
. "\n" |
1836 |
1836 |
. '# Disabling root login' . "\n" |
. '# Disabling root login' . "\n" |
1837 |
|
//TODO . 'chage -E 0 root' . "\n" |
|
|
1837 |
|
. 'chage -E 0 root' . "\n" |
1838 |
1838 |
. 'if [ "${?}" != "0" ]; then' . "\n" |
. 'if [ "${?}" != "0" ]; then' . "\n" |
1839 |
1839 |
. ' ERR="cannot disable root account"' . "\n" |
. ' ERR="cannot disable root account"' . "\n" |
1840 |
1840 |
. 'fi' . "\n" |
. 'fi' . "\n" |
|
... |
... |
function start_worker($job) |
1852 |
1852 |
. 'while [ "${ERR}" = "" ]; do' . "\n" |
. 'while [ "${ERR}" = "" ]; do' . "\n" |
1853 |
1853 |
. ' if [ "${job_url}" != "" ]; then' . "\n" |
. ' if [ "${job_url}" != "" ]; then' . "\n" |
1854 |
1854 |
. ' rg_notify "Checkout..."' . "\n" |
. ' rg_notify "Checkout..."' . "\n" |
1855 |
|
. ' echo; echo "`date`: Checkout"' . "\n" |
|
1856 |
1855 |
. ' su - build -c "cd /mnt/target/source && git branch -f rgw ${job_head} && git checkout --force rgw" >/mnt/status/checkout 2>&1' . "\n" |
. ' su - build -c "cd /mnt/target/source && git branch -f rgw ${job_head} && git checkout --force rgw" >/mnt/status/checkout 2>&1' . "\n" |
1857 |
1856 |
. ' if [ "${?}" != "0" ]; then' . "\n" |
. ' if [ "${?}" != "0" ]; then' . "\n" |
1858 |
|
. ' sleep 3' . "\n" |
|
1859 |
|
. ' continue' . "\n" |
|
1860 |
1857 |
. ' ERR="cannot checkout: $(< /mnt/status/checkout)"' . "\n" |
. ' ERR="cannot checkout: $(< /mnt/status/checkout)"' . "\n" |
1861 |
1858 |
. ' break' . "\n" |
. ' break' . "\n" |
1862 |
1859 |
. ' fi' . "\n" |
. ' fi' . "\n" |
|
... |
... |
function start_worker($job) |
1870 |
1867 |
. ' esac' . "\n" |
. ' esac' . "\n" |
1871 |
1868 |
. "\n" |
. "\n" |
1872 |
1869 |
. ' if [ "${pkg_deps}" != "" ]; then' . "\n" |
. ' if [ "${pkg_deps}" != "" ]; then' . "\n" |
1873 |
|
. ' echo; echo "`date`: Installing dependencies [${pkg_deps}]"' . "\n" |
|
|
1870 |
|
. ' rg_notify "Installing dependencies [${pkg_deps}]"' . "\n" |
|
1871 |
|
. ' final=""' . "\n" |
1874 |
1872 |
. ' for p in ${pkg_deps}; do' . "\n" |
. ' for p in ${pkg_deps}; do' . "\n" |
1875 |
1873 |
. ' if [[ ${p} =~ :// ]]; then' . "\n" |
. ' if [[ ${p} =~ :// ]]; then' . "\n" |
1876 |
1874 |
. ' rg_notify_warn "We do not allow remote packages for security reasons"' . "\n" // TODO: the net is already disabled; only for user! |
. ' rg_notify_warn "We do not allow remote packages for security reasons"' . "\n" // TODO: the net is already disabled; only for user! |
|
... |
... |
function start_worker($job) |
1878 |
1876 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1879 |
1877 |
. ' if [ -r "/etc/rgw/pkg/${p}" ]; then' . "\n" |
. ' if [ -r "/etc/rgw/pkg/${p}" ]; then' . "\n" |
1880 |
1878 |
. ' rg_notify "Package ${p} was already installed by rgw"' . "\n" |
. ' rg_notify "Package ${p} was already installed by rgw"' . "\n" |
1881 |
|
. ' else' . "\n" |
|
1882 |
|
. ' rg_notify "Installing package ${p}"' . "\n" |
|
1883 |
|
. ' ${rg_pkg_cmd} "${p}" 2>/tmp/install_pkg.err' . "\n" |
|
1884 |
|
. ' [ "${?}" = "0" ] || rg_notify_warn "Cannot install ${p}: "$(< /tmp/install_pkg.err)' . "\n" |
|
|
1879 |
|
. ' continue' . "\n" |
1885 |
1880 |
. ' fi' . "\n" |
. ' fi' . "\n" |
|
1881 |
|
. ' final+=" ${p}"' . "\n" |
1886 |
1882 |
. ' done' . "\n" |
. ' done' . "\n" |
|
1883 |
|
. ' rg_notify "Installing package(s) ${final}"' . "\n" |
|
1884 |
|
. ' ${rg_pkg_cmd} ${final} 2>/tmp/install_pkg.err' . "\n" |
|
1885 |
|
. ' [ "${?}" = "0" ] || rg_notify_warn "Cannot install ${final}: "$(< /tmp/install_pkg.err)' . "\n" |
|
1886 |
|
. ' # we ignore errors here' . "\n" |
1887 |
1887 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1888 |
1888 |
. "\n" |
. "\n" |
1889 |
1889 |
. ' rg_notify "Starting build.sh script"' . "\n" |
. ' rg_notify "Starting build.sh script"' . "\n" |
1890 |
|
. ' echo; echo "`date`: Running build.sh script"' . "\n" |
|
1891 |
1890 |
. ' date +%s > /mnt/status/build.sh.start' . "\n" // TODO: not read and not exposed? |
. ' date +%s > /mnt/status/build.sh.start' . "\n" // TODO: not read and not exposed? |
1892 |
1891 |
. ' su - build -c "bash /mnt/build.sh" &>/mnt/status/build.log' . "\n" |
. ' su - build -c "bash /mnt/build.sh" &>/mnt/status/build.log' . "\n" |
1893 |
1892 |
. ' E=${?}' . "\n" |
. ' E=${?}' . "\n" |
1894 |
1893 |
. ' date +%s > /mnt/status/build.sh.stop' . "\n" // TODO: not read and not exposed? |
. ' date +%s > /mnt/status/build.sh.stop' . "\n" // TODO: not read and not exposed? |
1895 |
1894 |
. ' rg_notify "build.sh finished with code ${E}"' . "\n" |
. ' rg_notify "build.sh finished with code ${E}"' . "\n" |
1896 |
1895 |
. ' if [ "${E}" != "0" ]; then' . "\n" |
. ' if [ "${E}" != "0" ]; then' . "\n" |
1897 |
|
. ' echo "`date`: DEBUG: build.sh exited with code ${E}"' . "\n" |
|
|
1896 |
|
. ' rg_notify_warn "DEBUG: build.sh exited with code ${E}"' . "\n" |
1898 |
1897 |
. ' ERR="build.sh returned ${E}"' . "\n" |
. ' ERR="build.sh returned ${E}"' . "\n" |
1899 |
1898 |
. ' break' . "\n" |
. ' break' . "\n" |
1900 |
1899 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1901 |
1900 |
. "\n" |
. "\n" |
1902 |
1901 |
. ' rg_notify "Starting build_rpms/debs.sh script"' . "\n" |
. ' rg_notify "Starting build_rpms/debs.sh script"' . "\n" |
1903 |
|
. ' echo; echo "`date`: Running build_rpms/debs.sh script"' . "\n" |
|
1904 |
1902 |
. ' date +%s > /mnt/T_MKPKGS_START' . "\n" // TODO: not exposed |
. ' date +%s > /mnt/T_MKPKGS_START' . "\n" // TODO: not exposed |
1905 |
1903 |
. ' case ${env_distro} in' . "\n" |
. ' case ${env_distro} in' . "\n" |
1906 |
1904 |
. ' fedora|centos|rocky)' . "\n" // TODO: pass 'rpm' not the distro? Same for 'deb'. |
. ' fedora|centos|rocky)' . "\n" // TODO: pass 'rpm' not the distro? Same for 'deb'. |
|
... |
... |
function start_worker($job) |
1908 |
1906 |
. ' su - build -c "bash /mnt/build_rpms.sh" &>/mnt/status/build_pkgs.log ;;' . "\n" // TODO replace everywhere build_rpms.log with build_pkgs.log |
. ' su - build -c "bash /mnt/build_rpms.sh" &>/mnt/status/build_pkgs.log ;;' . "\n" // TODO replace everywhere build_rpms.log with build_pkgs.log |
1909 |
1907 |
. ' debian|ubuntu)' . "\n" |
. ' debian|ubuntu)' . "\n" |
1910 |
1908 |
. ' su - build -c "bash /mnt/build_debs.sh" &>/mnt/status/build_pkgs.log ;;' . "\n" |
. ' su - build -c "bash /mnt/build_debs.sh" &>/mnt/status/build_pkgs.log ;;' . "\n" |
1911 |
|
. ' *) echo "Unsupported distro" ;;' . "\n" |
|
|
1909 |
|
. ' *) rg_notify "Unsupported distro" ;;' . "\n" |
1912 |
1910 |
. ' esac' . "\n" |
. ' esac' . "\n" |
1913 |
1911 |
. ' E=${?}' . "\n" |
. ' E=${?}' . "\n" |
1914 |
1912 |
. ' E=0' . "\n" // TODO: for now, we do not error on this |
. ' E=0' . "\n" // TODO: for now, we do not error on this |
|
... |
... |
function start_worker($job) |
1927 |
1925 |
. ' chown -R build2:build2 /mnt/build2 /mnt/rpmbuild' . "\n" |
. ' chown -R build2:build2 /mnt/build2 /mnt/rpmbuild' . "\n" |
1928 |
1926 |
. "\n" |
. "\n" |
1929 |
1927 |
. ' rg_notify "Starting build_rgfs.sh script"' . "\n" |
. ' rg_notify "Starting build_rgfs.sh script"' . "\n" |
1930 |
|
. ' echo; echo "`date`: Running build_rgfs.sh script"' . "\n" |
|
1931 |
1928 |
. ' bash /mnt/build_rgfs.sh &>/mnt/status/build_rgfs.log' . "\n" |
. ' bash /mnt/build_rgfs.sh &>/mnt/status/build_rgfs.log' . "\n" |
1932 |
1929 |
. ' if [ "${?}" != "0" ]; then' . "\n" |
. ' if [ "${?}" != "0" ]; then' . "\n" |
1933 |
1930 |
. ' rg_notify "error building rgfs; trying to continue"' . "\n" |
. ' rg_notify "error building rgfs; trying to continue"' . "\n" |
|
... |
... |
function start_worker($job) |
1935 |
1932 |
. "\n" |
. "\n" |
1936 |
1933 |
. ' if [ -x /mnt/build_repo.sh ]; then' . "\n" |
. ' if [ -x /mnt/build_repo.sh ]; then' . "\n" |
1937 |
1934 |
. ' rg_notify "Starting build_repo.sh script"' . "\n" |
. ' rg_notify "Starting build_repo.sh script"' . "\n" |
1938 |
|
. ' echo; echo "`date`: Running build_repo.sh script"' . "\n" |
|
1939 |
1935 |
. ' date +%s > /mnt/T_REPO_START' . "\n" |
. ' date +%s > /mnt/T_REPO_START' . "\n" |
1940 |
1936 |
. ' ls -l /home; mkdir -p /home/build2; chown build2:build2 /home/build2' . "\n" |
. ' ls -l /home; mkdir -p /home/build2; chown build2:build2 /home/build2' . "\n" |
1941 |
1937 |
. ' su - build2 -c "bash /mnt/build_repo.sh" &>/mnt/status/build_repo.log' . "\n" |
. ' su - build2 -c "bash /mnt/build_repo.sh" &>/mnt/status/build_repo.log' . "\n" |
|
... |
... |
function start_worker($job) |
1959 |
1955 |
. "\n" |
. "\n" |
1960 |
1956 |
. 'dmesg > /mnt/status/dmesg' . "\n" |
. 'dmesg > /mnt/status/dmesg' . "\n" |
1961 |
1957 |
. "\n" |
. "\n" |
1962 |
|
. 'echo; echo "`date`: Syncing"' . "\n" |
|
|
1958 |
|
. 'rg_notify "Syncing disks"' . "\n" |
1963 |
1959 |
. 'sync' . "\n" |
. 'sync' . "\n" |
1964 |
1960 |
. "\n" |
. "\n" |
1965 |
1961 |
. 'rg_notify "Shutting down"' . "\n" |
. 'rg_notify "Shutting down"' . "\n" |
1966 |
|
. 'echo; echo "`date`: Shutting down"' . "\n" |
|
1967 |
1962 |
. 'while [ -r /root/stop ]; do' . "\n" |
. 'while [ -r /root/stop ]; do' . "\n" |
1968 |
1963 |
. ' sleep 1' . "\n" |
. ' sleep 1' . "\n" |
1969 |
1964 |
. 'done' . "\n" |
. 'done' . "\n" |