| Building Debian Packages with git-buildpackage: Version: 0.4.43 |
|---|
Importing an already exsting debian package into a git repository is as easy as:
git-import-dsc package_0.1-1.dsc
This will create a new git repository named after the imported package, put
the upstream sources onto the upstream-branch and the
debian patch on the debian-branch. In case of a debian
native package only the debian-branch is being used.
You can specify alternative branch names via the
--upstream-branch and --debian-branch
options or via the upstream-branch and
debian-branch options in the configuration file.
If you want to import further versions you can change into your shiny new Git repository and just continue with the same command:
cd package/
git-import-dsc package_0.1-2.dsc
git-import-dsc package_0.1-3.dsc
git-import-dsc package_0.2-1.dsc
Or you can import all versions at once using git-import-dscs:
git-import-dscs /path/to/history/package_*.dsc
This will create a Git repository if necessary and import all versions sorted
by version number.
Change into your git repository (which can be empty), make sure it has all local modifications committed and run either of:
git-import-orig /path/to/package_0.2.orig.tar.gz
git-import-orig /path/to/package_0.2.tar.bz2
git-import-orig /path/to/package-0.2/
This puts the upstream souces onto the upstream-branch and
tags them accordingly (the default tag format is
upstream/<version>).
The result is then merged onto the debian-branch
and a new Debian changelog entry is created. You can again specify
different branch names via the --upstream-branch and
--debian-branch options. You can also filter out content
you don't want imported:
git-import-orig --filter='CVS/*' /path/to/package_0.2.orig.tar.gz
The --filter option can be used multiple times for more
complex filtering.
If you expect a merge conflict you can delay the merge to the
debian-branch via the --no-merge and pull in
the changes from the upstream-branch later.
If the Git repository wasn't created with git-import-dsc you have to tell git-buildpackage and friends where to find the upstream sources.
If the upstream sources are already on a separate branch things are pretty
simple. You can either rename that branch to the default
upstream-branch name upstream with:
git branch upstream theupstream-branch
git branch -D theupstream-branch
or you can tell git-buildpackage the name of the branch to use as
upstream-branch:
cat <<EOF > .git/gbp.conf
[DEFAULT]
# this is the upstream-branch:
upstream-branch=theupstream-branch
EOF
If you then use git-import-orig to import new upstream sources, they will
from now on end up on theupstream-branch and
merged to the debian-branch.
If you don't have an upstream branch but started your repository with only the upstream sources (not the debian patch) you can simply branch from that point. So use gitk or git-log to locate the commit-id of that commit and create the upstream branch from there, e.g.:
COMMIT_ID=`git log --pretty=oneline | tail -1 | awk '{ print $1 }'`
git branch upstream $COMMIT_ID
The important thing here is that the COMMIT_ID specifies a
point on the master branch that carried only the
upstream sources and not the debian modifications. The above example
assumes that this was the first commit to that repository.
| Warning |
There's currently no easy way to create the
|
In order to fix this you can prepend the upstream sources as a single commit to your tree using Git's grafts. Afterwards you can simply create a branch as explained above and git-import-orig will work as expected.
So far we assumed you already have a Debian package to start with but what if you want to start a new package? First create an empty repository:
mkdir package-0.1
cd package-0.1
git-init
Then you import the upstream sources, branch off the
upstream-branch branch and add the debian files (e.g. via dh_make):
git-import-orig -u 0.1 ../package-0.1.tar.gz
git branch upstream
dh_make
That's it, you're done.
| <<< Introduction | Building packages from the Git repository >>> |