repo/README.md

150 lines
4.2 KiB
Markdown
Raw Normal View History

2019-05-09 02:14:38 -06:00
# KISS Package Experiment
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.
├─ depends # Dependencies (one per line).
├─ 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 # The script to run after install.
```
2019-05-09 02:05:09 -06:00
When a built package is installed, this entire directory tree is copied to `/var/db/puke` 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.
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-09 03:20:42 -06:00
## TODO
- [ ] Checksums.
- [ ] Package installation.
- [ ] Package listing.
- [ ] Package removal.
- [ ] Package dependencies.
- [ ] Source extraction.
- [x] `tar.*`
- [ ] `git`
- [ ] `zip`
- [ ] `7z`
2019-05-09 02:12:31 -06:00
## Table of Contents
<!-- vim-markdown-toc GFM -->
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)
* [Getting started with `puke`](#getting-started-with-puke)
2019-05-09 02:12:31 -06:00
<!-- vim-markdown-toc -->
2019-05-09 06:58:14 -06:00
## The package format
### `build`
2019-05-09 02:12:31 -06:00
The `build` file should contain the necessary steps to patch, configure, build and install the package. When at the install step; the variable `$pkg_dir` is available. This variable points to the directory the package manager uses for built packages. Whatever is in this directory will become part of the package's manifest and will be copied to `/` (or `$PUKE_ROOT`).
2019-05-09 02:33:24 -06:00
```sh
./configure \
--prefix=/usr \
--libdir=/lib \
--shared
make
make DESTDIR="$pkg_dir" install
```
2019-05-09 06:58:14 -06:00
### `manifest`
2019-05-09 02:33:24 -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're empty without needing checks in-between.
```
/usr/share/man/man3/zlib.3
/usr/include/zconf.h
/usr/include/zlib.h
/lib/libz.so.1.2.11
/lib/libz.so.1
/lib/libz.so
/lib/libz.a
/lib/pkgconfig/zlib.pc
/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.
```
https://www.openssl.org/source/openssl-X.X.X.tar.gz
patches/fix-musl.patch
```
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.
```
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-09 06:58:14 -06:00
## Getting started with `puke`
Puke 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`.
Puke has 6 different "operators".
- `build`: Build a package.
- `checksum`: Generate checksums for a package.
- `install`: Install a built package.
- `remove`: Remove an installed package.
- `depends`: List a package's dependencies .
- `list`: List installed packages.