1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

repo-add : drop delta support to rewrite it from scratch

The current implementation has several problems :

Wrong database format

All the info is taken from the filename, which is a bit ugly

It looks for .delta files in the current directory when adding a package,
which is not very flexible

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
This commit is contained in:
Xavier Chantry 2009-02-26 20:08:33 +01:00
parent 994804f20e
commit 89685bdb29

View File

@ -107,37 +107,6 @@ find_pkgentry()
return 1
}
# write a delta entry to the pacman database
# arg1 - path to delta
db_write_delta()
{
# blank out all variables
local deltafile="$1"
local filename=$(basename "$deltafile")
local deltavars pkgname fromver tover arch csize md5sum
# format of the delta filename:
# (package)-(fromver)_to_(tover)-(arch).delta
deltavars=( $(echo "$filename" | sed -e 's/\(.*\)-\(.*-.*\)_to_\(.*-.*\)-\(.*\).delta/\1 \2 \3 \4/') )
pkgname=${deltavars[0]}
fromver=${deltavars[1]}
tover=${deltavars[2]}
arch=${deltavars[3]}
# get md5sum and size of delta
md5sum="$(openssl dgst -md5 "$deltafile" | awk '{print $NF}')"
csize=$(@SIZECMD@ "$deltafile")
# ensure variables were found
if [ -z "$pkgname" -o -z "$fromver" -o -z "$tover" -o -z "$arch" ]; then
return 1
fi
# add the entry for this delta file
echo -e "$fromver $tover $csize $filename $md5sum" >>deltas
} # end db_write_delta
# write an entry to the pacman database
# arg1 - path to package
db_write_entry()
@ -232,40 +201,12 @@ db_write_entry()
write_list_entry "PROVIDES" "$_provides" "depends"
write_list_entry "OPTDEPENDS" "$_optdepends" "depends"
# create deltas entry if there are delta files
# Xav : why should deltas be in $startdir?
for delta in $startdir/$pkgname-*-*_to_*-*-$arch.delta; do
# This for loop also pulls in all files that start with the current package
# name and are followed by a -whatever. For instance, running this loop for
# gcc would also grab gcc-libs. To guard against this, compare the package
# name of the delta to the current package name.
local filename=$(basename "$delta")
local dpkgname="$(echo "$filename" | sed -e 's/\(.*\)-.*-.*_to_.*-.*-.*.delta/\1/')"
if [ "$pkgname" = "$dpkgname" -a -f "$delta" ]; then
# create deltas file if it does not already exist
if [ ! -f "deltas" ]; then
msg2 "$(gettext "Creating 'deltas' db entry...")"
echo -e "%DELTAS%" >>deltas
fi
# write this delta entry
if db_write_delta "$delta"; then
msg2 "$(gettext "Added delta '%s'")" "$(basename "$delta")"
else
warning "$(gettext "Could not add delta '%s'")" "$(basename "$delta")"
fi
fi
done
# add the final newline
[ -f "deltas" ] && echo -e "" >>deltas
popd 2>&1 >/dev/null
# preserve the modification time
# Xav : what for?
pkgdir="$gstmpdir/$pkgname-$pkgver"
touch -r "$pkgfile" "$pkgdir/desc" "$pkgdir/depends"
[ -f "$pkgdir/deltas" ] && touch -r "$pkgfile" "$pkgdir/deltas"
return 0
} # end db_write_entry