Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/prioritize-build-list
blob: bbeb28839f2d738734b1677869bf2595553d11b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh

# shellcheck disable=SC2119,SC2120

# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"

if [ $# -ne 1 ]; then
  echo 'Usage: prioritize-build-list pkg-regex'
  echo ' moves packages matching pkg-regex to front of build list'
  exit 2
fi

# Create a lock file for build list.

exec 9> "${build_list_lock_file}"
if ! verbose_flock -n 9; then
  >&2 echo 'come back (shortly) later - I cannot lock build list.'
  exit 1
fi

exec 8> "${sanity_check_lock_file}"
if ! verbose_flock -s -n 8; then
  >&2 echo 'come back (shortly) later - sanity-check running.'
  exit 1
fi

# shellcheck disable=SC2016
{
  printf 'UPDATE `build_assignments`'
  mysql_join_build_assignments_package_sources
  mysql_join_build_assignments_binary_packages
  mysql_join_binary_packages_binary_packages_in_repositories
  mysql_join_binary_packages_in_repositories_repositories
  printf ' SET `build_assignments`.`priority`=('
    printf 'SELECT COALESCE(MAX(`all_priorities`.`priority`),0)+1'
    printf ' FROM ('
      printf 'SELECT `others`.`priority`'
      printf ' FROM `build_assignments` AS `others`'
    printf ') AS `all_priorities`'
  printf ')'
  printf ' WHERE `package_sources`.`pkgbase` REGEXP from_base64("%s")' \
    "$(printf '%s' "$1" | base64 -w0)"
  printf ' AND `repositories`.`name`="build-list";\n'
} | \
  mysql_run_query

# Remove the lock file

rm -f "${build_list_lock_file}"