summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xupdate-fdroids.bash (renamed from fdroids.sh)47
1 files changed, 26 insertions, 21 deletions
diff --git a/fdroids.sh b/update-fdroids.bash
index 8830a18..aa2804b 100755
--- a/fdroids.sh
+++ b/update-fdroids.bash
@@ -46,32 +46,37 @@ parse_pkgname()
46 esac 46 esac
47} 47}
48 48
49show_pkg()
50{
51 for x in name summary description
52 do
53 hxextract .package-$x "$1" |
54 w3m -T text/html |
55 sed -e '/^$/d'
56 echo
57 done
58}
59
49fetch_pkg() 60fetch_pkg()
50{ 61{
51 local pkg="$1" 62 local pkg="$1"
52 url=$baseurl/en/packages/$url 63 url=$baseurl/en/packages/$pkg
53 if wget_with_log -c -O index.html "$url" 64 if wget_with_log -O index.html.part "$url"
54 then 65 then
55 # Wget might not touch file if it is up-to-date 66 mv -T index.html.part index.html
56 # with server
57 touch "$pkgdir"/index.html
58 else 67 else
59 echo "failed to fetch url ${url@Q}" >&2 68 echo "failed to fetch url ${url@Q}" >&2
60 return 69 return 1
61 fi 70 fi
62 71
63 if hxwls "$pkgdir"/index.html | 72 hxwls index.html |
64 egrep "^$baseurl/repo/${pkg}_[0-9]+\.apk\$" | 73 egrep "^$baseurl/repo/${pkg}_[0-9]+\.apk\$" |
65 sort -n | 74 sort -n |
66 tail -n1 | 75 tail -n1 |
67 read link && 76 read link &&
68 [ "$link" ] 77 [ "$link" ] || return
69 then 78 show_pkg index.html >&2
70 (cd "$pkgdir" && 79 wget_with_log -c "$link" "$link.asc"
71 wget_with_log -c "$link" "$link.asc")
72 else
73 echo "failed to fetch package ${pkg@Q}" >&2
74 fi
75} 80}
76 81
77quiet dpkg-query -W html-xml-utils || sudo apt install html-xml-utils 82quiet dpkg-query -W html-xml-utils || sudo apt install html-xml-utils
@@ -89,13 +94,13 @@ do
89 fi 94 fi
90 pkgdir=repo/$pkg 95 pkgdir=repo/$pkg
91 mkdir -p "$pkgdir" 96 mkdir -p "$pkgdir"
92 if stale "$pkgdir"/index.html 97 stale "$pkgdir"/stamp || continue
98 stale "$pkgdir"/failstamp || continue
99 echo "$pkg" >&2
100 if ( cd "$pkgdir" && fetch_pkg "$pkg" )
93 then 101 then
94 echo "$pkg" >&2 102 touch "$pkgdir"/stamp
95 ( 103 else
96 cd "$pkgdir" 104 touch "$pkgdir"/failstamp
97 fetch_pkg "$pkg"
98 )
99 break
100 fi 105 fi
101done 106done