3 if [ -r "/etc/makepkg.conf" ]; then
4 source /etc
/makepkg.conf
6 echo "wget-xdelta: Unable to find makepkg.conf"
10 if [ -r ~
/.makepkg.conf
]; then
11 source ~
/.makepkg.conf
14 out_file
=$
(basename $1)
17 if ! [[ "$out_file" =~
"pkg.tar.gz" ]]; then
18 # If it's not a package file download as normal and exit.
19 #wget --passive-ftp -c -O "$out_file" "$file_url"
24 # Get the package name and version
25 [[ "$out_file" =~
"$CARCH" ]] && arch
="-$CARCH" || arch
=""
26 pkg_data
=$
(echo $out_file | \
27 sed "s|^\(.*\)-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)${arch}${PKGEXT}.part|\1 \2|")
28 pkgname
=$
(echo $pkg_data | cut
-d ' ' -f 1)
29 new_version
=$
(echo $pkg_data | cut
-d ' ' -f 2)
30 base_url
=${file_url%/*}
32 # Look for the last version
33 for file in $
(ls -r /var
/cache
/pacman
/pkg
/${pkgname}-*-*{,-$CARCH}$PKGEXT 2>/dev
/null
); do
34 [[ "$file" =~
"$CARCH" ]] && arch
="-$CARCH" || arch
=""
35 check_version
=$
(echo $file | \
36 sed "s|^.*/${pkgname}-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)${arch}$PKGEXT$|\1|" | \
37 grep -v "^/var/cache/pacman/pkg")
39 [ "$check_version" = "" ] && continue
41 vercmp
=$
(vercmp
"$check_version" "$old_version")
42 if [ "$check_version" != "$new_version" -a $vercmp -gt 0 ]; then
43 old_version
=$check_version
48 if [ "$old_version" != "" -a "$old_version" != "$new_version" ]; then
49 # Great, we have a cached file, now calculate a patch name from it
50 delta_name
="$pkgname-${old_version}_to_${new_version}-${CARCH}.delta"
52 echo "wget-xdelta: Attempting to download delta $delta_name..." >&2
53 if wget
--passive-ftp -c "$base_url/$delta_name"; then
54 echo "wget-xdelta: Applying delta..."
55 if xdelta
patch "$delta_name" "$old_file" "$out_file"; then
56 echo "wget-xdelta: Delta applied successfully!"
60 echo "wget-xdelta: Failed to apply delta!"
66 echo "wget-xdelta: Downloading new package..."
67 wget
--passive-ftp -c -O "$out_file" "$file_url"
70 # vim:set ts=4 sw=4 noet: