If you don't know what source format to use, you should probably
pick either '3.0 (quilt)' or '3.0 (native)'. See
https://wiki.debian.org/Projects/DebSrc3.0 for information on the
deployment of those formats within Debian.
Format: 1.0
A source package in this format consists either of a .orig.tar.gz
associated to a .diff.gz
or a single .tar.gz
(in that case the
package is said to be native). Optionally the original tarball
might be accompanied by a detached upstream signature
.orig.tar.gz.asc
, extraction supported since dpkg 1.18.5.
Extracting
Extracting a native package is a simple extraction of the single
tarball in the target directory. Extracting a non-native package
is done by first unpacking the .orig.tar.gz
and then applying the
patch contained in the .diff.gz
file. The timestamp of all
patched files is reset to the extraction time of the source
package (this avoids timestamp skews leading to problems when
autogenerated files are patched). The diff can create new files
(the whole debian directory is created that way) but can't remove
files (empty files will be left over).
Building
Building a native package is just creating a single tarball with
the source directory. Building a non-native package involves
extracting the original tarball in a separate '.orig' directory
and regenerating the .diff.gz
by comparing the source package
directory with the .orig directory.
Build options (with --build):
If a second non-option argument is supplied it should be the name
of the original source directory or tarfile or the empty string
if the package is a Debian-specific one and so has no
debianization diffs. If no second argument is supplied then
dpkg-source
will look for the original source tarfile
package_
upstream-version.orig.tar.gz
or the original source
directory directory.orig
depending on the -sX
arguments.
-sa
, -sp
, -sk
, -su
and -sr
will not overwrite existing tarfiles
or directories. If this is desired then -sA
, -sP
, -sK
, -sU
and
-sR
should be used instead.
-sk
Specifies to expect the original source as a tarfile, by
default package_
upstream-version.orig.tar.
extension. It
will leave this original source in place as a tarfile, or
copy it to the current directory if it isn't already
there. The tarball will be unpacked into directory.orig
for the generation of the diff.
-sp
Like -sk
but will remove the directory again afterwards.
-su
Specifies that the original source is expected as a
directory, by default package-
upstream-version.orig
and
dpkg-source
will create a new original source archive from
it.
-sr
Like -su
but will remove that directory after it has been
used.
-ss
Specifies that the original source is available both as a
directory and as a tarfile. dpkg-source
will use the
directory to create the diff, but the tarfile to create
the .dsc
. This option must be used with care - if the
directory and tarfile do not match a bad source archive
will be generated.
-sn
Specifies to not look for any original source, and to not
generate a diff. The second argument, if supplied, must
be the empty string. This is used for Debian-specific
packages which do not have a separate upstream source and
therefore have no debianization diffs.
-sa
or -sA
Specifies to look for the original source archive as a
tarfile or as a directory - the second argument, if any,
may be either, or the empty string (this is equivalent to
using -sn
). If a tarfile is found it will unpack it to
create the diff and remove it afterwards (this is
equivalent to -sp
); if a directory is found it will pack
it to create the original source and remove it afterwards
(this is equivalent to -sr
); if neither is found it will
assume that the package has no debianization diffs, only a
straightforward source archive (this is equivalent to
-sn
). If both are found then dpkg-source
will ignore the
directory, overwriting it, if -sA
was specified (this is
equivalent to -sP
) or raise an error if -sa
was specified.
-sa
is the default.
--abort-on-upstream-changes
The process fails if the generated diff contains changes
to files outside of the debian sub-directory (since dpkg
1.15.8). This option is not allowed in
debian/source/options
but can be used in
debian/source/local-options
.
Extract options (with --extract):
In all cases any existing original source tree will be removed.
-sp
Used when extracting then the original source (if any)
will be left as a tarfile. If it is not already located in
the current directory or if an existing but different file
is there it will be copied there. (This is the default
).
-su
Unpacks the original source tree.
-sn
Ensures that the original source is neither copied to the
current directory nor unpacked. Any original source tree
that was in the current directory is still removed.
All the -s
X options are mutually exclusive. If you specify more
than one only the last one will be used.
--skip-debianization
Skips application of the debian diff on top of the
upstream sources (since dpkg 1.15.1).
Format: 2.0
Extraction supported since dpkg 1.13.9, building supported since
dpkg 1.14.8. Also known as wig&pen. This format is not
recommended for wide-spread usage, the format '3.0 (quilt)'
replaces it. Wig&pen was the first specification of a new-
generation source package format.
The behaviour of this format is the same as the '3.0 (quilt)'
format except that it doesn't use an explicit list of patches.
All files in debian/patches/
matching the perl regular expression
[\w-]+
must be valid patches: they are applied at extraction
time.
When building a new source package, any change to the upstream
source is stored in a patch named zz_debian-diff-auto
.
Format: 3.0 (native)
Supported since dpkg 1.14.17. This format is an extension of the
native package format as defined in the 1.0 format. It supports
all compression methods and will ignore by default any VCS
specific files and directories as well as many temporary files
(see default value associated to -I
option in the --help
output).
Format: 3.0 (quilt)
Supported since dpkg 1.14.17. A source package in this format
contains at least an original tarball (.orig.tar.
ext where ext
can be gz
, bz2
, lzma
and xz
) and a debian tarball
(.debian.tar.
ext). It can also contain additional original
tarballs (.orig-
component.tar.
ext). component can only contain
alphanumeric ('a-zA-Z0-9') characters and hyphens ('-').
Optionally each original tarball can be accompanied by a detached
upstream signature (.orig.tar.
ext.asc
and
.orig-
component.tar.
ext.asc
), extraction supported since dpkg
1.17.20, building supported since dpkg 1.18.5.
Extracting
The main original tarball is extracted first, then all additional
original tarballs are extracted in subdirectories named after the
component part of their filename (any pre-existing directory is
replaced). The debian tarball is extracted on top of the source
directory after prior removal of any pre-existing debian
directory. Note that the debian tarball must contain a debian
sub-directory but it can also contain binary files outside of
that directory (see --include-binaries
option).
All patches listed in debian/patches/
vendor.series
or
debian/patches/series
are then applied, where vendor will be the
lowercase name of the current vendor, or debian
if there is no
vendor defined. If the former file is used and the latter one
doesn't exist (or is a symlink), then the latter is replaced with
a symlink to the former. This is meant to simplify usage of
quilt
to manage the set of patches. Vendor-specific series files
are intended to make it possible to serialize multiple
development branches based on the vendor, in a declarative way,
in preference to open-coding this handling in debian/rules
. This
is particularly useful when the source would need to be patched
conditionally because the affected files do not have built-in
conditional occlusion support. Note however that while
dpkg-source
parses correctly series files with explicit options
used for patch application (stored on each line after the patch
filename and one or more spaces), it does ignore those options
and always expect patches that can be applied with the -p1
option
of patch
. It will thus emit a warning when it encounters such
options, and the build is likely to fail.
Note that lintian
(1) will emit unconditional warnings when using
vendor series due to a controversial Debian specific ruling,
which should not affect any external usage; to silence these, the
dpkg lintian profile can be used by passing «--profile dpkg
» to
lintian
(1).
The timestamp of all patched files is reset to the extraction
time of the source package (this avoids timestamp skews leading
to problems when autogenerated files are patched).
Contrary to quilt
's default behaviour, patches are expected to
apply without any fuzz. When that is not the case, you should
refresh such patches with quilt
, or dpkg-source
will error out
while trying to apply them.
Similarly to quilt
's default behaviour, the patches can remove
files too.
The file .pc/applied-patches
is created if some patches have been
applied during the extraction.
Building
All original tarballs found in the current directory are
extracted in a temporary directory by following the same logic as
for the unpack, the debian directory is copied over in the
temporary directory, and all patches except the automatic patch
(debian-changes-
version or debian-changes
, depending on
--single-debian-patch
) are applied. The temporary directory is
compared to the source package directory. When the diff is non-
empty, the build fails unless --single-debian-patch
or
--auto-commit
has been used, in which case the diff is stored in
the automatic patch. If the automatic patch is created/deleted,
it's added/removed from the series file and from the quilt
metadata.
Any change on a binary file is not representable in a diff and
will thus lead to a failure unless the maintainer deliberately
decided to include that modified binary file in the debian
tarball (by listing it in debian/source/include-binaries
). The
build will also fail if it finds binary files in the debian sub-
directory unless they have been whitelisted through
debian/source/include-binaries
.
The updated debian directory and the list of modified binaries is
then used to generate the debian tarball.
The automatically generated diff doesn't include changes on VCS
specific files as well as many temporary files (see default value
associated to -i
option in the --help
output). In particular, the
.pc
directory used by quilt
is ignored during generation of the
automatic patch.
Note: dpkg-source --before-build
(and --build
) will ensure that
all patches listed in the series file are applied so that a
package build always has all patches applied. It does this by
finding unapplied patches (they are listed in the series
file but
not in .pc/applied-patches
), and if the first patch in that set
can be applied without errors, it will apply them all. The option
--no-preparation
can be used to disable this behavior.
Recording changes
--commit
[directory] [patch-name] [patch-file]
Generates a patch corresponding to the local changes that
are not managed by the quilt
patch system and integrates
it in the patch system under the name patch-name. If the
name is missing, it will be asked interactively. If patch-
file is given, it is used as the patch corresponding to
the local changes to integrate. Once integrated, an editor
is launched so that you can edit the meta-information in
the patch header.
Passing patch-file is mainly useful after a build failure
that pre-generated this file, and on this ground the given
file is removed after integration. Note also that the
changes contained in the patch file must already be
applied on the tree and that the files modified by the
patch must not have supplementary unrecorded changes.
If the patch generation detects modified binary files,
they will be automatically added to
debian/source/include-binaries
so that they end up in the
debian tarball (exactly like dpkg-source
--include-binaries --build
would do).
Build options
--allow-version-of-quilt-db=
version
Allow dpkg-source
to build the source package if the
version of the quilt
metadata is the one specified, even
if dpkg-source
doesn't know about it (since dpkg
1.15.5.4). Effectively this says that the given version
of the quilt
metadata is compatible with the version 2
that dpkg-source
currently supports. The version of the
quilt
metadata is stored in .pc/.version
.
--include-removal
Do not ignore removed files and include them in the
automatically generated patch.
--include-timestamp
Include timestamp in the automatically generated patch.
--include-binaries
Add all modified binaries in the debian tarball. Also add
them to debian/source/include-binaries
: they will be added
by default in subsequent builds and this option is thus no
more needed.
--no-preparation
Do not try to prepare the build tree by applying patches
which are apparently unapplied (since dpkg 1.14.18).
--single-debian-patch
Use debian/patches/debian-changes
instead of
debian/patches/debian-changes-
version for the name of the
automatic patch generated during build (since dpkg
1.15.5.4). This option is particularly useful when the
package is maintained in a VCS and a patch set can't
reliably be generated. Instead the current diff with
upstream should be stored in a single patch. The option
would be put in debian/source/local-options
and would be
accompanied by a debian/source/local-patch-header
file
explaining how the Debian changes can be best reviewed,
for example in the VCS that is used.
--create-empty-orig
Automatically create the main original tarball as empty if
it's missing and if there are supplementary original
tarballs (since dpkg 1.15.6). This option is meant to be
used when the source package is just a bundle of multiple
upstream software and where there's no 'main' software.
--no-unapply-patches, --unapply-patches
By default, dpkg-source
will automatically unapply the
patches in the --after-build
hook if it did apply them
during --before-build
(--unapply-patches
since dpkg
1.15.8, --no-unapply-patches
since dpkg 1.16.5). Those
options allow you to forcefully disable or enable the
patch unapplication process. Those options are only
allowed in debian/source/local-options
so that all
generated source packages have the same behavior by
default.
--abort-on-upstream-changes
The process fails if an automatic patch has been generated
(since dpkg 1.15.8). This option can be used to ensure
that all changes were properly recorded in separate quilt
patches prior to the source package build. This option is
not allowed in debian/source/options
but can be used in
debian/source/local-options
.
--auto-commit
The process doesn't fail if an automatic patch has been
generated, instead it's immediately recorded in the quilt
series.
Extract options
--skip-debianization
Skips extraction of the debian tarball on top of the
upstream sources (since dpkg 1.15.1).
--skip-patches
Do not apply patches at the end of the extraction (since
dpkg 1.14.18).
Format: 3.0 (custom)
Supported since dpkg 1.14.17. This format is special. It
doesn't represent a real source package format but can be used to
create source packages with arbitrary files.
Build options
All non-option arguments are taken as files to integrate in the
generated source package. They must exist and are preferably in
the current directory. At least one file must be given.
--target-format=
value
Required
. Defines the real format of the generated source
package. The generated .dsc file will contain this value
in its Format
field and not '3.0 (custom)'.
Format: 3.0 (git)
Supported since dpkg 1.14.17. This format is experimental.
A source package in this format consists of a single bundle of a
git repository .git
to hold the source of a package. There may
also be a .gitshallow
file listing revisions for a shallow git
clone.
Extracting
The bundle is cloned as a git repository to the target directory.
If there is a gitshallow file, it is installed as .git/shallow
inside the cloned git repository.
Note that by default the new repository will have the same branch
checked out that was checked out in the original source.
(Typically 'master', but it could be anything.) Any other
branches will be available under remotes/origin/.
Building
Before going any further, some checks are done to ensure that we
don't have any non-ignored uncommitted changes.
git-bundle(1) is used to generate a bundle of the git repository.
By default, all branches and tags in the repository are included
in the bundle.
Build options
--git-ref=
ref
Allows specifying a git ref to include in the git bundle.
Use disables the default behavior of including all
branches and tags. May be specified multiple times. The
ref can be the name of a branch or tag to include. It may
also be any parameter that can be passed to
git-rev-list(1). For example, to include only the master
branch, use --git-ref=
master. To include all tags and
branches, except for the private branch, use
--git-ref=
--all --git-ref=
^private
--git-depth=
number
Creates a shallow clone with a history truncated to the
specified number of revisions.
Format: 3.0 (bzr)
Supported since dpkg 1.14.17. This format is experimental. It
generates a single tarball containing the bzr repository.
Extracting
The tarball is unpacked and then bzr is used to checkout the
current branch.
Building
Before going any further, some checks are done to ensure that we
don't have any non-ignored uncommitted changes.
Then the VCS specific part of the source directory is copied over
to a temporary directory. Before this temporary directory is
packed in a tarball, various cleanup are done to save space.