summaryrefslogtreecommitdiff
path: root/testing2x
blob: 99280b59ef9df6c7858fe3e6000715f11354efd2 (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
51
52
53
54
55
#!/bin/bash

. "$(dirname "$(readlink -e "$0")")/config"
. "$(dirname "$(readlink -e "$0")")/db-functions"

if (( $# < 1 )); then
	msg "usage: %s <pkgname|pkgbase> ..." "${0##*/}"
	exit 1
fi

# Lock everything to reduce  possibility of interfering task between the different repo-updates
script_lock
for repo in "${TESTING_REPO}" "${STABLE_REPOS[@]}"; do
	for pkgarch in "${ARCHES[@]}"; do
		repo_lock "${repo}" "${pkgarch}" || exit 1
	done
done

declare -A pkgs

for pkgbase in "$@"; do
	found_source=false
	for tarch in "${ARCHES[@]}"; do
		if [[ -n $(arch_expac_pkgbase "$TESTING_REPO" "$tarch" '%n' "$pkgbase") ]]; then
			found_source=true
			break
		fi
	done
	[[ $found_source = true ]] || die "%s not found in [%s]" "$pkgbase" "$TESTING_REPO"
	found_target=false
	for tarch in "${ARCHES[@]}"; do
		for repo in "${STABLE_REPOS[@]}"; do
			if [[ -n $(arch_expac_pkgbase "$repo" "$tarch" '%n' "$pkgbase") ]]; then
				found_target=true
				pkgs[${repo}]+="${pkgbase} "
				break 2
			fi
		done
	done
	[[ $found_target = true ]] || die "%s not found in any of these repos: %s" "$pkgbase" "${STABLE_REPOS[*]}"
done

for pkgarch in "${ARCHES[@]}"; do
	repo_unlock "${TESTING_REPO}" "${pkgarch}"
done
for repo in "${STABLE_REPOS[@]}"; do
	for pkgarch in "${ARCHES[@]}"; do
		repo_unlock "${repo}" "${pkgarch}"
	done
	if [[ -n ${pkgs[${repo}]} ]]; then
		"$(dirname "$(readlink -e "$0")")/db-move" "${TESTING_REPO}" "${repo}" ${pkgs[${repo}]}
	fi
done

script_unlock