{
    "mode": "man",
    "parameter": "dpkg-buildpackage",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/dpkg-buildpackage/1/json",
    "generated": "2026-10-06T01:42:57Z",
    "synopsis": "dpkg-buildpackage [option...]",
    "sections": {
        "NAME": {
            "content": "dpkg-buildpackage - build binary or source packages from sources\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "dpkg-buildpackage [option...]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "dpkg-buildpackage is a program that automates the process of building a Debian package.  It\nconsists of the following steps:\n\n1.  It  runs  the  preinit  hook  before  reading  any  source  file.   It prepares the build\nenvironment by setting various environment variables (see  ENVIRONMENT),  runs  the  init\nhook, and calls dpkg-source --before-build (unless -T or --target has been used).\n\n2.  It  checks  that  the  build-dependencies and build-conflicts are satisfied (unless -d or\n--no-check-builddeps is specified).\n\n3.  If one or more specific targets have been selected with the -T  or  --target  option,  it\ncalls  those  targets  and  stops  here.   Otherwise  it runs the preclean hook and calls\nfakeroot debian/rules clean to clean the build-tree  (unless  -nc  or  --no-pre-clean  is\nspecified).\n\n4.  It  runs  the  source  hook and calls dpkg-source -b to generate the source package (if a\nsource build has been requested with --build or equivalent options).\n\n5.  It runs the build hook and calls debian/rules build-target, then  runs  the  binary  hook\nfollowed  by  fakeroot  debian/rules  binary-target  (unless a source-only build has been\nrequested with --build=source or equivalent options).  Note that build-target and binary-\ntarget are either build and binary (default case, or if an any and  all  build  has  been\nrequested  with  --build or equivalent options), or build-arch and binary-arch (if an any\nand not all build has been requested with --build or equivalent options), or  build-indep\nand  binary-indep  (if  an  all  and  not  any  build  has been requested with --build or\nequivalent options).\n\n6.  It runs the buildinfo hook and calls dpkg-genbuildinfo to  generate  a  .buildinfo  file.\nSeveral dpkg-buildpackage options are forwarded to dpkg-genbuildinfo.\n\n7.  It runs the changes hook and calls dpkg-genchanges to generate a .changes file.  The name\nof  the  .changes  file  will  depend  on  the  type  of build and will be as specific as\nnecessary but not more; the name will be:\n\nsource-namebinary-versionarch.changes\nfor a build that includes any\n\nsource-namebinary-versionall.changes\notherwise for a build that includes all\n\nsource-namesource-versionsource.changes.\notherwise for a build that includes source\n\nMany dpkg-buildpackage options are forwarded to dpkg-genchanges.\n\n8.  It runs the postclean hook and if -tc or --post-clean is specified, it will call fakeroot\ndebian/rules clean again.\n\n9.  It calls dpkg-source --after-build.\n\n10. It runs the check hook and calls a package checker for the .changes file (if a command is\nspecified in DEBCHECKCOMMAND or with --check-command).\n\n11. It runs the sign hook and signs using the OpenPGP backend  (as  long  as  it  is  not  an\nUNRELEASED build, or --no-sign is specified) to sign the .dsc file (if any, unless -us or\n--unsigned-source  is  specified), the .buildinfo file (unless -ui, --unsigned-buildinfo,\n-uc  or  --unsigned-changes  is  specified)  and  the  .changes  file  (unless   -uc   or\n--unsigned-changes is specified).\n\n12. It runs the done hook.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "All  long  options  can  be  specified  both on the command line and in the dpkg-buildpackage\nsystem and user configuration files.  Each line in the configuration file is either an option\n(exactly the same as the command line option but without leading hyphens) or a comment (if it\nstarts with a ‘#’).\n\n--build=type\nSpecifies the build type from a comma-separated list of components (since  dpkg  1.18.5).\nAll  the  specified components get combined to select the single build type to use, which\nimplies a single build run with a  single  .changes  file  generated.   Passed  to  dpkg-\ngenchanges.\n\nThe allowed values are:\n\nsource\nBuilds the source package.\n\nNote:  When  using this value standalone and if what you want is simply to (re-)build\nthe source package from a clean source tree, using dpkg-source directly is  always  a\nbetter option as it does not require any build dependencies to be installed which are\notherwise needed to be able to call the clean target.\n\nany Builds the architecture specific binary packages.\n\nall Builds the architecture independent binary packages.\n\nbinary\nBuilds  the  architecture specific and independent binary packages.  This is an alias\nfor any,all.\n\nfull\nBuilds everything.  This is an alias for source,any,all, and the same as the  default\ncase when no build option is specified.\n",
            "subsections": [
                {
                    "name": "-g   --build=source,all",
                    "content": "",
                    "flag": "-g",
                    "long": "--build",
                    "arg": "source,all"
                },
                {
                    "name": "-G   --build=source,any",
                    "content": "",
                    "flag": "-G",
                    "long": "--build",
                    "arg": "source,any"
                },
                {
                    "name": "-b   --build=binary  --build=any,all",
                    "content": "",
                    "flag": "-b",
                    "long": "--build",
                    "arg": "any,all"
                },
                {
                    "name": "-B   --build=any",
                    "content": "",
                    "flag": "-B",
                    "long": "--build",
                    "arg": "any"
                },
                {
                    "name": "-A   --build=all",
                    "content": "",
                    "flag": "-A",
                    "long": "--build",
                    "arg": "all"
                },
                {
                    "name": "-S   --build=source",
                    "content": "",
                    "flag": "-S",
                    "long": "--build",
                    "arg": "source"
                },
                {
                    "name": "-F   --build=full --build=source,binary  --build=source,any,all",
                    "content": "1.15.8).\n\n--target=target[,...]\n--target target[,...]",
                    "flag": "-F",
                    "long": "--build",
                    "arg": "source,any,all"
                },
                {
                    "name": "-T --rules-target=_",
                    "content": "Calls debian/rules target once  per  target  specified,  after  having  setup  the  build\nenvironment  (except for calling dpkg-source --before-build), and stops the package build\nprocess here (since dpkg 1.15.0, long option  since  dpkg  1.18.8,  multi-target  support\nsince  dpkg  1.18.16).   If --as-root is also given, then the command is executed as root\n(see --root-command).  Note that known targets that are required to be run as root do not\nneed this option (i.e. the clean, binary, binary-arch and binary-indep targets).\n",
                    "flag": "-T",
                    "long": "--rules-target",
                    "arg": "_"
                },
                {
                    "name": "--as-root",
                    "content": "Only meaningful together with --target (since dpkg 1.15.0).  Requires that the target  be\nrun with root rights.\n",
                    "long": "--as-root"
                },
                {
                    "name": "-si",
                    "content": ""
                },
                {
                    "name": "-sa",
                    "content": ""
                },
                {
                    "name": "-sd",
                    "content": ""
                },
                {
                    "name": "-v_",
                    "content": ""
                },
                {
                    "name": "-C_",
                    "content": ""
                },
                {
                    "name": "-m_",
                    "content": ""
                },
                {
                    "name": "-e_",
                    "content": "Passed unchanged to dpkg-genchanges.  See its manual page.\n\n--build-by=maintainer-address\n--source-by=maintainer-address (since dpkg 1.21.10)\nPass as -m to dpkg-genchanges.  See its manual page.\n\n--release-by=maintainer-address\n--changed-by=maintainer-address (since dpkg 1.21.10)\nPass as -e to dpkg-genchanges.  See its manual page.\n"
                },
                {
                    "name": "-a --host-arch _",
                    "content": "Specify  the  Debian  architecture  we  build  for (long option since dpkg 1.17.17).  The\narchitecture of the machine we build on is determined  automatically,  and  is  also  the\ndefault for the host machine.\n",
                    "flag": "-a",
                    "long": "--host-arch"
                },
                {
                    "name": "-t --host-type _",
                    "content": "Specify  the  GNU  system  type we build for (long option since dpkg 1.17.17).  It can be\nused in place of --host-arch or as a complement to override the default GNU  system  type\nof the host Debian architecture.\n\n--target-arch architecture\nSpecify  the  Debian architecture the binaries built will build for (since dpkg 1.17.17).\nThe default value is the host machine.\n\n--target-type gnu-system-type\nSpecify the GNU system type the binaries built will build for (since dpkg  1.17.17).   It\ncan  be  used  in  place  of --target-arch or as a complement to override the default GNU\nsystem type of the target Debian architecture.\n",
                    "flag": "-t",
                    "long": "--host-type"
                },
                {
                    "name": "-P --build-profiles=_",
                    "content": "Specify the profile(s) we build, as a  comma-separated  list  (since  dpkg  1.17.2,  long\noption  since  dpkg  1.18.8).   The default behavior is to build for no specific profile.\nAlso sets them (as a space separated list) as the DEBBUILDPROFILES environment variable\nwhich allows, for example, debian/rules files to use  this  information  for  conditional\nbuilds.\n",
                    "flag": "-P",
                    "long": "--build-profiles",
                    "arg": "_"
                },
                {
                    "name": "-j --jobs",
                    "content": "Specifies  the  number  of jobs allowed to be run simultaneously (since dpkg 1.14.7, long\noption since dpkg 1.18.8).  The number of jobs matching the number of  online  processors\nif  auto is specified (since dpkg 1.17.10), or unlimited number if jobs is not specified.\nThe default behavior is  auto  (since  dpkg  1.18.11)  in  non-forced  mode  (since  dpkg\n1.21.10), and as such it is always safer to use with any package including those that are\nnot parallel-build safe.  Setting the number of jobs to 1 will restore serial execution.\n\nWill  add  parallel=jobs  or parallel to the DEBBUILDOPTIONS environment variable which\nallows debian/rules files to opt-in to use this information for their own purposes.   The\njobs  value  will  override the parallel=jobs or parallel option in the DEBBUILDOPTIONS\nenvironment variable.  Note that the auto value will get replaced by the actual number of\ncurrently active processors, and as such will not get propagated to  any  child  process.\nIf  the  number  of  online  processors cannot be inferred then the code will fallback to\nusing serial execution (since dpkg 1.18.15), although this should only happen  on  exotic\nand unsupported systems.\n",
                    "flag": "-j",
                    "long": "--jobs"
                },
                {
                    "name": "-J --jobs-try",
                    "content": "This  option  (since  dpkg 1.18.2, long option since dpkg 1.18.8) is equivalent to the -j\nabove.\n\nSince the behavior for -j changed in dpkg 1.21.10 to the opt-in mode, you  can  use  this\noption instead if you need to guarantee semantics across dpkg release series.\n\n--jobs-force[=jobs|auto]\nThis  option  (since dpkg 1.21.10) is equivalent to the --jobs option except that it will\nenable forced parallel mode, by adding the make -j option with  the  computed  number  of\nparallel jobs to the MAKEFLAGS environment variable.\n\nThis should cause all subsequent make invocations to inherit the option, thus forcing the\nparallel  setting  on  the packaging (and possibly the upstream build system if that uses\nmake(1)) regardless of their  support  for  parallel  builds,  which  might  cause  build\nfailures.\n\nNote:  Any  Makefile  that  is not parallel-safe should be considered to be buggy.  These\nshould either be made parallel-safe, or  marked  as  not  being  safe  with  the  make(1)\n.NOTPARALLEL target.\n",
                    "flag": "-J",
                    "long": "--jobs-try"
                },
                {
                    "name": "-D --check-builddeps",
                    "content": "Check  build  dependencies  and  conflicts;  abort if unsatisfied (long option since dpkg\n1.18.8).  This is the default behavior.\n",
                    "flag": "-D",
                    "long": "--check-builddeps"
                },
                {
                    "name": "-d --no-check-builddeps",
                    "content": "Do not check build dependencies and conflicts (long option since dpkg 1.18.8).\n",
                    "flag": "-d",
                    "long": "--no-check-builddeps"
                },
                {
                    "name": "--ignore-builtin-builddeps",
                    "content": "Do not check built-in build dependencies and conflicts (since dpkg  1.18.2).   These  are\nthe  distribution  specific  implicit  build  dependencies  usually  required  in a build\nenvironment, the so called Build-Essential package set.\n",
                    "long": "--ignore-builtin-builddeps"
                },
                {
                    "name": "--rules-requires-root",
                    "content": "Do not honor the Rules-Requires-Root field, falling back  to  its  legacy  default  value\n(since dpkg 1.19.1).\n",
                    "long": "--rules-requires-root"
                },
                {
                    "name": "-nc --no-pre-clean",
                    "content": "Do not clean the source tree before building (long option since dpkg 1.18.8).  Implies -b\nif  nothing  else  has  been selected among -F, -g, -G, -B, -A or -S.  Implies -d with -S\n(since dpkg 1.18.0).\n",
                    "long": "--no-pre-clean"
                },
                {
                    "name": "--pre-clean",
                    "content": "Clean the source tree before building (since dpkg 1.18.8).  This is the default behavior.\n",
                    "long": "--pre-clean"
                },
                {
                    "name": "-tc --post-clean",
                    "content": "Clean the source tree (using gain-root-command debian/rules clean) after the package  has\nbeen built (long option since dpkg 1.18.8).\n",
                    "long": "--post-clean"
                },
                {
                    "name": "--no-post-clean",
                    "content": "Do  not clean the source tree after the package has been built (since dpkg 1.19.1).  This\nis the default behavior.\n",
                    "long": "--no-post-clean"
                },
                {
                    "name": "--sanitize-env",
                    "content": "Sanitize  the  build  environment  (since  dpkg  1.20.0).   This  will  reset  or  remove\nenvironment  variables,  umask,  and  any  other  process attributes that might otherwise\nadversely affect the build of packages.   Because  the  official  entry  point  to  build\npackages is debian/rules, packages cannot rely on these settings being in place, and thus\nshould work even when they are not.  What to sanitize is vendor specific.\n",
                    "long": "--sanitize-env"
                },
                {
                    "name": "-r --root-command=_",
                    "content": "When  dpkg-buildpackage  needs  to execute part of the build process as root, it prefixes\nthe command it executes with gain-root-command if one has  been  specified  (long  option\nsince  dpkg  1.18.8).   Otherwise,  if  none has been specified, fakeroot will be used by\ndefault, if the command is present.  gain-root-command should start with the  name  of  a\nprogram on the PATH and will get as arguments the name of the real command to run and the\narguments  it should take.  gain-root-command can include parameters (they must be space-\nseparated) but no shell metacharacters.  gain-root-command might typically  be  fakeroot,\nsudo,  super  or  really.   su is not suitable, since it can only invoke the user's shell\nwith -c instead of passing arguments individually to the command to be run.\n",
                    "flag": "-r",
                    "long": "--root-command",
                    "arg": "_"
                },
                {
                    "name": "-R --rules-file=_",
                    "content": "Building a Debian package usually  involves  invoking  debian/rules  as  a  command  with\nseveral  standard  parameters  (since dpkg 1.14.17, long option since dpkg 1.18.8).  With\nthis option it's possible to use another program invocation to build the package (it  can\ninclude  space  separated  parameters).   Alternatively  it  can  be  used to execute the\nstandard rules file with another make program (for example by  using  /usr/local/bin/make\n-f debian/rules as rules-file).\n\n--check-command=check-command\nCommand  used  to check the .changes file itself and any artifact built referenced in the\nfile (since dpkg 1.17.6).  The command should take the .changes pathname as an  argument.\nThis command will usually be lintian.\n\n--check-option=opt\nPass  option opt to the check-command specified with DEBCHECKCOMMAND or --check-command\n(since dpkg 1.17.6).  Can be used multiple times.\n\n--hook-hook-name=hook-command\nSet the specified shell code hook-command as the hook hook-name, which will  run  at  the\ntimes  specified in the run steps (since dpkg 1.17.6).  The hooks will always be executed\neven if the following action is not performed (except for  the  binary  hook).   All  the\nhooks will run in the unpacked source directory.\n\nSome  hooks  can  receive  addition information through environment variables (since dpkg\n1.22.0).  All hooks get the hook  name  in  the  DPKGBUILDPACKAGEHOOKNAME  environment\nvariable (since dpkg 1.22.0).\n\nNote:  Hooks  can  affect  the  build process, and cause build failures if their commands\nfail, so watch out for unintended consequences.\n\nThe current hook-name supported are:\n\npreinit\ninit\npreclean\nsource\nGets DPKGBUILDPACKAGEHOOKSOURCEOPTIONS with the space-separated lists of  options\nthat will passed to the dpkg-source call.\n\nbuild\nGets  DPKGBUILDPACKAGEHOOKBUILDTARGET  with  the  name  of the debian/rules build\ntarget called, but only if called.\n\nbinary\nGets DPKGBUILDPACKAGEHOOKBINARYTARGET with the name of  the  debian/rules  binary\ntarget called, but only if called.\n\nbuildinfo\nGets  DPKGBUILDPACKAGEHOOKBUILDINFOOPTIONS  with  the  space-separated  lists  of\noptions that will passed to the dpkg-genbuildinfo call.\n\nchanges\nGets DPKGBUILDPACKAGEHOOKCHANGESOPTIONS with the space-separated lists of options\nthat will passed to the dpkg-genchanges call.\n\npostclean\ncheck\nGets DPKGBUILDPACKAGEHOOKCHECKOPTIONS with the space-separated lists  of  options\nthat will passed to the check command call.\n\nsign\ndone\n\nThe  hook-command  supports  the  following  substitution  format  string, which will get\napplied to it before execution:\n\n%%  A single % character.\n\n%a  A boolean value (0  or  1),  representing  whether  the  following  action  is  being\nperformed.\n\n%p  The source package name.\n\n%v  The source package version.\n\n%s  The source package version (without the epoch).\n\n%u  The upstream version.\n\n--buildinfo-file=filename\nSet the filename for the generated .buildinfo file (since dpkg 1.21.0).\n\n--buildinfo-option=opt\nPass option opt to dpkg-genbuildinfo (since dpkg 1.18.11).  Can be used multiple times.\n\n--sign-backend=sign-backend\nSpecify  an  OpenPGP  backend interface to use when invoking the sign-command (since dpkg\n1.21.10).\n\nThe default is auto, where the best current backend available will be used.  The specific\nOpenPGP backends supported in order of preference are:\n\nsop (any conforming Stateless OpenPGP implementation)\n\nsq  (from Sequoia-PGP)\n\ngpg (from GnuPG)\n",
                    "flag": "-R",
                    "long": "--rules-file",
                    "arg": "_"
                },
                {
                    "name": "-p --sign-command=_",
                    "content": "When dpkg-buildpackage needs to execute an OpenPGP  backend  command  to  sign  a  source\ncontrol  (.dsc)  file,  a  .buildinfo  file  or  a .changes file it will run sign-command\n(searching the PATH if necessary) instead of the default or auto-detected backend command\n(long option since  dpkg  1.18.8).   sign-command  will  get  all  the  backend  specific\narguments  according  to  the  --sign-backend  selected.  sign-command should not contain\nspaces or any other shell metacharacters.\n",
                    "flag": "-p",
                    "long": "--sign-command",
                    "arg": "_"
                },
                {
                    "name": "-k --sign-keyid=_",
                    "content": "--sign-key=key-id\nSpecify an OpenPGP key-ID (either a fingerprint or a user-ID) for the secret key  to  use\nwhen signing packages (--sign-key since dpkg 1.18.8, --sign-keyid since dpkg 1.21.10).\n\n--sign-keyfile=key-file\nSpecify an OpenPGP key-file containing the secret key to use when signing packages (since\ndpkg 1.21.10).\n\nNote: For security reasons the key-file is best kept locked with a password.\n",
                    "flag": "-k",
                    "long": "--sign-keyid",
                    "arg": "_"
                },
                {
                    "name": "-us --unsigned-source",
                    "content": "Do not sign the source package (long option since dpkg 1.18.8).\n",
                    "long": "--unsigned-source"
                },
                {
                    "name": "-ui --unsigned-buildinfo",
                    "content": "Do not sign the .buildinfo file (since dpkg 1.18.19).\n",
                    "long": "--unsigned-buildinfo"
                },
                {
                    "name": "-uc --unsigned-changes",
                    "content": "Do not sign the .buildinfo and .changes files (long option since dpkg 1.18.8).\n",
                    "long": "--unsigned-changes"
                },
                {
                    "name": "--no-sign",
                    "content": "Do  not  sign  any  file,  this  includes the source package, the .buildinfo file and the\n.changes file (since dpkg 1.18.20).\n",
                    "long": "--no-sign"
                },
                {
                    "name": "--force-sign",
                    "content": "Force the signing of  the  resulting  files  (since  dpkg  1.17.0),  regardless  of  -us,\n--unsigned-source,  -ui,  --unsigned-buildinfo, -uc, --unsigned-changes or other internal\nheuristics.\n",
                    "long": "--force-sign"
                },
                {
                    "name": "-sn",
                    "content": ""
                },
                {
                    "name": "-ss",
                    "content": ""
                },
                {
                    "name": "-sA",
                    "content": ""
                },
                {
                    "name": "-sk",
                    "content": ""
                },
                {
                    "name": "-su",
                    "content": ""
                },
                {
                    "name": "-sr",
                    "content": ""
                },
                {
                    "name": "-sK",
                    "content": ""
                },
                {
                    "name": "-sU",
                    "content": ""
                },
                {
                    "name": "-sR",
                    "content": ""
                },
                {
                    "name": "-i --diff-ignore",
                    "content": "",
                    "flag": "-i",
                    "long": "--diff-ignore"
                },
                {
                    "name": "-I --tar-ignore",
                    "content": "",
                    "flag": "-I",
                    "long": "--tar-ignore"
                },
                {
                    "name": "-z --compression-level=_",
                    "content": "",
                    "flag": "-z",
                    "long": "--compression-level",
                    "arg": "_"
                },
                {
                    "name": "-Z --compression=_",
                    "content": "Passed unchanged to dpkg-source.  See its manual page.\n\n--source-option=opt\nPass option opt to dpkg-source (since dpkg 1.15.6).  Can be used multiple times.\n\n--changes-file=filename\nSet the filename for the generated .changes file (since dpkg 1.21.0).\n\n--changes-option=opt\nPass option opt to dpkg-genchanges (since dpkg 1.15.6).  Can be used multiple times.\n\n--admindir=dir\n--admindir dir\nChange the location of the dpkg database (since dpkg 1.14.0).  The  default  location  is\n/var/lib/dpkg.\n\n-?, --help\nShow the usage message and exit.\n",
                    "flag": "-Z",
                    "long": "--compression",
                    "arg": "_"
                },
                {
                    "name": "--version",
                    "content": "Show the version and exit.\n",
                    "long": "--version"
                }
            ]
        },
        "ENVIRONMENT": {
            "content": "",
            "subsections": [
                {
                    "name": "External environment",
                    "content": "DEBCHECKCOMMAND\nIf  set,  it  will be used as the command to check the .changes file (since dpkg 1.17.6).\nOverridden by the --check-command option.\n\nDEBSIGNKEYID\nIf set, it will be used to sign the .changes,  .buildinfo  and  .dsc  files  (since  dpkg\n1.17.2).  Overridden by the --sign-key option.\n\nDEBSIGNKEYFILE\nIf  set,  it  will  be  used  to sign the .changes, .buildinfo and .dsc files (since dpkg\n1.21.10).  Overridden by the --sign-keyfile option.\n\nDEBBUILDOPTIONS\nIf set, it will contain a space-separated list of options that  affect  the  behavior  of\nsome  dpkg tools involved in package building, and might affect the package build process\nif the code in debian/rules honors them.  These options  can  have  parameters  specified\nimmediately  after  an  equal  sign (‘=‘).  For options that support multiple parameters,\nthese will not be separated by spaces, as these are reserved to separate options.\n\nThe following are the options known and supported by dpkg tools, other options honored by\ndebian/rules might be defined by distribution specific policies.\n\nparallel=N\nThe debian/rules in the packaging might use this option to set up the  build  process\nto use N parallel jobs.  It is overridden by the --jobs and --jobs-force options.\n\nnocheck\ndpkg-buildpackage  will  ignore  the DEBCHECKCOMMAND variable.  The debian/rules in\nthe packaging is not expected to run test suites during the build.\n\nnoopt\nIf debian/rules calls dpkg-buildflags to set up the build flags, those will be set to\nnot enable any optimizations.\n\nnostrip\nThe debian/rules in the packaging should ensure that objects do not get the debugging\ninformation stripped.  If debian/rules includes the  mk/buildtools.mk  make  fragment\nthe STRIP make variable will respect this option.\n\nterse\ndpkg-buildpackage  will append the --no-print-directory make(1) flag to the MAKEFLAGS\nenvironment variable.  The debian/rules in the  packaging  should  reduce  verbosity,\nwhile not being completely quiet.\n\nhardening=feature-spec\nreproducible=feature-spec\nabi=feature-spec\nfuture=feature-spec\nqa=feature-spec\noptimize=feature-spec\nsanitize=feature-spec\nThese are feature areas that control build flag features.  See dpkg-buildflags(1) for\nfurther details.\n\nDEBBUILDPROFILES\nIf set, it will be used as the active build profile(s) for the package being built (since\ndpkg  1.17.2).   It  is  a  space  separated list of profile names.  Overridden by the -P\noption.\n\nDPKGCOLORS\nSets the color mode (since  dpkg  1.18.5).   The  currently  accepted  values  are:  auto\n(default), always and never.\n\nDPKGNLS\nIf set, it will be used to decide whether to activate Native Language Support, also known\nas  internationalization (or i18n) support (since dpkg 1.19.0).  The accepted values are:\n0 and 1 (default).\n"
                },
                {
                    "name": "Internal environment",
                    "content": "Even if dpkg-buildpackage exports some variables,  debian/rules  should  not  rely  on  their\npresence  and  should  instead  use  the  respective interface to retrieve the needed values,\nbecause that file is the main entry point to build packages and running it standalone  should\nbe supported.\n\nDEBBUILD*\nDEBHOST*\nDEBTARGET*\ndpkg-architecture  is  called with the -a and -t parameters forwarded.  Any variable that\nis output by its -s option is integrated in the build environment.\n\nDEBRULESREQUIRESROOT\nThis variable is set to the value obtained from the Rules-Requires-Root field, the  dpkg-\nbuild-api  level  or  from  the command-line.  When set, it will be a valid value for the\nRules-Requires-Root  field.   It   is   used   to   notify   debian/rules   whether   the\nrootless-builds.txt specification is supported.\n\nDEBGAINROOTCMD\nThis  variable is set to gain-root-command when the field Rules-Requires-Root is set to a\nvalue different to no and binary-targets.\n\nSOURCEDATEEPOCH\nThis variable is set to the Unix timestamp  since  the  epoch  of  the  latest  entry  in\ndebian/changelog, if it is not already defined.\n"
                }
            ]
        },
        "FILES": {
            "content": "/etc/dpkg/buildpackage.conf\nSystem wide configuration file\n\n$XDGCONFIGHOME/dpkg/buildpackage.conf or\n$HOME/.config/dpkg/buildpackage.conf\nUser configuration file.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "",
            "subsections": [
                {
                    "name": "Compiler flags are no longer exported",
                    "content": "Between dpkg 1.14.17 and 1.16.1, dpkg-buildpackage exported compiler flags (CFLAGS, CXXFLAGS,\nFFLAGS,  CPPFLAGS and LDFLAGS) with values as returned by dpkg-buildflags.  This is no longer\nthe case.\n"
                },
                {
                    "name": "Default build targets",
                    "content": "dpkg-buildpackage is using the build-arch and build-indep targets since dpkg  1.16.2.   Those\ntargets  are  thus  mandatory.   But  to  avoid  breakages of existing packages, and ease the\ntransition, if the source package does not build both architecture independent and  dependent\nbinary  packages  (since  dpkg  1.18.8)  it  will fallback to use the build target if make -f\ndebian/rules -qn build-target returns 2 as exit code.\n"
                }
            ]
        },
        "SECURITY": {
            "content": "Building binary or source packages should only be performed over trusted source data.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "It should be possible to specify spaces and shell metacharacters and  initial  arguments  for\ngain-root-command and sign-command.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "/usr/share/doc/dpkg/spec/rootless-builds.txt,      dpkg-source(1),      dpkg-architecture(1),\ndpkg-buildflags(1),  dpkg-genbuildinfo(1),   dpkg-genchanges(1),   fakeroot(1),   lintian(1),\n<https://datatracker.ietf.org/doc/draft-dkg-openpgp-stateless-cli/>, sq(1), gpg(1).\n\n1.22.6                                       2026-05-06                         dpkg-buildpackage(1)",
            "subsections": []
        }
    },
    "summary": "dpkg-buildpackage - build binary or source packages from sources",
    "flags": [
        {
            "flag": "-g",
            "long": "--build",
            "arg": "source,all",
            "description": ""
        },
        {
            "flag": "-G",
            "long": "--build",
            "arg": "source,any",
            "description": ""
        },
        {
            "flag": "-b",
            "long": "--build",
            "arg": "any,all",
            "description": ""
        },
        {
            "flag": "-B",
            "long": "--build",
            "arg": "any",
            "description": ""
        },
        {
            "flag": "-A",
            "long": "--build",
            "arg": "all",
            "description": ""
        },
        {
            "flag": "-S",
            "long": "--build",
            "arg": "source",
            "description": ""
        },
        {
            "flag": "-F",
            "long": "--build",
            "arg": "source,any,all",
            "description": "1.15.8). --target=target[,...] --target target[,...]"
        },
        {
            "flag": "-T",
            "long": "--rules-target",
            "arg": "_",
            "description": "Calls debian/rules target once per target specified, after having setup the build environment (except for calling dpkg-source --before-build), and stops the package build process here (since dpkg 1.15.0, long option since dpkg 1.18.8, multi-target support since dpkg 1.18.16). If --as-root is also given, then the command is executed as root (see --root-command). Note that known targets that are required to be run as root do not need this option (i.e. the clean, binary, binary-arch and binary-indep targets)."
        },
        {
            "flag": "",
            "long": "--as-root",
            "arg": null,
            "description": "Only meaningful together with --target (since dpkg 1.15.0). Requires that the target be run with root rights."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Passed unchanged to dpkg-genchanges. See its manual page. --build-by=maintainer-address --source-by=maintainer-address (since dpkg 1.21.10) Pass as -m to dpkg-genchanges. See its manual page. --release-by=maintainer-address --changed-by=maintainer-address (since dpkg 1.21.10) Pass as -e to dpkg-genchanges. See its manual page."
        },
        {
            "flag": "-a",
            "long": "--host-arch",
            "arg": null,
            "description": "Specify the Debian architecture we build for (long option since dpkg 1.17.17). The architecture of the machine we build on is determined automatically, and is also the default for the host machine."
        },
        {
            "flag": "-t",
            "long": "--host-type",
            "arg": null,
            "description": "Specify the GNU system type we build for (long option since dpkg 1.17.17). It can be used in place of --host-arch or as a complement to override the default GNU system type of the host Debian architecture. --target-arch architecture Specify the Debian architecture the binaries built will build for (since dpkg 1.17.17). The default value is the host machine. --target-type gnu-system-type Specify the GNU system type the binaries built will build for (since dpkg 1.17.17). It can be used in place of --target-arch or as a complement to override the default GNU system type of the target Debian architecture."
        },
        {
            "flag": "-P",
            "long": "--build-profiles",
            "arg": "_",
            "description": "Specify the profile(s) we build, as a comma-separated list (since dpkg 1.17.2, long option since dpkg 1.18.8). The default behavior is to build for no specific profile. Also sets them (as a space separated list) as the DEBBUILDPROFILES environment variable which allows, for example, debian/rules files to use this information for conditional builds."
        },
        {
            "flag": "-j",
            "long": "--jobs",
            "arg": null,
            "description": "Specifies the number of jobs allowed to be run simultaneously (since dpkg 1.14.7, long option since dpkg 1.18.8). The number of jobs matching the number of online processors if auto is specified (since dpkg 1.17.10), or unlimited number if jobs is not specified. The default behavior is auto (since dpkg 1.18.11) in non-forced mode (since dpkg 1.21.10), and as such it is always safer to use with any package including those that are not parallel-build safe. Setting the number of jobs to 1 will restore serial execution. Will add parallel=jobs or parallel to the DEBBUILDOPTIONS environment variable which allows debian/rules files to opt-in to use this information for their own purposes. The jobs value will override the parallel=jobs or parallel option in the DEBBUILDOPTIONS environment variable. Note that the auto value will get replaced by the actual number of currently active processors, and as such will not get propagated to any child process. If the number of online processors cannot be inferred then the code will fallback to using serial execution (since dpkg 1.18.15), although this should only happen on exotic and unsupported systems."
        },
        {
            "flag": "-J",
            "long": "--jobs-try",
            "arg": null,
            "description": "This option (since dpkg 1.18.2, long option since dpkg 1.18.8) is equivalent to the -j above. Since the behavior for -j changed in dpkg 1.21.10 to the opt-in mode, you can use this option instead if you need to guarantee semantics across dpkg release series. --jobs-force[=jobs|auto] This option (since dpkg 1.21.10) is equivalent to the --jobs option except that it will enable forced parallel mode, by adding the make -j option with the computed number of parallel jobs to the MAKEFLAGS environment variable. This should cause all subsequent make invocations to inherit the option, thus forcing the parallel setting on the packaging (and possibly the upstream build system if that uses make(1)) regardless of their support for parallel builds, which might cause build failures. Note: Any Makefile that is not parallel-safe should be considered to be buggy. These should either be made parallel-safe, or marked as not being safe with the make(1) .NOTPARALLEL target."
        },
        {
            "flag": "-D",
            "long": "--check-builddeps",
            "arg": null,
            "description": "Check build dependencies and conflicts; abort if unsatisfied (long option since dpkg 1.18.8). This is the default behavior."
        },
        {
            "flag": "-d",
            "long": "--no-check-builddeps",
            "arg": null,
            "description": "Do not check build dependencies and conflicts (long option since dpkg 1.18.8)."
        },
        {
            "flag": "",
            "long": "--ignore-builtin-builddeps",
            "arg": null,
            "description": "Do not check built-in build dependencies and conflicts (since dpkg 1.18.2). These are the distribution specific implicit build dependencies usually required in a build environment, the so called Build-Essential package set."
        },
        {
            "flag": "",
            "long": "--rules-requires-root",
            "arg": null,
            "description": "Do not honor the Rules-Requires-Root field, falling back to its legacy default value (since dpkg 1.19.1)."
        },
        {
            "flag": "",
            "long": "--no-pre-clean",
            "arg": null,
            "description": "Do not clean the source tree before building (long option since dpkg 1.18.8). Implies -b if nothing else has been selected among -F, -g, -G, -B, -A or -S. Implies -d with -S (since dpkg 1.18.0)."
        },
        {
            "flag": "",
            "long": "--pre-clean",
            "arg": null,
            "description": "Clean the source tree before building (since dpkg 1.18.8). This is the default behavior."
        },
        {
            "flag": "",
            "long": "--post-clean",
            "arg": null,
            "description": "Clean the source tree (using gain-root-command debian/rules clean) after the package has been built (long option since dpkg 1.18.8)."
        },
        {
            "flag": "",
            "long": "--no-post-clean",
            "arg": null,
            "description": "Do not clean the source tree after the package has been built (since dpkg 1.19.1). This is the default behavior."
        },
        {
            "flag": "",
            "long": "--sanitize-env",
            "arg": null,
            "description": "Sanitize the build environment (since dpkg 1.20.0). This will reset or remove environment variables, umask, and any other process attributes that might otherwise adversely affect the build of packages. Because the official entry point to build packages is debian/rules, packages cannot rely on these settings being in place, and thus should work even when they are not. What to sanitize is vendor specific."
        },
        {
            "flag": "-r",
            "long": "--root-command",
            "arg": "_",
            "description": "When dpkg-buildpackage needs to execute part of the build process as root, it prefixes the command it executes with gain-root-command if one has been specified (long option since dpkg 1.18.8). Otherwise, if none has been specified, fakeroot will be used by default, if the command is present. gain-root-command should start with the name of a program on the PATH and will get as arguments the name of the real command to run and the arguments it should take. gain-root-command can include parameters (they must be space- separated) but no shell metacharacters. gain-root-command might typically be fakeroot, sudo, super or really. su is not suitable, since it can only invoke the user's shell with -c instead of passing arguments individually to the command to be run."
        },
        {
            "flag": "-R",
            "long": "--rules-file",
            "arg": "_",
            "description": "Building a Debian package usually involves invoking debian/rules as a command with several standard parameters (since dpkg 1.14.17, long option since dpkg 1.18.8). With this option it's possible to use another program invocation to build the package (it can include space separated parameters). Alternatively it can be used to execute the standard rules file with another make program (for example by using /usr/local/bin/make -f debian/rules as rules-file). --check-command=check-command Command used to check the .changes file itself and any artifact built referenced in the file (since dpkg 1.17.6). The command should take the .changes pathname as an argument. This command will usually be lintian. --check-option=opt Pass option opt to the check-command specified with DEBCHECKCOMMAND or --check-command (since dpkg 1.17.6). Can be used multiple times. --hook-hook-name=hook-command Set the specified shell code hook-command as the hook hook-name, which will run at the times specified in the run steps (since dpkg 1.17.6). The hooks will always be executed even if the following action is not performed (except for the binary hook). All the hooks will run in the unpacked source directory. Some hooks can receive addition information through environment variables (since dpkg 1.22.0). All hooks get the hook name in the DPKGBUILDPACKAGEHOOKNAME environment variable (since dpkg 1.22.0). Note: Hooks can affect the build process, and cause build failures if their commands fail, so watch out for unintended consequences. The current hook-name supported are: preinit init preclean source Gets DPKGBUILDPACKAGEHOOKSOURCEOPTIONS with the space-separated lists of options that will passed to the dpkg-source call. build Gets DPKGBUILDPACKAGEHOOKBUILDTARGET with the name of the debian/rules build target called, but only if called. binary Gets DPKGBUILDPACKAGEHOOKBINARYTARGET with the name of the debian/rules binary target called, but only if called. buildinfo Gets DPKGBUILDPACKAGEHOOKBUILDINFOOPTIONS with the space-separated lists of options that will passed to the dpkg-genbuildinfo call. changes Gets DPKGBUILDPACKAGEHOOKCHANGESOPTIONS with the space-separated lists of options that will passed to the dpkg-genchanges call. postclean check Gets DPKGBUILDPACKAGEHOOKCHECKOPTIONS with the space-separated lists of options that will passed to the check command call. sign done The hook-command supports the following substitution format string, which will get applied to it before execution: %% A single % character. %a A boolean value (0 or 1), representing whether the following action is being performed. %p The source package name. %v The source package version. %s The source package version (without the epoch). %u The upstream version. --buildinfo-file=filename Set the filename for the generated .buildinfo file (since dpkg 1.21.0). --buildinfo-option=opt Pass option opt to dpkg-genbuildinfo (since dpkg 1.18.11). Can be used multiple times. --sign-backend=sign-backend Specify an OpenPGP backend interface to use when invoking the sign-command (since dpkg 1.21.10). The default is auto, where the best current backend available will be used. The specific OpenPGP backends supported in order of preference are: sop (any conforming Stateless OpenPGP implementation) sq (from Sequoia-PGP) gpg (from GnuPG)"
        },
        {
            "flag": "-p",
            "long": "--sign-command",
            "arg": "_",
            "description": "When dpkg-buildpackage needs to execute an OpenPGP backend command to sign a source control (.dsc) file, a .buildinfo file or a .changes file it will run sign-command (searching the PATH if necessary) instead of the default or auto-detected backend command (long option since dpkg 1.18.8). sign-command will get all the backend specific arguments according to the --sign-backend selected. sign-command should not contain spaces or any other shell metacharacters."
        },
        {
            "flag": "-k",
            "long": "--sign-keyid",
            "arg": "_",
            "description": "--sign-key=key-id Specify an OpenPGP key-ID (either a fingerprint or a user-ID) for the secret key to use when signing packages (--sign-key since dpkg 1.18.8, --sign-keyid since dpkg 1.21.10). --sign-keyfile=key-file Specify an OpenPGP key-file containing the secret key to use when signing packages (since dpkg 1.21.10). Note: For security reasons the key-file is best kept locked with a password."
        },
        {
            "flag": "",
            "long": "--unsigned-source",
            "arg": null,
            "description": "Do not sign the source package (long option since dpkg 1.18.8)."
        },
        {
            "flag": "",
            "long": "--unsigned-buildinfo",
            "arg": null,
            "description": "Do not sign the .buildinfo file (since dpkg 1.18.19)."
        },
        {
            "flag": "",
            "long": "--unsigned-changes",
            "arg": null,
            "description": "Do not sign the .buildinfo and .changes files (long option since dpkg 1.18.8)."
        },
        {
            "flag": "",
            "long": "--no-sign",
            "arg": null,
            "description": "Do not sign any file, this includes the source package, the .buildinfo file and the .changes file (since dpkg 1.18.20)."
        },
        {
            "flag": "",
            "long": "--force-sign",
            "arg": null,
            "description": "Force the signing of the resulting files (since dpkg 1.17.0), regardless of -us, --unsigned-source, -ui, --unsigned-buildinfo, -uc, --unsigned-changes or other internal heuristics."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-i",
            "long": "--diff-ignore",
            "arg": null,
            "description": ""
        },
        {
            "flag": "-I",
            "long": "--tar-ignore",
            "arg": null,
            "description": ""
        },
        {
            "flag": "-z",
            "long": "--compression-level",
            "arg": "_",
            "description": ""
        },
        {
            "flag": "-Z",
            "long": "--compression",
            "arg": "_",
            "description": "Passed unchanged to dpkg-source. See its manual page. --source-option=opt Pass option opt to dpkg-source (since dpkg 1.15.6). Can be used multiple times. --changes-file=filename Set the filename for the generated .changes file (since dpkg 1.21.0). --changes-option=opt Pass option opt to dpkg-genchanges (since dpkg 1.15.6). Can be used multiple times. --admindir=dir --admindir dir Change the location of the dpkg database (since dpkg 1.14.0). The default location is /var/lib/dpkg. -?, --help Show the usage message and exit."
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "Show the version and exit."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "dpkg-source",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dpkg-source/1/json"
        },
        {
            "name": "dpkg-architecture",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dpkg-architecture/1/json"
        },
        {
            "name": "dpkg-buildflags",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dpkg-buildflags/1/json"
        },
        {
            "name": "dpkg-genbuildinfo",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dpkg-genbuildinfo/1/json"
        },
        {
            "name": "dpkg-genchanges",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dpkg-genchanges/1/json"
        },
        {
            "name": "fakeroot",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/fakeroot/1/json"
        },
        {
            "name": "lintian",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/lintian/1/json"
        },
        {
            "name": "sq",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/sq/1/json"
        },
        {
            "name": "gpg",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/gpg/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Compile binary and/or source Debian packages from source code.",
        "examples": [
            {
                "description": "Generate source and binary packages",
                "command": "dpkg-buildpackage"
            },
            {
                "description": "Generate only binary packages (no source package)",
                "command": "dpkg-buildpackage {{-b|--build=binary}}"
            },
            {
                "description": "Generate only the source package (without compiling binaries)",
                "command": "dpkg-buildpackage {{-S|--build=source}}"
            },
            {
                "description": "Do not sign the `.dsc` and `.changes` files",
                "command": "dpkg-buildpackage {{-us|--unsigned-source}} {{-uc|--unsigned-changes}}"
            },
            {
                "description": "Do not run `clean` before compiling",
                "command": "dpkg-buildpackage {{-nc|--no-pre-clean}}"
            },
            {
                "description": "Use `fakeroot` as the command to gain root privileges during the build",
                "command": "dpkg-buildpackage {{-r|--root-command=}}fakeroot"
            },
            {
                "description": "Run a specific `debian/rules` target",
                "command": "dpkg-buildpackage {{-T|--rules-target=}}{{clean}}"
            }
        ]
    }
}