summaryrefslogtreecommitdiff
path: root/test/test.d/pool-transition.sh
blob: ff5b3ea61e718d76b821b4cb9d5481db102fbd0a (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash

curdir=$(readlink -e $(dirname $0))
source "${curdir}/../lib/common.inc"

testMovePackagesWithoutPool() {
	local arches=('i686' 'x86_64')
	local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b')
	local pkgbase
	local arch
	local pkg
	local old

	for pkgbase in ${pkgs[@]}; do
		for arch in ${arches[@]}; do
			releasePackage testing ${pkgbase} ${arch}
		done
	done

	../db-update

	# transform two packages to old style layout
	for arch in ${arches[@]}; do
		for old in 0 2; do
			for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}${package_extension_suffixfile}; do
				pkg=$(basename $pkg)
				mv -f "${root_dir}/${main_packages_pool}/${pkg}" "${root_dir}/testing/os/${arch}/${pkg}"
			done
		done
	done

	../cron-jobs/ftpdir-cleanup >/dev/null

	../db-move testing extra ${pkgs[@]}

	../cron-jobs/ftpdir-cleanup >/dev/null

	for pkgbase in ${pkgs[@]}; do
		for arch in ${arches[@]}; do
			for pkg in "${pkgdir}/${pkgbase}"/*-${arch}${package_extension_suffixfile}; do
				checkPackage extra $(basename ${pkg}) ${arch}
			done
			checkRemovedPackage testing ${pkgbase} ${arch}
		done
	done
}

testUpdateAnyPackageWithoutPool() {
	local pkgname='pkg-any-a'
	local pkg1='pkg-any-a-1-1-any.pkg.tar.xz'
	local pkg2='pkg-any-a-1-2-any.pkg.tar.xz'
	local arch


	releasePackage extra pkg-any-a any
	../db-update
	# transform two packages to old style layout
	mv -f "${root_dir}/${main_packages_pool}/${pkg1}" "${root_dir}/extra/os/any"
	for arch in i686 x86_64; do
		ln -sf "../any/${pkg1}" "${root_dir}/extra/os/${arch}"
	done

	pushd "${temporary_directory}/svn-packages-copy/${pkgname}/trunk/" >/dev/null
	sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD
	svn commit -q -m"update pkg to pkgrel=2" >/dev/null
	sudo extra-i686-build >/dev/null 2>&1
	mv "${pkg2}" "${pkgdir}/${pkgname}/"
	popd >/dev/null

	releasePackage extra ${pkgname} any
	../db-update
	rm -f "${pkgdir}/${pkgname}/${pkg2}"

	../cron-jobs/ftpdir-cleanup >/dev/null

	checkAnyPackage extra "${pkg2}"

	[ -f "${root_dir}/${main_packages_pool}/${pkg1}" ] && fail "${main_packages_pool}/${pkg1} found"
	for arch in any i686 x86_64; do
		[ -f "${root_dir}/extra/os/${arch}/${pkg1}" ] && fail "extra/os/${arch}/${pkg1} found"
	done
}

testMoveAnyPackagesWithoutPool() {
	local pkgs=('pkg-any-a' 'pkg-any-b')
	local pkgbase
	local arch
	local pkg

	for pkgbase in ${pkgs[@]}; do
		releasePackage testing ${pkgbase} any
	done

	../db-update

	# transform a package to old style layout
	for pkg in "${pkgdir}/${pkgs[0]}"/*-any${package_extension_suffixfile}; do
		pkg=$(basename $pkg)
		mv -f "${root_dir}/${main_packages_pool}/${pkg}" "${root_dir}/testing/os/any/${pkg}"
		for arch in i686 x86_64; do
			ln -sf "../any/${pkg}" "${root_dir}/testing/os/${arch}/${pkg}"
		done
	done

	../cron-jobs/ftpdir-cleanup >/dev/null

	../db-move testing extra ${pkgs[@]}

	../cron-jobs/ftpdir-cleanup >/dev/null

	for pkgbase in ${pkgs[@]}; do
		for pkg in "${pkgdir}/${pkgbase}"/*-any${package_extension_suffixfile}; do
			checkAnyPackage extra $(basename ${pkg})
		done
		checkRemovedAnyPackage testing ${pkgbase}
	done

	for pkg in "${pkgdir}/${pkgs[0]}"/*-any${package_extension_suffixfile}; do
		pkg=$(basename $pkg)
		for arch in any i686 x86_64; do
			[ -f "${root_dir}/testing/os/${arch}/${pkg}" ] && fail "testing/os/${arch}/${pkg} found"
		done
	done
}

testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() {
	local pkg
	local arch

	releasePackage extra pkg-any-a any
	../db-update

	# transform a package to old style layout
	for pkg in "${pkgdir}/pkg-any-a"/*-any${package_extension_suffixfile}; do
		pkg=$(basename $pkg)
		mv -f "${root_dir}/${main_packages_pool}/${pkg}" "${root_dir}/extra/os/any/${pkg}"
		for arch in i686 x86_64; do
			ln -sf "../any/${pkg}" "${root_dir}/extra/os/${arch}/${pkg}"
		done
	done

	releasePackage testing pkg-any-a any
	../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1)

	for arch in i686 x86_64; do
		( [ -r "${root_dir}/testing/os/${arch}/testing${database_extension_suffixfile%.tar.*}" ] \
			&& bsdtar -xf "${root_dir}/testing/os/${arch}/testing${database_extension_suffixfile%.tar.*}" -O | grep -q pkg-any-a) \
			&& fail "pkg-any-a should not be in testing/os/${arch}/testing${database_extension_suffixfile%.tar.*}"
	done
}

source "${curdir}/../lib/shunit2"