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]

Setup of default configuration files


Hi All,

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.

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.


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