Bug 8567

Summary: build system leaves stray files on uninstallation
Product: ThinLinc Reporter: Pierre Ossman <ossman>
Component: Build systemAssignee: Pierre Ossman <ossman>
Status: NEW ---    
Severity: Normal CC: adaha
Priority: P2 Keywords: adaha_tester, prosaic
Version: trunk   
Target Milestone: LowPrio   
Hardware: PC   
OS: Unknown   
URL: https://git.cendio.se/thinlinc/cenbuild/-/merge_requests/32
Acceptance Criteria:
MUST: * All static files should be removed after installing and removing any combination of cenbuild packages SHOULD: * All config or other dynamic files should also be removed COULD: * Developers are informed if they cause new issues with files not being removed
Bug Depends on: 8326    
Bug Blocks:    

Description Pierre Ossman cendio 2025-04-03 15:44:07 CEST
If you uninstall cenbuild (or individual packages), you are often left with stray files on disk. This can be confusing and possibly cause issues when other things trigger on those files or directories existing.

There are multiple reasons for this:

 * We've forgotten to tag everything in the .spec files
 * There are insufficient dependencies specified, so the owner of a directory is uninstalled before the owners of files in the directory
 * We have config files that change and are kept as .rpmsave

A related issue is also that doing "rpm -qf" doesn't work on all files.
Comment 1 Pierre Ossman cendio 2025-04-03 15:52:24 CEST
In the current state, we have almost 3000 stray files after a --no-repo rebuild:

> $ find /opt/cendio-build/arch | wc -l
> 2753

A normal install of cendio-build-everything leaves almost as many files after removing it:

> $ find /opt/cendio-build/arch | wc -l
> 2544
Comment 24 Pierre Ossman cendio 2025-04-11 09:19:41 CEST
Fixed a lot of issues, but not everything. What currently remains are:

 * Stray mounts from using cbrun (e.g. /home/johndoe)

 * Cross-compiled gtk-doc as we have some cross compiled libraries that put stuff there, but we don't have a cross compiled gtk-doc to own the base directories

 * Font directories, because a .uuid file is created by fc-cache. It's cleaned up *after* the font is uninstalled, but that is too late for rpm to clean up the directory. Doesn't happen on Fedora, so might be resolved by updating fontconfig.

These changes also introduced a weird new bug when uninstalling sgml-common:

> warning: file /opt/cendio-build/arch/osx64/etc/xml/catalog: remove failed: No such file or directory

The package has two catalog files that are changed as you install/remove other SGML and XML definitions. Hence they are marked as %config. The changes just committed removes those catalog files in %preun, as they should be empty by then.

For some reason rpm is perfectly happy with this when it comes to /etc/sgml/catalog, but gets upset about /etc/xml/catalog already being gone. Not sure why. 

One difference is that /etc/sgml/catalog is an empty file to start with, whilst /etc/xml/catalog is not.
Comment 25 Adam Halim cendio 2025-04-23 10:16:54 CEST
Tested installing cendio-build-everything on a fresh RHEL 9 machine, and
uninstalling the package again:
> find /opt/cendio-build/arch/ | wc -l
> 44
It left behind some empty directories.

I then installed cendio-build-everything again, and built client-zip and server-zip.
Uninstalling cendio-build-everything after this left several more files behind:
> find /opt/cendio-build/arch/ | wc -l
> 57
This is not perfect, but a huge improvement to how it was before this.

Here are all directories/files left behind:
> ├── armhf
> │   ├── home
> │   │   └── cendio
> │   └── usr
> │       └── arm-none-linux-gnueabi
> │           └── sys-root
> │               └── usr
> │                   └── share
> │                       └── gtk-doc
> │                           └── html
> ├── i386
> │   ├── home
> │   │   └── cendio
> │   └── usr
> │       └── share
> │           └── fonts
> │               ├── mulish
> │               ├── poppins
> │               ├── roboto
> │               ├── spacemono
> │               └── .uuid
> ├── osx64
> │   └── home
> │       └── cendio
> ├── win32
> │   ├── home
> │   │   └── cendio
> │   └── usr
> │       └── i686-pc-mingw32
> │           └── sys-root
> │               └── mingw
> │                   └── share
> │                       └── gtk-doc
> │                           └── html
> ├── win64
> │   ├── home
> │   │   └── cendio
> │   └── usr
> │       └── x86_64-w64-mingw32
> │           └── sys-root
> │               └── mingw
> │                   └── share
> │                       └── gtk-doc
> │                           └── html
> └── x86_64
>     ├── home
>     │   └── cendio
>     └── usr
>         └── share
>             └── fonts
>                 ├── mulish
>                 ├── poppins
>                 ├── spacemono
>                 ├── .uuid
>                 └── X11
>                     └── .uuid
> 
While this bug is not entirely fixed, it is in a much better place now than before.