Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/harvest-commit-times
diff options
context:
space:
mode:
Diffstat (limited to 'bin/harvest-commit-times')
-rwxr-xr-xbin/harvest-commit-times65
1 files changed, 36 insertions, 29 deletions
diff --git a/bin/harvest-commit-times b/bin/harvest-commit-times
index a978b41..9c6b0eb 100755
--- a/bin/harvest-commit-times
+++ b/bin/harvest-commit-times
@@ -12,13 +12,15 @@ usage() {
>&2 echo ' sources from git and put them into the database'
>&2 echo ''
>&2 echo 'possible options:'
+ >&2 echo ' -f|--force: Do not abort on error.'
>&2 echo ' -h|--help: Show this help and exit.'
>&2 echo ' -w|--wait: If necessary, wait for lock blocking.'
[ -z "$1" ] && exit 1 || exit "$1"
}
eval set -- "$(
- getopt -o hw \
+ getopt -o fhw \
+ --long force \
--long help \
--long wait \
-n "$(basename "$0")" -- "$@" || \
@@ -26,9 +28,13 @@ eval set -- "$(
)"
block_flag='-n'
+force=false;
while true; do
case "$1" in
+ -f|--force)
+ force=true
+ ;;
-h|--help)
usage 0
;;
@@ -76,9 +82,9 @@ trap 'rm "${tmp_file}"' EXIT
if ! ${i_am_the_master}; then
tmp_remote_file=$(
- ssh buildmaster "mktemp 'tmp.harvest-commit-times.remotely.XXXXXXXXXX' --tmpdir"
+ ssh -o PasswordAuthentication=No buildmaster "mktemp 'tmp.harvest-commit-times.remotely.XXXXXXXXXX' --tmpdir"
)
- trap 'rm "${tmp_file}"; ssh buildmaster rm "${tmp_remote_file}"' EXIT
+ trap 'rm "${tmp_file}"; ssh -o PasswordAuthentication=No buildmaster rm "${tmp_remote_file}"' EXIT
fi
while true; do
@@ -91,43 +97,44 @@ while true; do
printf '`package_sources`.`git_revision`,'
printf '`package_sources`.`mod_git_revision`,'
printf '`upstream_repositories`.`name`,'
- printf '`git_repositories`.`name`'
+ printf 'IF(`build_assignments`.`architecture`=%s,"any","x86_64")' "${architecture_ids__any}"
printf ' FROM `package_sources`'
mysql_join_package_sources_upstream_repositories
- mysql_join_upstream_repositories_git_repositories
+ mysql_join_package_sources_build_assignments
printf ' WHERE `package_sources`.`commit_time`="0000-00-00 00:00:00"'
printf ' AND `package_sources`.`uses_upstream`'
- if ! ${i_am_the_master}; then
- printf ' ORDER BY RAND()'
- fi
+ printf ' ORDER BY RAND()'
printf ' LIMIT 10'
- } | \
- mysql_run_query 'unimportant' | \
- sponge | \
- while read -r id pkgbase git_revision mod_git_revision repository git_repository; do
- eval 'git_directory="${repo_paths__'"${git_repository}"'}"'
- find_pkgbuilds "${pkgbase}" "${repository}" "${git_repository}" "${git_revision}" "${mod_git_revision}"
- commit_time=$(
- # shellcheck disable=SC2154
- git -C "${git_directory}" log -n 1 --pretty=format:%ct "${git_revision}" -- "${PKGBUILD}"
- )
- if [ -n "${commit_time}" ]; then
- printf '%s\t%s\n' \
- "${id}" \
- "${commit_time}"
- else
- >&2 printf 'Package source %s is not available in git.\n' \
- "${id}"
+ } \
+ | mysql_run_query 'unimportant' \
+ | sponge \
+ | while read -r id pkgbase git_revision mod_git_revision repository architecture; do
+ commit_time=$(
+ # shellcheck disable=SC2154
+ git -C "${repo_paths__state}" log -n 1 --pretty=format:%ct HEAD -- "${repository}-${architecture}/${pkgbase}"
+ )
+ if [ -n "${commit_time}" ]; then
+ printf '%s\t%s\n' \
+ "${id}" \
+ "${commit_time}"
+ else
+ >&2 printf 'Package source %s is not available in git:\n' \
+ "${id}"
+ >&2 printf '%s ' \
+ "${pkgbase}" "${git_revision}" "${mod_git_revision}" "${repository}" "${architecture}"
+ >&2 printf '\n'
+ if ! ${force}; then
exit 2
fi
- done > \
- "${tmp_file}"
+ fi
+ done > \
+ "${tmp_file}"
>&2 printf '.'
if [ -s "${tmp_file}" ]; then
if ! ${i_am_the_master}; then
- ssh buildmaster 'cat > "'"${tmp_remote_file}"'"' < \
+ ssh -o PasswordAuthentication=No buildmaster 'cat > "'"${tmp_remote_file}"'"' < \
"${tmp_file}"
fi
# shellcheck disable=SC2016
@@ -149,7 +156,7 @@ while true; do
if ${i_am_the_master}; then
mysql_run_query 'unimportant'
else
- ssh buildmaster 'mysql buildmaster -N --raw --batch'
+ ssh -o PasswordAuthentication=No buildmaster 'mysql buildmaster -N --raw --batch'
fi
else
>&2 printf '\n'