# Making a package in a PPA

Hey Chris,

This is how to create a PPA, make a minor package change, build a package, and upload to a PPA.

1) Useful env vars:
```
 export GPGKEY=0DCDF806
 export EDITOR=/usr/bin/vim
 export DEBFULLNAME="Corey Bryant"
 export DEBEMAIL="corey.bryant@canonical.com"
 export QUILT_PATCHES=debian/patches
```

2) Go to your launchpad page (e.g. https://launchpad.net/~chris.macnaughton) and click "Create a new PPA".

3) If working with bionic (queens by default), no changes are needed for your PPA dependencies. If working with xenial-queens (cloud archive) you'll need to "Edit PPA dependencies" and make your PPA depend on queens-staging. You may be able to get hints from https://launchpad.net/~corey.bryant/+archive/ubuntu/xenial-queens.

4) Clone package source: git clone https://git.launchpad.net/~ubuntu-server-dev/ubuntu/+source/keystone; cd keystone; git checkout stable/queens

5) ls debian  # the debian directory is where all package customization occurs
	- poke around and see what's there
    - maybe cherry-pick an upstream patch to debian/patches

6) dch -i  # make a changelog entry

7) Bonus:
	1) cherry pick a patch from the corresponding upstream branch that is not yet in the package
	2) or use quilt to create a new patch (quilt new; quilt edit <file>; quilt refresh; quilt pop -a)
	3) patch goes in debian/patches; patch name goes in debian/patches/series; 'git add' any new files

8) `debcommit -a`

9) `git log` # see your change?

10) `gbp buildpackage -S -sa`

11) `ppa_upload.sh --yes -d bionic --upload ppa:chris.macnaughton/bionic-rocky ../build-area/keystone*.dsc`  # [1]

12) look for package building in ppa

13) install package from ppa - ie. `sudo add-apt-repostiory ppa:chris.macnaughton/bionic-rocky && sudo apt update && sudo apt install keystone-common`

[1] ppa_upload.sh

```
#!/bin/bash
#
# This script just makes it easier to upload the same package version to a PPA multiple times.
#
# ppa_upload.sh -d bionic --upload ppa:corey.bryant/bionic-queens ../build-area/keystone*.dsc

backportpackage -S ~ppa`date +%Y%m%d%H%M` $@
```
  <p class="callout info">Trouble shooting:</p>
  
<p class="callout info">* git build-package may fail with something like "dpkg-checkbuilddeps: error: Unmet build dependencies: apache2-dev dh-apache2 openstack-pkg-tools (>= 23~) python3-sphinx (>= 1.6.2)
You will need to apt install these build dependency packages and try again. Note: look in debian/control at Build-Dependencies (that's where these are defined) and Depends are run-time dependencies
</p>