[pacman-dev] [PATCH 1/4] Add delta information to the repository database.
Kevin Piche
kevin.piche at cgi.com
Tue Oct 16 13:56:03 EDT 2007
On Tue, 2007-10-16 at 09:03 -0400, Nathan Jones wrote:
> On Mon, Oct 15, 2007 at 09:24:19PM -0500, Dan McGee wrote:
> > > + 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)"
> >
> > Is there any way to do it without so much sed-magic, or at least make
> > it look slightly cleaner? If not, then we'll have to live with it. Can
> > you add some comments above it explaining the regex in case someone
> > else ever has to change it though?
>
> This was the only method I could think of, aside from creating the delta
> as a tar file with a .DELTAINFO like packages. I'll add the comment.
You could remove the extra parentheses:
echo ${filename} | sed -e 's/^\(.*\)-.*-.*_to_.*$/\1/'
echo ${filename} | sed -e 's/^.*-\(.*-.*\)_to_.*$/\1/'
echo ${filename} | sed -e 's/^.*_to_\(.*-.*\)-.*$/\1/'
echo ${filename} | sed -e 's/^.*_to_.*-.*-\(.*\)\..*$/\1/'
or dump the parts to an array:
arr=(`echo ${filename} | sed -e 's/\(.*\)-\(.*-.*\)_to_\(.*-.*\)-\(.*
\).delta/\1 \2 \3 \4/'`)
To bad there is no "non-greedy" modifier in sed.
> > > + # 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
> >
> > Will this create an empty deltas file if it doesn't exist? We probably
> > don't want that (just db clutter).
>
> The deltas file will always have at least '%DELTAS%\n' in it. I will
> change it so it is only created if needed.
>
> _______________________________________________
> pacman-dev mailing list
> pacman-dev at archlinux.org
> http://archlinux.org/mailman/listinfo/pacman-dev
More information about the pacman-dev
mailing list