Metadata-Version: 2.1
Name: linux-kernel-compat-helper
Version: 1.0
Summary: A helper to get exact versions based on commit changes to maintain compatibility across kernel versions.
Home-page: UNKNOWN
Author: Chaitanya Tata
Author-email: Chaitanya.tk17@gmail.com
License: GPL-2.0
Platform: UNKNOWN
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyGithub
Provides-Extra: dev
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: coverage ; extra == 'dev'
Requires-Dist: mypy ; extra == 'dev'
Requires-Dist: black (>=20.8b0) ; extra == 'dev'
Requires-Dist: types-pyyaml ; extra == 'dev'
Requires-Dist: types-requests ; extra == 'dev'
Requires-Dist: types-jinja2 ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme ; extra == 'docs'

# linux-kernel-compat-helper
Linux kernel compatibility helper to add version guards for an out-of-tree modules or to get the tag information for a particular commit.

## Build and Coverage status

[![Build Status](https://travis-ci.com/chaitu-tk/linux-kernel-compat-helper.svg?branch=main)](https://travis-ci.com/chaitu-tk/linux-kernel-compat-helper)  [![codecov](https://codecov.io/gh/chaitu-tk/linux-kernel-compat-helper/branch/main/graph/badge.svg?token=T66GVAIN07)](https://codecov.io/gh/chaitu-tk/linux-kernel-compat-helper)

# Introduction
For maintaining an out-of-tree module it is important to support multiple kernel version compatibility
using Linux kernel version guards, we can get the exact commit for the fix by using `git blame` or `git bisect` etc, but the main problem is to figure out the version number which the fix
is present first.

## The problem statement

### Clone Linus's `linux.git`

If you have clone Linus tovarlds [`linux.git`](git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git)
then we can use below command to figure out the tag in which the commit first appeared. But cloning this repo
and keeping it up-to-date is inconvinient.

```
$ git describe --contains <commit_sha>
```

## Solution

### Github Linus's `linux.git`
This repo is kept up-to-date and we can use the Github API to query commits and tags without cloning the repo and maintaining it. This module uses this approach and does a simple binary search based on commit and tag date.

# Usage
## Prerequisites
* Github API token with proper permissions
* `pipenv` installed
* Tested on Ubuntu Distribution, but should work in others.

## Running
* Create and Install the virtual environment
    - `pipenv install`

* Run the application, below command will display the usage.
    - `pipenv run lk-get-tag -h`

## Example commands
```
$ export GITHUB_API_TOKEN=<token>
$ pipenv install
$ pipenv run lk-get-tag -c <commit_sha>
```


