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