Adam Williamson
2008-05-16 20:16:24 UTC
Hi, all. I only just signed up for the list but most of you probably
know me from IRC, I'm the guy packaging synce for Mandriva.
I realized today that synce's handling of its configuration file is
pretty bad. Quick overview of how it's handled at present:
synce installs a default configuration file to /usr somewhere. This copy
of the file is never actually used in operation. It's just used for the
next bit...
When you run sync-engine, it checks if ~/.synce/config.xml exists. If it
doesn't, it copies the default configuration file from /usr to
~/.synce/config.xml .
The default file is 'active' - that is, it actually sets all the values
it contains, they're not commented out by default.
This is fairly crack-addled in many ways. Easy to illustrate with a
single value from the file:
<OpensyncXMLFormat>OS20</OpensyncXMLFormat>
okay, so we're defaulting to opensync 0.2 format. Great, that's
perfectly sensible right now. But it won't be forever. Some day,
opensync 0.3 / 0.4 will be stable, and we'll want to default to OS30 /
OS40 / whatever it's called by then.
How do we that?
Well, we...er...can't, for existing users. Everyone who's already using
synce will have a ~/.synce/config.xml . We can't make synce's
installation routine edit that file, that'd just be horrible. So anyone
who's already used synce is basically stuck with all the default
configuration values that happened to exist whenever they first
installed synce. Forever. Even if those defaults stop making sense in
future. Even if they never actively set any of those values.
This is how it should be done:
The default config file should install in /etc somewhere, and if it
exists, sync-engine should take it into account when running. It should
*not* actually be 'active' by default: it should list all the default
settings, but they should be commented out. All the defaults should be
written into synce itself.
Whether we create ~/.synce/config.xml by default or not is essentially a
moot point. We may as well, because it aids discoverability, but even if
we don't, everything would work. (As a corollary, sync-engine should not
fail to run if no user configuration file exists and it can't copy the
original from /usr for some reason - that's just crack. It should go
ahead and run, but print a warning). If we do, it should obviously be
the same as the copy in /etc : it should not actually set any values at
all by default.
This would work far better. Now if we want to change a default value in
a new version of synce, it's no problem: just change it in synce's code,
and change the commented-out default in the copy of config.xml that
installs to /etc . Anyone who didn't choose to change any default values
themselves will get the new default automatically.
It's also far better for distribution packagers, like me. The current
situation gives us absolutely no way to set distro-specific defaults.
There *must* be a system-wide configuration file, which has priority
over the written-in defaults, but itself is overridden by the user's own
config file, if it exists. This is the only sane way for distributors,
as packages can touch system-wide configuration files but cannot touch
files in a user's home directory.
Thanks for reading, hope this can be changed soon :)
know me from IRC, I'm the guy packaging synce for Mandriva.
I realized today that synce's handling of its configuration file is
pretty bad. Quick overview of how it's handled at present:
synce installs a default configuration file to /usr somewhere. This copy
of the file is never actually used in operation. It's just used for the
next bit...
When you run sync-engine, it checks if ~/.synce/config.xml exists. If it
doesn't, it copies the default configuration file from /usr to
~/.synce/config.xml .
The default file is 'active' - that is, it actually sets all the values
it contains, they're not commented out by default.
This is fairly crack-addled in many ways. Easy to illustrate with a
single value from the file:
<OpensyncXMLFormat>OS20</OpensyncXMLFormat>
okay, so we're defaulting to opensync 0.2 format. Great, that's
perfectly sensible right now. But it won't be forever. Some day,
opensync 0.3 / 0.4 will be stable, and we'll want to default to OS30 /
OS40 / whatever it's called by then.
How do we that?
Well, we...er...can't, for existing users. Everyone who's already using
synce will have a ~/.synce/config.xml . We can't make synce's
installation routine edit that file, that'd just be horrible. So anyone
who's already used synce is basically stuck with all the default
configuration values that happened to exist whenever they first
installed synce. Forever. Even if those defaults stop making sense in
future. Even if they never actively set any of those values.
This is how it should be done:
The default config file should install in /etc somewhere, and if it
exists, sync-engine should take it into account when running. It should
*not* actually be 'active' by default: it should list all the default
settings, but they should be commented out. All the defaults should be
written into synce itself.
Whether we create ~/.synce/config.xml by default or not is essentially a
moot point. We may as well, because it aids discoverability, but even if
we don't, everything would work. (As a corollary, sync-engine should not
fail to run if no user configuration file exists and it can't copy the
original from /usr for some reason - that's just crack. It should go
ahead and run, but print a warning). If we do, it should obviously be
the same as the copy in /etc : it should not actually set any values at
all by default.
This would work far better. Now if we want to change a default value in
a new version of synce, it's no problem: just change it in synce's code,
and change the commented-out default in the copy of config.xml that
installs to /etc . Anyone who didn't choose to change any default values
themselves will get the new default automatically.
It's also far better for distribution packagers, like me. The current
situation gives us absolutely no way to set distro-specific defaults.
There *must* be a system-wide configuration file, which has priority
over the written-in defaults, but itself is overridden by the user's own
config file, if it exists. This is the only sane way for distributors,
as packages can touch system-wide configuration files but cannot touch
files in a user's home directory.
Thanks for reading, hope this can be changed soon :)
--
adamw
adamw