Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/mysql-functions
blob: cc21b2173c9b30e67f912753160fd4758f48e500 (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
#!/bin/sh

# contains functions used to access mysql db

# shellcheck disable=SC2039

mysql_command='mysql buildmaster -e'

# add_package_source $pkgbase $pkgver $pkgrel $git_revision $mod_git_revision $upstream_package_repository

# shellcheck disable=SC2016,SC2086
add_package_source() {
  local names='pkgbase pkgver pkgrel git_revision mod_git_revision upstream_package_repository'
  local values;
  for _ in ${names}; do
    values="${values}$(
      printf '%s' "$1" | \
        base64 -w0
    ) "
    shift
  done
  values="${values% }"

  ${mysql_command} "$(
    printf 'INSERT IGNORE INTO package_sources'
    {
      printf ' ('
      printf '`%s`, ' ${names}
      printf ') SELECT'
      printf ' from_base64("%s"), ' ${values% *}
      printf ' `upstream_repositories`.`id`'
      printf ' FROM `upstream_repositories`'
      printf ' WHERE `upstream_repositories`.`name` = from_base64("%s");' \
        "${values##* }"
    } | \
      sed 's|, )|)|g'
  )"
}