My sixth day with Haiku: Under the hood of resources, icons, and packages

probono
probono
Jul 15 · 25 min read
Hello again?

Resources in ELF files

ResEdit on the original Macintosh. Source: https://macgui.com/kb/article/12
Info.plist keys in a Mac OS X application bundle
Mathematica.app in NeXTSTEP 1.0 from 1989 appears as one object in the GUI but is actually a directory as seen on the Terminal

Manipulating resources

~> rc -h
Haiku Resource Compiler 1.1
To compile an rdef script into a resource file:
rc [options] [-o <file>] <file>...
To convert a resource file back into an rdef script:
rc [options] [-o <file>] -d <file>...
Options:
-d --decompile create an rdef script from a resource file
--auto-names construct resource names from ID symbols
-h --help show this message
-I --include <dir> add <dir> to the list of include paths
-m --merge do not erase existing contents of output file
-o --output specify output file name, default is out.xxx
-q --quiet do not display any error messages
-V --version show software version and license
/> xres
Usage: xres ( -h | --help )
xres -l <file> ...
xres <command> ...
The first form prints this help text and exits.The second form lists the resources of all given files.The third form manipulates the resources of one or more files according to
the given commands.
(...)
/> xres -l /Haiku/system/apps/WebPositive/Haiku/system/apps/WebPositive resources:type           ID        size  name
------ ----------- ----------- --------------------
'MIMS' 1 36 BEOS:APP_SIG
'APPF' 1 4 BEOS:APP_FLAGS
'MSGG' 1 421 BEOS:FILE_TYPES
'VICN' 101 7025 BEOS:ICON
'VICN' 201 91 kActionBack
'VICN' 202 91 kActionForward
'VICN' 203 300 kActionForward2
'VICN' 204 101 kActionStop
'VICN' 206 243 kActionGoStart
'MSGG' 205 1342 kActionGo
'APPV' 1 680 BEOS:APP_VERSION

Standard resource types

Vector icons, Haiku style

me@host:~$ ls /usr/share/icons/hicolor/
128x128 256x256 512x512 index.theme
160x160 28x28 64x64 scalable
16x16 32x32 72x72 symbolic
192x192 36x36 8x8
22x22 42x42 96x96
24x24 48x48 icon-theme.cache
me@host:~$ find /usr/share/icons/ -name 'firefox.*'
/usr/share/icons/HighContrast/16x16/apps/firefox.png
/usr/share/icons/HighContrast/22x22/apps/firefox.png
/usr/share/icons/HighContrast/24x24/apps/firefox.png
/usr/share/icons/HighContrast/256x256/apps/firefox.png
/usr/share/icons/HighContrast/32x32/apps/firefox.png
/usr/share/icons/HighContrast/48x48/apps/firefox.png
/usr/share/icons/elementary-xfce/apps/128/firefox.png
/usr/share/icons/elementary-xfce/apps/16/firefox.png
/usr/share/icons/elementary-xfce/apps/22/firefox.png
/usr/share/icons/elementary-xfce/apps/24/firefox.png
/usr/share/icons/elementary-xfce/apps/32/firefox.png
/usr/share/icons/elementary-xfce/apps/48/firefox.png
/usr/share/icons/elementary-xfce/apps/64/firefox.png
/usr/share/icons/elementary-xfce/apps/96/firefox.png
/usr/share/icons/hicolor/128x128/apps/firefox.png
Different Firefox versions have different ícons, stupid! Yet the Linux desktop can’t handle it without crude workarounds
Mac:~ me$ find /Applications/Firefox.app | grep icns/Applications/Firefox.app/Contents/MacOS/crashreporter.app/Contents/Resources/crashreporter.icns
/Applications/Firefox.app/Contents/MacOS/updater.app/Contents/Resources/updater.icns
/Applications/Firefox.app/Contents/Resources/document.icns
/Applications/Firefox.app/Contents/Resources/firefox.icns
HVIF icon file size compared to other formats. Source: https://www.haiku-os.org/docs/userguide/en/applications/icon-o-matic.html
Different Levels of Detail (LOD) depending on render size

Adding an icon to an application

/Haiku/home> xres /Haiku/system/apps/QtCreator/bin/Qt\ Creator  -o /Haiku/home/QtQuickApp/QtQuickApp  -a VICN:101:BEOS:ICON /Haiku/system/apps/QtCreator/bin/Qt\ Creator
/Haiku/home> xres -l /Haiku/home/QtQuickApp/QtQuickApp/Haiku/home/QtQuickApp/QtQuickApp resources:type           ID        size  name
------ ----------- ----------- --------------------
'VICN' 101 152238 BEOS:ICON
The copied VICN:101:BEOS:ICONs not used as the appliction icon by the file manager yet

Clever caching using the filesystem

Inspecting attributes in the filesystem

/> resattr 
Usage: resattr [ <options> ] -o <outFile> [ <inFile> ... ]
Reads resources from zero or more input files and adds them as attributes
to the specified output file, or (in reverse mode) reads attributes from
zero or more input files and adds them as resources to the specified output
file. If not existent the output file is created as an empty file.
(...)

The wizardy of hpkg packages

KERN: package_daemon [16042853:   924] active package: "gawk-4.2.1-1-x86_64.hpkg"KERN: package_daemon [16043023:   924] KERN: active package: "ca_root_certificates_java-2019_01_23-1-any.hpkg"KERN: package_daemon [16043232:   924] KERN: active package: "python-2.7.16-3-x86_64.hpkg"KERN: package_daemon [16043405:   924] KERN: active package: "openjdk12_default-12.0.1.12-1-x86_64.hpkg"KERN: package_daemon [16043611:   924] KERN: active package: "llvm_libs-5.0.0-3-x86_64.hpkg"
KERN: package_daemon [16040020:   924] KERN: active package: "haiku-r1~beta1_hrev53242-1-x86_64.hpkg"

Rollbacks using the hpkg system

/Haiku/system/packages/administrative. "state..." contains text files listing the filenames of active packages, "transaction-..." contains the packages themselves
The Haiku Boot Loader. Each entry reflects an “activation state”
The list of activated packages for any given point in time

Configuration data

GUI integration of the hpkg system

Inspecting the contents of a .hpkg package

The HaikuDepot GUI can list the contents of packages, but there is no way to, say, double-click on README.md

Installing a .hpkg package in the GUI

I downloaded sanity manualleand double-clicked its .hpkg, the packge manager knows where to get its dependencies from (as long as they are in a repository already known by the system). Not every Linux distribution can do this.

Deleting a .hpkg package in the GUI

This is what happens when you try to move a .hpkg package to the trash from /Haiku/system/packages
This is what happens when you “Install” the already-installed package
This is what happens after you click “Apply changes”

Quick fix: Put an “Uninstall” button there if the package is already in /Haiku/system/packages or /Haiku/home/config/packages

Deleting something that came in a .hpkg package in the GUI

This is what happens if you try to delete an application that came in a .hpkg file

Quick fix: Have the GUI offer to uninstall the .hpkg instead

Copying something that came in a .hpkg package to another system in the GUI

Quick fix: Have the GUI offer to move the .hpkg instead, and optionally the dependency .hpkg packages as well

Downloading a .hpkg package with all its dependencies in the GUI

Keeping .hpkg packages in a special place

Summary regarding GUI integration of the hpkg system

One more thing: Kernel Debug Land


Conclusion


Random nitpicks




Thanks to mr. waddlesplash

probono

Written by

probono

#AppImage #Linux

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade