From c9ad9623c80ddf2db2a734b4a7914ab9eebd84fb Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Sun, 1 Jun 2014 16:04:55 +0100 Subject: Added the script `make_repo_torrents' which makes torrents for all the packages. --- cron-jobs/make_repo_torrents | 81 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 cron-jobs/make_repo_torrents (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents new file mode 100644 index 0000000..d3c3df6 --- /dev/null +++ b/cron-jobs/make_repo_torrents @@ -0,0 +1,81 @@ +#! /bin/bash +# Copyright (C) 2014 Joseph Graham +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This script depends on `mktorrent' + +username=$( id -un ) + +case "${username}" in + repo | root ) + true + ;; + * ) + echo "This script must be run as repo user or root user." + echo "ByeBye!" + exit 1 + ;; +esac + +# pacman doesn't support multiple different packages of the same name, +# so it's OK to just stuff all the torrents into a single directory. +torrent_location='/srv/http/repo/public/torrents/' +public_location='/srv/http/repo/public/' + +# Tracker announce URL +tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon + +# All mirrors go here +declare -a url_prefixes=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/') + +cd "${torrent_location}" + +find "${public_location}" -name 'os' -type 'd' | +while read dir +do + find "${dir}" -name '*\.pkg\.tar\.xz' | + while read pkg + do + pkg_name="${pkg##*/}" + + if [[ -h "${pkg}" ]] # check if it's a symbolic link + then + # We get the target of the symlink + pkg=$( readlink -f "${pkg}" ) + fi + + if ! [[ -f "${torrent_location}${pkg_name}.torrent" ]] + then + # We need to make a comma seperated list of webseeds (this is passed + # as a single argument to mktorrent) + webseeds='' + + for prefix in "${url_prefixes[@]}" + do + webseeds+="${prefix}${pkg#${public_location}}," + done + + # There should not be a random comma at the end of the webseeds + webseeds="${webseeds%,}" + + mktorrent -a "${tracker}" "${pkg}" -w "${webseeds}" # "${torrent_location}" + fi + done +done + +if [[ "${username}" == root ]] +then + chown repo * +fi -- cgit v1.2.3-2-g168b From ee8da885dc5062001861e4355602a39ae972c32c Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Mon, 2 Jun 2014 12:48:47 +0100 Subject: Made it randomize the order of the webseed list for every torrent. --- cron-jobs/make_repo_torrents | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index d3c3df6..dffd0dc 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -38,7 +38,25 @@ public_location='/srv/http/repo/public/' tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon # All mirrors go here -declare -a url_prefixes=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/') +declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/') + +# I got this function from http://mywiki.wooledge.org/BashFAQ/026 . It +# shuffles an array. Uses a global array variable. Must be compact +# (not a sparse array). The array must be called `array'. +shuffle() { + local i tmp size max rand + + # $RANDOM % (i+1) is biased because of the limited range of $RANDOM + # Compensate by using a range which is a multiple of the array size. + size=${#array[*]} + max=$(( 32768 / size * size )) + + for ((i=size-1; i>0; i--)); do + while (( (rand=$RANDOM) >= max )); do :; done + rand=$(( rand % (i+1) )) + tmp=${array[i]} array[i]=${array[rand]} array[rand]=$tmp + done +} cd "${torrent_location}" @@ -62,7 +80,12 @@ do # as a single argument to mktorrent) webseeds='' - for prefix in "${url_prefixes[@]}" + # Randomize the order of the list of webseeds because I + # don't know if transmission might always use the one at + # the top otherwize. + shuffle + + for prefix in "${array[@]}" do webseeds+="${prefix}${pkg#${public_location}}," done -- cgit v1.2.3-2-g168b From 6979cf5d1e4a599fbabaed4fe643e9db0f0f871c Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Mon, 2 Jun 2014 12:54:47 +0100 Subject: Added encyclomundi's mirror to the webseeds array. --- cron-jobs/make_repo_torrents | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index dffd0dc..246264d 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -38,7 +38,7 @@ public_location='/srv/http/repo/public/' tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon # All mirrors go here -declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/') +declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/' 'http://mirror.parlementum.net/') # I got this function from http://mywiki.wooledge.org/BashFAQ/026 . It # shuffles an array. Uses a global array variable. Must be compact -- cgit v1.2.3-2-g168b From ad79659b3057fd5afac3629e9dd53ea3b93fb58e Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Fri, 6 Jun 2014 12:29:21 +0100 Subject: Made it only give output on an error. --- cron-jobs/make_repo_torrents | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index 246264d..797142e 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -93,7 +93,8 @@ do # There should not be a random comma at the end of the webseeds webseeds="${webseeds%,}" - mktorrent -a "${tracker}" "${pkg}" -w "${webseeds}" # "${torrent_location}" + mktorrent -a "${tracker}" "${pkg}" -w "${webseeds}" >/dev/null || + echo "Error making torrent for \"${pkg}\"" fi done done -- cgit v1.2.3-2-g168b From c121ead116f26ed2b36247247fdf4a0d19f063f2 Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Mon, 16 Jun 2014 14:09:50 +0100 Subject: removed all mirrors but one since pacman2pacman now re-writes the webseeds list to just point to the user's chosen mirror. --- cron-jobs/make_repo_torrents | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index 797142e..0798a5e 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -38,7 +38,11 @@ public_location='/srv/http/repo/public/' tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon # All mirrors go here -declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/' 'http://mirror.parlementum.net/') +#declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/' 'http://mirror.parlementum.net/') + +# I'm removing all mirrors but one since pacman2pacman now re-writes +# the webseeds list to just point to the user's chosen mirror +declare -a array=('http://repo.parabolagnulinux.org/') # I got this function from http://mywiki.wooledge.org/BashFAQ/026 . It # shuffles an array. Uses a global array variable. Must be compact -- cgit v1.2.3-2-g168b From ee08c7abc25647e8ad038df03ac35144401b6091 Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Sun, 29 Jun 2014 15:34:37 +0100 Subject: Added an additional tracker. --- cron-jobs/make_repo_torrents | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index 0798a5e..b5c6749 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -34,8 +34,8 @@ esac torrent_location='/srv/http/repo/public/torrents/' public_location='/srv/http/repo/public/' -# Tracker announce URL -tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon +# Tracker announce URLs, comma seperated +tracker='http://t67.eu:6969/announce,http://tracker.hackcoop.com.ar/announce' # t67.eu is run by Xylon # All mirrors go here #declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/' 'http://mirror.parlementum.net/') -- cgit v1.2.3-2-g168b