|
OpenBSD Packages and Ports Installation and upgrading of packages and ports on OpenBSD. |
|
Thread Tools | Display Modes |
|
|||
/usr/local/share/mime/application--How to delete files?
Scrolling through /usr/local/share/mime/application, I see files that appear to be left over from packages that I installed and later removed. I thought
$ doas pkg_delete -ac [package] was supposed to remove all files related to the package, except the configuration files deposited in the user's home folder.Is there a command to safely clean up this folder? I don't use a desktop environment or file manager, only jwm for window management. Thanks. -------------------------------------------------- UPDATE: I've worked out the answer. See https://daemonforums.org/showthread.php?p=72309, later in this thread. Last edited by gustaf; 11th April 2022 at 10:47 PM. Reason: Update |
|
|||
Quote:
Quote:
Quote:
Note to forum admins: OpenBSD's manpage does not link - I substituted FreeBSD's. Last edited by shep; 24th January 2020 at 04:00 PM. |
|
|||
Quote:
Since update-mime-database isn't part of the base system, its man page won't show up on the OpenBSD man page server. The update-mime-database executable and corresponding man page are installed from the misc/shared-mime-info package. After doing some further experimenting, I was able to peel back the layers created by this package. For documentation, see: shared-mime-info-spec overview shared-mime-info database specification (version 0.21) update-mime-database(1) - man page installed with the shared-mime-info package Referenced OpenBSD man pages: find(1) grep(1) pkg_add(1) pkg_delete(1) pkg_create(1) (explanation of '@' notation from $ pkg_info -f ; '%D' stands for '/usr/local')1. Install misc/shared-mime-info on a machine with a clean system install and no existing packages: Code:
$ doas pkg_add -iv shared-mime-info 2. Print a list of files in the installed package along with any package-management instructions: Code:
$ pkg_info -f shared-mime-info ... @define-tag update-mime-database at-end %D/bin/update-mime-database %D/share/mime @cwd /usr/local @tag update-mime-database @unexec-delete... # executed when 'shared-mime-info' is deleted @bin bin/update-mime-database # the program itself ... @man man/man1/update-mime-database.1 # the man page ... share/mime/packages/freedesktop.org.xml # the application-specific XML file ... Code:
$ ls -F /usr/local/share/mime XMLnamespaces generic-icons inode/ multipart/ types aliases globs magic packages/ version application/ globs2 message/ subclasses video/ audio/ icons mime.cache text/ x-content/ font/ image/ model/ treemagic x-epoc/ The @define-tag and @tag lines from $ pkg_info -f shared-mime-info reveal that, as part of the package installation process, /usr/local/bin/update-mime-database is executed, thus generating these files.The shared-mime-info database specification explains this further: Quote:
3. Install a package that updates the shared-mime-info database (for example, productivity/zim): Code:
# Before installing, search for any possible default zim-related files $ grep -aHinoRw zim /usr/local/share/mime/ | sort > mime-default.txt $ less mime-default.txt # Empty; no zim-related files # Install the package # To optionally capture the entire output, run '$ doas pkg_add -ivvvvvx zim > zim-add.txt' $ doas pkg_add -iv zim 4. Check the zim package file list and instructions: Code:
$ pkg_info -f zim | less ... @cwd /usr/local bin/zim ... @man man/man1/zim.1 ... share/mime/packages/zim.xml ... @tag update-mime-database ... 5. Search the mime directory a second time to catch the files added or modfied by update-mime-database(1) during the zim install: Code:
$ grep -aHinoRw zim /usr/local/share/mime/ | sort | > mime-zim.txt $ less mime-zim.txt # Line numbers may vary. /usr/local/share/mime/application/x-zim-notebook.xml:2:zim /usr/local/share/mime/globs2:837:zim /usr/local/share/mime/globs2:837:zim /usr/local/share/mime/globs:835:zim /usr/local/share/mime/globs:835:zim /usr/local/share/mime/magic:87:zim /usr/local/share/mime/mime.cache:1:zim /usr/local/share/mime/mime.cache:1:zim /usr/local/share/mime/packages/zim.xml:3:zim /usr/local/share/mime/subclasses:57:zim /usr/local/share/mime/text/x-zim-wiki.xml:2:zim /usr/local/share/mime/types:436:zim use $ strings file .Now, it's time to answer the original question: Quote:
6.To test if this is true, begin by deleting zim: Code:
$ doas pkg_delete -civ zim # Delete zim files and update the mime database $ doas pkg_delete -aciv # Clean up any unused dependencies 7. Search the mime directory to determine if zim has deleted its files: Code:
$ grep -aHinoRw zim /usr/local/share/mime/ | sort > mime-default-restore.txt $ less mime-default-restore.txt # Empty file; zim-related files have been deleted 8. Verify that the mime directory stucture still exists: Code:
$ ls -F /usr/local/share/mime XMLnamespaces generic-icons inode/ multipart/ types aliases globs magic packages/ version application/ globs2 message/ subclasses video/ audio/ icons mime.cache text/ x-content/ font/ image/ model/ treemagic x-epoc/ 9. Print the shared-mime-info packing list instructions; note the annotations specifically related to package removal: Code:
$ pkg_info -f shared-mime-info | less ... @define-tag update-mime-database at-end %D/bin/update-mime-database %D/share/mime ... @tag update-mime-database @unexec-delete find %D/share/mime/* -maxdepth 0 -type d ! -name packages -exec rm -rf '{}' \+ @unexec-delete find %D/share/mime/ -type f ! -name freedesktop.org.xml -exec rm -f '{}' \+ ... @unexec-delete find...-exec rm -rf '{}' \+ removes all directories except packages, then all remaining files except freedesktop.org.xml.10. Delete the shared-mime-info package (updates the shared-mime database, removes the /usr/local/share/mime/ directory, and deletes the package files): Code:
$ doas pkg_delete -civ shared-mime-info # To optionally capture the entire output, run '$ doas pkg_delete -civvvvvx shared-mime-info > mime-delete.txt' $ doas pkg_delete -aciv # Clean up any unused dependencies 11. Verify that the entire mime directory has been removed along with the shared-mime-info package: Code:
$ cd /usr/local/share ; ls -F ... locale/ misc/ ... $ pkg_info | less # shared-mime-info is no longer listed I can now see that there is no need to do any manual housekeeping on the /usr/local/share/mime directory. The commands built into the package management tools will keep things tidy. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
nnn: How do you copy, move and delete files? | Prevet | OpenBSD Packages and Ports | 5 | 26th May 2019 02:18 PM |
pcmanfm-qt requires refresh to determine MIME type of new files | brudan | OpenBSD Packages and Ports | 6 | 16th April 2019 03:28 PM |
Delete Files By Schedule Continued | plexter | OpenBSD General | 4 | 28th June 2008 03:43 AM |
Delete Files By Schedule | plexter | OpenBSD General | 12 | 4th June 2008 10:15 PM |
/usr/local and application directories | ducu_00 | FreeBSD Ports and Packages | 14 | 23rd May 2008 05:37 PM |