Differences between revisions 3 and 5 (spanning 2 versions)
Revision 3 as of 2009-07-03 20:30:26
Size: 6033
Editor: ?JohnGoerzen
Comment:
Revision 5 as of 2013-01-04 22:04:55
Size: 0
Editor: nomeata
Comment: Obsolete
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
##master-page:HelpTemplate
##master-date:Unknown-Date
#format wiki
#language en
== Haskell Packaging with Git ==

For some background information, read [[PackagingWithGit]].

== Starting Your Project in Git ==

Let's assume that you already have been working on a package. In this case, you'll want to use git-import-dsc to import your package into the Git repo. If you like, you can import multiple old versions into Git in order to import history. If you do that, just run git-import-dsc multiple times to get all the old versions. Let's say we'll import HDBC:

{{{
$ mkdir hdbc
$ cd hdbc
$ git init
Initialized empty Git reposiroty in ...
$ git-import-dsc --pristine-tar ../hdbc_2.0.0-1.dsc
tag upstream/2.0.0 not found, importing Upstream tarball
pristine-tar: committed hdbc_2.0.0.orig.tar.gz.delta to branch pristine-tar
Merging to master
Already up-to-date.
Everything imported under 'hdbc'
}}}

At this point, you'll have three branches:

{{{
$ git branch
* master
  pristine-tar
  upstream
}}}

The master branch represents your Debian work branch. upstream is the branch for upstream code; git-import-orig and git-import-dsc create it. and pristine-tar lets you build the source tarball out of the git repo. It will be automatically managed by the tools.

We can go on importing history if we like:

{{{
$ git-import-dsc --pristine-tar ../hdbc_2.1.0-1.dsc
tag upstream/2.1.0 not found, importing Upstream tarball
Switched to branch 'upstream'
pristine-tar: committed hdbc_2.1.0.orig.tar.gz.delta to branch pristine-tar
Switched to branch 'master'
Merging to master
Merge made by recursive.
Everything imported under 'hdbc'
}}}

At this point, you'll want to have a pkg-haskell admin create a Git repo. Then push to it for the first time:

{{{
$ git push --all ssh://<user>@git.debian.org/git/pkg-haskell/project.git
$ git push --tags ssh://<user>@git.debian.org/git/pkg-haskell/project.git
}}}

Now, tell the pkg-haskell admins you're ready for the commit hooks to be enabled (to send the data to the mailing lists).

Finally, you'll want to remove the tree you just created, and re-clone it as in [[Haskell/CollabMaint/GitBasic]] and set up your tracking branches:

{{{
$ git clone ssh://<user>@git.debian.org/git/pkg-haskell/project.git
$ cd project
$ git branch upstream origin/upstream
Branch upstream set up to track remote branch upstream from origin.
$ git branch pristine-tar origin/pristine-tar
Branch pristine-tar set up to track remote branch pristine-tar from origin.
}}}

Now, see [[Haskell/CollabMaint/GitBasic]] for basic instructions.

Also, you might be interested to see the tags created:

{{{
$ git tag
debian/2.0.0-1
debian/2.1.0-1
upstream/2.0.0
upstream/2.1.0
}}}

== Daily Work ==

You can use the regular git commit -a, git merge, etc. to work on the project on a daily basis. git-dch is especially interesting, as it can convert git commit messages into debian/changelog messages.

When you're ready to build the package, run:

{{{
$ git-buildpackage --git-pristine-tar --git-tag -rfakeroot
}}}

The --git-pristine-tar tells it to build the orig.tar.gz from the data in the repo, if you are lacking it. --git-tag will cause it to automatically create the debian/x.y-z tag if the build completes successfully (or you could always tag it yourself later). -rfakeroot is passed on to debuild.

Of course, {{{git push --all}}} when you're dong hacking.

== Importing New Upstream ==

When there's a new upstream release -- say, on Hackage -- you will import upstream's tar file into your tree. For instance:

{{{
$ git-import-orig --pristine-tar -u 2.1.1 ../HDBC-2.1.1.tar.gz
Upstream version is 2.1.1
Importing '../HDBC-2.1.1.tar.gz' to branch 'upstream'...
Switched to branch 'upstream'
[upstream 202bc26] Imported Upstream version 2.1.1
 5 files changed, 93 insertions(+), 6 deletions(-)
 create mode 100644 testsrc/TestInfrastructure.hs
 create mode 100644 testsrc/TestSqlValue.hs
 create mode 100644 testsrc/runtests.hs
pristine-tar: committed hdbc_2.1.1.orig.tar.gz.delta to branch pristine-tar
Merging to 'master'
Switched to branch 'master'
Merge made by recursive.
Succesfully merged version 2.1.1 of ../HDBC-2.1.1.tar.gz into .
}}}

This is a powerful command. First, it changes to the upstream branch. It imports the tar file there, commits it, and tags it. It also creates the pristine-tar metadata on the pristine-tar branch. Finally, it switches back to the master branch and uses Git's commands to merge upstream. It also creates a stub entry in debian/changelog with the new version.

You can now hack and use git-buildpackage when ready to build

== If Upstream Uses Git ==

If all of these hold:

 * Upstream uses Git (or another VCS that git interfaces with)
 * The upstream tree in VCS is identical to the orig.tar.gz tarballs they produce, or a superset of them

Then you can use upstream's git repo. You'll start out by cloning their repo:

{{{
$ git clone git://git.complete.org/hdbc
$ cd hdbc
}}}

Generally speaking, upstream's master branch becomes your upstream branch:

{{{
$ git branch upstream origin/master
Branch upstream set up to track remote branch master from origin.
}}}

Now, identify the commit that corresponds to the release and tag it with git tag upstream/x.y.z 1fecde3...

Now you can import the pristine-tar metadata:

{{{
$ git checkout upstream/2.1.1
Note: moving to 'upstream/2.1.1' which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
  git checkout -b <new_branch_name>
HEAD is now at fb518e1...
$ pristine-tar commit ../HDBC-2.1.1.tar.gz
pristine-tar: committed HDBC-2.1.1.tar.gz.delta to branch pristine-tar
}}}

Now, use git checkout master to move back to your Debian branch and start hacking.


=== See Also ===

 * [[Haskell/CollabMaint]] -- Parent Page