summaryrefslogtreecommitdiff
path: root/fdroids.sh
blob: 4eb18335fbf663e90ee8f63a32c47081041847fa (plain)
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
#!/bin/sh
set -ex
quiet() { "$@" >/dev/null 2>&1; }
quiet dpkg-query -W html-xml-utils || sudo apt install html-xml-utils
stale() { [ $(( $(date +%s) - $(stat -c%Y "$1") )) -gt $(( 60*60*12 )) ]; }
while read url
do
        case "$url" in
                https://f-droid.org/en/packages/*/)
                        pkg=${url#https://f-droid.org/en/packages/}
                        pkg=${pkg%/}
                        ;;
                *) continue ;;
        esac
        html=$pkg.html
        if [ ! -e "$html" ] || stale "$html"
        then
                wget -a wget-log.txt -c -O "$html" "$url" || { rm -f "$html"; break; }
                link=$(hxwls "$html" | egrep "/repo/${pkg}_[0-9]+\.apk\$" | sort -n | tail -n1)
                if [ "$link" ]
                then
                        mkdir -p repo
                        (cd repo && wget -c "$link" "$link.asc" -a "$pkg".wget-log.txt)
                fi
        fi
done < fdroids.txt