# 01 - Introduction to PKGUPD

> PKGUPD is a better package manager and successor of appctl in rlxos, PKGUPD aims to be a modular/extensible package manager whose functionality can be increase using the modules

## Working
PKGUPD uses YAML configuration files named recipe file that contains a minimal set of information about the specific package or sub-packages. As per the information, PKGUPD performs the tasks and calls the specified modules.

PKGUPD support 2 types of extensions:
- pack: This plugin provides a method to pack and unpack the binary packages that PKGUPD use to perform installations and package generation.
- plugin: (I know bad naming) This provided methods to compile the source codes.

PKGUPD currently provided 4 plugins:
- **auto**: Compilation plugin that can detect autogen.sh, configure, Makefile, CMakeLists.txt, meson.build and python setup.py
- **port**: Another compilation plugin that uses  appctl  port (like PKGBUILD files in arch linux).
- **rlx**: Packaging plugin that pack the binary packages in rlxos package format
- **app**: Another packaging plugin for AppImages format.

** Example Recipe file**
```yaml
id: example.package
version: 0.1.0
about: |
   Description about the package

pack: rlx
packages:
   - id: subpackage
     sources:
        - https://url.to/source/codes.tar.gz
        - custom-name.tar.xz::https://url.to/another/package.tar.gz
    dir: code
    plugin: auto
    flags:
        - id: configure
           value: >
               --enable-some-feature
```
| Node | About |
|------ |------- |
| **id** | *Name of recipe* |
| **version** | *Version of recipe* |
| **about** | *Description about the recipe file* |
| **pack** | *plugin/module which is going the pack the output binary package* |
| **packages** | *List of packages the recipe file provides* |
| **sources** | *List of source files require by all subpackages** |
| **prescript** | *Prescript execute during precompilation** |
| **postscript** | *Post Script execute during postcompilation** |
| **preinstall** | *Script execute during preinstallaton** |
| **postinstall** | *Script execute during post installation** |
| **environ** | *List of strings to export environment variables** |
| **users** | *List of users required by the package** |
| **groups** | *List of groups required by the package** |


**Packages**

| Node | About |
| ------| ------ |
| **id** | *Name of package* |
| **dir** | *Directory name of source code* |
| **sources** | *Source files url* |
| **plugin** | *plugin that compile the source code into binary package* |
| **flags** | *flags that plugin intake to customize the compilation* |


## Installation
```bash
sudo appctl sync
sudo appctl install pkgupd
```

## Usage

```bash
pkgupd-0.1.0: an extensible package manager for rlxos

Usage: pkgupd [Sub] <pkgid> <Args>

Sub:
  install             install specified package from recipe dir
  depends             Resolve required dependencies
  remove              Remove specified application from system
  info                Print Information about pkgid
  require             Check which package require specified package
  sync                Synchronize local database with repositories

Args:
  --help              
  --debug             
  --compile           force pkgupd to compile package from source code
  --force             force task to do
  --no-depends        skip dependencies resolvement
  --all               Set ALL flag
```


## File Hierarchy

| DIR/File | Description |
|---------|-------------|
| /etc/pkgupd.yml | PKGUPD configuration file |
| /var/cache/pkgupd/recipes | Default path for recipe files |
| /var/cache/pkgupd/pkgs | Default path to store cache packages |
| /var/cache/pkgupd/src | Default path to store source codes |
| /var/lib/pkgupd/data | Default path to store information of installed packages |
| /usr/lib/pkgupd | Default path for PKGUPD plugins |
