1======================== 2Package Management Ideas 3======================== 4 5.. contents:: 6 :depth: 2 7 :backlinks: none 8 9This page is a place to hash out ideas regarding Haiku's package management 10(and creation). The following is a draft specification for the package 11management system to be included in R1. It is based on (1), (2) and the 12discussion in (5). The draft does not yet cover everything from (1), however. 13 14Requirements 15============ 16This section describes the intended user experience. 17 18HaikuBits 19--------- 20HaikuBits is a complete directory of software for the Haiku platform. It is the 21one place a user needs when looking for Haiku software. While it does not host 22all software binaries, it does list 99.9% of all software available for Haiku. 23 24Software is classified into a number of categories. For each software, HaikuBits 25provides a short description, one or more screenshots, a link to the author's 26homepage and a download link. Additionally, a software's page has a community 27rating and important information such as security notices. 28 29Bundles 30------- 31A bundle_ is a single file that contains the binaries, data files and 32documentation. This makes software self-contained and easy to handle. An 33application can be run by double-clicking the bundle icon. Obvious exceptions 34to this rule are drivers and libraries. These have to be installed to be of any 35use. The contents of a bundle can be inspected by opening the bundle by means of 36a context-menu option which opens the bundle in Tracker just like a directory. 37 38.. _bundle: http://en.wikipedia.org/wiki/Application_Bundle 39 40Optionally, an **application** bundle can be **installed** by moving it to 41``/boot/apps`` (system-wide) or in ``/boot/home/<user>/apps`` (user-local). 42Another option is to right-click the icon and select "install for everyone" 43(only admins) or "install only for me". Any initial configuration (accepting a 44license) can be performed the first time a bundle is being run. 45 46**Libaries** can be installed the same way. The user normally does not have to 47install libraries manually, as the package manager will do so when it is needed, 48asking the user for permission. 49 50When an application bundle has been installed, shortcuts to the application 51appear in the Deskbar menu. This menu is subdivided into a number of a 52predefined categories (games, graphics, internet, ...) that match those on 53HaikuBits. 54 55**Drivers** ... ? 56 57 **brecht**: I don't like Waldemar's idea of having bundles spread all around 58 the filesystem, hence the clear distinction between installed and 59 non-installed bundles. This might be a necessity for multi-user too. 60 61 **axeld**: I have to agree with brecht. And also, I like the package file 62 system best, as it also solves on how to deal with ported software, and 63 libraries as well. Only drivers would probably need special treatment 64 (depends on how early the package file system is available, but I guess that 65 could be made work as well, like having a "actually install on disk" option 66 for driver packages). 67 68 **wkornewald**: My original intention was to not force the user through any 69 installation procedure. Simply download the app and run it directly from the 70 downloads folder to see if it works well and if yes the user can move it to 71 the "Apps" folder. 72 73Management 74---------- 75**Uninstallation** is performed by simply removing the bundle from 76``/boot/apps`` or ``/boot/home/<user>/apps``. 77 78A user's application **settings** are kept when a bundle is uninstalled or 79deleted. The system however provides a comprehensive listing of applications for 80which user settings exist. The user can choose to delete settings for each of 81the bundles. 82 83Application folders (``/boot/apps`` and ``/boot/home/<user>/apps``) display the 84list of installed bundles including information (description, availability of 85updates, security risk warning), just like the mail folder in BeOS displays 86emails. 87 88 **wkornewald**: The system should automatically remove settings of deleted 89 apps after a certain amount of time. You don't really want the user to 90 manually clean up his system. The cleanup delay should be long enough to allow 91 the user to update an app by deleting the old version and downloading the new 92 version and it should be long enough to allow the user to "undo" his action. 93 Maybe 1-2 months is fine. 94 95 **pulkomandy**: Deleting files without asking doesn't look right to me. Either 96 delete them as soon as the app is removed, or keep them forever. I like 97 Debian/apt way of doing it : when you delete a package, it's listed in the 98 package manager as 'removed, residual config files' and you can remove these 99 from there. 100 101Dependencies 102------------ 103The user does not have to worry about dependencies. If a bundle depends on other 104bundles, the package manager should make sure they are fulfilled (on run). If a 105dependency is not fulfilled, the system will ask the user for confirmation and 106automatically install any required bundles. This requires an internet 107connection. 108 109Alternatively, a user can download a **fat bundle** that includes the 110dependencies as well. 111 112Updates 113------- 114All *installed software* can be checked for new versions. For each of the 115installed applications, the changes with respect to the installed version can be 116displayed. Updates are flagged as 'strongly recommended' when security problems 117are known. The user can select which applications he/she would like to update 118and have the system perform the updates. 119 120By default, the updater tool does not show libraries in order to keep the list 121of updates as short as possible and understandable by the non-technical user. 122Libaries should only be updated when there are known problems with them. 123 124Implementation 125============== 126In this section the implementation of the system is discussed. 127 128Bundles 129------- 130A bundle is a compressed disk image that contains: 131 132- application executable(s) & data 133- metadata 134 135 - name 136 - version 137 - (revision?) 138 - hash (integrity-check) 139 - author 140 - homepage 141 - license 142 - category (for grouping applications in the Deskbar menu) 143 144- shortcuts to appear in the Deskbar menu 145 146 - a default shortcut to run when the bundle is being "run" 147 - right-clicking bundle could offer the option of opening a help document 148 about the application 149 150There are a number of different bundle types: 151 152- application 153- library 154- driver 155- font 156- ... 157 158Library, driver and font bundles have to be installed. 159 160Install or not? 161--------------- 162As bundles have to be compressed for distribution, they will need to be 163uncompressed at some point. There are two options: 164 165- Before using a bundle, it is decompressed. This is very similar to installing, 166 which many wanted to avoid. 167- The bundle's contents are decompressed on access. This is less efficient as 168 decompression needs to be performed on each access, as opposed to only one 169 time during installation. Performance of large applications and heavy games in 170 particular will suffer. 171 172It is possible to split application bundles into two sub-types; those that have 173to be installed, and those that can be run as-is. 174 175 **brecht**: While I initially liked the idea of not having to install 176 software, I now feel that it is not suited for all types of applications and 177 games. While we can make a differentiate between 'large' and 'small' 178 applications and require installation of large apps (or suffer from poor 179 performance), this feels like a bit of a kludge. Is is really that bad to 180 'install' software once? Installing can be reduced to decompressing and should 181 not bother the user much. If the user knows he has to install **all** bundles, 182 there can be no confusion. 183 184 **wkornewald**: I don't fully remember my original proposal (it's been several 185 years :), but I think there's a middle-path: When the bundle is opened for the 186 first time it's decompressed and cached automatically. When the bundle is 187 deleted from the file system the cache is cleaned, too. That way you have the 188 best of both worlds and the user only has a slow first start, but all 189 subsequent app starts will be fast. Maybe the cache itself could be a single 190 uncompressed bundle/image file if that's more efficient than having lots of 191 small files spread over the main file system. A large coherent file can 192 probably be read into memory much faster and should speed up app starts 193 noticeably. 194 195Merged 196------ 197By means of a union pkgfs (3). All ports are mounted under ``/boot/common``. 198 199It is not clear how multiple versions of libraries and applications can be 200handled in this scheme. 201 202Self-contained 203-------------- 204By means of assignfs (4). Each port receives its own unique assign: 205``/boot/apps/<port>-<version>-<revision>`` 206 207 **axeld**: I think the best solution would be a unionfs approach: the package 208 file system would just blend in the packages where needed. User packages would 209 be merged with the contents of config/, while system wide ones would be merge 210 with the contents of /boot/common/. 211 212Settings 213-------- 214global settings/user settings 215 216Multiple Application Version 217```````````````````````````` 218how to handle 219 220Dependency Hell 221--------------- 222`Dependency hell`_ is a problem mostly for ports. That does not mean it can be 223ignored. At least in the early years of Haiku, ports will be an important source 224of software. 225 226.. _Dependency hell: http://en.wikipedia.org/wiki/Dependency_hell 227 228Avoiding 229```````` 230Bundles are always fat bundles. All required libraries are included in the 231bundle. Problem solved! However, this very area-inefficient. Nor is it a 232realistic solution for bundles that depend on large packages like Python or 233Perl. 234 235Tacking 236``````` 237In order to solve conflicting dependencies, it is necessary to be able to have 238multiple versions of a library installed. Even worse, some libraries can be 239built with different options. 240 241To make this work, it is obvious that a central bundle repository is required: 242HaikuBits. Alongside offering a browsable directory of software like BeBits, it 243stores information about dependencies. Dependency information (problems arising 244from certain combinations of bundles) is updated by the community. 245 246An example. When ABC-1.0 is released, its dependency libfoo is at version 2471.2.10. Bundle ABC-1.0 specifies "libfoo >= 1.2.10" as a dependency. Later, when 248libfoo 1.2.12 is released, it appears that this breaks ABC-1.0. HaikuBits is 249updated to indicate this: "libfoo >= 1.2.10 && != 1.2.12". When ABC-1.0 is now 250downloaded from HaikuBits, the bundle contains the updated information. A 251software updating tool can also check HaikuBits to see whether dependencies are 252still OK. 253 254Because the act of porting can introduce additional incompatibilities, each port 255should be tagged with a revision number to uniquely identify it. Revisions can 256also be used to differentiate between ports with different build options. 257Specifying build options in the dependency information seems overkill anyway, as 258we should strive to have as few port revisions as possible (developers should 259have dependencies installed as bundles before porting). 260 261The bundle metadata needs to be extended to include information about the 262dependencies: 263 264- minimum/maximum version 265- preferred version/revision 266- non-working versions/revisions 267 268While bundles will not be available for download for retail software, it still 269makes sense to record dependency information about it on HaikuBits. 270 271Having an application use a particular library version can be done by 272manipulating LD_LIBRARY_PATH or by virtually placing the library in the 273applications directory by means of assignfs or pkgfs. 274 275Note the important difference with typical Linux package management systems. In 276Linux, the repository typically offers only one version of a particular package. 277This is the result of keeping all packages in the repository in sync, in order 278to avoid conflicting dependencies. In the proposed system however, the user is 279free to install any version of a bundle, as there is no need for any global 280synchronization of all bundles. 281 282 **axeld**: while having a central repository is a good thing, I don't think 283 our package manager should be based on that idea. I would allow each package 284 to define its own sources (the user can prevent that, of course). That way, we 285 avoid the situation of having to choose between outdated repositories, and 286 unstable software (or even having to build it on your own) like you usually 287 have to do in a Linux distribution. The central repository should also be a 288 fallback, though, and try to host most library packages. 289 290 Since we do care about binary compatibility, and stable APIs, having a central 291 repository is not necessary, or something desirable at all IMO. 292 293 **brecht**: I agree. I see the repository more as a central entity keeping 294 track of all software versions and the dependencies between them. This 295 dependency information is updated based on user feedback. I don't think it is 296 necessary to have the repository be the one and only source for bundles, 297 however. It can keep instead a list of available mirrors. However, it is 298 probably a good idea to have one large reliable mirror (hosting the most 299 important bundles) managed by Haiku Inc. alongside the repository in order not 300 to be too dependent on third parties. 301 302libalpm 303------- 304(and it's tool: pacman) 305 306libalpm is the package management library used on ArchLinux, most people know it 307as "pacman" since that's the main tool to use, however, all the functionality is 308part of the libalpm library which could be utilized to create a nice GUI 309frontend for the package manager. It of course can also be adapted. 310 311It uses libarchive to extract archives, and either libdownload or libfetch to 312download files - although one can also have it use an external command, like 313curl or wget. 314 315The current status is this: 316 317As far as libfetch is concerned: compiles and is linked to, but it doesn't 318really work, so I'm using curl instead - it works like a charm. 319 320The important part: libarchive needed some work to support zip files in a useful 321way. Basically, it now supports seeking (which it didn't before), the 322central-directory headers for ZIP files (so it supports stuff like symlinks), 323and BeOS file attributes! Also, when reading from a source which doesn't allow 324seeking (... which are... none - on our case) it simply reads the local headers, 325but can also - if explicitly requested - provide "update"-entries to update the 326raw data when the central directory is reached (but those are of no importance 327anymore). 328 329What's good about libalpm? Well, it provides useful configuring mechanisms, it 330stores dependencies and can also give you a list of which packages require a 331certain package. It keeps a database containing package information, including a 332file list. Configuration files in packages can be listed as such, which causes 333them to be installed as \*.pacnew when they are upgraded (unless the new and old 334files equal - an md5 sum check is used there.) It provides the ability to use 335different database directories which allows us to have an automated way of 336creating package bundles. For instance, I can set the installdir to 337/tmp/mypackage and install the game "einstein" including its dependencies there, 338then move /tmp/mypackage/einstein/common/lib to /tmp/mypackage/einstein/lib, 339remove the unnecessary manpages, share files (well, usually anything else which 340is in the common/ folder), and then strip those dependencies from einstein's 341.PKGINFO file and create a bundled package which I can then install normally to 342say /boot/apps. 343 344Another useful feature is the possibility to change the root directory. When a 345package contains a .INSTALL script, libalpm chroot()s into the root directory, 346cd()s into the installation directory, and then executes the .INSTALL script 347(which means, that install-scripts can and should work relative to the 348installation directory, although, if necessary, the absolute path is available 349in $PWD) 350 351Also, libalpm works similar to an actual database. It doesn't blindly attempt to 352install a package, but first check for file conflicts, see if any files need 353backups or configuration files need to be installed as .pacnew, and then 354installs a package. If you install multiple packages at once, then it only 355either installs all of them, or none. It allows you to find the owning package 356of a file in the filesystem as well as listing all the files and dependencies of 357a package. 358 359Where does it get the packages from? Two possibilities: One can use package 360files directly - which could be made in such a way that you could also just 361unzip them. In fact, it might be useful to put the .PKGINFO into the zip file as 362some extra data which is not unzipped when simply using ``unzip``, although 363package creation is easier if it's just a file. The other one being 364repositories. The pacman utility currently allows you to list repositories like 365this in pacman.conf:: 366 367 [core] 368 Server = file:///MyRepositories 369 370 [devel] 371 Server = file:///MyRepositories 372 373 [public] 374 Server = http://www.public-repository.com/ 375 376When you synchronize the repository databases, pacman downloads the file 377<Server>/<Reponame>.db.tar.gz which contains a list of packages with 378dependencies. When you install a package from such a repository, it downloads 379them from the very same location: <Server>/<Package File> The repo.db.tar.gz 380files are currently created using the tools ``repo-add`` and ``repo-remove`` 381provided in the pacman package. Those extract information from the .PKGINFO file 382and put it into the database which can be used as a repository then. 383 384Here's a little log of using pacman to install a package file, and bundle a 385package with dependencies together into one package file. 386http://stud4.tuwien.ac.at/~e0725517/using-pacman-on-haiku.log.txt 387 388Pros 389```` 390- It has been used on archlinux for a long time - so it works. 391- It's obviously possibly to compile and use it on haiku 392- Since most of its functionality is part of a library, it can be reused to 393 build a GUI-application utilizing libalpm 394- pacman also provides scripts for building packages using a PKGBUILD script. 395 396Cons 397```` 398- Likely to cause unwanted restrictions in the package management system. 399 400.. 401 402 **brecht**: I don't have a detailed view of pacman yet, but as far as I can 403 see it is very similar to your average Linux package manager. As we want 404 software management to be fundamentally different from the way Linux 405 distributions handle it (because it simply is not a very elegant solution), I 406 don't think pacman is a good choice. 407 408 **Blub**: Let me clarify: I was not suggesting to use 'pacman' as a package 409 manager, I was just thinking that its library could be a useful codebase for a 410 package-database, to keep track of dependencies, available packages and 411 updates. It 'could' be used to unpack/install packages into a 'specified' 412 folder, like /boot/apps (and even install dependencies into the same folder if 413 wanted), or, it could just as well be used to simply keep track of where which 414 package has been installed to without worrying about the actual contents. 415 416 Although when stripping the code to unpack the archives and keeping track of 417 their files it is indeed better to create something new. 418 419Brainstorming Results from BeGeistert 420===================================== 421These features were discussed/written down at BeGeistert: 422 423- Integrated app to add packages 424- Knows about repositories 425- Defined protocol to add repositories that everyone can use (for example 426 through description files with a special MIME type) 427- Multiple installations of the same package (if the software supports it) 428- Maintain shared libraries 429- runtime_loader uses package info to resolve libraries 430- Install packages per user 431- Repositories support keys to verify packages 432- Package database of installed packages 433- Packagemanagement API 434- Binary diffing for packages 435- Export/publish the set of installed packages to another system 436- System updates 437- Quality of packages (QA integrated into the process of releasing a package) 438- Property of live update possible 439 440Package Format 441============== 442A package format has to meet the following requirements: 443 444- It must be able to store BeOS/Haiku file attributes. 445- If the package shall be used directly (i.e. without prior extracting) by a 446 package file system, fast random access to the file data must be possible. 447 This disqualifies zipped TAR like formats. 448 449[PackageFormat The Haiku Package format] specifies a format meeting these 450requirements. 451 452References 453========== 454\(1) http://www.haiku-os.org/glass_elevator/rfc/installer 455 456\(2) http://www.freelists.org/post/haiku-development/software-management-proposal 457 458\(3) http://www.freelists.org/post/haiku-development/software-organizationinstallation,8 and 459http://www.freelists.org/post/haiku-development/software-organizationinstallation,55 460 461 **jonas.kirilla**: I hope it's clear enough in reference 3 (above) that my 462 ideas on package management approach it from a different angle. Which may or 463 may not overlap with the use of libalpm. FWIW, I'm not ready to endorse all 464 aspects of this proposal. 465 466\(4) http://www.freelists.org/post/haiku-development/Pathrelocatable-software-and-assigns 467 468\(5) http://www.freelists.org/post/haiku-development/software-organizationinstallation 469 470Other package managers to steal ideas from: 471 472- 0install_ - probably the most interesting 473- klik_ 474- glick_ 475- Conary_ 476 477.. _0install: http://0install.net/injector-design.html 478.. _klik: http://en.wikipedia.org/wiki/Klik_(packaging_method) 479.. _glick: http://www.gnome.org/~alexl/glick/ 480.. _Conary: http://wiki.rpath.com/wiki/Conary 481 482Useful articles: 483 484- `OSNews: Decentralised Installation Systems`_ - article by the 0install author 485- `Package management system`_ 486 487.. _OSNews\: Decentralised Installation Systems: 488 http://www.osnews.com/story/16956/Decentralised-Installation-Systems/ 489.. _Package management system: 490 http://en.wikipedia.org/wiki/Package_management_system 491 492Misc. 493 494- `Integrating OptionalPackages into Haiku's build system`_ 495 496.. _Integrating OptionalPackages into Haiku's build system: 497 http://lists.ports.haiku-files.org/pipermail/ 498 haikuports-devs-ports.haiku-files.org/2009-June/000516.html 499