Git-buildpackage
From Wikitech
(Difference between revisions)
(→Experiments) |
(→Initially cloning the git repository from Upstream) |
||
| (21 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
(To be written up once experimentation is done.) | (To be written up once experimentation is done.) | ||
| + | |||
| + | == Steps == | ||
| + | (extracted from [[#Experiments]] below.) | ||
| + | |||
| + | === Initially cloning the git repository from Upstream === | ||
| + | * Clone the repository from upstream if it doesn't already exist in Gerrit, e.g. from git.debian.org: | ||
| + | $ cd ~/git/debs/ | ||
| + | $ git clone git://git.debian.org/git/pkg-puppet/''repo''.git | ||
| + | * Set git username/email | ||
| + | $ git config --global user.name "Your Name" | ||
| + | $ git config --global user.email you@example.com | ||
| + | * Set up the local branches <tt>upstream</tt> and <tt>pristine-tar</tt> from the remote branches (but don't switch to them): | ||
| + | $ git branch upstream origin/upstream | ||
| + | $ git branch pristine-tar origin/pristine-tar | ||
| + | * Build a ''source package'': | ||
| + | $ git-buildpackage --git-export-dir=/var/tmp/build-area/''packagename'' -S | ||
| + | * Build the binary packages with [[Pbuilder]]: | ||
| + | # pbuilder --basetgz /var/cache/pbuilder/lucid.tgz /var/tmp/build-area/''packagename''/''packagename''_''version''.dsc | ||
| + | |||
| + | === Making changes and testing snapshot builds === | ||
| + | * Make changes to the package files | ||
| + | * Make commits or amended commits (uncommitted changes are not exported to the build directory) | ||
| + | * Build snapshot builds for testing with: | ||
| + | $ git-dch --snapshot | ||
| + | $ git-buildpackage --git-export-dir=/var/tmp/build-area/''packagename'' -S | ||
| + | # pbuilder --build --basetgz /var/cache/pbuilder/lucid.tgz /var/tmp/build-area/''packagename''/''packagename''_''version''.dsc | ||
| + | |||
| + | === Doing a release === | ||
| + | When a package is ready to be released, use the following steps: | ||
| + | $ git-dch -R -N ''version'' | ||
| + | * Commit the <tt>debian/changelog</tt> file (or amend a previous commit) | ||
| + | * Build the final source package with <tt>--git-tag</tt>: | ||
| + | $ git-buildpackage --git-tag --git-export-dir=/var/tmp/build-area/varnish -S | ||
| + | * Build the binaries with Pbuilder as usual | ||
| + | |||
| + | ==== Pushing changes into Gerrit ==== | ||
| + | Push changes for each of the three branches (if applicable): | ||
| + | $ git push gerrit master:refs/for/master | ||
| + | $ git push gerrit upstream:refs/for/upstream | ||
| + | $ git push gerrit pristine-tar:refs/for/pristine-tar | ||
| + | |||
| + | === Pushing the repository into Gerrit === | ||
| + | You should push any repository with local changes into Gerrit. | ||
| + | |||
| + | * Create a new repository, <tt>operations/debs/''packagename''</tt> using the following Gerrit command: | ||
| + | $ ssh ''username''@gerrit.wikimedia.org -p 29418 'gerrit create-project -d "Package ''packagename''" -n operations/debs/''packagename'' -o ops -p operations/debs' | ||
| + | * Create a new remote called ''gerrit'': | ||
| + | $ git remote add gerrit ssh://''username''@gerrit.wikimedia.org:29418/operations/debs/''packagename'' | ||
| + | * Push the three local branches (''master'', ''upstream'' and ''pristine-tar'') into the fresh remote repository: | ||
| + | $ git push gerrit --all | ||
== Experiments == | == Experiments == | ||
| Line 6: | Line 56: | ||
On i-00000080: | On i-00000080: | ||
| − | * The debian puppet package git repository was cloned into ~/git/debs/puppet | + | * The debian puppet package git repository was cloned into ~/git/debs/puppet: |
| + | $ cd ~/git/debs/ | ||
| + | $ git clone git://git.debian.org/git/pkg-puppet/puppet.git | ||
* Package build was attempted with <tt>git-buildpackage --git-ignore-new --git-pristine-tar</tt> | * Package build was attempted with <tt>git-buildpackage --git-ignore-new --git-pristine-tar</tt> | ||
* Signing the package failed, as the Debian maintainer's secret key is not available. | * Signing the package failed, as the Debian maintainer's secret key is not available. | ||
* Package build was attempted without signing: | * Package build was attempted without signing: | ||
| − | git-buildpackage --git-ignore-new --git-pristine-tar -us -uc | + | $ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc |
* This worked. We ended up with built packages in ~/git/debs, and a dirty git working dir. | * This worked. We ended up with built packages in ~/git/debs, and a dirty git working dir. | ||
* The git working directory was made clean again, and another build was attempted using | * The git working directory was made clean again, and another build was attempted using | ||
| − | git-buildpackage --git-ignore-new --git-pristine-tar -us -uc --git-export-dir=/var/tmp/build-area/puppet | + | $ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc --git-export-dir=/var/tmp/build-area/puppet |
* This worked as well. Packages were being built, and the git working dir remained clean. Packages ended up in the build dir. | * This worked as well. Packages were being built, and the git working dir remained clean. Packages ended up in the build dir. | ||
* The debian git dir only had version 2.7.6, but we want 2.7.7rc2. So I tried importing the dev release with | * The debian git dir only had version 2.7.6, but we want 2.7.7rc2. So I tried importing the dev release with | ||
| − | git-import-orig /tmp/puppet-2.7.7rc2.tar.gz | + | $ git-import-orig /tmp/puppet-2.7.7rc2.tar.gz |
| + | * This failed, as there was no local ''upstream'' branch in the cloned git repository yet. Ok, so let's create it from ''origin/upstream'': | ||
| + | $ git branch upstream origin/upstream | ||
| + | * Now the import worked. But commits were made, with the default git name/mail address. Do set it: | ||
| + | $ git config --global user.name "Your Name" | ||
| + | $ git config --global user.email you@example.com | ||
| + | * Try another build. | ||
| + | $ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc --git-export-dir=/var/tmp/build-area/puppet | ||
| + | * Oops. This used version 2.7.6. But, the git-buildpackage manual says changing the changelog itself all the time isn't a good idea. Let's try git-dch: | ||
| + | $ git-dch --snapshot | ||
| + | Changelog has been prepared for snapshot #1 at 48473567008ad82cdb0d0a5654dffe7c868fad91 | ||
| + | <pre> | ||
| + | $ git diff | ||
| + | diff --git a/debian/changelog b/debian/changelog | ||
| + | index 796b61e..f6da810 100644 | ||
| + | --- a/debian/changelog | ||
| + | +++ b/debian/changelog | ||
| + | @@ -1,3 +1,11 @@ | ||
| + | +puppet (2.7.6-1ubuntu1~1.gbp484735) UNRELEASED; urgency=low | ||
| + | + | ||
| + | + ** SNAPSHOT build @48473567008ad82cdb0d0a5654dffe7c868fad91 ** | ||
| + | + | ||
| + | + * Imported Upstream version 2.7.7rc2 | ||
| + | + | ||
| + | + -- Mark Bergsma <mark@i-00000080.pmtpa.wmflabs> Wed, 23 Nov 2011 14:06:45 +0000 | ||
| + | + | ||
| + | </pre> | ||
| + | * Cool, but not quite what I need. There was no commit, so let's simply revert that, and try again after reading the git-dch manual: | ||
| + | $ git checkout debian/changelog | ||
| + | $ git-dch --snapshot -N 2.7.6+2.7.7rc2 --git-author | ||
| + | <pre> | ||
| + | $ git diff | ||
| + | diff --git a/debian/changelog b/debian/changelog | ||
| + | index 796b61e..06a9cac 100644 | ||
| + | --- a/debian/changelog | ||
| + | +++ b/debian/changelog | ||
| + | @@ -1,3 +1,11 @@ | ||
| + | +puppet (2.7.6+2.7.7rc2~1.gbp484735) UNRELEASED; urgency=low | ||
| + | + | ||
| + | + ** SNAPSHOT build @48473567008ad82cdb0d0a5654dffe7c868fad91 ** | ||
| + | + | ||
| + | + * Imported Upstream version 2.7.7rc2 | ||
| + | + | ||
| + | + -- Mark Bergsma <mark@wikimedia.org> Wed, 23 Nov 2011 14:23:22 +0000 | ||
| + | + | ||
| + | </pre> | ||
| + | * Now let's try a new build: | ||
| + | $ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc --git-export-dir=/var/tmp/build-area/puppet | ||
| + | * Whoops. It built 2.7.6 instead. Probably because it exported HEAD into the build area. Let's see what it does within the git repository. | ||
| + | $ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc | ||
| + | * So that worked. Hmm, inconsistent. :( I guess we could choose not to care about version numbers for snapshots, and only care about them for releases. | ||
| + | |||
| + | == External links == | ||
| + | * [http://honk.sigxcpu.org/projects/git-buildpackage/manual-html Git-buildpackage documentation] | ||
[[Category:Ubuntu]] [[Category:Package management]] | [[Category:Ubuntu]] [[Category:Package management]] | ||
Latest revision as of 13:11, 3 April 2012
(To be written up once experimentation is done.)
Contents |
[edit] Steps
(extracted from #Experiments below.)
[edit] Initially cloning the git repository from Upstream
- Clone the repository from upstream if it doesn't already exist in Gerrit, e.g. from git.debian.org:
$ cd ~/git/debs/ $ git clone git://git.debian.org/git/pkg-puppet/repo.git
- Set git username/email
$ git config --global user.name "Your Name" $ git config --global user.email you@example.com
- Set up the local branches upstream and pristine-tar from the remote branches (but don't switch to them):
$ git branch upstream origin/upstream $ git branch pristine-tar origin/pristine-tar
- Build a source package:
$ git-buildpackage --git-export-dir=/var/tmp/build-area/packagename -S
- Build the binary packages with Pbuilder:
# pbuilder --basetgz /var/cache/pbuilder/lucid.tgz /var/tmp/build-area/packagename/packagename_version.dsc
[edit] Making changes and testing snapshot builds
- Make changes to the package files
- Make commits or amended commits (uncommitted changes are not exported to the build directory)
- Build snapshot builds for testing with:
$ git-dch --snapshot $ git-buildpackage --git-export-dir=/var/tmp/build-area/packagename -S # pbuilder --build --basetgz /var/cache/pbuilder/lucid.tgz /var/tmp/build-area/packagename/packagename_version.dsc
[edit] Doing a release
When a package is ready to be released, use the following steps:
$ git-dch -R -N version
- Commit the debian/changelog file (or amend a previous commit)
- Build the final source package with --git-tag:
$ git-buildpackage --git-tag --git-export-dir=/var/tmp/build-area/varnish -S
- Build the binaries with Pbuilder as usual
[edit] Pushing changes into Gerrit
Push changes for each of the three branches (if applicable): $ git push gerrit master:refs/for/master $ git push gerrit upstream:refs/for/upstream $ git push gerrit pristine-tar:refs/for/pristine-tar
[edit] Pushing the repository into Gerrit
You should push any repository with local changes into Gerrit.
- Create a new repository, operations/debs/packagename using the following Gerrit command:
$ ssh username@gerrit.wikimedia.org -p 29418 'gerrit create-project -d "Package packagename" -n operations/debs/packagename -o ops -p operations/debs'
- Create a new remote called gerrit:
$ git remote add gerrit ssh://username@gerrit.wikimedia.org:29418/operations/debs/packagename
- Push the three local branches (master, upstream and pristine-tar) into the fresh remote repository:
$ git push gerrit --all
[edit] Experiments
Mark is experimenting with building puppet using git-buildpackage, in labs.
On i-00000080:
- The debian puppet package git repository was cloned into ~/git/debs/puppet:
$ cd ~/git/debs/ $ git clone git://git.debian.org/git/pkg-puppet/puppet.git
- Package build was attempted with git-buildpackage --git-ignore-new --git-pristine-tar
- Signing the package failed, as the Debian maintainer's secret key is not available.
- Package build was attempted without signing:
$ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc
- This worked. We ended up with built packages in ~/git/debs, and a dirty git working dir.
- The git working directory was made clean again, and another build was attempted using
$ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc --git-export-dir=/var/tmp/build-area/puppet
- This worked as well. Packages were being built, and the git working dir remained clean. Packages ended up in the build dir.
- The debian git dir only had version 2.7.6, but we want 2.7.7rc2. So I tried importing the dev release with
$ git-import-orig /tmp/puppet-2.7.7rc2.tar.gz
- This failed, as there was no local upstream branch in the cloned git repository yet. Ok, so let's create it from origin/upstream:
$ git branch upstream origin/upstream
- Now the import worked. But commits were made, with the default git name/mail address. Do set it:
$ git config --global user.name "Your Name" $ git config --global user.email you@example.com
- Try another build.
$ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc --git-export-dir=/var/tmp/build-area/puppet
- Oops. This used version 2.7.6. But, the git-buildpackage manual says changing the changelog itself all the time isn't a good idea. Let's try git-dch:
$ git-dch --snapshot Changelog has been prepared for snapshot #1 at 48473567008ad82cdb0d0a5654dffe7c868fad91
$ git diff diff --git a/debian/changelog b/debian/changelog index 796b61e..f6da810 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +puppet (2.7.6-1ubuntu1~1.gbp484735) UNRELEASED; urgency=low + + ** SNAPSHOT build @48473567008ad82cdb0d0a5654dffe7c868fad91 ** + + * Imported Upstream version 2.7.7rc2 + + -- Mark Bergsma <mark@i-00000080.pmtpa.wmflabs> Wed, 23 Nov 2011 14:06:45 +0000 +
- Cool, but not quite what I need. There was no commit, so let's simply revert that, and try again after reading the git-dch manual:
$ git checkout debian/changelog $ git-dch --snapshot -N 2.7.6+2.7.7rc2 --git-author
$ git diff diff --git a/debian/changelog b/debian/changelog index 796b61e..06a9cac 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +puppet (2.7.6+2.7.7rc2~1.gbp484735) UNRELEASED; urgency=low + + ** SNAPSHOT build @48473567008ad82cdb0d0a5654dffe7c868fad91 ** + + * Imported Upstream version 2.7.7rc2 + + -- Mark Bergsma <mark@wikimedia.org> Wed, 23 Nov 2011 14:23:22 +0000 +
- Now let's try a new build:
$ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc --git-export-dir=/var/tmp/build-area/puppet
- Whoops. It built 2.7.6 instead. Probably because it exported HEAD into the build area. Let's see what it does within the git repository.
$ git-buildpackage --git-ignore-new --git-pristine-tar -us -uc
- So that worked. Hmm, inconsistent. :( I guess we could choose not to care about version numbers for snapshots, and only care about them for releases.