FS#13998 - Implement --clean to remove all traces of a package
Attached to Project:
Pacman
Opened by Nezmer (Nezmer) - Saturday, 28 March 2009, 20:52 GMT
Last edited by Dan McGee (toofishes) - Saturday, 28 March 2009, 21:15 GMT
Opened by Nezmer (Nezmer) - Saturday, 28 March 2009, 20:52 GMT
Last edited by Dan McGee (toofishes) - Saturday, 28 March 2009, 21:15 GMT
|
Details
Summary and Info:
I've been using Arch for more than 5 months . The only problem I encountered that wasn't trivial to fix was with CUPS . I tried downgrading packages , removing with 'pacman -cnsu' and reinstalling and finally rebuilding packages . Nothing actually worked . It turned out I had to remove /etc/cups directory to get rid of all traces of CUPS . That actually worked . The files in '/etc/cups' (not just the contents) varies from user to user and they can change continuously . When you remove cups (even with --nosave) , those files will remain in the system . What I'm suggesting here is to implement 'pacman -R --clean' (replace clean with any suitable word) to remove all traces of a package . What '--clean' should do can be determined in the '.install' file for flexibility . Another example is '/usr/lib/oss' . This directory is owned by OSS (Open Sound System) . Currently , this part is included in the .install' file : post_remove() { echo echo "-------------------------------------------------------------" echo " Open Sound System was now removed, and the ALSA kernel" echo " modules were restored." echo echo " Please note that OSS stores some of its configuration files" echo " at /usr/lib/oss. If you don't plan to use OSS anymore, you" echo " can remove this directory." echo "-------------------------------------------------------------" /bin/true } I know I should provide more real-life examples where this option can solve general problems but that's all I have . It's just a suggestion so feel free to ignore it . ""Sorry for my poor English"" Steps to Reproduce: Major upgrade to a package breaks something because some files not owned by the package but created by running it are not compatible with the new version . |
This task depends upon
FS#13932in that there is not always a perfect option to take- sometimes an empty directory is in fact required there, just as here we may end up blowing away files that a user wanted to keep.In short, if pacman doesn't know about the file, we aren't going to touch it. It is just too risky.
My initial thought was that the option should be used in extreme cases where the user wants to restore to the state before the package was ever installed . The option should not remove directories or files known to be used by more than one package .
Anyway , I understand how hard implementing this feature would be . I just wanted to share the thought .
Thank you for replying and explaining the complexity of the situation .
I agree with Nezmer, user should be given option with warnings
FS#11473#!/bin/bash
IGNORE="^/lib/modules|^/usr/local|^/usr/src|^/usr/share/mime|^/usr/share/texmf-var"
SEARCH="/bin /etc /lib /opt /sbin /usr"
# search for regular files
comm -2 -3 <(find $SEARCH -type f | sort -u | egrep -v $IGNORE) <(pacman -Qlq | awk '$2 !~ "/$" {print $2}' | sort -u)
# search for symlinks
# comm -2 -3 <(find $SEARCH -type l | sort -u | egrep -v $IGNORE) <(pacman -Qlq | awk '$2 !~ "/$" {print $2}' | sort -u)
http://bbs.archlinux.org/viewtopic.php?id=43548
http://bbs.archlinux.org/viewtopic.php?pid=348015
Add a "cleanup=()" variable in the PKGBUILD for known files the software generates and those files can be removed with the package.
Also you'd need to consider changes between application versions, where the new version might not use an old directory any more. You'd have to have a 'cleanup_upgrade' array as well probably.
Also what if a user doesn't want the files/folders to be deleted. If I'm switching from chromium to chromium-stable I might not want ~/.cache removed (as an example) because I'm just switching to a different flavour. Same could apply to switching between regular and -git packages.
To me it all seems a bit complex and risky for something fairly trivial, as much as I hate having old files hanging around. Maybe adding an option to pacman to do what the above scripts do, or including a script as pacman-clean (or whatever) to the pacman package, or just having that script in a package separate to pacman altogether (even if it's in the AUR and mentioned on the wiki somewhere)?