summaryrefslogtreecommitdiffstats
path: root/crossrepomove.in
blob: 8794326637d44ec2c37519e59c1b227591ee43f3 (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
#!/bin/bash

m4_include(lib/common.sh)

scriptname=${0##*/}

if [[ -z $1 ]]; then
	echo 'Usage: '$scriptname' [pkgbase]'
	exit 1
fi

pkgbase="${1}"

packages_svn='svn+ssh://gerolde.archlinux.org/srv/svn-packages'
packages_server='gerolde.archlinux.org'
community_svn='svn+ssh://svn-community@nymeria.archlinux.org/srv/repos/svn-community/svn'
community_server='nymeria.archlinux.org'
mirror='http://mirrors.kernel.org/archlinux'

case $scriptname in
	extra2community)
		source_svn="${packages_svn}"
		target_svn="${community_svn}"
		source_server="${packages_server}"
		target_server="${community_server}"
		source_repo='extra'
		target_repo='community'
		;;
	community2extra)
		source_svn="${community_svn}"
		target_svn="${packages_svn}"
		source_server="${community_server}"
		target_server="${packages_server}"
		source_repo='community'
		target_repo='extra'
		;;
	*)
		die "Couldn't find configuration for $scriptname"
		;;
esac

setup_workdir

pushd $WORKDIR >/dev/null

msg "Downloading sources for ${pkgbase}"
svn -q checkout -N "${target_svn}" target_checkout
mkdir -p "target_checkout/${pkgbase}/repos"
svn -q export "${source_svn}/${pkgbase}/trunk" "target_checkout/${pkgbase}/trunk" || die
. "target_checkout/${pkgbase}/trunk/PKGBUILD"

msg "Downloading packages for ${pkgbase}"
for _arch in ${arch[@]}; do
	if [[ "${_arch[*]}" == 'any' ]]; then
		repo_arch='x86_64'
	else
		repo_arch=${_arch}
	fi
	for _pkgname in ${pkgname[@]}; do
		fullver=$(get_full_version $_pkgname)
		# FIXME: this only works with .xz packages
		ssh "${target_server}" "cd staging/${target_repo}
			curl -O ${mirror}/${source_repo}/os/${repo_arch}/$_pkgname-$fullver-${_arch}.pkg.tar.xz
			curl -O ${mirror}/${source_repo}/os/${repo_arch}/$_pkgname-$fullver-${_arch}.pkg.tar.xz.sig" || die
	done
done

msg "Adding ${pkgbase} to ${target_repo}"
svn -q add "target_checkout/${pkgbase}"
svn -q propset svn:keywords 'Id' "target_checkout/${pkgbase}/trunk/PKGBUILD"
svn -q commit -m"${scriptname}: Moving ${pkgbase} from ${source_repo} to ${target_repo}" target_checkout
pushd "target_checkout/${pkgbase}/trunk" >/dev/null
archrelease "${arch[@]/#/$target_repo-}" || die
popd >/dev/null

if [[ "${target_server}" == "${community_server}" ]]; then
        dbscripts_path='/srv/repos/svn-community/dbscripts'
else
        dbscripts_path='/arch'
fi

ssh "${target_server}" "${dbscripts_path}/db-update" || die

msg "Removing ${pkgbase} from ${source_repo}"
if [[ "${source_server}" == "${community_server}" ]]; then
        dbscripts_path='/srv/repos/svn-community/dbscripts'
else
        dbscripts_path='/arch'
fi
for _arch in ${arch[@]}; do
	ssh "${source_server}" "${dbscripts_path}/db-remove ${source_repo} ${_arch} ${pkgbase}"
done
svn -q checkout -N "${source_svn}" source_checkout
svn -q up "source_checkout/${pkgbase}"
svn -q rm "source_checkout/${pkgbase}"
svn -q commit -m"${scriptname}: Moving ${pkgbase} from ${source_repo} to ${target_repo}" source_checkout

popd >/dev/null