Main Menu

FET installer

Started by gradgrind, September 03, 2026, 03:38:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gradgrind

I've been playing around with some ideas to make graphical installers for FET. My first attempt was for Windows using NSIS. It seemed to work, but is limited to Windows and I find NSIS a bit arcane.

Then I thought it should be possible to make an installer using Qt – one which uses the same program libraries as FET itself, so the additional size would be minimal. I have now got one which works on Linux, with a matching uninstaller. Also desktop menu entries and file-type associations are possible.

There is a single script to compile all the code, including FET, and pack the results in a runnable installer, so it should be quite easy to build the installer. It uses the Qt libraries from the Qt online installer, and "makeself" to create the runnable installer package.

It's still rather new, but should be quite functional. Anyone interested? See fetinstaller.

Volker Dirr

#1
hmm... not sure. Looks like for Linux only. Qt has an installer framework. see: https://doc.qt.io/qtinstallerframework/ifw-overview.html?utm_source=chatgpt.com
I think using that is much better.

I only done a very quick reading and saw some lines like:
"-- parallel 6" which I don't like since other guys might have much more or less threads.
Or lines like:
echo "ABORTING 2"
That doesn't help users much. Should be maybe more detailed feedback.

I asked chat-gpt about your installer, since I am not good in that.
Just in case you are interested in the answer from chat-gpt:

Quote:

I reviewed the central installer/uninstaller logic, the build scripts, and the CMake configuration. My overall impression is: **for a small, focused Qt utility, the code is reasonably clean and easy to understand, but I would not yet consider it a fully robust production-grade installer.** I would rate it around **6.5–7/10**.

The architecture has several good aspects. The installer and uninstaller are clearly separated, time-consuming file operations are moved to worker threads, and the installation is deliberately designed as a per-user installation without requiring root privileges. The default destination is `~/.local`, and the installer updates the MIME and desktop databases afterwards. [fetinstaller repository](https://github.com/gradgrind/fetinstaller?utm_source=chatgpt.com)

The packaging approach is also straightforward: the required Qt dependencies are bundled with the application, and `makeself` is used to produce a single `.run` installer. [BUILDALL.sh](https://github.com/gradgrind/fetinstaller/blob/main/LinuxInstaller/BUILDALL.sh?utm_source=chatgpt.com)

One particularly good design decision is the uninstall mechanism. During installation, the installer records the files it actually copied in `share/fet/installed_files`. The uninstaller later reads that list, removes those files individually, and then removes directories only when they are empty. This is much safer than simply doing a recursive deletion of the installation directory.

There are, however, several things I would change:

* **There is a potentially problematic container modification in the uninstaller.** In `Uninstaller::page_2()`, the code iterates over `dirsSet` while also inserting additional elements into the same `QSet` with `dirsSet.insert(p)`. Modifying a container while iterating over it is fragile and can lead to iterator invalidation. I would collect the additional directories in a second `QSet` and merge the two sets afterwards.

* **The uninstall path validation should be stronger.** The code checks whether a path from `installed_files` begins with `basedir + "/"`. A path such as `/home/user/.local/../Documents/foo` can satisfy a simple string-prefix check even though its normalized location is outside `.local`. This is not necessarily a remotely exploitable vulnerability because `installed_files` is normally generated by the installer itself, but an uninstaller should nevertheless treat its manifest defensively. I would normalize/canonicalize both paths and verify that the target is genuinely located below the installation root before calling `QFile::remove()`.

* **There is a small programming error in `installationExists()`.** The function receives a `QDir rootdir` parameter but appears to use the member `dst_dir` instead of `rootdir`. At the moment this probably does not cause visible problems because the function is called with `dst_dir` anyway, but the interface and implementation contradict each other. Either remove the parameter or actually use `rootdir`.

* **Replacing existing files is somewhat aggressive.** `copyFile()` removes an existing destination file before copying the new one. If the subsequent copy fails, the previous working file has already been lost. For an installer, I would prefer copying to a temporary file and then performing a rename/replacement, or implementing a simple backup/rollback mechanism.

* **Directory creation errors are not checked directly.** `mkpath()` is called, but its return value is apparently ignored. The following `QFile::copy()` will probably fail as well, so an error eventually gets reported, but the actual cause becomes less obvious.

* **Symlink handling is not completely resolved.** The code itself contains the TODO: `"This will not handle absolute links correctly!"` This deserves attention in installer software because incorrect symlink handling can produce surprising paths or files outside the expected installation tree. I would either explicitly reject unsupported symlinks or handle absolute and relative links deliberately.

* **Existing FET installations are detected via `which fet`.** The installer then looks for `fet_uninstall` in the corresponding directory and may execute it. This works, but it relies on the user's `PATH`. If multiple FET installations exist, the result may not necessarily be the installation the user expects. The GUI could explicitly show which existing installation was detected and is about to be removed.

* **The build scripts are rather machine-specific.** Qt `6.11.2`, `$HOME/Qt`, `gcc_64`, and a fixed parallel build count are hard-coded. That is perfectly acceptable for a developer's personal build script, but for a public repository I would make the Qt location/version configurable or auto-detect it. [BUILD.sh](https://github.com/gradgrind/fetinstaller/blob/main/LinuxInstaller/BUILD.sh?utm_source=chatgpt.com)

What I like about the project overall is that the code is **small, straightforward, and not over-engineered**. It is relatively easy to follow the installation process from beginning to end. For a utility of this size, that is a significant advantage over introducing unnecessary abstraction layers.

The biggest missing piece for me is **automated testing**. I would particularly want tests covering installation into a temporary directory, upgrading an existing installation, interrupted/failed copying, a manipulated `installed_files` manifest, `..` path traversal cases, symlinks, read-only destinations, and a complete install → uninstall round trip.

I would prioritize the improvements in this order:

1. **Harden the uninstall path validation.**
2. **Fix the `QSet` modification during iteration.**
3. **Make file replacement safer/transactional.**
4. **Improve error handling around filesystem operations.**
5. **Improve build portability and add automated tests.**

The first two are the ones I would address before distributing the installer more widely.

Overall, though, I don't see this as badly written code. The basic design is sensible, readable, and appropriately simple for what the program does. Most of my criticism is about **defensive filesystem programming and robustness**, which matters more for installers/uninstallers than it does for ordinary application code.

gradgrind

Thanks Volker! I'll have a look at the analysis. The code I posted is just like a "proof of concept", so I wouldn't be surprised at shortcomings. For Windows it would need to be a bit different, but I think it should be possible.

Just to the point about the Qt Installer Framework: yes, I know about this, but I find the documentation really bad, so that I'm not convinced that it's well maintained as a serious framework for normal users. I would have to experiment a lot, to figure out what it does and how. I am normally very happy with the Qt documentation, but the installer framework seems very substandard.

Volker Dirr

True. I already tried the Qt installer framework myself last year. It "worked" with Windows (but i didn't tried Linux nor MacOS), since I got problems while uploading it to the Microsoft Store. I don't remember exactly what the reason was. But I think we should try to use a as global installer as possible, since in other case we will be much to many special installer versions.
Not sure what Liviu think about it, but I prefer a "stable/very well tested/multi-OS" installer like the official Qt framework more.

gradgrind

I've now done some more work on the installer. Here is my response to Volker's & ChatGPT's analysis:

Quotehmm... not sure. Looks like for Linux only. Qt has an installer framework. see: https://doc.qt.io/qtinstallerframework/ifw-overview.html?utm_source=chatgpt.com
I think using that is much better.

As this is an "officially" supported tool, it might have advantages. On the other hand, its scope is much wider and it looks significantly more complicated. My "home grown" approach uses normal programming in C++ in a fairly straightforward QtWidgets application.

It looks like the Qt Installer Framework will produce quite large installer files as it bundles its own Qt libraries (using static linking?). As far as I can see (github repo), it is not very actively developed and has not made the switch to cmake.

QuoteI only done a very quick reading and saw some lines like:
"-- parallel 6" which I don't like since other guys might have much more or less threads.

This was just a compromise to avoid having to think about the number of threads for the moment. In fact I did some tests and the bottlenecks are often elsewhere. It looks like more threads don't help that much.

QuoteOr lines like:
echo "ABORTING 2"
That doesn't help users much. Should be maybe more detailed feedback.

These are just after the calls to cmake – if there are errors you would need to read the preceding output from cmake. The "ABORTING x" points are just there to stop the script after a failed cmake command, so that the error messages can be dealt with before the next command is started. They are not part of the installer itself, just the build script.

QuoteI asked chat-gpt about your installer, since I am not good in that.
Just in case you are interested in the answer from chat-gpt:

Quote:

I reviewed the central installer/uninstaller logic, the build scripts, and the CMake configuration. My overall impression is: **for a small, focused Qt utility, the code is reasonably clean and easy to understand, but I would not yet consider it a fully robust production-grade installer.** I would rate it around **6.5–7/10**.

That is perhaps not bad for a start?

QuoteThe architecture has several good aspects. The installer and uninstaller are clearly separated, time-consuming file operations are moved to worker threads, and the installation is deliberately designed as a per-user installation without requiring root privileges. The default destination is `~/.local`, and the installer updates the MIME and desktop databases afterwards. [fetinstaller repository](https://github.com/gradgrind/fetinstaller?utm_source=chatgpt.com)

The packaging approach is also straightforward: the required Qt dependencies are bundled with the application, and `makeself` is used to produce a single `.run` installer. [BUILDALL.sh](https://github.com/gradgrind/fetinstaller/blob/main/LinuxInstaller/BUILDALL.sh?utm_source=chatgpt.com)

One particularly good design decision is the uninstall mechanism. During installation, the installer records the files it actually copied in `share/fet/installed_files`. The uninstaller later reads that list, removes those files individually, and then removes directories only when they are empty. This is much safer than simply doing a recursive deletion of the installation directory.

I could add a snippet or two of that to the introductory documentation ...

QuoteThere are, however, several things I would change:

* **There is a potentially problematic container modification in the uninstaller.** In `Uninstaller::page_2()`, the code iterates over `dirsSet` while also inserting additional elements into the same `QSet` with `dirsSet.insert(p)`. Modifying a container while iterating over it is fragile and can lead to iterator invalidation. I would collect the additional directories in a second `QSet` and merge the two sets afterwards.

Oops! I've fixed that. Well, actually I've changed it completely.

Quote* **The uninstall path validation should be stronger.** The code checks whether a path from `installed_files` begins with `basedir + "/"`. A path such as `/home/user/.local/../Documents/foo` can satisfy a simple string-prefix check even though its normalized location is outside `.local`. This is not necessarily a remotely exploitable vulnerability because `installed_files` is normally generated by the installer itself, but an uninstaller should nevertheless treat its manifest defensively. I would normalize/canonicalize both paths and verify that the target is genuinely located below the installation root before calling `QFile::remove()`.

The installer should generate no paths with "..", but perhaps it is sensible to check in the uninstaller, as suggested above, in case of errors or corruption.

I have changed the design to use relative paths in "installed_files" now (still no ".." in the paths). A FET installation is, in principle, position-independent, it can be moved around. In some respects that may be inadvisable – it might be linked from elsewhere, such as in a "desktop" file or a symlink. But the change to relative files in the installer's "installed_files" file now allows these packages to be moved around like the original FET packages.

The uninstaller now checks for relative paths and "..". It also doesn't do any file deletions (see further below).

Quote* **There is a small programming error in `installationExists()`.** The function receives a `QDir rootdir` parameter but appears to use the member `dst_dir` instead of `rootdir`. At the moment this probably does not cause visible problems because the function is called with `dst_dir` anyway, but the interface and implementation contradict each other. Either remove the parameter or actually use `rootdir`.

Fixed, the function is gone ...

Quote* **Replacing existing files is somewhat aggressive.** `copyFile()` removes an existing destination file before copying the new one. If the subsequent copy fails, the previous working file has already been lost. For an installer, I would prefer copying to a temporary file and then performing a rename/replacement, or implementing a simple backup/rollback mechanism.

I have changed this so that overwriting is simply not allowed. This is checked before starting to copy. To install over an old installation, the old installation must be uninstalled first.
Also, apart from the default destination, which is unlikely to be empty, empty destination folders are preferred. If the (non-default) destination is not empty, a warning is issued. An extra box must then be ticked to allow installation to this destination.

Quote* **Directory creation errors are not checked directly.** `mkpath()` is called, but its return value is apparently ignored. The following `QFile::copy()` will probably fail as well, so an error eventually gets reported, but the actual cause becomes less obvious.

I have added creation/write checks. Now, if installation errors are detected they will be reported. There is an additional installer "page" to remove the incomplete installation.

Quote* **Symlink handling is not completely resolved.** The code itself contains the TODO: `"This will not handle absolute links correctly!"` This deserves attention in installer software because incorrect symlink handling can produce surprising paths or files outside the expected installation tree. I would either explicitly reject unsupported symlinks or handle absolute and relative links deliberately.

Now only a limited subset of symlinks are permitted in the installation folder:

1) relative links within the folder – these are necessary for the program libraries, and the target must exist;

2) absolute links outside the folder – whether or not the target exists – a warning is shown for each of these as they are tolerated, but not "first class citizens".

This is enforced in the installer. As the uninstaller doesn't do anything with symlink targets, it doesn't need to take any special action.

Quote* **Existing FET installations are detected via `which fet`.** The installer then looks for `fet_uninstall` in the corresponding directory and may execute it. This works, but it relies on the user's `PATH`.

That is the only way that a FET installation is "recorded" on Linux. Multiple installations could be recorded (by the installer in the FET settings, for example), but there could be other installations (not installed by this installer) which don't record themselves. Perhaps someone who has multiple versions installed should decide how to manage them in their own way. A normal user will not need this.

QuoteIf multiple FET installations exist, the result may not necessarily be the installation the user expects. The GUI could explicitly show which existing installation was detected and is about to be removed.

It did this already! Did ChatGPT miss that?

Quote* **The build scripts are rather machine-specific.** Qt `6.11.2`, `$HOME/Qt`, `gcc_64`, and a fixed parallel build count are hard-coded. That is perfectly acceptable for a developer's personal build script, but for a public repository I would make the Qt location/version configurable or auto-detect it. [BUILD.sh](https://github.com/gradgrind/fetinstaller/blob/main/LinuxInstaller/BUILD.sh?utm_source=chatgpt.com)

I think I disagree with this one. Sometimes it's easier and clearer to do a quick edit of a script than to fiddle about with external configuration options.
TODO?: It would be possible to use a variable for the thread number. Even some form of autodetection of processor cores would be possible, but as I wrote above, I am not convinced it would make much difference. Perhaps also the Qt version could be autodetected, but it is possible for multiple versions to be installed ...

QuoteWhat I like about the project overall is that the code is **small, straightforward, and not over-engineered**. It is relatively easy to follow the installation process from beginning to end. For a utility of this size, that is a significant advantage over introducing unnecessary abstraction layers.

Exactly, though it has got a little larger now. The Qt Installer Framework is rather different in this respect ...

QuoteThe biggest missing piece for me is **automated testing**. I would particularly want tests covering installation into a temporary directory, upgrading an existing installation, interrupted/failed copying, a manipulated `installed_files` manifest, `..` path traversal cases, symlinks, read-only destinations, and a complete install → uninstall round trip.

I would prioritize the improvements in this order:

1. **Harden the uninstall path validation.**
2. **Fix the `QSet` modification during iteration.**
3. **Make file replacement safer/transactional.**
4. **Improve error handling around filesystem operations.**
5. **Improve build portability and add automated tests.**

The first two are the ones I would address before distributing the installer more widely.

Overall, though, I don't see this as badly written code. The basic design is sensible, readable, and appropriately simple for what the program does. Most of my criticism is about **defensive filesystem programming and robustness**, which matters more for installers/uninstallers than it does for ordinary application code.

TODO: automated tests? That sounds like a lot of work for little gain. I have been testing some of these things, and I could at least document these tests.

gradgrind

Since my initial attempts at an installer for FET the code has changed a lot. The installer is still Qt-based and shares the libraries with the application it is installing. But now it works on Windows as well as Linux and a great many details have changed. It is also not dedicated to FET alone, it should work for pretty well any Qt/C++ application which is packaged together with its libraries.

If anyone is interested, have a look at fetinstaller and try it out. On the Releases page I have put installers for the current version of FET (7.12.0), compiled with Qt 6.11.3 (not 6.12.0, because of a bug in that release).

I'm not saying I think Liviu should adopt this – I know he is rather hesitant on the subject of installers, and Volker would like it done differently. It is just something I wanted to try out.

Liviu Lalescu

Thank you, Michael! I stickied this topic.

I will have a look at your work, later. Is it fetinstaller-main.zip the complete source code?

gradgrind

Yes, the current code is in the "main" branch, but the "misc" folder is not relevant – that is connected with old experiments. The actual installer/uninstaller code is in the "QAIFUS" folder and subfolders, "QaifusTest" is a simple test application, "apps" contains the configurations for building QaifusTest and FET.

Volker Dirr

#8
Nice idea, but I still prefer the official Qt installer. It is well tested. Coded from skilled guys and works with every supported Qt OS.

Looks like there are several critical parts in your installer. I just asked AI to do a static check. So a dynamic real check might even report more problems. Writing a good installer is not easy. Maybe there are a few false positivs, but you should think about this:

https://chatgpt.com/share/6aeb306c-9e5c-83ed-89a1-f3952cf8e811

gradgrind

Thanks (again) Volker for the analysis! I suppose I should really start doing this myself, but I am still a little reluctant to dive into the AI tools arena. Nevertheless, I am grateful for the feedback. As I am a lot slower than these AI tools, it will take me a bit longer to go through all the points ...

(And I still certainly do not prefer the official Qt installer – perhaps we will never agree on that one, but then why should we?)

Liviu Lalescu

Michael, I tried to have a closer look, but it is much code and many things I don't understand... Maybe I'll read more later.

Yes, also I am reluctant to AI. But Volker used AI and found some (I think 3-5) important logic bugs in FET.

Volker Dirr

#11
About AI: We must at least "white code". I agree "black code" is bad.
With "black code" I mean: AI code all and human doesn't understand the source.
"White code": AI code, but a human at least read the source and totally understand it.

AI is a nice helper tool. It must not code, but using it as a checker is nice.
In my opinion it is, if you use it like i used it here with your installer, just a improved version of "static code analyzer" (like all compilers), "static code analyzer" (like cppcheck, ...), "dynamic code analyzer" (like valgrind, ...). I used all those analyzer tools in the past 20 years also, so long before AI. (different compilers, cppcheck, facebook infer, valgrind, coverity scan, ...). In my opinion it is "only" an improved version of such tools and it has sometimes the same problems like the other tools. There are also sometimes false positives or wrong suggestions, like in every other tool also. Even in compiler warnings are sometimes wrong suggestions. E.g. try a simple "digitalWrite{13,0};" instead of "digitalWrite(13,0);". Depending on your compiler (the Arduino compiler does), the compiler suggest "; before {". After that it suggest "; before }". Then the code looks like this: "digitalWrite;{13,0;};". This code compiles without a warning, but of course do something totally different than "digitalWrite(13,0);". So compilers and also AI can also do stupid suggestions.

gradgrind

I've now addressed many of the points in Volker's latest ChatGPT analysis. I've put a copy of (the English version of) the report containing my comments in the "docs" directory. Some of it was quite a challenge, especially on Windows. Among other things, the handling of paths and non-ASCII characters on Windows is a really dark art, actually something only for masochists. Anyway, the latest packages seem to work with all sorts of user names.

See fetinstaller.

Volker Dirr

Looks much better, but also looks like still some work to do. I didn't read the full answer, maybe there are false positives, but maybe have a look yourself:
https://chatgpt.com/s/t_6af343212dcc819188fa1c6cfe2a404c