How to make an installer for a Rust program?

I have a Rust program and I want to distribute it to other people, but I do not know how to do it. Please do not recommend automatic programs like Inno Setup, etc. I am interested in real installation methods, as real programmers do.

What isn't real about inno setup ? It's what many "real programmers" use.

4 Likes

From where I stand, Inno setup manages a lot of boring work for you.

I suppose it may be worth mentioning that the build of your installer can be fully automated via ISCC.exe

Iā€™d be curious to hear of any cross platform solutions.

I noticed lately that Microsoft managed to pull off a common installer experience for Edge, for Windows and MacOS.

1 Like

I would like to learn about this not only in a practical sense, but also for educational purposes in order to better understand how it works.

I would like to learn about it also for educational purposes to better understand how it works.

There are a lot of different ways to install software on Windows, but many installers are just simple executables that copy files to the right place(s), and possibly do some registry edits.

AIUI Windows Installer is the less "roll your own" option that still gives you a fair amount of control.

MSIX is a newer option, though I don't know much about it other than that it exists.

2 Likes

Installation is a big and complex topic, and depends on both the requirements of the system you're installing software onto and the requirements of the software being installed.

Many programs don't actually need installation of any kind, and can be run just fine from the executable file itself. Self-contained programs that do not rely on supporting files, registration, the creation of operating system services, or other support from the OS can often run from anywhere at all. These can be distributed to users as bare programs, zip files, disk images (common on macOS), or by any other means you feel is appropriate.

Programs that need additional setup may do that setup themselves on first run, or may be packaged for installation on the target OS. Examples of additional setup that may be needed include:

  • Putting the program in a system-specific "programs" directory, which may require elevated privileges;
  • Setting up desktop items, such as the Windows menu or Gnome's launcher icons;
  • Associating your program with specific file types;
  • Starting or stopping long-running services;
  • Registering the program with OS-side services such as COM (for Windows) or DBUS (on Linux);
  • Installing or removing hardware drivers;
  • Creating users or accounts;

and a multitude of other administrative tasks that may be necessary for your program to work correctly for your users on your target platform.

All of these steps can, in principle, be done by hand by the end user, and you can write your installation process as a checklist to be followed. This isn't a good idea, in general, but it is a good way to learn what's involved. Installer frameworks such as MSI, InnoSetup, the various Linux packaging protocols, and even the macOS .app bundle format, all serve to automate these steps so that they happen repeatably and reliably when the end user wants to set up your software.

Unfortunately, you haven't given us enough information to make a concrete recommendation. What systems do you want users to install your software on? What does your software need to have set up on those systems to work correctly? Does the system in question have a standard installation process, or are developers expected to define their own?

4 Likes

In general, I am interested in both Windows and Linux. As far as I understand, to install in linux, you just need to package the software in the right format for the package manager, for example: deb, rpm and others. I would like to know the standard, normal installation process, but if possible, tell us about your own mode. I'm considering a dependency-free installation, but I'm interested in all the options.

I tried MSIX, and it's a really good option, but to install the application, it needs to be signed with a certificate, which I don't have. As far as I understand, it can be purchased from a trusted certification authority. Is it possible to get a valid certificate without paying for it? For the windows installer, I discovered and tested the tool Orca.exe ā€” this is a database table editor for creating and editing Windows Installer packages and merge modules. I didn't understand how to use it to create an installer. It is not necessary to sign the software in the Windows installer, but it is more outdated than MSIX.

On linux, installation and packaging depends on the distribution, but since you mentioned Debian, I'd be remiss if I didn't point you to cargo-deb. It's not perfect, and in particular it's not suitable for packages meant for inclusion in Debian or Ubuntu's own repositories, but it works well for packaging your own software or distributing it via a personal package archive. It covers a lot of the featureset I mentioned, and has support for systemd if your program is meant to be run as a service, and for desktop resources if it's meant to be run in a GUI environment.

For RPMs, there's cargo-rpm, which I have not used and therefore cannot vouch for.

You can also do a more complete job by learning the tools for the package type you want to create, and using them directly. rpm and deb both have sophisticated toolchains with a lot of flexibility.

Under the hood, installing a program on Linux usually means

  • copying the binary/binaries to /usr/bin or /bin (if you're doing it by hand, use /usr/local/bin instead),
  • copying libraries to /usr/lib and, if necessary, telling ld.so how to find them,
  • copying documentation into a subdirectory under /usr/share/doc,
  • creating any necessary service unit files in /lib/systemd/system or /etc/systemd/system,
  • copying man pages into the systemwide man page path,

and so on, as well as making sure the permissions all of these files are correct and registering them with the package manager so that they can be removed or upgraded later.

2 Likes

How can I make an installer for a program in windows installer?