Building the distribution is the final stage of preparing a program for publication. Unfortunately, there is no talk of any standardization in this area, moreover, on some operating systems (we will not point the finger), so generally a whole zoo of formats.
So ideally we need distributions:
- Windows
- OS X ( .dmg )
- OS X ( .pkg - App Store )
- Linux ( .deb )
- Linux ( .rpm )
- Linux ( .tar.gz - universal )
Qt Installer Framework
In fairness it should be noted that Qt has its own, of course, cross-platform
framework for creating installers. It allows you to create both regular and online installers that can download additional components from the repository. It is also possible to insert your own widgets, add new actions (pages). You probably installed Qt Creator, which means you saw this system in operation. However, when creating an installer, you have to write an xml config, work with keys on the command line, in general, the setting has a rather high threshold of entry, especially compared to other solutions. At the same time, I did not find in the
documentation any mention of how to skip the component selection page. In general, it turned out to be a very specific product, the disadvantage of which is that this installation method is considered native only on the Windows platform.
Windows
Accordingly, the options for creating installers for this OS weight, but I stopped at a fairly convenient open source product - Inno setup. Creating an installer in it is no more difficult than the actual installation of βfurther, further, ready.β
After going through the creation wizard, we get a script at the output that can be easily changed for the next versions of our program.
')
Linux
Historically, software for Linux is distributed through repositories, and the distribution of each program is a special type of package containing the actual program files, dependency information, and some other metadata. Despite all attempts at standardization, other than mainstream .deb and .rpm, there are many other
formats specific to individual Linux distributions. Canonical is experimenting with the
.click format, reminiscent of application
bundles in OS X, but itβs still premature to consider this option among the
main ones . Since Ubuntu is the de facto Linux standard on the desktop, I will describe package creation on this platform. It should also be noted that, more often than not, the third-party software distribution kit carries with it everything that is necessary for its operation; therefore, the advanced capabilities of the package system remain untapped.
.tar.gz
What is common between distros? Of course the command shell! So we will make a script installer that will run on any system, regardless of the intended package format. In order for the system to βseeβ that a new program is installed, each file must take its proper place. The minimum set consists of: an icon, an executable file, and a special config with the extension .desktop
Icon: According to the
specification , Linux does not require to convert the source of the icon into any build, you just need to copy (during installation) files in a subdirectory like:
/ usr / share / icons / hicolor / RxR / apps, where R is the resolution of the icon
or
/ usr / share / icons / hicolor / scalable / apps - if you want to install a vector image in .svg format
However, this is not all, each icon theme has its own cache, and if it is not updated, itβs impossible to see the new icon. The cache is automatically updated during the regular installation of packages, or you can do it manually by running the command:
gtk-update-icon-cache /usr/share/icons/hicolor
Executable file
/usr/bin
Configuration file .desktop
/usr/share/applications
contains all information about the program - the name and description of the application, its category, the name of the icon, etc.
For example:
[Desktop Entry] Name=iStodo Comment=iStodo is an organizer for students with scheduling and planning features. GenericName=Organizer for students Exec=istodo Icon=istodo Categories=Office;Qt; Terminal=false Type=Application Version=1.2 Name[ru]= iStodo Comment[ru]= GenericName[ru]=
You can learn more by reading the
standard .
The rule of good tone when installing third-party programs with a non-standard method of installation will be to store all of their files in the
/opt/myapp
subdirectory, where you should also install uninstaller.
So, in the end, I got the following script, which assumes that next to it is a binary, a .desktop file, a delete script, a folder with icons (in it are subdirectories by size):
It is logical that you need a script to remove the program:
.deb
Despite the frighteningly monstrous format specifications, the simplest package requires only one configuration file - control. But first we need to make some preparations:
a) Create a project folder with the version of the program and package, for example myapp-1.1-1
b) Add the DEBIAN folder to it (the register is important!), which will contain all service files, in particular control
Example for control Package: istodo Version: 1.2-1 Section: misc Architecture: amd64 Installed-Size: 16500 Maintainer: Yakov Eremin <support@istodo.ru> Description: Organizer for students iStodo is an organizer for students with scheduling and planning features.
Everything is obvious, you just need to note that the full description begins with a space
c) Create a directory structure that repeats the position of the files of the installed program in the file system, something like
myapp-1.1-1 βββ DEBIAN β βββ control βββ usr βββ bin β βββ myapp βββ share βββ applications β βββ myapp.desktop βββ icons βββ hicolor βββ 128x128 β βββ apps β βββ myapp.png βββ 256x256 β βββ apps β βββ myapp.png βββ 32x32 β βββ apps β βββ myapp.png βββ 48x48 β βββ apps β βββ myapp.png βββ 64x64 βββ apps βββ myapp.png
In order to create packages without elevating privileges to the superuser, you should use the fakeroot utility, which emulates the appropriate environment.
Well, we collect the package with the command:
fakeroot dpkg-deb --build myapp-1.1-1/
If you need additional features, you can read a detailed review here.
.rpm
As they say, there are two ways - simple and correct.
Simple : if the .deb package does not contain any dependencies and scripts, then you can simply convert it, as a result you will certainly get a correctly working package of the .rpm format. To do this, use the alien utility, which can be installed from the repository.
fakeroot alien -kr myapp-1.0-1.deb
The disadvantage of this approach is the inoperability of packages on Fedora 18 and later. As far as I understand, the problem is caused by the difference in access rights to system directories, which is why a conflict occurs. There are two options: either fix the packages by hand (an installed Fedora is required), or build the .rpm packages as expected.
Correct : Unfortunately, there is no three and a half lines to get rid of here, because βBuild rpm for dummiesβ is the topic of a separate article. In this case, the full
manual is available in Russian.
More information about assembling packages can be read
here .
OS X
As mentioned above, there are two main methods of distribution - a disk image with a program, or download from a directory. Both methods are already well disassembled, it is worth noting only a few fundamental points.
In order for the program to run not only on systems with the Qt SDK installed, you need to use a specialized utility - macdeployqt, which copies all the necessary plug-ins and frameworks into the application bundle. When adding the "-d" key, a .dmg image will be generated, which can be used as a base for customization.
- Open it via disk utility, convert to read / write
- Open the resulting image in the Finder
- In the "View" menu, hide the extra items (status bar, etc.)
- Add a link to / Applicatons
- Create a hidden folder, copy the background image into it
- In the "view parameters" (PCM) adjust the size of the icons, grid, background
- Convert image back
The contents of the series of articles