Metadata-Version: 2.4
Name: f2r
Version: 3.1.0
Summary: Produces RPMs for FLP packages out of aliBuild output
Author-email: Barthelemy von Haller <bvonhall@cern.ch>
License-Expression: GPL-3.0-only
Project-URL: Homepage, https://gitlab.cern.ch/AliceO2Group/flp-to-rpm
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Utilities
Classifier: Environment :: Console
Classifier: Operating System :: Unix
Classifier: Development Status :: 4 - Beta
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: COPYING
Requires-Dist: PyYAML
Requires-Dist: coloredlogs
Requires-Dist: s3cmd
Requires-Dist: alibuild>=1.16.0
Requires-Dist: dryable
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# f2r

Command line tool to create RPMs out of aliBuild output.

## Prerequisites
 - [aliBuild](https://alisw.github.io/alibuild/) 1.16.0 or higher (writes `.meta.json` in the install directories)
 - Optional: To enable S3 support you need to create a config file under `~/.s3cfg`, see [CERN IT instructions](https://clouddocs.web.cern.ch/object_store/s3cmd.html)
 - gem + fpm: `yum install rubygems -y ; gem install fpm`

## Installation

To just install the tool:
`python3 -m pip install f2r`

OR

Use [flp-release-server](https://gitlab.cern.ch/AliceO2Group/system-configuration/-/tree/dev/ansible/roles/flp-release-server) role from `system-configuration` to fully provision a build server.


## Quickstart
Build packages using `aliBuild`, eg:
```bash
aliBuild build O2Suite --defaults o2-dataflow --always-prefer-system
```
Then create RPMs providing the package and version as found under `sw/<architecture>/`:
```bash
f2r generate --package O2Suite --version latest-o2-dataflow
```
Validate created RPMs (this requires `sudo`):
```
f2r validate
```
Create YUM repo:
```bash
f2r repo
```

and sync it to S3:
```bash
f2r sync
```

## CLI options

Simple run `f2r -h` to see all available options


## Developers documentation

### Software lifecycle
- Make changes and merge MR when lint and tests pass
- Bump `version` in `pyproject.toml`
- Push a git tag matching the version: the `release` CI job builds the sdist and wheel with `python3 -m build` and uploads them to PyPI
- Update build server using `pip`

### Simple description of the logic
Creates tree of dependencies by recursively iterating over "alidist" recipes. It disables certain packages based on selected "defaults".
It retrieves versioning information from the `.meta.json` file that aliBuild writes in each install directory (`sw/<architecture>/<package>/<version>/.meta.json`), which lists the direct runtime and build dependencies resolved for that build.

It is capable of generating "devel" RPMs. In such case, in addition to runtime dependencies, it also packs build dependencies, with the versions recorded in `.meta.json`.

A dependency listed in the recipe but not recorded in `.meta.json` was not built by aliBuild and is treated as a system dependency. Definitions in `(devel|runtime).slc*.yaml` translate system dependencies into a list of RPM packages.

Then, it uses [fpm](https://fpm.readthedocs.io) tool to generate RPMs.

When the requested top-level package is `O2Suite`, it additionally generates the dependency-free `o2-flp-suite-buildinfo` RPM, which ships `/etc/o2.d/FLP_suite_alidist_revision` with the full alidist commit SHA the suite was built from (taken from `.meta.json`, falling back to the `alidist` checkout HEAD). The RPM version is the commit's committer date (`YYYYMMDDHHMM`, UTC) and its release starts with the short SHA, so newer alidist revisions are dnf-visible upgrades and regeneration from the same revision is idempotent.

## Development setup

```bash
cd flp-to-rpm
python3 -m venv env
source env/bin/activate
python3 -m pip install -e '.[dev]'
```

The editable install exposes the `f2r` command and picks up code changes without reinstalling.

## Lint and unit tests

Run from the repository root:

```bash
ruff check .
ruff format --check .
python3 -m unittest discover tests

# Run a single test:
python3 -m unittest tests.testPackage.TestPackage.test_deps_with_versions
```
