1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
<chapter id="gbp.import">
<title>Importing Sources</title>
<sect1 id="gbp.import.existing">
<title>Importing already existing &debian; packages</title>
<para>Importing an already exsting debian package into a git repository is as easy as:
<screen>
&git-import-dsc; package_0.1-1.dsc
</screen>
This will create a new git repository named after the imported package, put
the upstream sources onto the <option>upstream-branch</option> and the
debian patch on the <option>debian-branch</option>. In case of a debian
native package only the <option>debian-branch</option> is being used.
You can specify alternative branch names via the
<option>--upstream-branch</option> and <option>--debian-branch</option>
options or via the <option>upstream-branch</option> and
<option>debian-branch</option> options in the configuration file.
</para>
<para>
If you want to be able to exactly recreate the original tarball
(orig.tar.gz) from &git; you should also specify the
<option>--pristine-tar</option> option. This is recommended.
</para>
<para>
If you want to import further versions you can change into your shiny new
&git; repository and just continue with the same command:
<screen>
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
</screen>
</para>
<para>
Or you can import all versions at once using &git-import-dscs;:
<screen>
&git-import-dscs; /path/to/history/package_*.dsc
</screen>
This will create a &git; repository if necessary and import all versions sorted
by version number.
</para>
</sect1>
<sect1 id="gbp.import.new.upstream">
<title>Importing a new upstream version</title>
<para>Change into your git repository (which can be empty), make sure it
has all local modifications committed and run either of:
<screen>
&git-import-orig; <filename>/path/to/package_0.2.orig.tar.gz</filename>
&git-import-orig; <filename>/path/to/package_0.2.tar.bz2</filename>
&git-import-orig; <filename>/path/to/package-0.2/</filename>
</screen>
This puts the upstream souces onto the <option>upstream-branch</option> and
tags them accordingly (the default tag format is
<replaceable>upstream/%(version)s</replaceable>).
The result is then merged onto the <option>debian-branch</option>
and a new &debian; changelog entry is created. You can again specify
different branch names via the <option>--upstream-branch</option> and
<option>--debian-branch</option> options. You can also filter out content
you don't want imported:
<screen>
&git-import-orig; <option>--filter</option>=<replaceable>'CVS/*'</replaceable> <filename>/path/to/package_0.2.orig.tar.gz</filename>
</screen>
The <option>--filter</option> option can be used multiple times for more
complex filtering.
</para>
<para>
If you expect a merge conflict you can delay the merge to the
<option>debian-branch</option> via the <option>--no-merge</option> and pull in
the changes from the <option>upstream-branch</option> later.
</para>
<para>
If you want to be able to exactly recreate the original tarball
(orig.tar.gz) from &git; you should also specify the
<option>--pristine-tar</option> option. This is recommended.
</para>
<para>To customize the commit message used by &git-import-orig; use
the <option>--import-msg</option> option. This string is a standard
python format string, into which the
<replaceable>version</replaceable> variable is interpolated. (i.e.,
use <replaceable>%(version)s</replaceable> in your message to get
the imported upstream version).
</para>
</sect1>
<sect1 id="gbp.import.convert">
<title>Converting an existing &git; repository</title>
<para>
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.
</para>
<sect2>
<title>Upstream sources on a branch</title>
<para>
If the upstream sources are already on a separate branch things are pretty
simple. You can either rename that branch to the default
<option>upstream-branch</option> name <emphasis>upstream</emphasis> with:
<screen>
&gitcmd; branch upstream theupstream-branch
&gitcmd; branch <option>-D</option> theupstream-branch
</screen>
or you can tell &git-buildpackage; the name of the branch to use as
<option>upstream-branch</option>:
<screen>
<command>cat</command> <<EOF > <filename>.git/gbp.conf</filename>
[DEFAULT]
# this is the upstream-branch:
upstream-branch=theupstream-branch
EOF
</screen>
If you then use &git-import-orig; to import new upstream sources, they will
from now on end up on <emphasis>theupstream-branch</emphasis> and
merged to the <option>debian-branch</option>.
</para>
</sect2>
<sect2>
<title>Upstream sources not on a branch</title>
<para>
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 &gitkcmd; or &gitcmd;-log to locate the commit-id of that commit
and create the upstream branch from there, e.g.:
<screen>
COMMIT_ID=`&gitcmd; log --pretty=oneline | tail -1 | awk '{ print $1 }'`
&gitcmd; branch upstream $COMMIT_ID
</screen>
The important thing here is that the <envar>COMMIT_ID</envar> specifies a
point on the master branch that carried <emphasis>only</emphasis> the
upstream sources and not the debian modifications. The above example
assumes that this was the first commit to that repository.
</para>
<warning><para>There's currently no <emphasis>easy</emphasis> way to create the
<option>upstream-branch</option> if you never had the upstream sources
as a single commit. Using &git-import-orig; on such repositories might lead
to unexpected merge results.</para></warning>
<para>In order to fix this you can prepend the upstream sources as a
single commit to your tree using &git;'s <ulink
url="http://git.or.cz/gitwiki/GraftPoint">grafts</ulink>. Afterwards you
can simply create a branch as explained above and &git-import-orig; will
work as expected.</para>
<para>Alternatively, if you are only importing source from original tarballs
(for instance when converting from a Subversion repository where the
mergeWithUpstream was set for svn-buildpackage), you can create an empty
upstream branch with the following commands:
<screen>
<command>git checkout</command> <option>--orphan</option> <replaceable>upstream</replaceable>
<command>git rm</command> <option>-rf</option> <replaceable>.</replaceable>
<command>git commit</command> <option>--allow-empty</option> <option>-m</option> <replaceable>'Initial upstream branch.'</replaceable>
<command>git checkout</command> <option>-f</option> <replaceable>master</replaceable>
</screen>
With Git versions lower than 1.7.2.3, the commands are slightly more complicated:
<screen>
<command>git symbolic-ref</command> <replaceable>HEAD</replaceable> <replaceable>refs/heads/upstream</replaceable>
<command>git rm</command> <option>--cached</option> <option>-r</option> <replaceable>.</replaceable>
<command>git commit</command> <option>--allow-empty</option> <option>-m</option> <replaceable>'Initial upstream branch.'</replaceable>
<command>git checkout</command> <option>-f</option> <replaceable>master</replaceable>
</screen>
</para>
</sect2>
</sect1>
<sect1 id="gbp.import.fromscratch">
<title>Starting a Debian package from scratch</title>
<para>
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:
</para>
<screen>
<command>mkdir</command> package-0.1
<command>cd</command> package-0.1
<command>git init</command>
</screen>
<para>Then you import the upstream sources, branch off the
<option>upstream-branch</option> branch and add the debian files (e.g. via dh_make):
<screen>
&git-import-orig; <option>-u</option> <replaceable>0.1</replaceable> <filename>../package-0.1.tar.gz</filename>
<command>dh_make</command>
</screen>
That's it, you're done. If you want to publish you're new repository you can use &gbp-create-remote-repo;.
</para>
</sect1>
<sect1 id="gbp.import.upstream-git">
<title>When upstream uses GIT</title>
<para>
If upstream already uses git for packaging there are several ways to handle packaging. Two will
be described in a bit detail here:
</para>
<sect2 id="gbp.import.upstream.git.notarball">
<title>No upstream tarballs</title>
<para>If upstream doesn't build upstream tarballs or you don't care about them the simplest
way is to clone upstreams repository and create a separate packaging branch in there.
</para>
<para>
&git-buildpackage; will by default create an upstream tarball for you. By default it will
be created from the tag name given by the <option>--git-upstream-tag</option> option.
You can customize it's value via the <option>upstream-tag</option> configuration variable.
</para>
<para>
A common upstream format is to put a <replaceable>v</replaceable> in front of the version number.
In this case the configuration option would look like:
</para>
<screen>
[git-buildpackage]
upstream-tag = v%(version)s
</screen>
<para>
<replaceable>version</replaceable> will be replaced with the upstream version number as read from
<filename>debian/changelog</filename>.
</para>
<para>If you're using &pristine-tar; you can make &git-buildpackage commit the tarball back to the
pristine-tar branch by using the <option>--git-pristine-tar-commit</option> option.
</para>
</sect2>
<sect2 id="gbp.import.upstream.git.tarball">
<title>Upstream tarballs</title>
<para>If you want to track upstream's git but continue to import the upstream tarballs,
e.g. to make sure the tarball uploaded
to &debian; has the same checksum as upstream's you can use the <option>--upstream-vcs-tag</option> option
when importing new tarballs with &git-import-orig;. Assuming you have the upstream source in your
repository with a tag <replaceable>v0.0.1</replaceable> you can use:
<screen>
&git-import-orig; --upstream-vcs-tag=v0.0.1 foo_0.0.1.orig.tar.gz
</screen>
to add upstream's tag as additional parent to the merge commit.
See <ulink url="http://bugs.debian.org/664771">#664771</ulink> for more details.
</para>
</sect2>
</sect1>
</chapter>
<!-- LocalWords: tarballs
-->
|