blob: 2a52fac7f8ddf677587d983e48463f6a04ac8f4b (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#!/bin/bash
. "$(dirname "$(readlink -e "$0")")/config"
. "$(dirname "$(readlink -e "$0")")/db-functions"
if (( $# < 3 )); then
msg "usage: %s <repo-from> <repo-to> <pkgbase> ..." "${0##*/}"
msg " or: %s <repo-from> <repo-to> pkgname=<pkgname> ..." "${0##*/}"
exit 1
fi
args=("${@}")
repo_from="${args[0]}"
repo_to="${args[1]}"
ftppath_from="${FTP_BASE}/${repo_from}/os/"
ftppath_to="${FTP_BASE}/${repo_to}/os/"
if ! check_repo_permission "$repo_to" || ! check_repo_permission "$repo_from"; then
die "You don't have permission to move packages from %s to %s" "$repo_from" "$repo_to"
fi
# TODO: this might lock too much (architectures)
for pkgarch in "${ARCHES[@]}"; do
repo_lock "${repo_to}" "${pkgarch}" || exit 1
repo_lock "${repo_from}" "${pkgarch}" || exit 1
done
# First loop is to check that all necessary files exist
for pkg in "${args[@]:2}"; do
found=false
for tarch in "${ARCHES[@]}"; do
while read -r pkgbase pkgname pkgfile; do
[[ $pkgbase != '(null)' ]] || pkgbase=$pkgname
if ! vcs_move_preflight_check "$repo_from" "$tarch" "$pkgbase"; then
die "%s not found in %s-%s" "$pkgbase" "$repo_from" "$tarch"
fi
# getpkgfile will `exit` for us if it fails;
# no need to check its result
getpkgfile "${ftppath_from}/${tarch}/${pkgfile}" >/dev/null
found=true
done < <(
if [[ $pkg = 'pkgname='* ]]; then
arch_expac "$repo_from" "$tarch" '%e %n %f' "${pkg#pkgname=}"
else
arch_expac_pkgbase "$repo_from" "$tarch" '%e %n %f' "$pkg"
fi
)
done
[[ $found = true ]] || die "%s not found in %s" "$pkg" "$repo_from"
done
msg "Moving packages from [%s] to [%s]..." "$repo_from" "$repo_to"
for arch in "${ARCHES[@]}"; do
declare -a add_pkgs_$arch
declare -a remove_pkgs_$arch
done
for pkg in "${args[@]:2}"; do
if [[ $pkg != 'pkgname='* ]]; then
vcs_move_start "$repo_from" "$repo_to" "$pkg"
fi
for tarch in "${ARCHES[@]}"; do
msg2 "%s (%s)" "$pkg" "$tarch"
declare -n add_pkgs="add_pkgs_${tarch}"
declare -n remove_pkgs="remove_pkgs_${tarch}"
if [[ $pkg != 'pkgname='* ]]; then
vcs_move_arch "$tarch"
fi
while read -r pkgbase pkgname pkgver pkgfile; do
[[ $pkgbase != '(null)' ]] || pkgbase=$pkgname
plain 'pkgname=%s (%s)' "$pkgname" "$pkgver"
ln -s "../../../${PKGPOOL}/${pkgfile}" "${ftppath_to}/${tarch}/"
if [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig ]]; then
ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "${ftppath_to}/${tarch}/"
fi
add_pkgs+=("${FTP_BASE}/${PKGPOOL}/${pkgfile}")
remove_pkgs+=("${pkgname}")
done < <(
if [[ $pkg = 'pkgname='* ]]; then
arch_expac "$repo_from" "$tarch" '%e %n %v %f' "${pkg#pkgname=}"
else
arch_expac_pkgbase "$repo_from" "$tarch" '%e %n %v %f' "$pkg"
fi
)
done
if [[ $pkg != 'pkgname='* ]]; then
vcs_move_finish
fi
done
for tarch in "${ARCHES[@]}"; do
declare -n add_pkgs="add_pkgs_${tarch}"
declare -n remove_pkgs="remove_pkgs_${tarch}"
if [[ -n ${add_pkgs[@]} ]]; then
arch_repo_modify add "${repo_to}" "${tarch}" "${add_pkgs[@]}"
arch_repo_modify remove "${repo_from}" "${tarch}" "${remove_pkgs[@]}"
fi
done
for pkgarch in "${ARCHES[@]}"; do
repo_unlock "${repo_from}" "${pkgarch}"
repo_unlock "${repo_to}" "${pkgarch}"
done
|