# mbpk **M**inimal **B**inary **P**ackage **K**it ## What is mbpk? `mbpk` is a dead-simple binary package manager, primarily developed for [Yerba Linux](https://git.arslaancodes.com/yerbalinux.git/about). Core functions are handled in libmbpk, whereas the commands themselves are simply wrappers around the library. ## Package Format A package is a `.tar.zst` archive with the file extension `.mpk`. ### Structure ``` pkgname-1.2.3.mpk -> pkg.ini # Metadata -> _install.tar.zst # This will be extracted to / -> post-install # Optional, runs after install -> pre-remove # Optional, runs before remove ``` #### pkg.ini ```ini name = pkgname version = 1.2.3 desc = testing testing 123, i like chicken nuggets, not 3 deps = dep1 dep2 dep maintainer = French Hacker license = WTFPL ``` #### Scripts - `post-install`: Runs after `_install.tar.zst` is extracted - `pre-remove`: Runs before files are removed If they don't exist, mbpk simply ignores them. If they do exist, they are executed at their respective times. Failure to execute these scripts will be ignored and the package manager will continue, warning the user. ## Repositories Repository configuration is stored in `/etc/mbpk-repos.ini`. Configuration format is as follows: ```ini # Example repository configuration for mbpk # Format: name = url [core] url = https://repo.yerba.arslaancodes.com/core [extra] url = https://repo.yerba.arslaancodes.com/extra ``` Repos will be synchronized by copying them into `/var/lib/mbpk-repo/`. For example, the repos from the previous configuration example would be at the following locations: - `/var/lib/mbpk-repo/core` - `/var/lib/mbpk-repo/extra` ### Structure Repository structure is as follows: ``` core/ # Example repository name -> repo.ini # Repository metadata -> pkg/ -> pkgname.ini # Package metadata -> pkgname2.ini # More package metadata -> files/ -> pkgname-1.2.3.mpk # Example package file ``` #### repo.ini ```ini name = core desc = Core repo for Yerba Linux url = https://repo.yerba.arslaancodes.com/core ``` #### pkg/pkgname.ini ```ini name = pkgname version = 1.2.3 desc = testing testing 123, i like chicken nuggets, not 3 url = https://repo.yerba.arslaancodes.com/core/files/pkgname-1.2.3.mpk deps = dep1 dep2 dep3 maintainer = French Hacker license = WTFPL ``` ## Database & Package Installation/Removal The database is dead-simple. Upon installing a package, the .mpk file will first be extracted to `/var/lib/mbpk/`. From there, the package manager will continue to extract `_install.tar.zst` to `/`. This installation flow ensures that the package database is automatically handled, because `/var/lib/mbpk` itself acts as a database of all packages. Removal of a package is simple: - Read package metadata from the database - Check for `pre-remove`, and run if it exists - Use libarchive to list all files in `_install.tar.zst` and remove them respectively ## Usage `mbpk` is not one standalone command-line tool, it is actually a combination of many binaries wrapping the `libmbpk` library. - `mbpk-install `: installs a package from a repository - `mbpk-install-local `: installs a local package file - `mbpk-remove `: removes a package - `mbpk-list`: lists all installed packages - `mbpk-update`: updates package repositories - `mbpk-upgrade `: upgrades the specified package - `mbpk-search `: searches repositories for a specified term - `mbpk-info `: shows metadata of a requested installed package Running these commands require superuser privileges or for the user to be in the `mbpk` group. Users that are in the `mbpk` group will be able to run `mbpk` commands without superuser access. For this reason all `mbpk-*` wrapper binaries will be setuid.