base-files request

Igor Pechtchanski pechtcha@cs.nyu.edu
Mon Jun 21 19:03:00 GMT 2004


On Mon, 21 Jun 2004, John Morrison wrote:

> > From: Igor Pechtchanski
>
> > Another thing that was talked about was checking whether /etc/profile was
> > edited and updating it if it wasn't (same probably goes for other
> > /etc/defaults scripts).  One way to do this is to compare /etc/profile
> > with /etc/defaults/etc/profile in the preremove script, and if it's the
> > same, remove /etc/profile, i.e.,
>
> Yes, I've been playing with this idea...
>
> > if /bin/cmp -s /etc/defaults/etc/profile /etc/profile; then
> >   echo "/etc/profile was modified, leaving as-is"

Whoops.  cmp returns true if the files are the same...  I'm properly
embarrassed.

> > elif [ $? -eq 127 ]; then
> >   echo "diffutils must have been uninstalled, sorry"
> > else
> >   /bin/rm /etc/profile
> > fi
> >
> > The contortions above are needed to correctly handle the case when
> > "diffutils" is being upgraded as well.  Of course, upgrading "fileutils"
> > will cause "rm" to fail, and no postinstall script will work if either
> > "cygwin" or "bash" is upgraded, but at least the above won't remove
> > /etc/profile if /bin/cmp is missing (as the first obvious choice,
> >
> > if ! /bin/cmp -s /etc/defaults/etc/profile /etc/profile; then

Same here.  This shouldn't have been a negation, and thus a missing cmp
will be safe.

> >   /bin/rm /etc/profile
> > fi
> >
> > would have).
>
> #!/bin/sh
> [ -f /etc/preremove/base-files-manifest.lst ] || exit 0
>
> echo "*** Removing unmodified base files."
> echo "*** These will be updated by the postinstall script."
> echo "*** Please wait."
>
> while read f; do
> /bin/cmp -s "${f}" "/etc/defaults${f}"
>   if [ "`echo $?`" -eq "0" ]; then
>     echo ${f} hasn't been modified, it will be updated
>     /bin/rm -f "${f}"
>   fi
> done < base-files-manifest.lst
         ^^^^^^^^^^^^^^^^^^^^^^^
Shouldn't this be "/etc/preremove/base-files-manifest.lst"?

Also, why not simply

while read f; do
  if /bin/cmp -s "${f}" "/etc/defaults${f}"; then
    echo $f hasn't been modified, it will be updated
    /bin/rm -f "${f}"
  fi
done < /etc/preremove/base-files-manifest.lst

or even

while read f; do
  /bin/cmp -s "${f}" "/etc/defaults${f}" && \
    echo $f hasn't been modified, it will be updated && \
    /bin/rm -f "${f}"
done < /etc/preremove/base-files-manifest.lst

> but I'll add the test for diffutils :)

No need -- it should be safe here.  You really need this test if you want
to distinguish between "false" (i.e., 1..126) and "missing" (i.e., 127).

> This way the skel files will be upgraded in the same manner.
>
> I have been wondering how best to release this, there have been
> several patches to profile, but if I release a new package with the
> new version of profile then the preremove script will never
> upgrade... but how long do I (we? ;) give people to upgrade?
>
> J.

Maybe just add a note in the announcement (and, of course, the README)
that if the /etc/profile doesn't contain any customizations, one should
remove it before upgrading the "base-files" package to be able to get the
latest versions in the future...
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton



More information about the Cygwin-apps mailing list