blob: 4c18167a9393ca8d018f30d916d37ecec46b13c9 (
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
|
#!/bin/bash
if [ $# -ne 4 ]; then
msg "usage: $(basename $0) <repo-from> <repo-to> <arch> <pkgname|pkgbase> ..."
exit 1
fi
. "$(dirname $0)/db-functions"
. "$(dirname $0)/config"
args=(${@})
repofrom="${args[0]}"
repoto="${args[1]}"
arch="${args[2]}"
# TODO: make db-move arch-independent?
if [ "${arch}" == 'any' ]; then
tarches=(${ARCHES[@]})
else
tarches=("${arch}")
fi
ftppath_from="$FTP_BASE/$repofrom/os/"
ftppath_to="$FTP_BASE/$repoto/os/"
svnrepo_from="$repofrom-$arch"
svnrepo_to="$repoto-$arch"
if ! check_repo_permission $repoto || ! check_repo_permission $repofrom; then
error "You don't have permission to move packages from ${repofrom} to ${repoto}"
exit 1
fi
# TODO: add other tests before touch the repos
repo_lock $repoto $arch || exit 1
repo_lock $repofrom $arch || exit 1
pushd "$WORKDIR" >/dev/null
/usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null
pushd checkout >/dev/null
add_pkgs=()
remove_pkgs=()
for pkgbase in ${args[@]:3}; do
# TODO: optimize
/usr/bin/svn up -q $pkgbase
if [ -d "$pkgbase/repos/$svnrepo_from" ]; then
pkgname=($(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgname[@]}))
pkgver=$(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgver})
pkgrel=$(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgrel})
msg "Moving $pkgbase from $repofrom to $repoto..."
if [ -d "$pkgbase/repos/$svnrepo_to" ]; then
/usr/bin/svn rm --force -q "$pkgbase/repos/$svnrepo_to"
/usr/bin/svn commit -q -m "$(basename $0): $pkgbase removed by $(id -un) for move to $repoto"
fi
/usr/bin/svn mv -q -r HEAD "$pkgbase/repos/$svnrepo_from" "$pkgbase/repos/$svnrepo_to"
/usr/bin/svn commit -q -m "$(basename $0): moved $pkgbase from [$repofrom] to [$repoto] ($arch)"
for i in ${pkgname[@]}; do
for tarch in ${tarches[@]}; do
pkgpath=$(getpkgfile "$ftppath_from/${tarch}/"$i-$pkgver-$pkgrel-$arch$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}/
done
add_pkgs[${#add_pkgs[*]}]="$FTP_BASE/$(get_pkgpool_for_host)/${pkgfile}"
remove_pkgs[${#remove_pkgs[*]}]=${i}
done
else
die "$pkgbase is not in repo $repofrom"
fi
done
for tarch in ${tarches[@]}; do
/usr/bin/repo-add -q "$ftppath_to/${tarch}/$repoto$DBEXT" ${add_pkgs[@]} >/dev/null || die "Error in repo-add"
/usr/bin/repo-remove -q "$ftppath_from/${tarch}/$repofrom$DBEXT" ${remove_pkgs[@]} >/dev/null || die "Error in repo-remove"
done
popd >/dev/null
popd >/dev/null
repo_unlock $repoto $arch || exit 1
repo_unlock $repofrom $arch || exit 1
|