-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpurge.sh
98 lines (81 loc) · 3.09 KB
/
purge.sh
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/sh
#
# Copyright (C) 2008-2021 Ruben Rodriguez <ruben@trisquel.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
set -e
DIST=$1
CODENAME=$2
echo Updating git package-helpers...
git --git-dir=/home/ubuntu/package-helpers/.git fetch --all
REPLACE=$(git --git-dir=/home/ubuntu/package-helpers/.git ls-tree -r --name-only origin/$CODENAME|grep helpers/make-|sed 's/.*make-//')
if [ -x purge-$DIST ]
then
. ./purge-$DIST
else
exit 1
fi
echo Listing packages currently in local $DIST repository
reprepro -A source list $DIST | cut -d' ' -f2 > list-$DIST
reprepro -A source list $DIST-updates | cut -d' ' -f2 > list-$DIST-updates
reprepro -A source list $DIST-security | cut -d' ' -f2 > list-$DIST-security
reprepro -A source list $DIST-backports | cut -d' ' -f2 > list-$DIST-backports
# blocklist packages
echo Blocklisting packages defined in purge-$DIST
for PACKAGE in $REMOVE $UNBRAND $FAILSAFE; do
if echo $PACKAGE |grep -q '\*'; then
PACKAGE=$(echo $PACKAGE |sed 's/-*//; s/*//')
EXTRAPACKAGES=$(grep "^$PACKAGE" list-$DIST* | sed 's/.*://' ||true)
for EXTRA in $EXTRAPACKAGES; do
echo "$EXTRA purge" >> conf/purge-$DIST
done
else
echo "$PACKAGE purge" >> conf/purge-$DIST
fi
done
# helper packages
echo Blacklisting packages defined by $CODENAME helpers
rm conf/replace-$DIST* -f
for PACKAGE in $REPLACE; do
BACKPORT=false
git --git-dir=/home/ubuntu/package-helpers/.git \
show origin/$CODENAME:helpers/make-$PACKAGE |grep -q '^BACKPORTS*=true' \
&& BACKPORT=true
if $BACKPORT; then
echo "$PACKAGE purge" >> conf/replace-$DIST-backports
else
echo "$PACKAGE purge" >> conf/replace-$DIST
fi
done
for file in conf/purge-$DIST* conf/replace-$DIST*; do
cat $file | sort -u > $file.tmp
mv $file.tmp $file
done
echo Removing blocklisted packages found in local repository
for REPO in $DIST $DIST-updates $DIST-security; do
for PACKAGE in $(cat conf/purge-$DIST conf/replace-$DIST | sed 's/ .*//'); do
if grep "^$PACKAGE$" -q list-$REPO; then
echo reprepro -v removesrc $REPO $PACKAGE
reprepro -v removesrc $REPO $PACKAGE | echo $? | grep -qv 249
fi
done
done
for PACKAGE in $(cat conf/replace-$DIST-backports | sed 's/ .*//'); do
if grep "^$PACKAGE$" -q list-$DIST-backports; then
echo reprepro -v removesrc $DIST-backports $PACKAGE
reprepro -v removesrc $DIST-backports $PACKAGE | echo $? | grep -qv 249
fi
done
echo Finished