A recipe made to create your first PR for the Fedora Project
Tags: fedora, linux, development
Published: 2023-10-19 11:47:05

## Step 0: Creating your Fedora account and installing Fedora

* Go to https://accounts.fedoraproject.org, and click on Register following the next steps to create your Fedora account.
* Go to [Fedora download page](https://fedoraproject.org/workstation/download/), download and install the latest Fedora version.
* Alternatively, create a Fedora container using [podman](https://fedoramagazine.org/getting-started-with-podman-in-fedora/).

## Step 1: Set up your Fedora environment

* [Install and configure your packaging tools](https://docs.fedoraproject.org/en-US/package-maintainers/Installing_Packager_Tools/)


I strong recommend you to install the development tools group:
```
dnf install @development-tools
```

## Step 2: Find some package needing an update

* First of all, you have to create your [Bugzilla account](https://bugzilla.redhat.com/createaccount.cgi)
When a package needs an update, an automatic bz is created, so you can use a query like this one below:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3tjq0rmeqgpfrfvy4v3w.png)

* Then, clone it using fedpkg. For example, for python-pluggy we have:
```
fedpkg clone --anonymous python-pluggy
```


## Step 3: Making your own changes

* Go to [Fedora Packager Sources](https://src.fedoraproject.org/fork/prgutier/rpms/python-pluggy), fork the project and change your remote origin. 

It didn't work for me cloning the project directly from my own fork, I had problems when trying to upload my changes.
 ```
cd ./python-pluggy
git remote remove origin
```
Then, add your remote origin
```
git remote add origin https://src.fedoraproject.org/forks/<your_fedora_user>/rpms/python-pluggy.git
```
* Check the project's github page. In this case,looking at the Changelog, the latest version is 1.3.0 .

* Open the specfile with your favorite editor:
```
cd ./python-pluggy
code python-pluggy.spec
```
Change the Version string:
```
Version:        1.3.0
```
You also need to change the Release string to 1, because is the first build of this new version:
```
Release:        1%{?dist}
```
Now we are going to download the sources to create our local build:
```
spectool -g <your_package>.spec
```
Create your local mockbuild:
```
fedpkg mockbuild
```

## Step 4: Checking results & troubleshooting


If you get an output like that:

```
(...)
Finish: build phase for python-pluggy-1.3.0-1.fc40.src.rpm
INFO: Done(/home/priscila/Fedora/packages/fedpkg/python-pluggy/python-pluggy-1.3.0-1.fc40.src.rpm) Config(fedora-rawhide-x86_64) 0 minutes 30 seconds
INFO: Results and/or logs in: /home/priscila/Fedora/packages/fedpkg/python-pluggy/results_python-pluggy/1.3.0/1.fc40
INFO: Cleaning up build root ('cleanup_on_success=True')
Start: clean chroot
Finish: clean chroot
Finish: run
```
Go to the next step :-)

Otherwise, is time to debug what is going on.
Common issues are: 
* A new BuildRequirement is needed: if apparently a package is missing during the build time, check for new dependencies in the Changelog.

* A test is failing: in this case, you need to debug the source code. Is absolutely necessary have a strong knowledge  about the programming languages in the package you are working on
If nothing works and you are still in trouble.
Note that some tests are not supported by koji during the build time.

* A new patch is needed: this [article](https://blog.aloni.org/posts/how-to-easily-patch-fedora-packages/) covers this case.

## Step 5: Finish editing the specfile

* Now that everything is working as expected, you have to add the changelog to the specfile:

```
%changelog
* Tue Oct 17 2023 Priscila Gutierres <pgutier@redhat.com> - 1.3.0-1
- Update to 1.3.0.
```
* Add the sources:
```
fedpkg new-sources --offline pluggy-1.3.1.tar.gz
```
* Add and commit the changes using git

## Step 6: Creating your Pull Request

As a non-maintainer, you can't upload the sources, so when creating your PR, the checking pipeline will fail.
To fix it, ask the maintainer to upload the sources.
And.. Congrats! You have your first Fedora contribution :-)