Contribute to pkgdb2
How to get started with contributing to pkgdb2.
Pkgdb2 is the application managing in Fedora, who is allowed to access which git repo containing the files necessary to build the packages present in the distribution.
It's a python web application, using the flask framework, on the top of a SQL database.
Every once in a while, someone opens a ticket on pkgdb2 asking for a small improvement or reporting a small bug which do not need a deep understanding of pkgdb2's code base to implement or fix. These tickets are tagged as easyfix and are a good way to get started with pkgdb2.
In this post I am going to help you setting up a local pkgdb2 instance so that you work on it and, if you like, contribute to it.
Installing the dependencies
All the dependencies for pkgdb2 are in the Fedora repositories, so you can just install them as you do for any packages:
sudo dnf install python2-devel python-flask python-flask-wtf python-wtforms\ python-kitchen python-fedora python-fedora-flask python-openid-teams \ python-openid-cla python-docutils python-dateutil python-dogpile-cache \ python-mock python-bugzilla python-memcached python-setuptools \ python-blinker python-psutil python-sqlalchemy
Download the sources
The sources are stored in git, so if you do not have git installed on your machine:
sudo dnf install git
You can then clone the sources:
git clone http://git.fedorahosted.org/git/pkgdb2.git
or from it's mirror on github
git clone https://github.com/fedora-infra/pkgdb2.git
The rest of the work will be done within the sources, so let's get into the folder
Create the database
There are two options for the database, either you use a local sqlite database and you create a couple of packages locally to play with, or you use the dump of the real postgresql database that Fedora uses in production.
Local SQLite database
Pkgdb2 is configured by default to create and run from a local SQLite database located at:
You can create it by simply running:
Use a PostgreSQL database
You will need to install and set-up your postgresql server. There are many documentations on the internet on how to do this and I will let you find the one that suits you best.
Once you have set-up your postgresql server, you can download the daily dump of the pkgdb2 database from prod.
(Note: you may have to
sudo dnf install wget if it is not already installed).
You then need to create a pkgdb2 database. You can either use
pgadmin3 (a graphical application to manage postgresql databases and users) or do it via the command line:
sudo -u postgres createdb pkgdb2
Finally, loading the pkgdb2 database can be done using:
xzcat pkgdb2.dump.xz | sudo -u postgres psql pkgdb2
You might need to tweak these commands according to the way you set-up your database server.
Pkgdb2 has a configuration file allowing to, well, configure pkgdb2 :-).
To run a local instance, you may need to tweak it a little.
For example, if you run pkgdb2 against a postgresql server, you will have to specify to pkgdb2 where to look for this database (since by default it will search for the SQLite one).
Another situation where you will need to tweak the configuration is to give yourself admin rights on your local pkgdb2 instance.
There is a template configuration file at:
Copy this file over to the top folder of the sources:
cp utility/pkgdb2.cfg.sample pkgdb2.cfg
Now edit it:
In there you will need to change:
- DB_URL if you are not using the default SQLite database
- ADMIN_GROUP to include a group that you are part of (this will give you admin rights on your own pkgdb2 instance)
- PKGDB2_FAS_USER and PKGDB2_FAS_PASSWORD if you work on something that requires asking FAS which users are packagers (so if you want to add someone to a package or create a new package, you will likely need it). Just use your own FAS credentials here but beware to not add the file to your commits later on.
- SESSION_COOKIE_SECURE will need to be changed to False since you are likely not running to development instance with https.
Start your local pkgdb2 instance
From there starting pkgdb2 is really easy.
If you did not modify anything in
pkgdb2.cfg, then you can start the server directly:
If you did modify
pkgdb2.cfg, then you need to tell pkgdb2 to use this configuration file which is achieved by specifying an environment variable to pkgdb2 telling it where this configuration file is located:
Now that you have a local pkgdb2 instance running, you can checkout the list of bugs that needs addressing on both bug trackers (https://fedorahosted.org/pkgdb2/ and https://github.com/fedora-infra/pkgdb2/issues)
But if it is the first time you are looking at pkgdb2, I recommend you check out the easyfix tickets that should help you get started