-
Notifications
You must be signed in to change notification settings - Fork 0
/
dupes
executable file
·35 lines (33 loc) · 1.15 KB
/
dupes
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
#!/bin/sh
HERE="$(pwd)"
rm -f "$HERE"/*.dupes
cat >"$HERE"/killdupes.sh <<EOF
#!/bin/sh
EOF
TREE=cooker
for arch in x86_64 znver1 aarch64; do
for repo in main unsupported restricted non-free; do
cd /media/space/openmandriva/abf-downloads/$TREE/repository/$arch/$repo/release
echo "# $arch $repo" >>"$HERE"/killdupes.sh
ls -1 |while read r; do
# We might still get here on a dupe that has already been removed
[ -e $r ] || continue
N="$(rpm -q --qf '%{NAME}' $r)"
V="$(rpm -q --qf '%{VERSION}-%{RELEASE}' $r)"
for i in $N-*.rpm; do
[ "$i" = "$r" ] && continue
NN="$(rpm -q --qf '%{NAME}' $i)"
[ "$N" != "$NN" ] && continue
VV="$(rpm -q --qf '%{VERSION}-%{RELEASE}' $i)"
if [ $(echo -e "$V\n$VV" |sort -V |head -n1) = "$V" ]; then
echo $r >>"$HERE"/$TREE-$arch-$repo.dupes
echo "rm -f /media/space/openmandriva/abf-downloads/$TREE/repository/$arch/$repo/release/$r" >>"$HERE"/killdupes.sh
else
echo $i >>"$HERE"/$TREE-$arch-$repo.dupes
echo "rm -f /media/space/openmandriva/abf-downloads/$TREE/repository/$arch/$repo/release/$i" >>"$HERE"/killdupes.sh
fi
done
done
done
done
chmod +x "$HERE"/killdupes.sh