On Thu, Mar 30, 2006 at 06:02:29PM +0200, Marco d'Itri wrote:
> On Mar 30, Julian Gilbey <[EMAIL PROTECTED]> wrote:
> 
> > > > Also, the default installation of a package should *NOT* give error
> > > > messages: I haven't touched any of the udev configuration files or
> > > > anything.
> > > The default installation does not, but at least for a while (until %e
> > > will work) I will not automatically change an existing configuration.
> > But my installation *does* give this error!  (Unless you mean the
> > default installation in 0.088.)
> Yes. It's a warning. If your system has been working so far then you do
> not need to worry, else you would have already been searching for a
> different solution.
> 
> > A user who installs version 0.4 of a package, makes no local
> > modifications, and then simlpy upgrades 0.4 -> 0.5 -> 0.6 should have
> > a functionally identical system to a user who installs 0.6 in the
> > first place.  That is not happening here.
> An nice principle, but something which may not be trivial to be
> implemented. If the change were just s/a/b/ I would have done it like I
> did for other changes in the past (look at preinst...).

I see what you mean.  I've been thinking hard about this one, and
don't think it's trivial at all.  But it would be the right thing to
do to get it correct.

One way of doing it - not nice, admittedly, but probably good, would
be to keep a record of the symlinks in each version, and then you can
test whether anything has changed, somewhat like the way ucf does
things.  So you could have a list which reads:

020_permissions.rules ../permissions.rules 0.056-2 0.078-1 0.083-1
025_libgphoto2.rules ../libgphoto2.rules 0.065-2
cd-aliases.rules ../cd-aliases.rules 0.022-1 0.087-2

which lists the name of the symlink, the destination, and the versions
in which this was an official symlink.  The version syntax I have used
is very simple:
first_version_symlink_present [first_version_symlink_not_present
  [first version_symlink_present ...]]

Then parsing it would go something like this:

link_in_version() {
  prev_version=shift

  # Can we simply say the if the last version is less than 0.088-3,
  # we'll just ignore version checking?  Don't like this idea, though!
  # But the cd-aliases.rules and the new cd-aliases-generator.rules
  # show that a link may not be removed from rules.d even if the
  # package no longer installs it and it may not be installed if the
  # new package does.  Or maybe these just need special-casing?

  first_new_version=0.088-3
  if dpkg --compare-versions $prev_version -lt $first_new_version; then
    return "unknown"
  fi

  exist=false
  while [ $# -gt 0 ]; do
    test_version=shift
    if dpkg --compare-versions $old_version -lt $test_version; then
      break
    fi
    if [ $exist = false ]; then exist=true; else exist=false; fi
  done
  return $exist
}


prev_version=$2
pristine=true

cat symlinklist |
while read linkname linkdest versions; do
  status=$(link_in_version $prev_version $versions)
  if [ $status = true ]; then
    if [ ! -L /etc/udev/rules.d/$linkname ] ||
      [ "$(readlink /etc/udev/rules.d)" != $linkdest ]; then
      pristine=false
      break
    fi
  elif [ $status = false ]; then
    if [ -e /etc/udev/rules.d/$linkname ]; then
      pristine=false
      break
    fi
  else
    # we don't know whether or not it will exist, but we'll
    # still check that *if* the link does exist, it's sensible
    if [ -L /etc/udev/rules.d/$linkname ] &&
      [ "$(readlink /etc/udev/rules.d)" != $linkdest ]; then
      pristine=false
      break
    fi
  fi
done

for link in $deprecated_links; do
  if [ -L /etc/udev/rules.d/$link ]; then
    if [ $pristine = true ]; then
      rm /etc/udev/rules.d/$link
    else
      # warn that things have changed and you might want to remove
      # /etc/udev/rules.d/$link manually
    fi
  fi
done

for link in $current_links
  if [ ! -e $link ]; then
    if [ $pristine = true ]; then
      add_rules_link $link
    else
      # warn that things have changed etc.
    fi
  fi
done



Extra things which could be useful:
- a file in /etc/udev/rules.d which says "I'm still pristine; if you
  remove me, I will not automatically be updated any longer"
- a file in /etc/udev/rules.d which would list those actions not taken
  by the maintainer script because things had changed

   Julian


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to