2
0
mirror of https://codeberg.org/kiss-community/repo synced 2024-11-17 04:00:14 -07:00
repo/README.md

207 lines
7.5 KiB
Markdown
Raw Normal View History

2019-05-10 12:24:31 -06:00
# KISS Alternative Package System
2019-05-09 01:59:27 -06:00
This is an alternative package system I am experimenting with. Instead of the usual `PKGBUILD`, `APKBUILD`, `xbps-template` and `Pkgfile` format, this repository explores a more unixy approach.
Each Package is split into multiple files.
```sh
zlib/ # Package name.
├─ build # Build script.
2019-05-16 08:59:20 -06:00
├─ depends # Dependencies (one per line) (sometimes optional).
2019-05-09 01:59:27 -06:00
├─ sources # Sources (one per line).
├─ version # Package version.
# Files generated by the package manager.
├─ manifest # The built package's files and directories.
├─ checksums # The checksums for the source files.
# Optional files.
├─ post_install # Script to run after package installation.
2019-05-16 08:20:32 -06:00
├─ patches/* # Directory to store patches.
├─ files/* # Directory to misc files.
2019-05-16 08:59:20 -06:00
2019-05-09 01:59:27 -06:00
```
2019-05-09 02:05:09 -06:00
2019-06-13 08:46:05 -06:00
When a built package is installed, this entire directory tree is copied to `/var/db/kiss` where it becomes a database entry. Listing the dependencies for a package is a simple as printing the contents of the `depends` file. Searching for which package owns a file is as simple as checking each `manifest` file.
2019-05-09 02:05:09 -06:00
This new structure also allows the package manager to be stupid simple. POSIX `sh` has no arrays. However, they are mimicked by looping over each line of each file. No more insecure `depends="pkg pkg pkg"` and `for pkg in $depends`.
Instead, the following can be done.
```sh
while read -r depend; do
# do thing.
done < depends
```
2019-05-09 02:12:31 -06:00
2019-05-16 08:04:05 -06:00
This also means anyone can write a tool to manipulate the repository or even their own package manager. It's all plain text files delimited by a new line or a space.
2019-05-09 02:12:31 -06:00
## Table of Contents
<!-- vim-markdown-toc GFM -->
2019-06-13 08:46:05 -06:00
* [Getting started with `kiss`](#getting-started-with-kiss)
* [`kiss build pkg`](#kiss-build-pkg)
* [`kiss checksum pkg`](#kiss-checksum-pkg)
* [`kiss install pkg`](#kiss-install-pkg)
* [`kiss remove pkg`](#kiss-remove-pkg)
* [`kiss list` or `kiss list pkg`](#kiss-list-or-kiss-list-pkg)
* [`kiss update`](#kiss-update)
2019-05-09 06:58:14 -06:00
* [The package format](#the-package-format)
* [`build`](#build)
* [`manifest`](#manifest)
* [`sources`](#sources)
* [`depends`](#depends)
* [`version`](#version)
* [`checksums`](#checksums)
2019-05-10 12:44:26 -06:00
* [`post-install`](#post-install)
2019-05-16 02:08:40 -06:00
* [Frequently asked questions](#frequently-asked-questions)
* [How do I change compiler options globally?](#how-do-i-change-compiler-options-globally)
2019-05-09 02:12:31 -06:00
<!-- vim-markdown-toc -->
2019-05-09 07:05:22 -06:00
2019-06-13 08:46:05 -06:00
## Getting started with `kiss`
2019-05-09 07:05:22 -06:00
2019-06-13 08:46:05 -06:00
Kiss is a simple package manager written in POSIX `sh`. The package manager does not need to be added to your `PATH`. Instead it runs inside the packages repository, very similar to Void Linux's `xbps-src`.
2019-05-09 07:05:22 -06:00
2019-06-13 08:46:05 -06:00
Kiss has 6 different "operators".
2019-05-09 07:05:22 -06:00
- `build`: Build a package.
- `checksum`: Generate checksums for a package.
- `install`: Install a built package.
- `remove`: Remove an installed package.
- `list`: List installed packages.
2019-05-10 11:38:50 -06:00
- `update`: List packages with available updates.
2019-05-09 07:05:22 -06:00
2019-06-13 08:46:05 -06:00
### `kiss build pkg`
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
Kiss's `build` operator handles a package from its source code to the installable `.tar.gz` file. Sources are downloaded, checksums are verified, dependencies are checked and the package is compiled then packaged.
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
### `kiss checksum pkg`
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
Kiss's `checksum` operator generates the initial checksums for a package from every source in the `sources` file.
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
### `kiss install pkg`
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
Kiss's `install` operator takes the built `.tar.gz` file and installs it in the system. This is as simple as removing the old version of the package (*if it exists*) and unpacking the archive at `/`.
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
### `kiss remove pkg`
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
Kiss's `remove` operator uninstalls a package from your system. Files and directories in `/etc` are untouched. Support for exclusions will come as they are needed.
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
### `kiss list` or `kiss list pkg`
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
Kiss's `list` operator lists the installed packages and their versions. Giving `list` an argument will check if a singular package is installed.
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
### `kiss update`
2019-05-10 12:00:46 -06:00
2019-06-13 08:46:05 -06:00
Kiss's `update` operator compares the repository versions of packages to the installed database versions of packages. Any mismatch in versions is considered a new upgrade from the repository.
2019-05-13 06:48:25 -06:00
2019-06-11 03:17:42 -06:00
The `update` mechanism doesn't do a `git pull` of the repository. This must be done manually beforehand and is intentional. It allows the user to `git pull` selectively. You can slow down the distribution's package updates by limiting pulling to a week behind master for example.
2019-05-10 12:00:46 -06:00
2019-05-09 06:58:14 -06:00
## The package format
### `build`
2019-05-09 02:12:31 -06:00
2019-06-13 08:46:05 -06:00
The `build` file should contain the necessary steps to patch, configure, build and install the package. The build script is sent a single argument. This argument points to the package directory. Whatever is in this directory will become part of the package's manifest and will be copied to `/` (or `$kiss_ROOT`). The first argument is frequently used in `make DESTDIR="$1" install` for example.
The `build` file can be written in any language. The only requirement is that the file be executable.
2019-05-09 02:33:24 -06:00
```sh
./configure \
--prefix=/usr \
--libdir=/lib \
--shared
make
2019-06-11 03:17:42 -06:00
make DESTDIR="$1" install
2019-05-09 02:33:24 -06:00
```
2019-05-09 06:58:14 -06:00
### `manifest`
2019-05-09 02:33:24 -06:00
2019-06-11 03:17:42 -06:00
The `manifest` file contains the built package's file and directory list. The full paths to files are listed first and the directories (*in reverse*) follow. This allows the package manager to remove the directories if they are empty without needing checks in-between.
2019-05-09 02:33:24 -06:00
2019-06-13 08:46:05 -06:00
The manifest also includes the package's database entry. You can install the package with or without `kiss` and it will be recognized.
2019-05-10 01:06:18 -06:00
2019-05-09 02:33:24 -06:00
```
/usr/share/man/man3/zlib.3
/usr/include/zconf.h
/usr/include/zlib.h
2019-06-13 08:46:05 -06:00
/var/db/kiss/zlib/sources
/var/db/kiss/zlib/manifest
/var/db/kiss/zlib/checksums
/var/db/kiss/zlib/build
/var/db/kiss/zlib/version
2019-05-09 02:33:24 -06:00
/lib/libz.so.1.2.11
/lib/libz.so.1
/lib/libz.so
/lib/libz.a
/lib/pkgconfig/zlib.pc
2019-06-13 08:46:05 -06:00
/var/db/kiss/zlib
/var/db/kiss
2019-05-10 01:06:18 -06:00
/var/db
/var
2019-05-09 02:33:24 -06:00
/usr/share/man/man3
/usr/share/man
/usr/share
/usr/include
/usr
/lib/pkgconfig
/lib
```
2019-05-09 02:44:02 -06:00
2019-05-09 06:58:14 -06:00
### `sources`
2019-05-09 02:44:02 -06:00
The `sources` file contains the package's sources one per line. Sources can be local or remote.
2019-06-13 00:17:04 -06:00
An optional destination field can be added to tell the package manager where to extract the source. This is relative to the regular extraction directory. The passed directories are also created.
2019-05-09 02:44:02 -06:00
```
https://www.openssl.org/source/openssl-X.X.X.tar.gz
patches/fix-musl.patch
2019-06-12 12:08:18 -06:00
https://www.openssl.org/source/openssl-X.X.X.tar.gz lib/example/
2019-05-09 02:44:02 -06:00
```
2019-05-09 06:58:14 -06:00
### `depends`
2019-05-09 02:44:02 -06:00
The `depends` file contains the package's dependencies one per line.
```
zlib
binutils
openssl
```
2019-05-09 02:52:34 -06:00
2019-05-09 06:58:14 -06:00
### `version`
2019-05-09 02:52:34 -06:00
The `version` file contains the package's version as well as its release number. The format of this file is `version release`. The `release` portion allows a package upgrade without the modification of the version number.
2019-05-10 01:06:18 -06:00
The version can also be `git 1` to specify that the package is built from the latest `git` head.
2019-05-09 02:52:34 -06:00
```
1.2.11 1
```
2019-05-09 06:51:37 -06:00
2019-05-09 06:58:14 -06:00
### `checksums`
2019-05-09 06:51:37 -06:00
The `checksums` file contains the `sha256` sums of each entry in the `sources` file. This is generated and verified automatically.
```
c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 zlib-1.2.11.tar.gz
```
2019-05-10 12:44:26 -06:00
### `post-install`
The `post-install` file should contain any steps required directly after the package is installed. This includes updating font databases and creating any post-install symlinks which may be required.
2019-05-16 02:08:40 -06:00
## Frequently asked questions
### How do I change compiler options globally?
2019-06-13 08:46:05 -06:00
All you need to do is define `CFLAGS`, `MAKEFLAGS` or equivalent in your environment. Either give it to `kiss` directly (`CFLAGS=-O3 MAKEFLAGS=-j4 ./kiss build zlib`) or set it in your shell's RC file.