The RESF primary purpose is to rebuild and debrand a 1:1 bug replica of RHEL and have built tools that support this process. The SIGs are modifications to that initial purpose while reusing the tooling already developed for the base dist-git process. The SIG dist-gits are controlled by automation that executes the `srpmproc` command so to modify the dist-git in any manner a developer needs to integrate their changes to the `sig/cloud/patch` configs related to that SIG. [SIG/CLOUD - SRPMPROC Kernel Patches](https://git.rockylinux.org/sig/cloud/kernel) -> [SIG/CLOUD - Kernel dist-git](https://git.rockylinux.org/sig/cloud/rpms/kernel)
`srpmproc` is designed to only modify the `dist-git` and if a SIG wants a particular driver branch, that cleanly applies, they need to use another program called `sideline` to create a monolithic patch against a point in time source code base. That is then added to the `SIDELINE/_supporting` directory of the `sig/cloud/patch/kernel` directory. `srpmproc` knows that these patches are to be included into `SOURCES/` and added to `applypatch` directives in the `kernel.spec` with appropriate config settings for `srpmproc`.
## Diagram Production
```
|--------------------------|
| : SRPMPRROC : |
| Pulls RESF dist-git |
| Alters dist-git files |
| Injects SIDELINE patches |
|---Pull---| into soruce/ and .spec |---Automation:--|
| |--------------------------| Push |
v v
|----------| |-----------|
| : RESF : | | : RESF : |
| dist-git | | SIG/CLOUD |
|----------| | dist-git |
|-----------|
```
## Developer Process
The general process by the RESF was not initially created with ad-hoc development in mind but rather pulling entire branches from upstream into the current RESF base releases. The following is to provide a general guide on how to develop with `srpmproc` as the `SIG/CLOUD` dist-git is not to be modified directly for development support.
4. Make Changes, local builds and testing (not covered in doc)
5. Source changes from local build to `sig/cloud/patch/kernel`
6. Regenerate `dist-git` with srpmproc
7. Mock test rpm builds.
The following sections are going to be based off real work that was ultimately abandoned for Rocky8.
### Prep for SRPMPROC: Cloning patch/kernel
This is the general prep of the directories used. Note some directions for `srpmproc` use a temp directory, that is not used here as depending on how long development can last you could lose important work, specifically around the `srpmproc-cache`
Create Needed Directories
```
mkdir -p SIG/cloud/
cd SIG/cloud/
mkdir -p {rpms,patch,src,srpmproc-cache,src-git}
```
Clone the configuration Directives and Patches repo
This step will be missing a lot of output just so that we can focus on the results and where we source building a local source git tree.
RUN SRPMPROC with script or by hand.
```
./sprmproc.sh
```
After `srpmproc` runs you'll have a a new directory (`kernel`) in your current path that will have a working copy of the `sig/cloud``dist-git` used to build the RPMs for `sig/cloud`
This is ultimately up to the back porter but due to the massive monolithic patch that is preferred by `srpmproc` and its current configuration changes its best to leave some markers in the backport commits. In the following example we used these markers to make sure we could reproduce the upstream change log for future cherry-picks
c44180277750 clocksource/drivers/arch_arm_timer: Move workaround synchronisation around
4245d37d01b5 clocksource/drivers/arm_arch_timer: Fix masking for high freq counters
c9a41f6ca50a clocksource/drivers/arm_arch_timer: Drop unnecessary ISB on CVAL programming
79cbc595435b clocksource/drivers/arm_arch_timer: Remove any trace of the TVAL programming interface
5ce552b7c335 clocksource/drivers/arm_arch_timer: Work around broken CVAL implementations
e616b69d5656 clocksource/drivers/arm_arch_timer: Advertise 56bit timer to the core code
7d8301d23b2d clocksource/drivers/arm_arch_timer: Move MMIO timer programming over to CVAL
96f3d866ac46 clocksource/drivers/arm_arch_timer: Fix MMIO base address vs callback ordering issue
405b16cdf7ea clocksource/drivers/arm_arch_timer: Add __ro_after_init and __init
a674842337c0 clocksource/drivers/arm_arch_timer: Move drop _tval from erratum function names
7362b3b1507d clocksource/drivers/arm_arch_timer: Move system register timer programming over to CVAL
fa7e8c083474 clocksource/drivers/arm_arch_timer: Extend write side of timer register accessors to u64
39df82354a3b clocksource/drivers/arm_arch_timer: Drop CNT*_TVAL read accessors
8be2a2c2ce27 clocksource/arm_arch_timer: Add build-time guards for unhandled register accesses
26523a2078fe (mainline) Add RESF Google Patch
4be223b7a767 Initial Commit from RESF Source
```
#### Local Kernel Builds
Compile the kernel in place (outside the scope of this document).
You could also export all these patches and manually add them to the `dist-git` like by many other `dist-git` builds however they can not be submitted to the SIG from this state. So this would be exclusively for your local testing. If you choose to do this and are not sure how to use `mock` builds, [Skip's Blog](https://skip.linuxdn.org/blog.html#005_Rocky5_BuildLab_Part1) as a relevant primer tutorial for Rocky
### Prepare changes for srpmproc integration
This is the part deviates pretty drastically from normal developer workflows.
#### Generate Monolithic Patch
In this case you'll want to take the commit you're branched off to the HEAD of your branch and create a single patch. Using the local commits in the above output we'll want `26523a2078fe` to be the first sha and `c92984ca64bb` to be the final
#### Generate cherry-pick patch and changelog entries (a basic method)
This segment is a manual way of producing the needed changelog entries and a nicer patch header than a standard `git diff`. And is being used to show examples of how and where to contribute.
```
echo -e "Backport AmpereOne CPU clocksource and related bug fixes\n\nThis is just a monolithic diff.\nThe Commits backported are in git log order.\n" > ../patch_msg.resf.txt;
message: "af246cc6d0ed - Yang Guo - 2022-09-27 - clocksource/drivers/arm_arch_timer: Fix CNTPCT_LO and CNTVCT_LO value"\n
[19 lines ommited for readability]
message: "4775bc63f880 - Marc Zyngier - 2021-10-17 - clocksource/arm_arch_timer: Add build-time guards for unhandled register accesses"\n
```
Patch File so there is local reference to what was done. Its important to show how the monolithic patch is generated in the event the changes need to be re-played in the event of a code correction:
```
$ cat ../ampereone.resf.patch
Backport AmpereOne CPU clocksource and related bug fixes
This requires manual modification of directives file as `srpmproc` needs to be told what to do with the new file.
Some unique notes about `srpmproc`
*`patch` - directive applies a patch to the `dist-git` files themselves, NOT adding a patch the `.spec` file
*`add: {file: <path>}` is what will copy the file from `srpmproc` directories INTO the `dist-git``SOURCES/` location.
*`spec_change` is where we configure changes to the specfile like would be done to a standard `dist-git`
* This is processed in order, so `search_and_replace` will be processed in order for adding patches. Make sure the patches are applied in correct order.
* Since the file is processed in order the changelog items need to be placed in reverse order ie newest item at the top.
Example of a modification, NOTE `search_and_replace` were below the `chagnelog` entries. They were moved on this abandoned work such that the `file` and `search_and_replace` were located generally in order relation to how they would be modified in a pure `dist-git` style repo. In a hope to avoid jumping back and forth in the file.
As of 2024.01.29 `srpmproc` cannot work off dev branches so this code will need to be on the main `r<version>` branch. Once this is done re-running `srpmproc` using the above script or exact same command parameters used when creating the local `srpmproc` will use the new local HEAD.