Forum Forum czatu www.czat.wp.pl --->  RPG Strona Główna
Home - FAQ - Szukaj - Użytkownicy - Grupy - Galerie - Rejestracja - Profil - Zaloguj się, by sprawdzić wiadomości - Zaloguj
s obsolete and you’

 
Napisz nowy temat   Odpowiedz do tematu    Forum Forum czatu www.czat.wp.pl ---> RPG Strona Główna -> Zastrzeżenia co do niektórych ludzi z czatu ... -.-'
Zobacz poprzedni temat :: Zobacz następny temat  
Autor Wiadomość
fertieg97
Zwiastujący Szatana



Dołączył: 23 Wrz 2010
Posty: 395
Przeczytał: 0 tematów

Ostrzeżeń: 0/5
Skąd: England

PostWysłany: Czw 5:42, 14 Paź 2010    Temat postu: s obsolete and you’

if dpkg-maintscript-helper supports rm_conffile 2>/dev/null; then dpkg-maintscript-helper rm_conffile /etc/foo/conf.d/bar 1.2-1 -- "$@"
fi
You can avoid the preliminary test if you pre-depend on “dpkg (>= 1.15.7.2)” or if enough time has passed to assume that everybody has a newer version anyway. You can learn all the details in dpkg-maintscript-helper’s manual page.
When is that needed?
A conffile is a configuration file managed by dpkg, I’m sure you remember the introductory article about conffiles. When your package stops providing a conffile, the file stays on disk and it’s recorded as obsolete by the package manager. It’s only removed during purge. If you want the file to go away, you have to remove it yourself within your package’s configuration scripts. You will now learn how to do this right.
I hope you found this article helpful. You can follow me on Identi.ca,[link widoczny dla zalogowanych], Twitter and Facebook.
What’s complicated in “rm”?
The correct action is thus to move the file away in the prerm, to ensure it doesn’t disturb the new version. At the same time, you need to verify whether the conffile has been modified by the administrator and remember it for later. In the postinst, you need to remove the file if it’s unmodified,[link widoczny dla zalogowanych], or keep it under a different name that doesn’t interfere with the software. In many cases adding a simple .dpkg-bak suffix is enough. For instance,[link widoczny dla zalogowanych], run-parts ignore files that contain a dot, and many other software are configured to only include files with a certain extension―say *.conf. In the postrm, you have to remove the obsolete conffiles that were kept due to local changes and you should also restore the original conffile in case the upgrade obsoleting the conffile is aborted.
Phewww… that’s a lot of things to do for a seemingly simple task. Fortunately everything can be automated with dpkg-maintscript-helper. Let’s assume you want to remove /etc/foo/conf.d/bar because it’s obsolete and you’re going to prepare a new version 1.2-1 with the appropriate code to remove the file on upgrade. You just have to put this snippet in the 3 relevant scripts (preinst, postinst,[link widoczny dla zalogowanych], postrm):
dpkg errs on the side of safety by not removing the file until purge but in most cases it’s best to remove it sooner so as to not confuse the user. In some cases,[link widoczny dla zalogowanych], it’s even required because keeping the file could break the software (for example if the file is in a .d configuration directory, and if it contains directives that are either no longer supported by the new version or in conflict with other new configuration files).
Automating everything with dpkg-maintscript-helper
So you want to remove the conffile. Adding an “rm” command in debian/postinst sounds easy. Except it’s not the right thing to do. The conffile might contain customizations made by the administrator and you don’t want to wipe those. Instead you want to keep the file around so that he can get his changes back and do whatever is required with those.


Post został pochwalony 0 razy
Powrót do góry
Zobacz profil autora
Wyświetl posty z ostatnich:   
Napisz nowy temat   Odpowiedz do tematu    Forum Forum czatu www.czat.wp.pl ---> RPG Strona Główna -> Zastrzeżenia co do niektórych ludzi z czatu ... -.-' Wszystkie czasy w strefie EET (Europa)
Strona 1 z 1

 
Skocz do:  
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach


fora.pl - załóż własne forum dyskusyjne za darmo
Powered by phpBB
Appalachia Theme © 2002 Droshi's Island