# Packaging Workflow with Git-Stuff

## Table of Contents

1. Definitions
2. Preparations
3. Handling new packages
4. Handling existing package

## 1. Definitions

- package: name of the source package of your program
- revision: debian version string
- version: upstream version string

^

## 2 Preparations

- Install git

      # apt-get install git

- Install git-stuff

      # apt-get install git-stuff

- Install pristine-tar

      # apt-get install pristine-tar

- Install git-buildpackage

      # apt-get install git-buildpackage

^

## 3 Handling new packages

### 3.1 Preparing upstream tarball

- Download upstream source tarball.
- Rename it to `package_version.orig.tar.gz`.

### 3.2 Preparing git repository

- Create the repository directory

      $ mkdir program
      $ cd program

- Unpack upstream sources into the directory.
- Import upstream into git

      $ git-upstream-add version

- Import pristine-tar delta

      $ git-upstream-tar ../program_version.orig.tar.gz

- Create and switch to debian branch

      $ git checkout -b debian

- Prepare bare git repository

      $ cd ..
      $ git clone --bare program program.git

- Upload git repository to server

      $ scp -r program.git username@server:~/

^

## 4. Handling existing package

### 4.1 Checking out

- Checkout repository

      $ git clone git@server:path/package.git

- Checkout branches

      $ cd package

      $ git-checkout-branches

### 4.2 Checking in

- Make sure that you are on the debian branch

      $ cd package

      $ git checkout debian

- Do your modifications on the package here. Remeber to not touch debian/changelog at all, it will be later automatically generated from the git log.
- Commit changes

      $ git commit -a -m "My commit message."

- After a bunch of commits, you push changes

      $ git push

### 4.3 Adding new Upstream version

- Make sure that you are on the upstream branch

      $ cd package

      $ git checkout upstream

- Removing current files

      $ rm -rf *

- Unpacking new upstream sources into the git repository
- Adding files

      $ git-upstream-add version

- Upstream tarball

      $ git-upstream-tar version ../package_version.orig.tar.gz

- Make sure that you are on the debian branch

      $ git checkout debian

- Merging

      $ git cherry-pick -n upstream
      $ git commit -a -m "Merging upstream version version."

- Pushing

      $ git-push

### 4.4 Releasing new Debian version

- Creating changelog

      $ git-debian-changelog

- Releasing

      $ git-debian-release

- Pushing

      $ git-push

- Upstream tarball

      $ pristine-tar checkout package_version.orig.tar.gz

- Build in chroot and upload to ftp-master as usual.

^