[opensuse-packaging] changed config location
Hi, I'm currently packaging wbar in my home-project. Recently upstream has changed the default config directory from /etc/default/wbar to /etc/wbar.d/ Now I want to make sure that any existing (changed) configuration in /etc/default/wbar will be kept in /etc/wbar.d Otherwise there would be both an old config dir (with possibly changed .conf files) and a new config dir (with "stock" configuration). I think I have to do this via a script in %pre. Any ideas how to exactly do this? -- Lutz Thuns openSUSE member (lOtz1009) LXDE team -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On Tue, Mar 06, 2012 at 11:56:11AM +0100, Lutz Thuns wrote:
I'm currently packaging wbar in my home-project.
Recently upstream has changed the default config directory from /etc/default/wbar to /etc/wbar.d/ Now I want to make sure that any existing (changed) configuration in /etc/default/wbar will be kept in /etc/wbar.d Otherwise there would be both an old config dir (with possibly changed .conf files) and a new config dir (with "stock" configuration).
I think I have to do this via a script in %pre. Any ideas how to exactly do this?
rpm calculates the fate of the files before running the transactions, so it's not really possible to change the fate in the transaction (even a %pretrans script won't help). It should be possible to emulate rpm's behaviour in a posttrans scriptlet, though. (I.e. *cp* the old config from /etc/default/wbar to /etc/wbar.d/ while adding a .rpmsave suffix or the like.) Also, note that you currently can't replace directories with symlinks to directories and vice versa. So please do not add a "compatibility symlink", it'll just break updates. Cheers, Michael. -- Michael Schroeder mls@suse.de SUSE LINUX Products GmbH, GF Jeff Hawn, HRB 16746 AG Nuernberg main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);} -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Am 06.03.2012 15:25, schrieb Michael Schroeder:
On Tue, Mar 06, 2012 at 11:56:11AM +0100, Lutz Thuns wrote:
I'm currently packaging wbar in my home-project.
Recently upstream has changed the default config directory from /etc/default/wbar to /etc/wbar.d/ Now I want to make sure that any existing (changed) configuration in /etc/default/wbar will be kept in /etc/wbar.d Otherwise there would be both an old config dir (with possibly changed .conf files) and a new config dir (with "stock" configuration).
I think I have to do this via a script in %pre. Any ideas how to exactly do this?
rpm calculates the fate of the files before running the transactions, so it's not really possible to change the fate in the transaction (even a %pretrans script won't help). It should be possible to emulate rpm's behaviour in a posttrans scriptlet, though. (I.e. *cp* the old config from /etc/default/wbar to /etc/wbar.d/ while adding a .rpmsave suffix or the like.)
Also, note that you currently can't replace directories with symlinks to directories and vice versa. So please do not add a "compatibility symlink", it'll just break updates.
Thanks. I'm thinking of following %post section: %post # backup old configuration files to new location if [ -d /etc/default/wbar ]; then for i in /etc/default/wbar/*; do cp $i /etc/wbar.d/$i.rpmsave done rm -r /etc/default/wbar fi Or is this a rather dirty solution? Cheers, Lutz -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Hello, Am Mittwoch, 7. März 2012 schrieb Lutz Thuns:
I'm thinking of following %post section:
%post # backup old configuration files to new location if [ -d /etc/default/wbar ]; then for i in /etc/default/wbar/*; do
AFAIK the paths in %post scripts shouldn't start with / and instead assume that you are in / - so your script should be if [ -d etc/default/wbar ]; then for i in etc/default/wbar/*; do Using /etc in the script will probably break if rpm --root is used (in other words: when booting the installation system from DVD)
cp $i /etc/wbar.d/$i.rpmsave
This will overwrite existing *.rpmsave files. I'd use something like test -e "etc/wbar.d/$i.rpmsave" || mv "$i" "/etc/wbar.d/$i.rpmsave" I also added some quoting to avoid problems with funny filenames (you never know what a user puts there...) This solution still contains a race condition (the *.rpmsave could in theory be created between "test" and "mv"). However that's more a theoretical problem in this case - we are talking about installing packages, which can't happen in parallel, and it's unlikely that the admin creates a *.rpmsave file in exactly this moment.
done rm -r /etc/default/wbar
Better use rmdir etc/default/wbar It will fail if not all config files could be moved, but that's probably better than deleting someone's configfile.
fi
Or is this a rather dirty solution?
Moving around config files is always a dirty job ;-) Regards, Christian Boltz -- Du hast jetzt relativ kompliziert die völlig korrekte Aussage: "SPF ist krank, funktioniert nicht und vom Ansatz her bereits defekt." formuliert. [Peer Heinlein in postfixbuch-users] -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On Thu, Mar 08, 2012 at 01:39:02AM +0100, Christian Boltz wrote:
Am Mittwoch, 7. M?rz 2012 schrieb Lutz Thuns:
I'm thinking of following %post section:
%post # backup old configuration files to new location if [ -d /etc/default/wbar ]; then for i in /etc/default/wbar/*; do
AFAIK the paths in %post scripts shouldn't start with / and instead assume that you are in / - so your script should be
if [ -d etc/default/wbar ]; then for i in etc/default/wbar/*; do
Using /etc in the script will probably break if rpm --root is used (in other words: when booting the installation system from DVD)
Uh, a long time ago old yast called scriptlets after cd'ing into the root directory, but those dark times are over. Rpm always uses a chroot() before running a scriplet, so using an absolute path is the prefered way. Cheers, Michael. -- Michael Schroeder mls@suse.de SUSE LINUX Products GmbH, GF Jeff Hawn, HRB 16746 AG Nuernberg main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);} -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Am 08.03.2012 18:00, schrieb Michael Schroeder:
On Thu, Mar 08, 2012 at 01:39:02AM +0100, Christian Boltz wrote:
Am Mittwoch, 7. M?rz 2012 schrieb Lutz Thuns:
I'm thinking of following %post section:
%post # backup old configuration files to new location if [ -d /etc/default/wbar ]; then for i in /etc/default/wbar/*; do
AFAIK the paths in %post scripts shouldn't start with / and instead assume that you are in / - so your script should be
if [ -d etc/default/wbar ]; then for i in etc/default/wbar/*; do
Using /etc in the script will probably break if rpm --root is used (in other words: when booting the installation system from DVD)
Uh, a long time ago old yast called scriptlets after cd'ing into the root directory, but those dark times are over. Rpm always uses a chroot() before running a scriplet, so using an absolute path is the prefered way.
Hi all, following script is working fine, had to use basename... %post # backup old configuration files to new location if [ -d /etc/default/wbar ]; then for FILE in /etc/default/wbar/*; do cp $FILE /etc/wbar.d/`basename "$FILE"`.rpmsave done fi I dropped the "rm -r /etc/default/wbar" line because zypper/rpm seem to remove the old files after the installation (and after the %post-script). Thanks, -- Lutz Thuns openSUSE member (lOtz1009) LXDE-Team -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (3)
-
Christian Boltz
-
Lutz Thuns
-
Michael Schroeder