forked from a-detiste/cruft-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruleset.sh
executable file
·89 lines (81 loc) · 1.36 KB
/
ruleset.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
#!/bin/bash
LC_ALL=C.UTF-8
set -e
RULESET="$1"
shift
rm -f "$RULESET"
function concat() {
(
release="$1"
find "$release" -type f -printf "%f\n" | sort | while read -r file
do
echo "$file"
while read -r rule
do
case "$rule " in
" ")
;;
"# END"*" $RULESET "*)
break
;;
'#'*)
;;
*"/ ")
echo "${rule:0: -1}"
echo "${rule}**"
;;
*)
echo "$rule"
;;
esac
done < "$release/$file"
done
)
}
concat rules > "$RULESET"
concat non-free >> "$RULESET"
# releases are in reverse order
if dpkg-vendor --is kali
then
concat kali >> "$RULESET"
exit 0
elif dpkg-vendor --derives-from Ubuntu
then
concat ubuntu/devel >> "$RULESET"
archive="ubuntu"
releases="jammy focal bionic xenial"
else
concat archive/sid >> "$RULESET"
archive="archive" # 'debian/' has a special meaning
releases="forky trixie bookworm bullseye buster"
fi
# backport
release="$1"
case "$release" in
"")
exit 0
;;
UNRELEASED)
exit 0
;;
unstable)
exit 0
;;
*-backports)
release="${release%\-backports}"
;;
esac
echo "target release: $release"
for r in $releases
do
if [ -d "$archive/$r" ]
then
echo "adding: $r"
concat "archive/$r" >> "$RULESET"
fi
if [ "$r" = "$release" ]
then
# we are done
exit 0
fi
done