db-repo-add.bats 2.82 KB
Newer Older
1
2
load ../lib/common

3
4
5
6
7
8
__movePackageToRepo() {
	local repo=$1
	local pkgbase=$2
	local arch=$3
	local tarch
	local tarches
9
	local is_debug=0
10
11
12
13
14
15
16
17

	if [[ $arch == any ]]; then
		tarches=(${ARCHES[@]})
	else
		tarches=(${arch})
	fi

	# FIXME: pkgbase might not be part of the package filename
18
19
20
21
	if __isGlobfile "${STAGING}"/${repo}/${pkgbase}-debug-*-*-${arch}${PKGEXT}; then
		mv -v "${STAGING}"/${repo}/${pkgbase}-debug-*-*-${arch}${PKGEXT}{,.sig} "${FTP_BASE}/${DEBUGPKGPOOL}/"
		is_debug=1
	fi
22
23
24
25
	mv -v "${STAGING}"/${repo}/${pkgbase}-*-*-${arch}${PKGEXT}{,.sig} "${FTP_BASE}/${PKGPOOL}/"
	for tarch in ${tarches[@]}; do
		ln -sv ${FTP_BASE}/${PKGPOOL}/${pkgbase}-*-*-${arch}${PKGEXT} "${FTP_BASE}/${repo}/os/${tarch}/"
		ln -sv ${FTP_BASE}/${PKGPOOL}/${pkgbase}-*-*-${arch}${PKGEXT}.sig "${FTP_BASE}/${repo}/os/${tarch}/"
26
27
28
29
		if ((is_debug)); then
			ln -sv ${FTP_BASE}/${DEBUGPKGPOOL}/${pkgbase}-*-*-${arch}${PKGEXT} "${FTP_BASE}/${repo}-debug/os/${tarch}/"
			ln -sv ${FTP_BASE}/${DEBUGPKGPOOL}/${pkgbase}-*-*-${arch}${PKGEXT}.sig "${FTP_BASE}/${repo}-debug/os/${tarch}/"
		fi
30
31
32
	done
}

33
@test "add single packages" {
34
35
36
37
38
39
	local arches=('i686' 'x86_64')
	local pkgs=('pkg-simple-a' 'pkg-simple-b')
	local pkgbase
	local arch

	for pkgbase in ${pkgs[@]}; do
40
		releasePackage extra ${pkgbase}
41
		for arch in ${arches[@]}; do
42
			__movePackageToRepo extra ${pkgbase} ${arch}
43
			db-repo-add extra ${arch} ${pkgbase}-1-1-${arch}${PKGEXT}
44
45
46
47
		done
	done

	for pkgbase in ${pkgs[@]}; do
48
		checkPackageDB extra ${pkgbase} 1-1
49
50
51
	done
}

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
@test "add debug packages" {
	local arches=('i686' 'x86_64')
	local pkgs=('pkg-debuginfo')
	local pkgbase
	local arch

	for pkgbase in ${pkgs[@]}; do
		releasePackage extra ${pkgbase}
		for arch in ${arches[@]}; do
			__movePackageToRepo extra ${pkgbase} ${arch}
			db-repo-add extra ${arch} ${pkgbase}-1-1-${arch}${PKGEXT}
			db-repo-add extra-debug ${arch} ${pkgbase}-debug-1-1-${arch}${PKGEXT}
		done
	done

	checkPackageDB extra ${pkgbase} 1-1
	checkPackageDB extra-debug ${pkgbase} 1-1
}

71
@test "add multiple packages" {
72
73
74
75
76
	local arches=('i686' 'x86_64')
	local pkgs=('pkg-simple-a' 'pkg-simple-b')
	local pkgbase
	local arch

77
78
79
80
	for pkgbase in ${pkgs[@]}; do
		releasePackage extra ${pkgbase}
	done

81
82
83
	for arch in ${arches[@]}; do
		add_pkgs=()
		for pkgbase in ${pkgs[@]}; do
84
			__movePackageToRepo extra ${pkgbase} ${arch}
85
			add_pkgs+=("${pkgbase}-1-1-${arch}${PKGEXT}")
86
		done
87
		db-repo-add extra ${arch} ${add_pkgs[@]}
88
89
90
	done

	for pkgbase in ${pkgs[@]}; do
91
		checkPackageDB extra ${pkgbase} 1-1
92
93
	done
}
94

95
@test "add any packages" {
96
97
98
99
100
101
	local arches=('i686' 'x86_64')
	local pkgs=('pkg-any-a' 'pkg-any-b')
	local pkgbase
	local arch

	for pkgbase in ${pkgs[@]}; do
102
		releasePackage extra ${pkgbase}
103
		__movePackageToRepo extra ${pkgbase} any
104
		db-repo-add extra any ${pkgbase}-1-1-any${PKGEXT}
105
106
107
	done

	for pkgbase in ${pkgs[@]}; do
108
		checkPackageDB extra "${pkgbase}" 1-1
109
110
	done
}