blob: ae989580dcb4017c1493f5199035b707238ea115 (
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
|
#!/bin/bash
. "$(dirname $0)/db-functions"
. "$(dirname $0)/config"
if [ $# -lt 3 ]; then
msg "usage: $(basename $0) <repo-from> <repo-to> <pkgname|pkgbase> ..."
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 ${repo_from} to ${repo_to}"
fi
/usr/bin/svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null
for pkgbase in ${args[@]:2}; do
/usr/bin/svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null
for pkgarch in ${ARCHES[@]} 'any'; do
svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}"
if [ -r "${svnrepo_from}/PKGBUILD" ]; then
continue 2
fi
done
die "${pkgbase} not found in ${repo_from}"
done
# 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
msg "Moving packages from [${repo_from}] to [${repo_to}]..."
declare -A add_pkgs
declare -A remove_pkgs
for pkgbase in ${args[@]:2}; do
for pkgarch in ${ARCHES[@]} 'any'; do
svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}"
svnrepo_to="${WORKDIR}/svn/${pkgbase}/repos/${repo_to}-${pkgarch}"
if [ -f "${svnrepo_from}/PKGBUILD" ]; then
if [ "${pkgarch}" == 'any' ]; then
tarches=(${ARCHES[@]})
else
tarches=("${pkgarch}")
fi
msg2 "${pkgbase} ($(echo ${tarches[@]}))"
pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]}))
pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo "${pkgver}-${pkgrel}")
if [ -d "${svnrepo_to}" ]; then
/usr/bin/svn rm --force -q "${svnrepo_to}"
/usr/bin/svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "$(basename $0): ${pkgbase} removed by $(id -un) for move to [${repo_to}] (${pkgarch})"
fi
/usr/bin/svn mv -q -r HEAD "${svnrepo_from}" "${svnrepo_to}"
/usr/bin/svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "$(basename $0): moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${pkgarch})"
for pkgname in ${pkgnames[@]}; do
for tarch in ${tarches[@]}; do
pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT})
pkgfile=$(basename "${pkgpath}")
# copy package to pool if needed
# TODO: can be removed once every package has been moved to the package pool
if [ ! -f ${FTP_BASE}/$(get_pkgpool_for_host)/${pkgfile} ]; then
cp ${pkgpath} ${FTP_BASE}/$(get_pkgpool_for_host)
fi
ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" ${ftppath_to}/${tarch}/
add_pkgs[${tarch}]+="${FTP_BASE}/$(get_pkgpool_for_host)/${pkgfile} "
remove_pkgs[${tarch}]+="${pkgname} "
done
done
fi
done
done
for tarch in ${ARCHES[@]}; do
if [ -n "${add_pkgs[${tarch}]}" ]; then
/usr/bin/repo-add -q "${ftppath_to}/${tarch}/${repo_to}${DBEXT}" ${add_pkgs[${tarch}]} >/dev/null \
|| die "Error in repo-add ${add_pkgs[${tarch}]}"
/usr/bin/repo-remove -q "${ftppath_from}/${tarch}/${repo_from}${DBEXT}" ${remove_pkgs[${tarch}]} >/dev/null \
|| die "Error in repo-remove ${remove_pkgs[${tarch}]}"
fi
done
for pkgarch in ${ARCHES[@]}; do
repo_unlock ${repo_from} ${pkgarch}
repo_unlock ${repo_to} ${pkgarch}
done
|