summaryrefslogtreecommitdiff
path: root/cron-jobs/make_repo_torrents
diff options
context:
space:
mode:
authorJoseph Graham <joseph@fibreglass.tunachunks>2014-07-27 11:55:01 +0100
committerJoseph Graham <joseph@fibreglass.tunachunks>2014-07-27 11:55:01 +0100
commitb2a763cee1f67751065c39800a59c431ec872bfa (patch)
tree310c352345873799e81de94ff016e9539ece5cdc /cron-jobs/make_repo_torrents
parent52951d35c69766d0d196fc4cf59fb4864f46d334 (diff)
Dividing make_repo_torrents into two scripts, one to make the actual torrent and a wrapper to find any updated packages and call the first script for each...
Diffstat (limited to 'cron-jobs/make_repo_torrents')
-rwxr-xr-xcron-jobs/make_repo_torrents57
1 files changed, 7 insertions, 50 deletions
diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents
index faee191..c94d073 100755
--- a/cron-jobs/make_repo_torrents
+++ b/cron-jobs/make_repo_torrents
@@ -14,7 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# This script depends on `mktorrent'
+# This script finds any updated packages and makes calls
+# `make_indivudual_torrent' for each of them.
username=$( id -un )
@@ -35,71 +36,27 @@ esac
public_location="$FTP_BASE/"
torrent_location="$FTP_BASE/torrents/"
-# 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/')
-
-# 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
-# (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}"
+# Find any directories that might have packages in then
find "${public_location}" -name 'os' -type 'd' |
while read dir
do
+ # Find any packages
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 a .torrent file does not already exist for this package, we call
+ # `make_individual_torrent' to make it.
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=''
-
- # 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
-
- # There should not be a random comma at the end of the webseeds
- webseeds="${webseeds%,}"
-
- mktorrent -a "${tracker}" "${pkg}" -w "${webseeds}" >/dev/null ||
- echo "Error making torrent for \"${pkg}\""
+ /srv/http/repo/dbscripts/make_individual_torrent "${pkg}"
fi
done
done