index : releng | |
Archlinux32 release engineering | gitolite user |
summaryrefslogtreecommitdiff |
author | Simon Doppler <dopsi@dopsi.ch> | 2017-08-06 14:59:08 +0200 |
---|---|---|
committer | Simon Doppler <dopsi@dopsi.ch> | 2017-08-06 14:59:08 +0200 |
commit | 11f19906592d422ee4f320a28527499e4c4a85a4 (patch) | |
tree | 28491ef08a321e831be56275705d3e08d0ff7aee |
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | al32-mktorrent.sh | 71 |
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0cb6b4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.iso* +*sums diff --git a/al32-mktorrent.sh b/al32-mktorrent.sh new file mode 100644 index 0000000..65ba794 --- /dev/null +++ b/al32-mktorrent.sh @@ -0,0 +1,71 @@ +#! /bin/bash +set -euo pipefail + +function join_by { local IFS="$1"; shift; echo "$*"; } + +usage () { + echo "Usage: $0 [i686|dual]" +} + +if [ "$#" -eq 0 ] ; then + echo "No architecture specified, selecting 'i686'" + arch="i686" +elif [ "$#" -eq 1 ] ; then + echo "Selecting architecture '$1'" + arch="$1" +else + usage + echo "Too many arguments, exiting" >&2 + exit 1 +fi + +fg_green="\033[32m" +fg_red="\033[31m" +fg_blue="\033[34m" +fg_reset="\033[0m" +fg_bold="\033[1m" + +MIRRORLIST_FILE="https://raw.githubusercontent.com/archlinux32/packages/master/core/pacman-mirrorlist/mirrorlist" + +mirrorlist="$(curl "$MIRRORLIST_FILE" 2>/dev/null | grep Server | cut -d '=' -f 2 | sed -e 's/\s//g;s_$arch/$repo_archisos/_')" + +declare -a available_mirrors + +read -r -p "Date of the ISO: " iso_date + +iso_string="archlinux-$iso_date-$arch.iso" + +for i in $mirrorlist ; do + echo -n -e "$fg_reset${fg_bold}Checking $fg_reset$fg_blue$i$fg_reset " + curl -g "$i" 2>/dev/null | grep -q "$iso_string" && ( + echo -e "$fg_reset${fg_green}OK$fg_reset" + ) || ( echo -e "$fg_reset${fg_red}Failed$fg_reset" ; false ) || continue + available_mirrors=(${available_mirrors[@]} "$i") +done + +echo "${#available_mirrors[@]} mirrors available" + + +if [ ! -f "$iso_string" ] ; then + echo -e "$fg_reset${fg_bold}Downloading iso...$fg_reset" + curl -O "${available_mirrors[0]}$iso_string" +else + echo -e "$fg_reset${fg_bold}Reusing already downloaded iso...$fg_reset" +fi + + +echo -e "$fg_reset${fg_bold}Downloading verification files...$fg_reset" +curl -O "${available_mirrors[0]}$iso_string.sig" +curl -O "${available_mirrors[0]}sha512sums" + +echo -n -e "$fg_reset${fg_bold}Checking PGP signature...$fg_reset " +gpg --verify "$iso_string.sig" "$iso_string" || exit 100 +echo -e "$fg_reset${fg_green}OK" + +echo -e "$fg_reset${fg_bold}Checking SHA512 sums...$fg_reset" +sha512sum --ignore-missing --check sha512sums || exit 101 + +echo -e "$fg_reset${fg_bold}Create torrent file...$fg_reset" +mktorrent --announce=http://dopsi.ch:6969/announce --web-seed="$(join_by ',' "${available_mirrors[@]}")" "$iso_string" + +# vim: set ts=4 sw=4: |