Linux "dpkg-source" Command Line Options and Examples
Debian source package

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.COMMANDS -x, --extract filename.


Usage:

dpkg-source [option...] command




Command Line Options:

-ccontrol-file
Specifies the main source control file to read information from. The default is debian/control. If given with relativepathname this is interpreted starting at the source tree's top level directory.
dpkg-source -ccontrol-file ...
-lchangelog-file
Specifies the changelog file to read information from. The default is debian/changelog. If given with relative pathname thisis interpreted starting at the source tree's top level directory.
dpkg-source -lchangelog-file ...
-Fchangelog-format
Specifies the format of the changelog. See dpkg-parsechangelog(1) for information about alternative formats.
dpkg-source -Fchangelog-format ...
--format
Use the given format for building the source package (since dpkg 1.14.17). It does override any format given indebian/source/format.
dpkg-source --format ...
-Vname
Set an output substitution variable. See deb-substvars(5) for a discussion of output substitution.
dpkg-source -Vname ...
-Tsubstvars-file
Read substitution variables in substvars-file; the default is to not read any file. This option can be used multiple times toread substitution variables from multiple files (since dpkg 1.15.6).
dpkg-source -Tsubstvars-file ...
-Dfield
Override or add an output control file field.
dpkg-source -Dfield ...
-Ufield
Remove an output control file field.
dpkg-source -Ufield ...
-Zcompression
Specify the compression to use for created tarballs and diff files (--compression since dpkg 1.15.5). Note that this optionwill not cause existing tarballs to be recompressed, it only affects new files. Supported values are: gzip, bzip2, lzma andxz. The default is xz for formats 2.0 and newer, and gzip for format 1.0. xz is only supported since dpkg 1.15.5.
dpkg-source -Zcompression ...
-zlevel
Compression level to use (--compression-level since dpkg 1.15.5). As with -Z it only affects newly created files. Supportedvalues are: 1 to 9, best, and fast. The default is 9 for gzip and bzip2, 6 for xz and lzma.
dpkg-source -zlevel ...
-i[regex]
You may specify a perl regular expression to match files you want filtered out of the list of files for the diff
dpkg-source -i[regex] ...
--extend-diff-ignore
The perl regular expression specified will extend the default value used by --diff-ignore and its current value, if set (sincedpkg 1.15.6). It does this by concatenating “|regex” to the existing value. This option is convenient to use indebian/source/options to exclude some auto-generated files from the automatic patch generation.
dpkg-source --extend-diff-ignore ...
-I[file-pattern]
If this option is specified, the pattern will be passed to tar(1)'s --exclude option when it is called to generate a .orig.taror .tar file (--tar-ignore since dpkg 1.15.6). For example, -ICVS will make tar skip over CVS directories when generating a.tar.gz file. The option may be repeated multiple times to list multiple patterns to exclude.
dpkg-source -I[file-pattern] ...
--no-copy
Do not copy original tarballs near the extracted source package (since dpkg 1.14.17).
dpkg-source --no-copy ...
--no-check
Do not check signatures and checksums before unpacking (since dpkg 1.14.17).
dpkg-source --no-check ...
--no-overwrite-dir
Do not overwrite the extraction directory if it already exists (since dpkg 1.18.8).
dpkg-source --no-overwrite-dir ...
--require-valid-signature
Refuse to unpack the source package if it doesn't contain an OpenPGP signature that can be verified (since dpkg 1.15.0) eitherwith the user's trustedkeys.gpg keyring, one of the vendor-specific keyrings, or one of the official Debian keyrings(/usr/share/keyrings/debian-keyring.gpg and /usr/share/keyrings/debian-maintainers.gpg).
dpkg-source --require-valid-signature ...
--require-strong-checksums
Refuse to unpack the source package if it does not contain any strong checksums (since dpkg 1.18.7). Currently the only knownchecksum considered strong is SHA-256.
dpkg-source --require-strong-checksums ...
--ignore-bad-version
Turns the bad source package version check into a non-fatal warning (since dpkg 1.17.7). This option should only be necessarywhen extracting ancient source packages with broken versions, just for backwards compatibility.SOURCE PACKAGE FORMATSIf you don't know what source format to use, you should probably pick either “3.0 (quilt)” or “3.0 (native)”. Seehttps://wiki.debian.org/Projects/DebSrc3.0 for information on the deployment of those formats within Debian.Format: 1.0A 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 thepackage 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.ExtractingExtracting a native package is a simple extraction of the single tarball in the target directory. Extracting a non-native package isdone by first unpacking the .orig.tar.gz and then applying the patch contained in the .diff.gz file. The timestamp of all patchedfiles is reset to the extraction time of the source package (this avoids timestamp skews leading to problems when autogenerated filesare patched). The diff can create new files (the whole debian directory is created that way) but can't remove files (empty files willbe left over).BuildingBuilding a native package is just creating a single tarball with the source directory. Building a non-native package involvesextracting the original tarball in a separate “.orig” directory and regenerating the .diff.gz by comparing the source packagedirectory 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 ifthe package is a Debian-specific one and so has no debianization diffs. If no second argument is supplied then dpkg-source will lookfor the original source tarfile package_upstream-version.orig.tar.gz or the original source directory directory.orig depending on the
dpkg-source --ignore-bad-version ...
-sa
should be used instead.
dpkg-source -sa ...
-sp
Like -sk but will remove the directory again afterwards.
dpkg-source -sp ...
-sr
Like -su but will remove that directory after it has been used.
dpkg-source -sr ...
--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.
dpkg-source --abort-on-upstream-changes ...
-su
Unpacks the original source tree.
dpkg-source -su ...
--skip-debianization
Skips application of the debian diff on top of the upstream sources (since dpkg 1.15.1).Format: 2.0Extraction supported since dpkg 1.13.9, building supported since dpkg 1.14.8. Also known as wig&pen. This format is not recommendedfor wide-spread usage, the format “3.0 (quilt)” replaces it. Wig&pen was the first specification of a new-generation source packageformat.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. Allfiles 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 allcompression methods and will ignore by default any VCS specific files and directories as well as many temporary files (see defaultvalue 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 begz, 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 characters and hyphens (‘-’). Optionally each original tarballcan be accompanied by a detached upstream signature (.orig.tar.ext.asc and .orig-component.tar.ext.asc), extraction supported sincedpkg 1.17.20, building supported since dpkg 1.18.5.ExtractingThe main original tarball is extracted first, then all additional original tarballs are extracted in subdirectories named after thecomponent part of their filename (any pre-existing directory is replaced). The debian tarball is extracted on top of the sourcedirectory after prior removal of any pre-existing debian directory. Note that the debian tarball must contain a debian sub-directorybut it can also contain binary files outside of that directory (see --include-binaries option).All patches listed in debian/patches/debian.series or debian/patches/series are then applied. If the former file is used and thelatter one doesn't exist (or is a symlink), then the latter is replaced with a symlink to the former. This is meant to simplify usageof quilt to manage the set of patches. Note however that while dpkg-source parses correctly series files with explicit options usedfor patch application (stored on each line after the patch filename and one or more spaces), it does ignore those options and alwaysexpect patches that can be applied with the -p1 option of patch. It will thus emit a warning when it encounters such options, and thebuild is likely to fail.The timestamp of all patched files is reset to the extraction time of the source package (this avoids timestamp skews leading toproblems 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 refreshsuch 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.BuildingAll original tarballs found in the current directory are extracted in a temporary directory by following the same logic as for theunpack, 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 tothe source package directory. When the diff is non-empty, the build fails unless --single-debian-patch or --auto-commit has beenused, in which case the diff is stored in the automatic patch. If the automatic patch is created/deleted, it's added/removed fromthe 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 decidedto include that modified binary file in the debian tarball (by listing it in debian/source/include-binaries). The build will alsofail 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 valueassociated to -i option in the --help output). In particular, the .pc directory used by quilt is ignored during generation of theautomatic patch.Note: dpkg-source --before-build (and --build) will ensure that all patches listed in the series file are applied so that a packagebuild 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
dpkg-source --skip-debianization ...
--no-preparation
Recording changes
dpkg-source --no-preparation ...
--commit
Generates a patch corresponding to the local changes that are not managed by the quilt patch system and integrates it in thepatch system under the name patch-name. If the name is missing, it will be asked interactively. If patch-file is given, it isused as the patch corresponding to the local changes to integrate. Once integrated, an editor is launched so that you can editthe 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 isremoved after integration. Note also that the changes contained in the patch file must already be applied on the tree and thatthe 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 sothat they end up in the debian tarball (exactly like dpkg-source --include-binaries --build would do).Build options
dpkg-source --commit ...
--allow-version-of-quilt-db
Allow dpkg-source to build the source package if the version of the quilt metadata is the one specified, even if dpkg-sourcedoesn't know about it (since dpkg 1.15.5.4). Effectively this says that the given version of the quilt metadata is compatiblewith the version 2 that dpkg-source currently supports. The version of the quilt metadata is stored in .pc/.version.
dpkg-source --allow-version-of-quilt-db ...
--include-removal
Do not ignore removed files and include them in the automatically generated patch.
dpkg-source --include-removal ...
--include-timestamp
Include timestamp in the automatically generated patch.
dpkg-source --include-timestamp ...
--include-binaries
Add all modified binaries in the debian tarball. Also add them to debian/source/include-binaries: they will be added bydefault in subsequent builds and this option is thus no more needed.
dpkg-source --include-binaries ...
--single-debian-patch
Use debian/patches/debian-changes instead of debian/patches/debian-changes-version for the name of the automatic patchgenerated during build (since dpkg 1.15.5.4). This option is particularly useful when the package is maintained in a VCS anda patch set can't reliably be generated. Instead the current diff with upstream should be stored in a single patch. The optionwould be put in debian/source/local-options and would be accompanied by a debian/source/local-patch-header file explaining howthe Debian changes can be best reviewed, for example in the VCS that is used.
dpkg-source --single-debian-patch ...
--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 softwareand where there's no “main” software.
dpkg-source --create-empty-orig ...
--no-unapply-patches
By default, dpkg-source will automatically unapply the patches in the --after-build hook if it did apply them during
dpkg-source --no-unapply-patches ...
--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
dpkg-source --auto-commit ...
--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 createsource packages with arbitrary files.Build optionsAll non-option arguments are taken as files to integrate in the generated source package. They must exist and are preferably in thecurrent directory. At least one file must be given.
dpkg-source --skip-patches ...
--target-format
Required. Defines the real format of the generated source package. The generated .dsc file will contain this value in itsFormat 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 alsobe a .gitshallow file listing revisions for a shallow git clone.ExtractingThe bundle is cloned as a git repository to the target directory. If there is a gitshallow file, it is installed as .git/shallowinside 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/.BuildingBefore 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 includedin the bundle.Build options
dpkg-source --target-format ...
--git-ref
Allows specifying a git ref to include in the git bundle. Use disables the default behavior of including all branches andtags. May be specified multiple times. The ref can be the name of a branch or tag to include. It may also be any parameterthat can be passed to git-rev-list(1). For example, to include only the master branch, use --git-ref=master. To include alltags and branches, except for the private branch, use --git-ref=--all --git-ref=^private
dpkg-source --git-ref ...
--git-depth
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.ExtractingThe tarball is unpacked and then bzr is used to checkout the current branch.BuildingBefore 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 packedin a tarball, various cleanup are done to save space.DIAGNOSTICSno source format specified in debian/source/formatThe 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 tofail 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, youshould be explicit about it and put “1.0” in debian/source/format.the diff modifies the following upstream filesWhen using source format “1.0” it is usually a bad idea to modify upstream files directly as the changes end up hidden and mostlyundocumented 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.cannot represent change to fileChanges to upstream sources are usually stored with patch files, but not all changes can be represented with patches: they can onlyalter the content of plain text files. If you try replacing a file with something of a different type (for example replacing a plainfile with a symlink or a directory), you will get this error message.newly created empty file file will not be represented in diffEmpty files can't be created with patch files. Thus this change is not recorded in the source package and you are warned about it.executable mode perms of file will not be represented in diffPatch files do not record permissions of files and thus executable permissions are not stored in the source package. This warningreminds you of that fact.special mode perms of file will not be represented in diffPatch files do not record permissions of files and thus modified permissions are not stored in the source package. This warningreminds you of that fact.ENVIRONMENTSOURCE_DATE_EPOCHIf set, it will be used as the timestamp (as seconds since the epoch) to clamp the mtime in the tar(5) file entries.VISUALEDITOR Used by the “2.0” and “3.0 (quilt)” source format modules.GIT_DIRGIT_INDEX_FILEGIT_OBJECT_DIRECTORYGIT_ALTERNATE_OBJECT_DIRECTORIESGIT_WORK_TREEUsed by the “3.0 (git)” source format modules.FILESdebian/source/formatThis file contains on a single line the format that should be used to build the source package (possible formats are describedabove). No leading or trailing spaces are allowed.debian/source/include-binariesThis file contains a list of binary files (one per line) that should be included in the debian tarball. Leading and trailing spacesare stripped. Lines starting with ‘#’ are comments and are skipped. Empty lines are ignored.debian/source/optionsThis file contains a list of long options that should be automatically prepended to the set of command line options of a dpkg-source
dpkg-source --git-depth ...