Sometimes you might need to identify the version of an Haiku application in a script or in the Terminal.
There's a nice command which exists for that purpose, and rely on the attributes or the resource information attached to the application's binary.
Its name is "version" and we will review how to use it.
Let's suppose you would like to identify the exact version of the Genio IDE which is installed on your system.
The usage of such information could be useful in a script of your own for instance.
To get the corresponding information, type in a Terminal :
version -n /boot/system/apps/Genio
You can get also the version details (long format) with the below command :
version -l /boot/system/apps/Genio
If you don't want to use the Terminal, the same information can be retrieved with the "Get info" pop-up menu on the application :
The numerical version ("-n") will correspond to the version field, while the long version ("-l") will match the description field. What about Haiku libraries versioning ?
Let's check the Tracker lib :
version -n /system/lib/libtracker.so
Ok, the version number is not relevant here.
What about the Be library ?
version -n /system/lib/libbe.so
Ok the version number "1.0.0" is indicated.
What is strange is that the "raw" version is indicating the release number of the system, ie "R1/beta5" :)
What about an external library like "boost" ?
There's no version number recognized by Haiku for this library, however the naming of the library file is explicit enough to provide the version number : "1.83.0".
This information is also available via the SONAME from the readelf command.
Now let's review in details how the versioning is handled with two cases :
From the Tracker, we can see the version number for each application :
And the corresponding version will be displayed by the version command :
For StyleEdit, let's check the attributes attached to the file :
listattr /boot/system/apps/StyleEdit
There's a "BEOS:APP_VERSION" attribute attached to the file.
Let's display its content :
catattr BEOS:APP_VERSION /boot/system/apps/StyleEdit
The version "1.0.0" is available in the first data of the resource file.
Now let's check Genio :
listattr /boot/system/apps/Genio
There's no "BEOS:APP_VERSION" attribute.
How could it be possible that Genio has a version number attached to the application ?
If you remember at the beginning of this article, I've written that the version command rely on the attributes or the resource information attached to the application's binary.
It means that in case of Genio, it's a resource attached to the binary.
Let's verify it.
As there can be a lot of information, let's filter with "VERSION" string :
xres -l /boot/system/apps/Genio | grep VERSION
It's confirmed !
Let's extract the resource file and decompile it :
xres -o /boot/home/Desktop/Genio.rsrc /boot/system/apps/Genio
rc -o /boot/home/Desktop/Genio.rdef -d /boot/system/apps/Genio
If you open the "Genio.rdef" file in Pe editor, you will see the BEOS:APP_VERSION information available:
Note : when you package an application via HaikuPorts, the default behavior is to use the "resource" approach to add the version to the binary.
In this case, you don't have to add anything more in the "recipe" of the application, because the haikuporter tool will do the job for you :).
The reason is that the version is defined automatically during the default install, see in haikuporter the ShellScriptlets.py file which is using addResourcesToBinaries() function where xres command is used to integrate the corresponding resource to the application.
The version command will get rid of the complexity on how the version of the application can be stored. So you can rely on it for your bash scripts to facilitate the version discovery when needed :)