diff options
author | Simon Doppler <dopsi+gitkraken@dopsi.ch> | 2018-05-14 16:38:45 +0200 |
---|---|---|
committer | Simon Doppler <dopsi+gitkraken@dopsi.ch> | 2018-05-14 16:38:45 +0200 |
commit | f0f38c7807dbbd7eb8e34b6927a7a486a3bb7d8d (patch) | |
tree | 81f6133543ce8ad4c3d0b9e0a917bace016e25c4 | |
parent | 5dd19e71327bbb83e74dc353f9752072ab93c6c9 (diff) | |
download | releng-f0f38c7807dbbd7eb8e34b6927a7a486a3bb7d8d.tar.xz |
update-website: add option '--torrent-only'
Useful to automate torrent generation and website update (no manual
intervention required).
-rwxr-xr-x | update-website | 74 |
1 files changed, 44 insertions, 30 deletions
diff --git a/update-website b/update-website index 2d51bc3..fb58871 100755 --- a/update-website +++ b/update-website @@ -24,6 +24,8 @@ usage() { >&2 echo ' Set website-dir to $dir.' >&2 echo ' --mirror-dir $dir:' >&2 echo ' Set mirror-dir to $dir.' + >&2 echo ' --torrent-only:' + >&2 echo ' Update only torrent related data.' [ -z "$1" ] && exit 1 || exit "$1" } @@ -36,6 +38,7 @@ eval set -- "$( --long torrent-seed-dual: \ --long mirror-dir: \ --long website-dir: \ + --long torrent-only \ -n "$(basename "$0")" -- "$@" || \ echo usage )" @@ -109,6 +112,13 @@ while [ $# -gt 0 ]; do website_dir="$1" echo "$website_dir" > "${tmp_dir}/website_dir.set" ;; + '--torrent-only') + if [ -s "${tmp_dir}/torrent_only.set" ]; then + printf 'Option %s given multiple times.\n' "$1" + usage + fi + echo "true" > "${tmp_dir}/torrent_only.set" + ;; '--') shift break @@ -194,6 +204,40 @@ declare -A desc desc['i686']='i686 only' desc['dual']='dual bootable' +for arch in "${!desc[@]}"; do + if [ ! -s "${tmp_dir}/magnet.${arch}" ]; then + continue + fi + if ! tr '&' '\n' < \ + "${tmp_dir}/magnet.${arch}" | \ + grep -qxF "dn=archlinux-${latest_iso_date}-${arch}.iso"; then + >&2 printf 'Magnet link for %s is not for %s, skipping.\n' "${arch}" "archlinux-${latest_iso_date}-${arch}.iso" + continue + fi + sed -i ' + /<li><a href="magnet:?.*-'"${arch}"'\.iso/ s/href="[^"]\+"/href="'"$(sed 's|&|\\&|g' "${tmp_dir}/magnet.${arch}")"'"/ + /title="Magnet link">Magnet link for \S\+ ('"${desc["${arch}"]}"')/ s/>Magnet link for \S\+ />Magnet link for '"${latest_iso_date}"' / + ' "${website_dir}/download/index.html" +done + +for arch in "${!desc[@]}"; do + if [ ! -s "${tmp_dir}/torrent-seed.${arch}" ]; then + continue + fi + if ! grep -qF "archlinux-${latest_iso_date}-${arch}" "${tmp_dir}/torrent-seed.${arch}"; then + >&2 printf 'Torrent seed for %s is not for %s, skipping.\n' "${arch}" "archlinux-${latest_iso_date}-${arch}.iso" + continue + fi + sed -i ' + /<li><a href="http.*-'"${arch}"'\.iso.torrent/ s/href="[^"]\+"/href="'"$(sed -e 's_/_\\/_g' "${tmp_dir}/torrent-seed.${arch}")"'"/ + /title="Download torrent">Torrent for \S\+ ('"${desc["${arch}"]}"')/ s/>Torrent for \S\+ />Torrent for '"${latest_iso_date}"' / + ' "${website_dir}/download/index.html" +done + +if [ -s "${tmp_dir}/torrent_only.set" ]; then + exit +fi + unset kernels unset sizes declare -A sizes @@ -281,33 +325,3 @@ sed -i "$( ) " \ "${website_dir}/download/index.html" - -for arch in "${!desc[@]}"; do - if [ ! -s "${tmp_dir}/magnet.${arch}" ]; then - continue - fi - if ! tr '&' '\n' < \ - "${tmp_dir}/magnet.${arch}" | \ - grep -qxF "dn=archlinux-${latest_iso_date}-${arch}.iso"; then - >&2 printf 'Magnet link for %s is not for %s, skipping.\n' "${arch}" "archlinux-${latest_iso_date}-${arch}.iso" - continue - fi - sed -i ' - /<li><a href="magnet:?.*-'"${arch}"'\.iso/ s/href="[^"]\+"/href="'"$(sed 's|&|\\&|g' "${tmp_dir}/magnet.${arch}")"'"/ - /title="Magnet link">Magnet link for \S\+ ('"${desc["${arch}"]}"')/ s/>Magnet link for \S\+ />Magnet link for '"${latest_iso_date}"' / - ' "${website_dir}/download/index.html" -done - -for arch in "${!desc[@]}"; do - if [ ! -s "${tmp_dir}/torrent-seed.${arch}" ]; then - continue - fi - if ! grep -qF "archlinux-${latest_iso_date}-${arch}" "${tmp_dir}/torrent-seed.${arch}"; then - >&2 printf 'Torrent seed for %s is not for %s, skipping.\n' "${arch}" "archlinux-${latest_iso_date}-${arch}.iso" - continue - fi - sed -i ' - /<li><a href="http.*-'"${arch}"'\.iso.torrent/ s/href="[^"]\+"/href="'"$(sed -e 's_/_\\/_g' "${tmp_dir}/torrent-seed.${arch}")"'"/ - /title="Download torrent">Torrent for \S\+ ('"${desc["${arch}"]}"')/ s/>Torrent for \S\+ />Torrent for '"${latest_iso_date}"' / - ' "${website_dir}/download/index.html" -done |