dpkg-source - Debian source package (.dsc) manipulation tool
| Use Case | Command | Description |
|---|---|---|
| Extract a source package | dpkg-source -x package.dsc | Unpack a Debian source package from its .dsc control file |
| Build a source package | dpkg-source -b directory | Build a source package from a debianized source tree |
| Print the build format | dpkg-source --print-format directory | Show which source format would be used without building |
| Run preβbuild hook | dpkg-source --before-build directory | Prepare the source tree (e.g., apply patches) before a build |
| Run postβbuild hook | dpkg-source --after-build directory | Clean up after a build (e.g., unapply patches) |
| Record changes (quilt) | dpkg-source --commit directory | Commit local changes as a new patch in the quilt series |
| Specify a source format | dpkg-source --format=3.0\ (quilt) | Override the format used for building |
| Set compression | dpkg-source -Z bzip2 -z 9 | Use bzip2 maximum compression for created tarballs |
| Ignore VCS files in diff | dpkg-source -i | Filter out common revision control files from the diff |
| Ignore tar entries | dpkg-source -I CVS | Exclude CVS directories when creating orig tarballs |
dpkg-source [option...] command
dpkg-source packs and unpacks Debian source archives.
None of these commands allow multiple options to be combined into one, and they do not allow the value for an option to be specified in a separate argument.
Extract a source package (--extract since dpkg 1.17.14). One non-option argument must be supplied, the name of the Debian source control file (.dsc). An optional second non-option argument may be supplied to specify the directory to extract the source package to, this must not exist. If no output directory is specified, the source package is extracted into a directory named source-version under the current working directory.
dpkg-source will read the names of the other file(s) making up the source package from the control file; they are assumed to be in the same directory as the .dsc.
The files in the extracted package will have their permissions and ownerships set to those which would have been expected if the files and directories had simply been created - directories and executable files will be 0777 and plain files will be 0666, both modified by the extractors' umask; if the parent directory is setgid then the extracted directories will be too, and all the files and directories will inherit its group ownership.
If the source package uses a non-standard format (currently this means all formats except β1.0β), its name will be stored in debian/source/format so that the following builds of the source package use the same format by default.
Build a source package (--build since dpkg 1.17.14). The first non-option argument is taken as the name of the directory containing the debianized source tree (i.e. with a debian sub-directory and maybe changes to the original files). Depending on the source package format used to build the package, additional parameters might be accepted.
dpkg-source will build the source package with the first format found in this ordered list: the format indicated with the --format command line option, the format indicated in debian/source/format , β1.0β. The fallback to β1.0β is deprecated and will be removed at some point in the future, you should always document the desired source format in debian/source/format . See section SOURCE PACKAGE FORMATS for an extensive description of the various source package formats.
Print the source format that would be used to build the source package if dpkg-source --build directory was called (in the same conditions and with the same parameters; since dpkg 1.15.5).
Run the corresponding hook of the source package format (since dpkg 1.15.8). This hook is called before any build of the package (dpkg-buildpackage calls it very early even before debian/rules clean). This command is idempotent and can be called multiple times. Not all source formats implement something in this hook, and those that do usually prepare the source tree for the build for example by ensuring that the Debian patches are applied.
Run the corresponding hook of the source package format (since dpkg 1.15.8). This hook is called after any build of the package (dpkg-buildpackage calls it last). This command is idempotent and can be called multiple times. Not all source formats implement something in this hook, and those that do usually use it to undo what --before-build has done.
Record changes in the source tree unpacked in directory (since dpkg 1.16.1). This command can take supplementary parameters depending on the source format. It will error out for formats where this operation doesn't mean anything.
Show the usage message and exit. The format specific build and extract options can be shown by using the --format option.
Show the version and exit.
Note: While they have similar purposes, -i and -I have very different syntax and semantics. -i can only be specified once and takes a perl compatible regular expression which is matched against the full relative path of each file. -I can specified multiple times and takes a filename pattern with shell wildcards. The pattern is applied to the full relative path but also to each part of the path individually. The exact semantic of tar's --exclude option is somewhat complicated, see <https://www.gnu.org/software/tar/manual/tar.html#wildcards> for a full documentation.
The default regex and patterns for both options can be seen in the output of the --help command.
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.
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 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 cannot remove files (empty files will be left over) and cannot create or change symlinks.
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.
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.
In all cases any existing original source tree will be removed.
All the -sX options are mutually exclusive. If you specify more than one only the last one will be used.
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.
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).
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.
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 expects 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.
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 allowed 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.
--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).
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.
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.
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.
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/.
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.
Supported since dpkg 1.14.17. This format is experimental. It generates a single tarball containing the bzr repository.
The tarball is unpacked and then bzr is used to checkout the current branch.
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.
The file debian/source/format should always exist and indicate the desired source format. For backwards compatibility, format β1.0β is assumed when the file doesn't exist but you should not rely on this: at some point in the future dpkg-source will be modified to fail when that file doesn't exist.
The rationale is that format β1.0β is no longer the recommended format, you should usually pick one of the newer formats (β3.0 (quilt)β, β3.0 (native)β) but dpkg-source will not do this automatically for you. If you want to continue using the old format, you should be explicit about it and put β1.0β in debian/source/format.
When using source format β1.0β it is usually a bad idea to modify upstream files directly as the changes end up hidden and mostly undocumented in the .diff.gz file. Instead you should store your changes as patches in the debian directory and apply them at build-time. To avoid this complexity you can also use the format β3.0 (quilt)β that offers this natively.
Changes to upstream sources are usually stored with patch files, but not all changes can be represented with patches: they can only alter the content of plain text files. If you try replacing a file with something of a different type (for example replacing a plain file with a symlink or a directory), you will get this error message.
Empty files can't be created with patch files. Thus this change is not recorded in the source package and you are warned about it.
Patch files do not record permissions of files and thus executable permissions are not stored in the source package. This warning reminds you of that fact.
Patch files do not record permissions of files and thus modified permissions are not stored in the source package. This warning reminds you of that fact.
This file contains on a single line the format that should be used to build the source package (possible formats are described above). No leading or trailing spaces are allowed.
This file contains a list of pathnames of binary files (one per line) relative to the source root directory that should be included in the debian tarball. Leading and trailing spaces are stripped. Lines starting with β#β are comments and are skipped. Empty lines are ignored.
This file contains a list of long options that should be automatically prepended to the set of command line options of a dpkg-source --build or dpkg-source --print-format call. Options like --compression and --compression-level are well suited for this file.
Each option should be put on a separate line. Empty lines and lines starting with β#β are ignored. The leading β--β should be stripped and short options are not allowed. Optional spaces are allowed around the β=β symbol and optional quotes are allowed around the value. Here's an example of such a file:
# let dpkg-source create a debian.tar.bz2 with maximal compression
compression = "bzip2"
compression-level = 9
# use debian/patches/debian-changes as automatic patch
single-debian-patch
# ignore changes on config.{sub,guess}
extend-diff-ignore = "(^|/)(config.sub|config.guess)$"
Note: format options are not accepted in this file, you should use debian/source/format instead.
Exactly like debian/source/options except that the file is not included in the generated source package. It can be useful to store a preference tied to the maintainer or to the VCS repository where the source package is maintained.
Free form text that is put on top of the automatic patch generated in formats β2.0β or β3.0 (quilt)β. local-patch-header is not included in the generated source package while patch-header is.
This file lists all patches that have to be applied (in the given order) on top of the upstream source package. Leading and trailing spaces are stripped. The vendor will be the lowercase name of the current vendor, or debian if there is no vendor defined. If the vendor-specific series file does not exist, the vendor-less series file will be used. Lines starting with β#β are comments and are skipped. Empty lines are ignored. Remaining lines start with a patch filename (relative to the debian/patches/ directory) up to the first space character or the end of line. Optional quilt options can follow up to the end of line or the first β#β preceded by one or more spaces (which marks the start of a comment up to the end of line).
The point at which field overriding occurs compared to certain standard output field settings is rather confused.
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 17:12 @2600:1f28:365:80b0:f8a4:e764:d6bb:8e66
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format