summaryrefslogtreecommitdiff
path: root/pacman2pacman-get
diff options
context:
space:
mode:
Diffstat (limited to 'pacman2pacman-get')
-rw-r--r--pacman2pacman-get69
1 files changed, 35 insertions, 34 deletions
diff --git a/pacman2pacman-get b/pacman2pacman-get
index 1a82b4c..d3066b9 100644
--- a/pacman2pacman-get
+++ b/pacman2pacman-get
@@ -35,8 +35,8 @@ pkg_cache_location='/var/cache/pacman/pkg'
# XferCommand = /usr/bin/pacman2pacman-get %u %o
# Check that the args are not empty.
-[[ -z ${1} ]] && { echoerr "The first argument should be the download url." ; exit 1 ; }
-[[ -z ${2} ]] && { echoerr "The second argument should be the local filename, plus a “.part” extension." ; exit 1 ; }
+[[ -z ${1} ]] && { echoerr $"The first argument should be the download url." ; exit 1 ; }
+[[ -z ${2} ]] && { echoerr $"The second argument should be the local filename, plus a “.part” extension." ; exit 1 ; }
url="${1}" # The download url.
filename="${2}" # This is where the downloaded file needs to be saved
@@ -45,7 +45,7 @@ filename="${2}" # This is where the downloaded file needs to be saved
# Check if transmission daemon is running.
if ! systemctl show --property='ActiveState' transmission | grep -q 'ActiveState=active'
then
- echoerr 'Error: The transmission daemon is not running.'
+ echoerr $"Error: The transmission daemon is not running."
exit 1
fi
@@ -121,7 +121,7 @@ else
fi
# We were looking for a torrent, but we didn't find one :o
-[[ "${response}" == 'torrenttime' ]] && echo "Can't find a torrent file for this package :S"
+[[ "${response}" == 'torrenttime' ]] && echo $"Can't find a torrent file for this package :S"
gotourbaby=0 # to record if we've got the torrent yet.
@@ -138,7 +138,7 @@ then
# The filename of the torrent
torntname="${torrent_folder}/${url##*/}.torrent"
-
+
# Move the torrent to the correct location
mv "${response#found_torrent:}" "${torntname}"
@@ -162,9 +162,9 @@ then
(( debugmode )) && transmission-remote -a "${torntname}" -w "${pkg_cache_location}" 2>&1 | tee "${transmission_output}"
(( debugmode )) || transmission-remote -a "${torntname}" -w "${pkg_cache_location}" 2>&1 > "${transmission_output}"
- if grep "Error: invalid or corrupt torrent file" "${transmission_output}"
+ if [[ $? != 0 ]]
then
- echo "Invalid or corrupt torrent file - falling back to HTTP"
+ echo $"Transmission didn't accept our torrent file - falling back to HTTP"
gotourbaby=0
else
# The torrent is now downloading. To get info about the torrent in
@@ -200,7 +200,7 @@ then
# the right place.
progress='0.0%'
- echo -n "Pacman2pacman p2p download: ${pname}: ${progress}"
+ echo -n $"Pacman2pacman p2p download: ${pname}: ${progress}"
count=0
@@ -210,7 +210,8 @@ then
until [[ "${progress}" == '100%' ]]
do
- progress=$(transmission-remote -t "${id}" -i | grep 'Percent Done:')
+ # This finds the line with the percent done.
+ progress=$(transmission-remote -t "113" -i | grep '[[:digit:]]%$' | head -1)
progress="${progress##* }" # Remove stuff we don't want
# If we're still at 0.0% after ${webseed_check_after} attempts
@@ -223,7 +224,7 @@ then
if [[ last_webseed_check[1] == 'broken' ]]
then
# Just set the message without checking.
- progress='0.0% Warning: Webseed dead...'
+ progress=$"0.0% Warning: Webseed dead..."
else
# We don't need to do anything
true
@@ -234,27 +235,27 @@ then
# The webseed seems to be invalid so we print an error
# message.
- progress='0.0% Warning: Webseed dead...' # This
- # most
- # likely
- # means
- # the
- # user
- # needs
- # to run
- # pacman
- # -Sy, or
- # that
- # their
- # internet
- # is
- # down.
+ progress=$"0.0% Warning: Webseed dead..." # This
+ # most
+ # likely
+ # means
+ # the
+ # user
+ # needs
+ # to run
+ # pacman
+ # -Sy, or
+ # that
+ # their
+ # internet
+ # is
+ # down.
# If there are no peers we remove the torrent from
# transmission, print an error message and exit.
if (( $(transmission-remote -t "${id}" -pi | wc -l) < 2 ))
then
- echo "Webseed dead and no peers, removing torrent from transmission and try by HTTP."
+ echo $"Webseed dead and no peers, removing torrent from transmission and trying by HTTP."
transmission-remote -t "${id}" -r > /dev/null
gotourbaby=0
break
@@ -270,7 +271,7 @@ then
fi
fi
- printf "\rPacman2pacman p2p download: %s: %s " "${pname}" "${progress}"
+ printf $"\rPacman2pacman p2p download: %s: %s " "${pname}" "${progress}"
sleep 0.7
@@ -286,7 +287,7 @@ then
do
if (( err_count > 50 ))
then
- echo "error moving \"${pkg_cache_location}/${url##*/}\". removing torrent from transmission"
+ echo $"error moving \"${pkg_cache_location}/${url##*/}\". removing torrent from transmission"
transmission-remote -t "${id}" -r > /dev/null
exittidy ; exit 1
fi
@@ -316,7 +317,7 @@ then
progress='0.0%'
- echo -n "Pacman2pacman http download: ${pname}: ${progress}"
+ echo -n $"Pacman2pacman http download: ${pname}: ${progress}"
# The first loop gets rid of all the backspace and '#'es and
# stuff. The second loop isolates the percent done number.
@@ -347,14 +348,14 @@ then
# start of the download. This should fix it.
[[ "${progress}" == '100.0%' ]] && continue
- printf "\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
+ printf $"\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
done
# It's the end of the download so we can now display 100%
if [[ "${progress}" == '100.0%' ]]
then
progress='100%'
- printf "\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
+ printf $"\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
fi
}
@@ -366,20 +367,20 @@ then
if ! new_mod_time=$(stat -c %Y "/srv/pacman2pacman/dbcache/${filename##*/}" 2>/dev/null)
then
progress='failed'
- printf "\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
+ printf $"\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
# If the file was not modified we display such
elif [[ "${new_mod_time}" == "${mod_time}" ]]
then
progress='file not modified'
- printf "\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
+ printf $"\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
fi
else
# It's not a dbfile. Just check the output file exists.
if ! [[ -f "${filename}" ]]
then
progress='failed'
- printf "\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
+ printf $"\rPacman2pacman http download: %s: %s " "${pname}" "${progress}"
fi
fi