makepkg: fix download functions with weird urls.

This fixes FS#11076.

1) quote the url in get_downloadclient
2) only enable nullglob where it is needed
You can see in 7fc306cd41 that nullglob was only enabled for one part, and
that it already caused other problems, which were fixed in 7ff5a917fd.
Thanks to Henning Garus for pointing out that nullglob was problematic with
urls containing expansion char like '?'.
3) change get_downloadcmd which displayed the download command line to
download_file which actually executes the download. It seems nicer that way.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Xavier Chantry 2008-08-01 08:29:46 +02:00 committed by Dan McGee
parent 692ea72822
commit 9bc799ec7b
1 changed files with 14 additions and 12 deletions

View File

@ -36,10 +36,6 @@ export TEXTDOMAINDIR='@localedir@'
# file -i does not work on Mac OSX unless legacy mode is set
export COMMAND_MODE='legacy'
# when fileglobbing, we want * in an empty directory to expand to the null
# string rather than itself
shopt -s nullglob
myver='@PACKAGE_VERSION@'
confdir='@sysconfdir@'
startdir="$PWD"
@ -256,7 +252,7 @@ in_array() {
get_downloadclient() {
# $1 = url with valid protocol prefix
local url=$1
local proto=$(echo $netfile | sed 's|://.*||')
local proto=$(echo "$url" | sed 's|://.*||')
# loop through DOWNLOAD_AGENTS variable looking for protocol
local i
@ -287,18 +283,19 @@ get_downloadclient() {
echo "$agent"
}
get_downloadcmd() {
local dlagent=$1
download_file() {
local dlcmd=$1
local netfile=$2
local file=$3
if echo "$dlagent" | grep -q "%u" ; then
local dlcmd=$(echo "$dlagent" | sed "s|%o|$file.part|" | sed "s|%u|$netfile|")
if echo "$dlcmd" | grep -q "%u" ; then
dlcmd=${dlcmd//%o/$file.part}
dlcmd=${dlcmd//%u/$netfile}
else
local dlcmd="$dlagent $netfile"
dlcmd="$dlcmd $netfile"
fi
echo "$dlcmd"
$dlcmd
}
check_deps() {
@ -443,7 +440,7 @@ download_sources() {
msg2 "$(gettext "Downloading %s...")" "$file"
# fix flyspray bug #3289
local ret=0
$(get_downloadcmd "$dlclient" "$netfile" "$file") || ret=$?
download_file "$dlclient" "$netfile" "$file" || ret=$?
if [ $ret -gt 0 ]; then
error "$(gettext "Failure while downloading %s")" "$file"
plain "$(gettext "Aborting...")"
@ -848,10 +845,15 @@ create_package() {
local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
# when fileglobbing, we want * in an empty directory to expand to
# the null string rather than itself
shopt -s nullglob
if ! bsdtar -czf "$pkg_file" $comp_files *; then
error "$(gettext "Failed to create package file.")"
exit 1 # TODO: error code
fi
shopt -u nullglob
}
create_xdelta() {