Differences between revisions 3 and 9 (spanning 6 versions)
Revision 3 as of 2008-07-25 18:18:34
Size: 2407
Editor: SandroTosi
Comment:
Revision 9 as of 2010-03-27 10:24:46
Size: 3452
Comment: Added advertisement and a --no-name option to stabilise the orig.gz's md5 sum.
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
Line 10: Line 9:
 2. the code in the svn is the preliminary version the new upstream release, be it x.(y+1) or x.y.n
 1. the code in the svn is the preliminary version the new upstream release, be it x.(y+1) or x.y.n
Line 18: Line 16:
Line 22: Line 19:
 2. if x.y-z is in sid and you're packaging the new version x.(y+1) or x.y.n, then go with x.(y+1)~svn<rev>-1 or x.y.n~svn<rev>-1
 1. if x.y-z is in sid and you're packaging the new version x.(y+1) or x.y.n, then go with x.(y+1)~svn<rev>-1 or x.y.n~svn<rev>-1
Line 25: Line 21:
Line 31: Line 26:
Line 33: Line 27:
Line 37: Line 30:
# Adapted from http://wiki.debian.org/SandroTosi/Svn_get-orig-source
Line 38: Line 32:
SRC_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | sed 's/^Version: \(.*\)-.*/\1/') SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
Line 41: Line 35:
Line 46: Line 39:
        svn export -r $(SVN_REVISION) <UPSTREAM SVN REPOSITORY> get-orig-source/$(PACKAGE)-$(SRC_VERSION)
        tar czf $(TARBALL) -C get-orig-source $(PACKAGE)-$(SRC_VERSION)
        svn export -r $(SVN_REVISION) <UPSTREAM SVN REPOSITORY> \
         
get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig
        GZIP='--best --no-name' tar czf $(TARBALL) -C get-orig-source $(PACKAGE)-$(SRC_VERSION).orig
Line 51: Line 45:
Some explanations:
Line 52: Line 47:
 * {{{SRC_VERSION}}} take the version from the {{{debian/changelog}}} (that's why you need to modify it at first)
 * {{{SVN_REVISION}}} extracts the revision from the version (TODO: be smart and field separator must be '+' and '~')
 * {{{TARBALL}}} is the generated tarball name
 * {{{GZIP='--best --no-name'}}} ensures that compression rate is highest and md5sum is reproducible.
 * some cleanup before running the real "core"
 * export the code from svn in a subdir under {{{get-orig-source}}}, made by name and version (dash separated)
=== Notes ===
 * With the needed changes, this can be adapted to other VCS; this is for SVN because I needed for it.
 * If upstream source code is under autotools, once you have downloaded the source code, you got to run all the commands chain (like autogen.sh and so).
Line 53: Line 57:
Line 55: Line 58:
 * godog and kaeso from #debian-it@OFTC
Line 57: Line 61:
 * http://lists.debian.org/debian-mentors/2007/01/msg00413.html

I want to describe how to write a nice get-orig-source target for debian/rules in presence of an upstream SVN repository.

Let's first consider that <pkg> is currently in sid with version x.y-z (upstream version = x.y, Debian revision = z).

Choose the right version

There are two differents path here, based on what "version" of the upstream code you're packaging

  1. the code in the svn is the update for the version x.y but you don't know yet how upstream would call it
  2. the code in the svn is the preliminary version the new upstream release, be it x.(y+1) or x.y.n

A couple of magic characters you can use in version come in our help here: '~' and '+'; here are how they are interpreted

x.(y+1)-1
   or     > x.y+foo-1 > x.y-z > x.y~bar-1
x.y.n-1

So, here it is how you have to choose the version number for the svn snapshot:

  1. if x.y-z is in sid and you're packaging the new version "without a name", then go with x.y+svn<rev>-1

  2. if x.y-z is in sid and you're packaging the new version x.(y+1) or x.y.n, then go with x.(y+1)~svn<rev>-1 or x.y.n~svn<rev>-1

Update the debian/changelog

now that you have your new package version what you have to do is:

$ dch -v "<new version>" "New upstream SVN snapshot"

Create get-orig-source target for debian/rules

We are almost done, we need to create the get-orig-source target in debian/rules file:

# Adapted from http://wiki.debian.org/SandroTosi/Svn_get-orig-source
PACKAGE = <YOUR PACKAGE NAME>
SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
SVN_REVISION := $(shell echo $(SRC_VERSION) | awk -F"+" '{ print $$2 }' | sed 's/svn//' )
TARBALL = $(PACKAGE)_$(SRC_VERSION).orig.tar.gz
.PHONY: get-orig-source
get-orig-source:
        rm -rf get-orig-source $(TARBALL)
        mkdir get-orig-source
        svn export -r $(SVN_REVISION) <UPSTREAM SVN REPOSITORY> \
         get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig
        GZIP='--best --no-name' tar czf $(TARBALL) -C get-orig-source $(PACKAGE)-$(SRC_VERSION).orig
        rm -rf get-orig-source
        echo "  "$(TARBALL)" created; move it to the right destination to build the package"

Some explanations:

  • SRC_VERSION take the version from the debian/changelog (that's why you need to modify it at first)

  • SVN_REVISION extracts the revision from the version (TODO: be smart and field separator must be '+' and '~')

  • TARBALL is the generated tarball name

  • GZIP='--best --no-name' ensures that compression rate is highest and md5sum is reproducible.

  • some cleanup before running the real "core"
  • export the code from svn in a subdir under get-orig-source, made by name and version (dash separated)

Notes

  • With the needed changes, this can be adapted to other VCS; this is for SVN because I needed for it.
  • If upstream source code is under autotools, once you have downloaded the source code, you got to run all the commands chain (like autogen.sh and so).

Thanks to