Clean up variable usage in create_xdelta() and add a check for the xdelta program.
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
This commit is contained in:
parent
a8c552d477
commit
cad44221c8
1 changed files with 16 additions and 17 deletions
|
@ -601,43 +601,42 @@ create_package() {
|
||||||
create_xdelta() {
|
create_xdelta() {
|
||||||
if [ "$(check_buildenv xdelta)" != "y" ]; then
|
if [ "$(check_buildenv xdelta)" != "y" ]; then
|
||||||
return
|
return
|
||||||
|
elif [ ! "$(type -p xdelta)" ]; then
|
||||||
|
error "$(gettext "Cannot find the xdelta binary! Is xdelta installed?")"
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check to see if we have any old versions to create deltas with
|
|
||||||
local pkg_file=$1
|
local pkg_file=$1
|
||||||
local base_file=""
|
local cache_dir="/var/cache/pacman/pkg" # TODO: autoconf me
|
||||||
local delta_file=""
|
local old_versions=( $(ls {"$cache_dir","$PKGDEST"}/${pkgname}-*-${CARCH}.${PKGEXT} 2>/dev/null) )
|
||||||
local cache_dir="/var/cache/pacman/pkg"
|
|
||||||
local latest_version=""
|
|
||||||
local old_versions=( $(ls ${cache_dir}/${pkgname}-*-${CARCH}.${PKGEXT} 2>/dev/null; ls ${PKGDEST}/${pkgname}-*-${CARCH}.${PKGEXT} 2>/dev/null) )
|
|
||||||
|
|
||||||
local old_file dirname filename namend old_version
|
# Check to see if we have any old versions to create deltas with
|
||||||
|
local old_file old_version latest_version base_file
|
||||||
for old_file in "${old_versions[@]}"; do
|
for old_file in "${old_versions[@]}"; do
|
||||||
dirname=$(dirname $old_file)
|
old_version=$(basename "${old_file%-$CARCH.$PKGEXT}")
|
||||||
filename=$(basename $old_file)
|
old_version=${old_version#$pkgname-}
|
||||||
namend=${filename#"$pkgname-"}
|
|
||||||
old_version=${namend%-"${CARCH}.${PKGEXT}"}
|
|
||||||
|
|
||||||
# old_version may include the target package, only use the old versions
|
# old_version may include the target package, only use the old versions
|
||||||
if [ "$old_version" != "$pkgver-$pkgrel" ] && [[ "$old_version" > "$latest_version" ]]; then
|
if [ "$old_version" != "$pkgver-$pkgrel" ] && [[ "$old_version" > "$latest_version" ]]; then
|
||||||
latest_version=$old_version
|
latest_version=$old_version
|
||||||
base_file=$old_file
|
base_file=$old_file
|
||||||
delta_file=$PKGDEST/$pkgname-${old_version}_to_$pkgver-$pkgrel-${CARCH}.delta
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$delta_file" != "" ]; then
|
if [ "$base_file" != "" ]; then
|
||||||
msg "Making delta from version $latest_version"
|
msg "Making delta from version $latest_version"
|
||||||
|
local delta_file="$PKGDEST/$pkgname-${old_version}_to_$pkgver-$pkgrel-$CARCH.delta"
|
||||||
|
|
||||||
# xdelta will decompress base_file & pkg_file into TMP_DIR (or /tmp if TMP_DIR is unset)
|
# xdelta will decompress base_file & pkg_file into TMP_DIR (or /tmp if TMP_DIR is unset)
|
||||||
# then perform the delta on the resulting tars
|
# then perform the delta on the resulting tars
|
||||||
xdelta delta $base_file $pkg_file $delta_file
|
xdelta delta "$base_file" "$pkg_file" "$delta_file"
|
||||||
|
|
||||||
# Generate the final gz using xdelta for compression. xdelta will be our common
|
# Generate the final gz using xdelta for compression. xdelta will be our common
|
||||||
# denominator compression utility between the packager and the users
|
# denominator compression utility between the packager and the users
|
||||||
#
|
#
|
||||||
# makepkg and pacman must use the same compression algorithm or the delta generated
|
# makepkg and pacman must use the same compression algorithm or the delta generated
|
||||||
# package may not match, producing md5 checksum errors.
|
# package may not match, producing md5 checksum errors.
|
||||||
#
|
xdelta patch "$delta_file" "$base_file" "$pkg_file"
|
||||||
xdelta patch $delta_file $base_file $pkg_file
|
|
||||||
else
|
else
|
||||||
msg "No previous version found, skipping xdelta"
|
msg "No previous version found, skipping xdelta"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue