This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Setup of default configuration files


"John Morrison" <john.r.morrison@ntlworld.com> 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

http://www.cygwin.com/ml/cygwin-announce/2002-08/msg00007.html

   * Some care has been taken to treat config files specially (see
     /etc/postinstall/post-texmf.sh).  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.

Greetings,
Jan.

>From post-texmf.sh:

# 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?
    changed=0
    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
	    changed=$?
	    ## 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
	fi
    fi
    
    # No user changes to previous install, install it
    if [ $changed -eq 0 ]; then
	cp -f $i.cygwin-dist $i
    fi
    
    # 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)
> <http://homepage.ntlworld.com/j-n-s.morrison/john/cygwin/update-defaults/upd
> ate-defaults-1.0-1.tar.bz2>
> <http://homepage.ntlworld.com/j-n-s.morrison/john/cygwin/update-defaults/def
> aults.html>
>
> (this should be added to the 'how to create a package' instructions, or
> something like?)
> <http://homepage.ntlworld.com/j-n-s.morrison/john/cygwin/update-defaults/set
> 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
>
> <http://homepage.ntlworld.com/j-n-s.morrison/john/cygwin/update-defaults/md5
> sum>
>
> Also, I've re-done base-files using this mechanism as
> a demonstration...
> <http://homepage.ntlworld.com/j-n-s.morrison/john/cygwin/base-files/base-fil
> es-1.2-1.tar.bz2>
> <http://homepage.ntlworld.com/j-n-s.morrison/john/cygwin/base-files/setup.hi
> nt>
> <http://homepage.ntlworld.com/j-n-s.morrison/john/cygwin/base-files/md5sum>
>
> Thanks for reading so much, hope to hear some
> feedback :)
>
> J.
>
>
>

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien       | http://www.lilypond.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]