blob: 33f5d6d851f356e040fa8373ea60460254c01e24 (
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
|
#!/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'
)"
${mysql_command} "$(
printf 'SELECT * FROM package_sources'
printf ' LEFT JOIN upstream_repositories'
printf ' ON package_sources.upstream_package_repository = upstream_repositories.id;'
)"
}
|