-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb-update
More file actions
executable file
·170 lines (144 loc) · 4.83 KB
/
db-update
File metadata and controls
executable file
·170 lines (144 loc) · 4.83 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash
. "$(dirname $0)/config"
. "$(dirname $0)/db-functions"
if [ $# -ge 1 ]; then
warning "Calling ${0##*/} with a specific repository is no longer supported"
exit 1
fi
# Find repos with packages to release
staging_repos=($(find "${STAGING}" -mindepth 1 -type f -name "*${PKGEXT}" -printf '%h\n' | sort -u))
if [ $? -ge 1 ]; then
die "Could not read ${STAGING}"
fi
repos=()
for staging_repo in ${staging_repos[@]##*/}; do
if in_array ${staging_repo} ${PKGREPOS[@]} ${PKGREPOS[@]/%/-${DEBUGSUFFIX}}; then
repos+=(${staging_repo})
fi
done
locks=()
for repo in ${repos[@]}; do
for pkgarch in ${ARCHES[@]}; do
if [ -n "$(find "$STAGING/$repo" -maxdepth 1 \( -name "*${pkgarch}${PKGEXT}" -o \
-name "*any${PKGEXT}" \) -a -type f -print -quit)" ]; then
repo_lock ${repo} ${pkgarch} || exit 1
locks+=($repo/$pkgarch)
fi
done
done
# check if packages are valid
for repo in ${repos[@]}; do
if ! check_repo_permission "${repo}"; then
die "You don't have permission to update packages in ${repo}"
fi
pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT}))
if [ $? -eq 0 ]; then
for pkg in ${pkgs[@]}; do
if [ -h "${pkg}" ]; then
die "Package ${repo}/${pkg##*/} is a symbolic link"
fi
if ! check_pkgfile "${pkg}"; then
die "Package ${repo}/${pkg##*/} is not consistent with its meta data"
fi
if ${REQUIRE_SIGNATURE} && ! pacman-key -v "${pkg}.sig" >/dev/null 2>&1; then
die "Package ${repo}/${pkg##*/} does not have a valid signature"
fi
if ! check_pkgrepos "${pkg}"; then
die "Package ${repo}/${pkg##*/} already exists in another repository"
fi
if ! check_packager "${pkg}"; then
die "Package ${repo}/${pkg##*/} does not have a valid packager"
fi
if ! check_buildinfo "${pkg}"; then
die "Package ${repo}/${pkg##*/} does not have a .BUILDINFO file"
fi
if ! check_builddir "${pkg}"; then
die "Package ${repo}/${pkg##*/} was not built in a chroot"
fi
done
else
die "Could not read ${STAGING}"
fi
done
msg "Updating all packages in ${STAGING}"
declare -a pkgs_to_remove
declare -a pkgs_to_push
declare -A pkgs_should_push
for repo in ${repos[@]}; do
for pkgfile in $(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT} 2>/dev/null); do
_pkgname=$(getpkgname "$pkgfile")
_pkgbase=$(getpkgbase "$pkgfile")
_pkgver=$(getpkgver "$pkgfile")
_pkgarch=$(getpkgarch "$pkgfile")
msg2 "$repo\t$_pkgarch\t$_pkgname\t$_pkgver"
pkgs_to_push+=($_pkgname)
arch_add_to_pool "$pkgfile"
get_pkgbuild $repo $_pkgbase $_pkgver || die "PKGBUILD not found for $_pkgbase-$_pkgver"
_pkgnames=($(. "$WORKDIR/pkgbuilds/$repo/$_pkgbase-$_pkgver"; echo ${pkgname[@]}))
if [ "$_pkgarch" == "any" ]; then
_pkgarch=${ARCHES[0]}
fi
_db_ver=($(pkgver_from_db $repo $_pkgarch $_pkgname)) || continue # if not in db, skip rest of logic
get_pkgbuild $repo $_pkgbase $_db_ver || die "PKGBUILD not found for $_pkgbase-$_db_ver"
_db_names=($(. "$WORKDIR/pkgbuilds/$repo/$_pkgbase-$_db_ver"; echo ${pkgname[@]}))
# duplicate pkgnames to make uniq_array only return entries only found in db_names
for _pkg in $(uniq_array ${_pkgnames[@]} ${_pkgnames[@]} ${_db_names[@]}); do
_rarchs=($(. "$WORKDIR/pkgbuilds/$repo/$_pkgbase-$_db_ver"; get_arch $_pkg))
for _rarch in ${_rarchs[@]}; do
pkgs_to_remove+=($repo/$_pkg/$_rarch)
done
done
for _pkg in ${_pkgnames[@]}; do
pkgs_should_push[$_pkg]=$_pkgver
done
done
for file in "$STAGING/$repo"/*/*; do
if [[ -h $file ]]; then
pkgfiles=("${pkgfiles[@]}" "${file##*/}")
fi
done
for pkgarch in ${ARCHES[@]}; do
declare -a pkgs_to_add=()
for pkgfile in "${pkgfiles[@]}"; do
pkgfile_arch="$STAGING/$repo/$pkgarch/$pkgfile"
if [[ -h "$pkgfile_arch" ]]; then
pkgs_to_add=("${pkgs_to_add[@]}" "$pkgfile")
rm "$pkgfile_arch"
fi
done
if [[ ${#pkgs_to_add[@]} = 0 ]]; then
continue
fi
for pkg in $(uniq_array ${pkgs_to_push[@]} ${pkgs_to_push[@]} ${!pkgs_should_push[@]}); do
pkgver=($(pkgver_from_db $repo $pkgarch $pkg))
# check if already released first
if [ -z "$pkgver" ] || [ $pkgver != ${pkgs_should_push[$pkg]} ]; then
warning "Missing split package $pkg-$pkgarch. Did you forget to commitpkg?"
fi
done
arch_db_add $repo "$pkgarch" "${pkgs_to_add[@]}"
done
done
if [ ${#pkgs_to_remove[@]} -gt 0 ]; then
pkgs_to_remove=($(dedup_array ${pkgs_to_remove[@]}))
for rem in ${pkgs_to_remove[@]}; do
repo=${rem%%/*}
rem=${rem#*/}
pkg=${rem%/*}
arch=${rem#*/}
msg2 "$repo\t$arch\t$pkg\t[removal]"
[ "$arch" == "any" ] && arch=(${ARCHES[@]})
for a in ${arch[@]}; do
arch_db_remove $repo $a $pkg
if [[ -f "$HISTORYREPO/$repo-$DEBUGSUFFIX/$a/$pkg-$DEBUGSUFFIX" ]]; then
arch_db_remove $repo-$DEBUGSUFFIX $a $pkg-$DEBUGSUFFIX
fi
done
done
fi
arch_history_commit "db-update: ${repos[*]}"
for lock in ${locks[@]}; do
repo=${lock%/*}
pkgarch=${lock#*/}
repo_unlock ${repo} ${pkgarch}
done