-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb-remove
More file actions
executable file
·101 lines (78 loc) · 2.37 KB
/
db-remove
File metadata and controls
executable file
·101 lines (78 loc) · 2.37 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
#!/bin/bash
. "$(dirname $0)/config"
. "$(dirname $0)/db-functions"
if [ $# -lt 3 ]; then
msg "usage: ${0##*/} <repo> <arch> <pkgname> ..."
exit 1
fi
repo="$1"
arch="$2"
pkgnames=(${@:3})
ftppath="$FTP_BASE/$repo/os"
ftppath_debug="$FTP_BASE/$repo-$DEBUGSUFFIX/os"
if ! check_repo_permission $repo; then
die "You don't have permission to remove packages from ${repo}"
fi
if [ "$arch" == "all" ]; then
tarches=(${ARCHES[@]})
else
tarches=("$arch")
fi
for tarch in ${tarches[@]}; do
repo_lock $repo $tarch || exit 1
if [[ ! $repo =~ .*-${DEBUGSUFFIX}$ ]]; then
repo_lock $repo-$DEBUGSUFFIX $tarch || exit 1
fi
done
remove_pkgs=()
remove_dbg_pkgs=()
for pkgname in ${pkgnames[@]}; do
msg "Removing $pkgname from [$repo] ($arch)..."
pkgver=$(pkgver_from_db $repo ${tarches[0]} $pkgname)
# expand name
pkg=$(echo "$ftppath/${tarches[0]}/$pkgname-$pkgver"*${PKGEXT})
if [ -n "$pkgver" ] && [ -f "$pkg" ]; then
pkgbase=$(getpkgbase "$pkg")
pkgarch=$(getpkgarch "$pkg")
else
warning "Package $pkgname not found in repo"
continue
fi
remove_pkgs+=($pkgname)
[[ $pkgname =~ .*-${DEBUGSUFFIX}$ ]] && continue # skip if removing a debug package
get_pkgbuild $repo $pkgbase $pkgver
pkgs=($(. "$WORKDIR/pkgbuilds/$repo/$pkgbase-$pkgver"; echo "${pkgname[@]}"))
extrapkgs=($(uniq_array $pkgname ${remove_pkgs[@]} ${remove_pkgs[@]} ${pkgs[@]}))
if [[ ${#extrapkgs[@]} > 0 ]]; then
msg "Removing split packages:"
for extrapkg in ${extrapkgs[@]}; do
msg2 $extrapkg
done
fi
remove_pkgs+=(${extrapkgs[@]})
for pkg in "${pkgs[@]}"; do
if [[ -f "$HISTORYREPO/$repo-$DEBUGSUFFIX/${tarches[0]}/$pkg-$DEBUGSUFFIX" ]]; then
remove_dbg_pkgs+=("$pkg-$DEBUGSUFFIX")
fi
done
done
remove_pkgs=($(dedup_array "${remove_pkgs[@]}"))
remove_dbg_pkgs=($(dedup_array "${remove_dbg_pkgs[@]}"))
# TODO: assumes all packages are in the same repo, might not be the case for auto-removed split packages
if [[ ${#remove_pkgs[@]} > 0 ]]; then
for tarch in ${tarches[@]}; do
arch_db_remove "$repo" "$tarch" ${remove_pkgs[@]}
done
if [[ ${#remove_dbg_pkgs[@]} > 0 ]]; then
for tarch in ${tarches[@]}; do
arch_db_remove "$repo-$DEBUGSUFFIX" "$tarch" ${remove_dbg_pkgs[@]}
done
fi
arch_history_commit "db-remove: ${remove_pkgs[*]}"
fi
for tarch in ${tarches[@]}; do
repo_unlock $repo $tarch
if [[ ! $repo =~ .*-${DEBUGSUFFIX}$ ]]; then
repo_unlock $repo-$DEBUGSUFFIX $tarch
fi
done