]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blob - wwwbin/archive-dupe-cleanup.sh
Use 'x in dict' syntax, it's more pythonic and has_key() is gone in python3
[projects/pld-ftp-admin.git] / wwwbin / archive-dupe-cleanup.sh
1 #!/bin/sh
2 set -e
3
4 archive_tree=.archive/PLD
5 other_tree=$1
6 ftp_dir=~ftp/pld/dists/th
7
8 die() {
9         echo >&2 "$*"
10         exit 1
11 }
12
13
14 test -n "$other_tree" || die 'specify other tree, ex: 2015/PLD'
15
16 archive_dir=$ftp_dir/$archive_tree/SRPMS/.metadata
17 other_dir=$ftp_dir/$other_tree/SRPMS/.metadata
18
19 test -d "$archive_dir" || die '$archive_dir not a dir'
20 test -d "$other_dir" || die '$other_dir not a dir'
21
22 match_pkgs() {
23         for f in $archive_dir/*.info; do
24                 fn=${f##*/}
25                 if [ -f "$other_dir/$fn" ]; then
26                         echo $fn
27                 fi
28         done
29 }
30
31 remove_pkgs=$(match_pkgs)
32 test -n "$remove_pkgs" || die "nothing matched"
33 c=$(echo "$remove_pkgs" | wc -l)
34 echo >&2 "$c packages to remove from $archive_dir. ctrl-c to abort"
35 read a
36
37 echo >&2 pfa-rmpkg $archive_tree $remove_pkgs
38 pfa-rmpkg $archive_tree $remove_pkgs
This page took 0.029339 seconds and 3 git commands to generate.