Bug 246131 - asymptote package triggers too complicated and not entirely correct
Summary: asymptote package triggers too complicated and not entirely correct
Alias: None
Product: Fedora
Classification: Fedora
Component: asymptote
Version: 8
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Tom "spot" Callaway
QA Contact: Fedora Extras Quality Assurance
Whiteboard: bzcl34nup
Depends On:
TreeView+ depends on / blocked
Reported: 2007-06-28 18:29 UTC by Michal Jaegermann
Modified: 2008-07-21 18:54 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2008-07-21 18:54:32 UTC
Type: ---

Attachments (Terms of Use)

Description Michal Jaegermann 2007-06-28 18:29:19 UTC
Description of problem:

Various triggers in asymptote packages sport a code like this:

VIMVEROLD=`rpm -q --qf='%{epoch}:%{version}\n' vim-common | sort | head -n 1 |
sed -e 's/[0-9]*://' | sed -e 's/\.[0-9]*$//' | sed -e 's/\.//'`
VIMVERNEW=`rpm -q --qf='%{epoch}:%{version}\n' vim-common | sort | tail -n 1 |
sed -e 's/[0-9]*://' | sed -e 's/\.[0-9]*$//' | sed -e 's/\.//'`

A simpler way to get similar results would be something along those

   set_vversions () {
   set_vversions `rpm -q --qf='%{epoch} %{version}\n' vim-common \
     | sort -n | sed -e 's/\.//' -e 's/\..*$//'`

followed by a check if VIMVEROLD was actually set non-empty.

This indeed should be 'sort -n' or otherwise a transition which
bumps a number of digits in %{epoch} will sort incorrectly.
Also version sorting may run into troubles.  The same is true
about the original trigger code.

Version-Release number of selected component (if applicable):
asymptote-1.31-1 and below

Comment 1 Jose Pedro Oliveira 2007-06-28 20:23:52 UTC

Thanks again for the report.

I'll try to update both asymptote and syslog-ng this weekend.


Comment 2 Michal Jaegermann 2007-06-28 21:06:45 UTC
I started to wonder how reliable is a format of %{version} you
will get from 'rpm -q ... vim-common'?  Maybe a more paranoid sed
would be in order?  Something like that:

 ... | sed -e 's/\( [^.]*\.[^.]*\).*/\1/' -e 's/\.\([^.]*\)/\1/'

If you will never get '.' from %{epoch} then this is too paranoid
but conceivably not that much.  OTOH it does not handle a situtation
"dot in %{epoch} and no dot in %{version}".  Something like that
can be accounted for as well but if that is really a possibility
then the easiest would be to process that inside of 'set_vversions'
with a help of 'tr -d .'.

Comment 3 Michal Jaegermann 2007-06-28 21:17:07 UTC
Err..., no.  I am not thinking too well.  AFAICS the following
 ... | sed -e 's/\( [^.]*\)\.\([^.]*\).*/\1\2/'
handles every spread of dots correctly in one substitution.

Comment 4 Michal Jaegermann 2007-07-04 21:21:27 UTC
I looked at the latest version of asimptote triggers and I think
that %triggerpostun is still mildly incorrect.  The idea is to
remove old asy.vim links.  If you would have more old versions
and various VIMVEROLD would be produced for those (not very likely
but something which could happen on a seriously messed up
installation) then you would remove asy.vim only in one of those
and that could leave after cleanup some "orphaned" directories
behind.  If you would do something like that instead:

if [ $1 = 1 ]; then
    VIMVERNEW=`rpm -q --qf='%%{epoch} %%{version}\n' vim-common | \
	sort -n | tail -n 1 | \
	sed -e 's/[^ ]* \([^.]*\)\.\([^.]*\).*/\1\2/'`
    find "%{_datadir}/vim/" -name asy.vim | while read -r f ; do
	echo "$f" | grep -q vim/vim${VIMVERNEW} && continue
	rm -f "$f"
    cd "%{_datadir}/vim/vim${VIMVERNEW}/syntax" 2>/dev/null && \
        ln -sf ../../../%{name}/asy.vim . || :

that would cover such convoluted situations too.

If you are sure that no blanks will ever show up in file names then
a simpler
  find .. | grep -v -q vim/vim${VIMVERNEW | xargs rm -f
could be used instead but a practical difference is minimal.

You do not need to test for a directory presence before 'cd'.
If that is ok then the target exists.

'%triggerun -- vim-common' is even bigger headeache and I would
leave it alone.

I am not sure why you added "[^ ]*" at the beginning of sed match
pattern.  If you can find blank in %{epoch} that you have a mess
on hands anyway.  If you cannot that this does not really change
anything.  Whatever you like.

Comment 5 Bug Zapper 2008-04-04 12:52:31 UTC
Based on the date this bug was created, it appears to have been reported
during the development of Fedora 8. In order to refocus our efforts as
a project we are changing the version of this bug to '8'.

If this bug still exists in rawhide, please change the version back to
(If you're unable to change the bug's version, add a comment to the bug
and someone will change it for you.)

Thanks for your help and we apologize for the interruption.

The process we're following is outlined here:

We will be following the process here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping to ensure this
doesn't happen again.

Comment 6 Tom "spot" Callaway 2008-07-21 18:54:32 UTC
When I picked up this package, I got rid of these triggers, as they were really

Note You need to log in before you can comment on or make changes to this bug.