Setup of default configuration files

Jan Nieuwenhuizen
Tue Jan 7 09:16:00 GMT 2003

"John Morrison" <> writes:

> Christopher and I had a little conversation at the beginning of
> December.  It occured to me/us that a lot of cygwin packages
> have postinstall scripts which just copy default versions of
> configuration files into the correct location if they don't
> already exist.

Isn't that an awfully fragile approach?  What about my suggestion

   * Some care has been taken to treat config files specially (see
     /etc/postinstall/  However, the previous packages
     did not do this, and if you don't want to risk losing changes you
     made, make backups first.  (Does setup.exe have a framework yet
     to tag and handle config files?  It would be good if setup.exe
     would offer choices and show diffs.)

that installs new version of a config file if the user hasn't changed
the previous one?  It would be good to have setup handle this, because
if the user _has_ edited the config file, you want to ask the user
what to do and present the option to show the diff.



# 3] Check the configuration files in /usr/share/texmf/web2c
#      texmf.cnf, fmtutil.cnf and mktex.cnf
#   Note that if you made any changes to the configuration files,
#   new versions won't be installed:

# This should be (made) available from Cygwin install tools...
install_config_file () {
    d=$(dirname $1)
    i=$(basename $1)
    cd $d || return  ## exit 1
    # Any user changes since last time?
    if [ -r $i ]; then
        # If so, should ask user what to do, showing this diff ...
	if [ -r $i.cygwin-orig ]; then
	    diff -u $i $i.cygwin-orig ## > /tmp/$i.diff
	    ## rm -f /tmp/$i.diff
	# No original version to compare to eh?
	# Hmm.  Better install our own, saving current configuration first.
	elif [ ! -r $i.cygwin-save ]; then
	    cp -f $i $i.cygwin-save
    # No user changes to previous install, install it
    if [ $changed -eq 0 ]; then
	cp -f $i.cygwin-dist $i
    # Save distributed config file for next time
    cp -f $i.cygwin-dist $i.cygwin-orig

> It was thought that this could be simplified into just one
> postinstallation script.  Basically, the script would, when a
> new file has been placed under a particular directory
> (/etc/defaults/) it would be copied (/etc/defaults/ becomming
> the equivalent of /) if a file of the same name didn't already
> exist.
> This has (I think) two advantages
> 1) not everyone has to maintain such a post installation script and
> 2) there's no excuse not to make use of it and config files
>    wouldn't be deleted upon uninstall.
> Anyway, the script...
> #!/bin/sh
> cd /etc/defaults
> for f in `find . -type f`; do
>         fDest=`echo $f | sed 's/^\.//g'`
>         if [ ! -f $fDest ]; then
>                 echo Using the default version of $fDest
>                 cp $f $fDest
>         else
>                 echo $fDest is already in existance, not overwriting.
>         fi
> done
> Packages can be found... (note that it needs renumbering,
> but should give you some idea of the functionality)
> <
> ate-defaults-1.0-1.tar.bz2>
> <
> aults.html>
> (this should be added to the 'how to create a package' instructions, or
> something like?)
> <
> up.hint>
> sdesc: "Conditionally move default files to proper location"
> category: _PostInstallLast
> requires: ash findutils fileutils sed sh-utils
> autodep: etc/defaults/.*
> incver_ifdep: yes
> <
> sum>
> Also, I've re-done base-files using this mechanism as
> a demonstration...
> <
> es-1.2-1.tar.bz2>
> <
> nt>
> <>
> Thanks for reading so much, hope to hear some
> feedback :)
> J.

Jan Nieuwenhuizen <> | GNU LilyPond - The music typesetter       |

More information about the Cygwin-apps mailing list