Signed-off-by: Nathan Jones <nathanj@insightbb.com> --- scripts/repo-add.sh.in | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 45 insertions(+), 1 deletions(-) diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index cb741d7..67fa4f1 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -97,6 +97,34 @@ write_list_entry() { fi } +# write a delta entry to the pacman database +# arg1 - path to delta +db_write_delta() +{ + # blank out all variables and set deltafile + local deltafile=$(readlink -f "$1") + local filename=$(basename "$deltafile") + local pkgname fromver tover arch csize md5sum + + pkgname="$(echo "$filename" | sed -e 's/\(.*\)-\(.*-.*\)_to_\(.*-.*\)-\(.*\).delta/\1/')" + fromver="$(echo "$filename" | sed -e 's/\(.*\)-\(.*-.*\)_to_\(.*-.*\)-\(.*\).delta/\2/')" + tover="$(echo "$filename" | sed -e 's/\(.*\)-\(.*-.*\)_to_\(.*-.*\)-\(.*\).delta/\3/')" + arch="$(echo "$filename" | sed -e 's/\(.*\)-\(.*-.*\)_to_\(.*-.*\)-\(.*\).delta/\4/')" + md5sum="$(md5sum "$deltafile" | cut -d ' ' -f 1)" + + # get size of delta + csize=$(du -b -L "$deltafile" | cut -f 1) + + # ensure $pkgname and $pkgver variables were found + if [ -z "$pkgname" -o -z "$fromver" ]; 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() @@ -106,6 +134,7 @@ db_write_entry() local pkgname pkgver pkgdesc url builddate packager csize size \ group depend backup license replaces provides conflict \ _groups _depends _backups _licenses _replaces _provides _conflicts + local startdir local OLDIFS="$IFS" # IFS (field seperator) is only the newline character @@ -133,6 +162,7 @@ db_write_entry() # get compressed size of package csize=$(du -b -L "$pkgfile" | cut -f 1) + startdir=`pwd` pushd "$gstmpdir" 2>&1 >/dev/null # ensure $pkgname and $pkgver variables were found @@ -183,8 +213,22 @@ db_write_entry() write_list_entry "CONFLICTS" "$_conflicts" "depends" write_list_entry "PROVIDES" "$_provides" "depends" + # create deltas entry + msg2 "$(gettext "Creating 'deltas' db entry...")" + echo -e "%DELTAS%" >>deltas + for delta in $startdir/$pkgname-*-*_to_*-*-$arch.delta; do + if [ -e "$delta" ]; then + if db_write_delta "$delta"; then + msg2 "$(gettext "Added delta '%s'")" "$(basename "$delta")" + else + msg2 "$(gettext "Could not add delta '%s'")" "$(basename "$delta")" + fi + fi + done + echo -e "" >>deltas + # preserve the modification time - touch -r "$pkgfile" desc depends + touch -r "$pkgfile" desc depends deltas popd 2>&1 >/dev/null } # end db_write_entry -- 1.5.3.4