Enable support for other download protocols in makepkg
This patch fixes FS #4404 as well as adding support for future protocols by generalizing the concept of a download agent and allowing a downloader to be specified for each protocol. Original work done by Andrew Fyfe <andrew@neptune-one.net>. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
4db7948d1a
commit
df290b499a
2 changed files with 71 additions and 43 deletions
|
@ -6,10 +6,18 @@
|
||||||
# SOURCE ACQUISITION
|
# SOURCE ACQUISITION
|
||||||
#########################################################################
|
#########################################################################
|
||||||
#
|
#
|
||||||
#-- The FTP/HTTP download utility that makepkg should use to acquire sources
|
#-- The download utilities that makepkg should use to acquire sources
|
||||||
FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3 --no-check-certificate"
|
# Format: 'protocol::agent'
|
||||||
#FTPAGENT="/usr/bin/snarf"
|
DLAGENTS=('ftp::/usr/bin/wget -c --passive-ftp -t 3 --waitretry=3'
|
||||||
#FTPAGENT="/usr/bin/lftpget -c"
|
'http::/usr/bin/wget -c -t 3 --waitretry=3'
|
||||||
|
'https::/usr/bin/wget -c -t 3 --waitretry=3 --no-check-certificate'
|
||||||
|
'rsync::/usr/bin/rsync -z'
|
||||||
|
'scp::/usr/bin/scp -C')
|
||||||
|
|
||||||
|
# Other common tools:
|
||||||
|
# /usr/bin/snarf
|
||||||
|
# /usr/bin/lftpget -c
|
||||||
|
# /usr/bin/curl
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
# ARCHITECTURE, COMPILE FLAGS
|
# ARCHITECTURE, COMPILE FLAGS
|
||||||
|
|
|
@ -189,6 +189,39 @@ in_array() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getdownloadclient() {
|
||||||
|
# $1 = url with valid protocol prefix
|
||||||
|
local url=$1
|
||||||
|
local proto=$(echo $netfile | sed 's|://.*||')
|
||||||
|
|
||||||
|
# loop through DOWNLOAD_AGENTS variable looking for protocol
|
||||||
|
for i in "${DLAGENTS[@]}"; do
|
||||||
|
local handler=$(echo $i | sed 's|::.*||')
|
||||||
|
if [ "$proto" == "$handler" ]; then
|
||||||
|
agent=$(echo $i | sed 's|^.*::||')
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# if we didn't find an agent, return an error
|
||||||
|
if [ -z "$agent" ]; then
|
||||||
|
error "$(eval_gettext "There is no agent set up to handle \$proto URLs. Check /etc/makepkg.conf.")"
|
||||||
|
error "$(gettext "Aborting...")"
|
||||||
|
exit 1 # $E_CONFIG_ERROR # TODO: error code
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ensure specified program is installed
|
||||||
|
local program="$(echo $agent | awk '{print $1 }')"
|
||||||
|
if [ ! -x "$program" ]; then
|
||||||
|
local baseprog=$(basename $program)
|
||||||
|
error "$(eval_gettext "The download program \$baseprog is not installed.")"
|
||||||
|
error "$(gettext "Aborting...")"
|
||||||
|
exit 1 # $E_MISSING_PROGRAM # TODO: error code
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$agent"
|
||||||
|
}
|
||||||
|
|
||||||
checkdeps() {
|
checkdeps() {
|
||||||
[ $# -gt 0 ] || return
|
[ $# -gt 0 ] || return
|
||||||
|
|
||||||
|
@ -674,59 +707,46 @@ fi
|
||||||
|
|
||||||
cd "$startdir"
|
cd "$startdir"
|
||||||
|
|
||||||
# retrieve sources
|
|
||||||
msg "$(gettext "Retrieving Sources...")"
|
|
||||||
mkdir -p src
|
mkdir -p src
|
||||||
cd "$startdir/src"
|
cd "$startdir/src"
|
||||||
|
|
||||||
|
msg "$(gettext "Retrieving Sources...")"
|
||||||
for netfile in ${source[@]}; do
|
for netfile in ${source[@]}; do
|
||||||
file=$(strip_url "$netfile")
|
file=$(strip_url "$netfile")
|
||||||
if [ -f "../$file" ]; then
|
if [ -f "../$file" ]; then
|
||||||
msg2 "$(eval_gettext "Found \$file in build dir")"
|
msg2 "$(eval_gettext "Found \$file in build dir")"
|
||||||
cp "../$file" .
|
cp "../$file" .
|
||||||
|
continue
|
||||||
elif [ -f "$SRCDEST/$file" ]; then
|
elif [ -f "$SRCDEST/$file" ]; then
|
||||||
msg2 "$(eval_gettext "Using cached copy of \$file")"
|
msg2 "$(eval_gettext "Using cached copy of \$file")"
|
||||||
cp "$SRCDEST/$file" .
|
cp "$SRCDEST/$file" .
|
||||||
else
|
continue
|
||||||
# check for a download utility
|
|
||||||
if [ -z "$FTPAGENT" ]; then
|
|
||||||
error "$(gettext "FTPAGENT is not configured. Check the /etc/makepkg.conf file.")"
|
|
||||||
msg "$(gettext "Aborting...")"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
ftpclient=$(echo $FTPAGENT | awk {'print $1'})
|
|
||||||
if [ ! -x "$ftpclient" ]; then
|
|
||||||
local clientname=$(basename $ftpclient)
|
|
||||||
error "$(eval_gettext "ftpclient \$clientname is not installed.")"
|
|
||||||
msg "$(gettext "Aborting...")"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
proto=$(echo "$netfile" | sed 's|://.*||')
|
|
||||||
if [ "$proto" != "ftp" -a "$proto" != "http" -a "$proto" != "https" ]; then
|
|
||||||
error "$(eval_gettext "\$netfile was not found in the build directory and is not a proper URL.")"
|
|
||||||
msg "$(gettext "Aborting...")"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# find the client we should use for this URL
|
||||||
|
dlclient=$(getdownloadclient $netfile) || exit $?
|
||||||
|
|
||||||
msg2 "$(eval_gettext "Downloading \$file")"
|
msg2 "$(eval_gettext "Downloading \$file")"
|
||||||
$FTPAGENT "$netfile"
|
|
||||||
# fix flyspray bug #3289
|
# fix flyspray bug #3289
|
||||||
ftpret=$?
|
ret=0
|
||||||
if [ $ftpret -gt 0 ]; then
|
$dlclient "$netfile" || ret=$?
|
||||||
error "$(eval_gettext "Failure while downloading \$file")"
|
if [ $ret -gt 0 ]; then
|
||||||
|
error "$(gettext "Failure while downloading $file")"
|
||||||
msg "$(gettext "Aborting...")"
|
msg "$(gettext "Aborting...")"
|
||||||
#rm "$file"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$SRCDEST" ]; then
|
if [ -n "$SRCDEST" ]; then
|
||||||
mkdir -p $SRCDEST && cp "$file" $SRCDEST
|
mkdir -p "$SRCDEST" && cp "$file" "$SRCDEST" || ret=$?
|
||||||
if [ $? -ne 0 ]; then
|
if [ $ret -gt 0 ]; then
|
||||||
warning "$(eval_gettext "You do not have correct permissions to cache source in \$SRCDEST")"
|
warning "$(eval_gettext "You do not have correct permissions to cache source in \$SRCDEST")"
|
||||||
cp "$file" ..
|
cp "$file" ..
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
cp "$file" ..
|
cp "$file" ..
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
unset netfile file dlclient ret
|
||||||
|
|
||||||
if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
|
if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
|
||||||
warning "$(gettext "Skipping source integrity checks -- using existing src/ tree")"
|
warning "$(gettext "Skipping source integrity checks -- using existing src/ tree")"
|
||||||
|
|
Loading…
Add table
Reference in a new issue