{
    "mode": "man",
    "parameter": "DEBUILD",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/DEBUILD/1/json",
    "generated": "2026-06-12T07:21:18Z",
    "synopsis": "debuild [debuild options] [dpkg-buildpackage options] [--lintian-opts lintian options]\ndebuild [debuild options] -- binary|binary-arch|binary-indep|clean ...",
    "sections": {
        "NAME": {
            "content": "debuild - build a Debian package\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "debuild [debuild options] [dpkg-buildpackage options] [--lintian-opts lintian options]\ndebuild [debuild options] -- binary|binary-arch|binary-indep|clean ...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "debuild  creates all the files necessary for uploading a Debian package.  It first runs dpkg-\nbuildpackage, then runs lintian on the .changes file created (assuming that  lintian  is  in‐\nstalled),  and  finally  signs  the appropriate files (using debsign(1) to do this instead of\ndpkg-buildpackage(1) itself; all relevant key-signing options are passed on).   Signing  will\nbe  skipped if the distribution is UNRELEASED, unless dpkg-buildpackage's --force-sign option\nis used.  Parameters can be passed to dpkg-buildpackage and lintian, where the parameters  to\nthe  latter are indicated with the --lintian-opts option.  The allowable options in this case\nare --lintian and --no-lintian to force or skip the lintian step, respectively.  The  default\nis to run lintian.  There are also various options available for setting and preserving envi‐\nronment variables, as described below in the Environment Variables section.  In  this  method\nof running debuild, we also save a build log to the file ../<package><version><arch>.build.\n\nAn  alternative  way of using debuild is to use one or more of the parameters binary, binary-\narch, binary-indep and clean, in which case debuild will attempt to gain root privileges  and\nthen  run  debian/rules  with the given parameters.  A --rootcmd=gain-root-command or -rgain-\nroot-command option may be used to specify a method of gaining root  privileges.   The  gain-\nroot-command  is  likely to be one of fakeroot, sudo or super.  See below for further discus‐\nsion of this point.  Again, the environment preservation options may be used.  In this  case,\ndebuild  will also attempt to run dpkg-checkbuilddeps first; this can be explicitly requested\nor switched off using the options -D and -d respectively.  Note also that if either of  these\nor  a -r option is specified in the configuration file option DEBUILDDPKGBUILDPACKAGEOPTS,\nthen it will be recognised even in this method of invocation of debuild.\n\ndebuild also reads the devscripts configuration files as described below.   This  allows  de‐\nfault options to be given.\n",
            "subsections": [
                {
                    "name": "Directory name checking",
                    "content": "In common with several other scripts in the devscripts package, debuild will climb the direc‐\ntory tree until it finds a debian/changelog file before attempting to build the package.   As\na  safeguard  against stray files causing potential problems, it will examine the name of the\nparent directory once it finds the debian/changelog file, and check that the  directory  name\ncorresponds  to the package name.  Precisely how it does this is controlled by two configura‐\ntion file variables DEVSCRIPTSCHECKDIRNAMELEVEL  and  DEVSCRIPTSCHECKDIRNAMEREGEX,  and\ntheir corresponding command-line options --check-dirname-level and --check-dirname-regex.\n\nDEVSCRIPTSCHECKDIRNAMELEVEL can take the following values:\n\n0      Never check the directory name.\n\n1      Only check the directory name if we have had to change directory in our search for de‐\nbian/changelog.  This is the default behaviour.\n\n2      Always check the directory name.\n\nThe directory name is checked by testing whether the current directory name (as determined by\npwd(1))    matches    the    regex    given    by   the   configuration   file   option   DE‐‐\nVSCRIPTSCHECKDIRNAMEREGEX or by the command line option --check-dirname-regex regex.  Here\nregex  is  a  Perl regex (see perlre(3perl)), which will be anchored at the beginning and the\nend.  If regex contains a '/', then it must match the full directory path.  If not,  then  it\nmust match the full directory name.  If regex contains the string ´PACKAGE', this will be re‐\nplaced by the source package name, as determined from the changelog.  The default  value  for\nthe regex is: ´PACKAGE(-.+)?', thus matching directory names such as PACKAGE and PACKAGE-ver‐\nsion.\n"
                }
            ]
        },
        "ENVIRONMENT VARIABLES": {
            "content": "As environment variables can affect the building of a package, often unintentionally, debuild\nsanitises  the  environment by removing all environment variables except for TERM, HOME, LOG‐‐\nNAME, GNUPGHOME, PGPPATH,  GPGAGENTINFO,  GPGTTY,  DBUSSESSIONBUSADDRESS,  FAKEROOTKEY,\nDEBEMAIL,  DEB*,  the  (C, CPP, CXX, LD and F)FLAGS variables and their APPEND counterparts\nand the locale variables LANG and LC*.  TERM is set to `dumb' if it is unset,  and  PATH  is\nset to \"/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11\".\n\nIf  a particular environment variable is required to be passed through untouched to the build\nprocess, this may be specified by using a --preserve-envvar envvar (which can also be written\nas  -e envvar option).  The environment may be left untouched by using the --preserve-env op‐\ntion.  However, even in this case, the PATH will be set to the sane  value  described  above.\nThe  only way to prevent PATH from being reset is to specify a --preserve-envvar PATH option.\nBut you are warned that using programs from non-standard locations can easily result  in  the\npackage being broken, as it will not be able to be built on standard systems.\n\nNote  that  one  may  add  directories  to  the  beginning  of  the sanitised PATH, using the\n--prepend-path option. This is useful when one wishes to use tools such as ccache  or  distcc\nfor building.\n\nIt  is also possible to avoid having to type something like FOO=bar debuild -e FOO by writing\ndebuild -e FOO=bar or the long form debuild --set-envvar FOO=bar.\n",
            "subsections": []
        },
        "SUPERUSER REQUIREMENTS": {
            "content": "debuild needs to be run as superuser to function properly.   There  are  three  fundamentally\ndifferent  ways  to  do  this.  The first, and preferable, method is to use some root-gaining\ncommand.  The best one to use is probably fakeroot(1), since it does not involve granting any\ngenuine  privileges.   super(1)  and sudo(1) are also possibilities.  If no -r (or --rootcmd)\noption is given (and recall that dpkg-buildpackage also accepts a -r option) and  neither  of\nthe following methods is used, then -rfakeroot will silently be assumed.\n\nThe  second method is to use some command such as su(1) to become root, and then to do every‐\nthing as root.  Note, though, that lintian will abort if it is run as root  or  setuid  root;\nthis can be overcome using the --allow-root option of lintian if you know what you are doing.\n\nThe  third  possible method is to have debuild installed as setuid root.  This is not the de‐\nfault method, and will have to be installed as such by the  system  administrator.   It  must\nalso  be  realised  that anyone who can run debuild as root or setuid root has full access to\nthe whole machine.  This method is therefore not recommended, but will work.   debuild  could\nbe installed with mode 4754, so that only members of the owning group could run it.  A disad‐\nvantage of this method would be that other users would then not be able to use  the  program.\nThere are many other variants of this option involving multiple copies of debuild, or the use\nof programs such as sudo or super to grant root privileges  to  users  selectively.   If  the\nsysadmin  wishes  to do this, she should use the dpkg-statoverride program to change the per‐\nmissions of /usr/bin/debuild.  This will ensure that these permissions are  preserved  across\nupgrades.\n",
            "subsections": []
        },
        "HOOKS": {
            "content": "debuild supports a number of hooks when running dpkg-buildpackage.  Note that the hooks dpkg-\nbuildpackage to lintian (inclusive) are passed through to dpkg-buildpackage using its  corre‐\nsponding --hook-name option.  The available hooks are as follows:\n",
            "subsections": [
                {
                    "name": "dpkg-buildpackage-hook",
                    "content": "Run before dpkg-buildpackage begins by calling dpkg-checkbuilddeps.\n\nHook is run inside the unpacked source.\n\nCorresponds to dpkg's init hook.\n"
                },
                {
                    "name": "clean-hook",
                    "content": "Run  before  dpkg-buildpackage runs debian/rules clean to clean the source tree.  (Run\neven if the tree is not being cleaned because -nc is used.)\n\nHook is run inside the unpacked source.\n\nCorresponds to dpkg's preclean hook.\n"
                },
                {
                    "name": "dpkg-source-hook",
                    "content": "Run after cleaning the tree and before running dpkg-source.  (Run even if  dpkg-source\nis not being called because -b, -B, or -A is used.)\n\nHook is run inside the unpacked source.\n\nCorresponds to dpkg's source hook.\n"
                },
                {
                    "name": "dpkg-build-hook",
                    "content": "Run  after  dpkg-source and before calling debian/rules build.  (Run even if this is a\nsource-only build, so debian/rules build is not being called.)\n\nHook is run inside the unpacked source.\n\nCorresponds to dpkg's build hook.\n"
                },
                {
                    "name": "dpkg-binary-hook",
                    "content": "Run between debian/rules build and debian/rules binary(-arch).  Run only if  a  binary\npackage is being built.\n\nHook is run inside the unpacked source.\n\nCorresponds to dpkg's binary hook.\n"
                },
                {
                    "name": "dpkg-genchanges-hook",
                    "content": "Run after the binary package is built and before calling dpkg-genchanges.\n\nHook is run inside the unpacked source.\n\nCorresponds to dpkg's changes hook.\n"
                },
                {
                    "name": "final-clean-hook",
                    "content": "Run  after  dpkg-genchanges  and before the final debian/rules clean.  (Run even if we\nare not cleaning the tree post-build, which is the default.)\n\nHook is run inside the unpacked source.\n\nCorresponds to dpkg's postclean hook.\n"
                },
                {
                    "name": "lintian-hook",
                    "content": "Run (once) before calling lintian.  (Run even if we are not calling lintian.)\n\nHook is run from parent directory of unpacked source.\n\nCorresponds to dpkg's check hook.\n"
                },
                {
                    "name": "signing-hook",
                    "content": "Run after calling lintian before any signing takes place.  (Run even  if  we  are  not\nsigning anything.)\n\nHook is run from parent directory of unpacked source.\n\nCorresponds to dpkg's sign hook, but is run by debuild.\n"
                },
                {
                    "name": "post-dpkg-buildpackage-hook",
                    "content": "Run after everything has finished.\n\nHook is run from parent directory of unpacked source.\n\nCorresponds to dpkg's done hook, but is run by debuild.\n\nA  hook  command  can  be  specified  either  in  the configuration file as, for example, DE‐\nBUILDSIGNINGHOOK='foo' (note the hyphens change into underscores!) or as a command line op‐\ntion  --signing-hook-foo.  The command will have certain percent substitutions made on it: %%\nwill be replaced by a single % sign, %p will be replaced by the package name, %v by the pack‐\nage version number, %s by the source version number, %u by the upstream version number.  Nei‐\nther %s nor %u will contain an epoch.  %a will be 1 if the immediately following action is to\nbe  performed  and  0 if not (for example, in the dpkg-source hook, %a will become 1 if dpkg-\nsource is to be run and 0 if not).  Then it will be handed to the shell to deal with,  so  it\ncan  include  redirections and stuff.  For example, to only run the dpkg-source hook if dpkg-\nsource is to be run, the hook could be something like: \"if [ %a -eq 1 ]; then ...; fi\".\n\nPlease take care with hooks, as misuse of them can lead to  packages  which  FTBFS  (fail  to\nbuild from source).  They can be useful for taking snapshots of things or the like.\n"
                }
            ]
        },
        "OPTIONS": {
            "content": "For details, see above.\n\n--no-conf, --noconf\nDo  not read any configuration files.  This can only be used as the first option given\non the command-line.\n\n--rootcmd=gain-root-command, -rgain-root-command\nCommand to gain root (or fake root) privileges.\n",
            "subsections": [
                {
                    "name": "--preserve-env",
                    "content": "Do not clean the environment, except for PATH.\n\n--preserve-envvar=var, -evar\nDo not clean the var variable from the environment.\n\nIf var ends in an asterisk (\"*\") then all variables with names that match the  portion\nof var before the asterisk will be preserved.\n\n--set-envvar=var=value, -evar=value\nSet the environment variable var to value and do not remove it from the environment.\n\n--prepend-path=value\nOnce the normalized PATH has been set, prepend value to it.\n",
                    "long": "--preserve-env"
                },
                {
                    "name": "--lintian",
                    "content": "Run  lintian after dpkg-buildpackage.  This is the default behaviour, and it overrides\nany configuration file directive to the contrary.\n",
                    "long": "--lintian"
                },
                {
                    "name": "--no-lintian",
                    "content": "Do not run lintian after dpkg-buildpackage.\n",
                    "long": "--no-lintian"
                },
                {
                    "name": "--no-tgz-check",
                    "content": "Even if we're running dpkg-buildpackage and the version number has a Debian  revision,\ndo  not check that the .orig.tar.gz file or .orig directory exists before starting the\nbuild.\n",
                    "long": "--no-tgz-check"
                },
                {
                    "name": "--tgz-check",
                    "content": "If we're running dpkg-buildpackage and the version number has a Debian revision, check\nthat  the .orig.tar.gz file or .orig directory exists before starting the build.  This\nis the default behaviour.\n\n--username username\nWhen signing, use debrsign instead of debsign.  username specifies the credentials  to\nbe used.\n\n--foo-hook=hook\nSet a hook as described above.  If hook is blank, this unsets the hook.\n",
                    "long": "--tgz-check"
                },
                {
                    "name": "--clear-hooks",
                    "content": "Clears all hooks.  They may be reinstated by later command line options.\n\n--check-dirname-level N\nSee the above section Directory name checking for an explanation of this option.\n\n--check-dirname-regex regex\nSee the above section Directory name checking for an explanation of this option.\n",
                    "long": "--clear-hooks"
                },
                {
                    "name": "-d",
                    "content": "",
                    "flag": "-d"
                },
                {
                    "name": "-D",
                    "content": "",
                    "flag": "-D"
                }
            ]
        },
        "CONFIGURATION VARIABLES": {
            "content": "The  two configuration files /etc/devscripts.conf and ~/.devscripts are sourced by a shell in\nthat order to set configuration variables.  Command line options can be used to override some\nof  these  configuration file settings, otherwise the --no-conf option can be used to prevent\nreading these files.  Environment variable settings  are  ignored  when  these  configuration\nfiles are read.  The currently recognised variables are:\n\nDEBUILDPRESERVEENV\nIf  this is set to yes, then it is the same as the --preserve-env command line parame‐\nter being used.\n\nDEBUILDPRESERVEENVVARS\nWhich environment variables to preserve.  This should be  a  comma-separated  list  of\nvariables.   This  corresponds  to using possibly multiple --preserve-envvar or -e op‐\ntions.\n\nDEBUILDSETENVVARvar=value\nThis corresponds to --set-envvar=var=value.\n\nDEBUILDPREPENDPATH\nThis corresponds to --prepend-path.\n\nDEBUILDROOTCMD\nSetting this variable to prog is the equivalent of -rprog.\n\nDEBUILDTGZCHECK\nSetting this variable to no is the same as the --no-tgz-check command line option.\n\nDEBUILDSIGNINGUSERNAME\nSetting this variable is the same as using the --username command line option.\n\nDEBUILDDPKGBUILDPACKAGEOPTS\nThese are options which should be passed to the invocation of dpkg-buildpackage.  They\nare  given before any command-line options.  Due to issues of shell quoting, if a word\ncontaining spaces is required as a single option, extra quotes will be required.   For\nexample,  to  ensure that your own GPG key is always used, even for sponsored uploads,\nthe configuration file might contain the line:\n\nDEBUILDDPKGBUILDPACKAGEOPTS=\"-k'Julian Gilbey <jdg@debian.org>' -sa\"\n\nwhich gives precisely two options.  Without the extra single quotes, dpkg-buildpackage\nwould reasonably complain that Gilbey is an unrecognised option (it doesn't start with\na - sign).\n\nAlso, if this option contains any -r, -d or -D options, these will always be taken ac‐\ncount of by debuild.  Note that a -r option in this variable will override the setting\nin DEBUILDROOTCMD.\n\nDEBUILDFOOHOOK\nThe hook variable for the foo hook.  See the section on hooks above for more  details.\nBy default, this is empty.\n\nDEBUILDLINTIAN\nShould we run lintian?  If this is set to no, then lintian will not be run.\n\nDEBUILDLINTIANOPTS\nThese are options which should be passed to the invocation of lintian.  They are given\nbefore any command-line options, and the usage of this variable is  as  described  for\nthe DEBUILDDPKGBUILDPACKAGEOPTS variable.\n\nDEVSCRIPTSCHECKDIRNAMELEVEL, DEVSCRIPTSCHECKDIRNAMEREGEX\nSee  the  above section Directory name checking for an explanation of these variables.\nNote that these are package-wide configuration variables, and  will  therefore  affect\nall  devscripts scripts which check their value, as described in their respective man‐\npages and in devscripts.conf(5).\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To build your own package, simply run debuild from inside the source  tree.   dpkg-buildpack‐‐\nage(1) options may be given on the command line.\n\nThe  typical  command  line  options  to build only the binary package(s) without signing the\n.changes file (or the non-existent .dsc file):\n\ndebuild -i -us -uc -b\n\nChange the -b to -S to build only a source package.\n\nAn example using lintian to check the resulting packages and passing options to it:\n\ndebuild --lintian-opts -i\n\nNote the order of options here: the debuild options come first,  then  the  dpkg-buildpackage\nones,  then  finally  the  checker options.  (And lintian is called by default.)  If you find\nyourself using  the  same  dpkg-buildpackage  options  repeatedly,  consider  using  the  DE‐‐\nBUILDDPKGBUILDPACKAGEOPTS configuration file option as described above.\n\nTo  build  a package for a sponsored upload, given foobar1.0-1.dsc and the respective source\nfiles, run something like the following commands:\n\ndpkg-source -x foobar1.0-1.dsc\ncd foobar-1.0\ndebuild -k0x12345678\n\nwhere 0x12345678 is replaced by your GPG key ID or other key identifier such  as  your  email\naddress.  Again, you could also use the DEBUILDDPKGBUILDPACKAGEOPTS configuration file op‐\ntion as described above to avoid having to type the -k option each time you  do  a  sponsored\nupload.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "chmod(1),  debsign(1), dpkg-buildpackage(1), dpkg-checkbuilddeps(1), fakeroot(1), lintian(1),\nsu(1), sudo(1), super(1), devscripts.conf(5), dpkg-statoverride(8)\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "The original debuild program was written by  Christoph  Lameter  <clameter@debian.org>.   The\ncurrent version has been written by Julian Gilbey <jdg@debian.org>.\n\n\n\nDEBIAN                                    Debian Utilities                                DEBUILD(1)",
            "subsections": []
        }
    },
    "summary": "debuild - build a Debian package",
    "flags": [
        {
            "flag": "",
            "long": "--preserve-env",
            "arg": null,
            "description": "Do not clean the environment, except for PATH. --preserve-envvar=var, -evar Do not clean the var variable from the environment. If var ends in an asterisk (\"*\") then all variables with names that match the portion of var before the asterisk will be preserved. --set-envvar=var=value, -evar=value Set the environment variable var to value and do not remove it from the environment. --prepend-path=value Once the normalized PATH has been set, prepend value to it."
        },
        {
            "flag": "",
            "long": "--lintian",
            "arg": null,
            "description": "Run lintian after dpkg-buildpackage. This is the default behaviour, and it overrides any configuration file directive to the contrary."
        },
        {
            "flag": "",
            "long": "--no-lintian",
            "arg": null,
            "description": "Do not run lintian after dpkg-buildpackage."
        },
        {
            "flag": "",
            "long": "--no-tgz-check",
            "arg": null,
            "description": "Even if we're running dpkg-buildpackage and the version number has a Debian revision, do not check that the .orig.tar.gz file or .orig directory exists before starting the build."
        },
        {
            "flag": "",
            "long": "--tgz-check",
            "arg": null,
            "description": "If we're running dpkg-buildpackage and the version number has a Debian revision, check that the .orig.tar.gz file or .orig directory exists before starting the build. This is the default behaviour. --username username When signing, use debrsign instead of debsign. username specifies the credentials to be used. --foo-hook=hook Set a hook as described above. If hook is blank, this unsets the hook."
        },
        {
            "flag": "",
            "long": "--clear-hooks",
            "arg": null,
            "description": "Clears all hooks. They may be reinstated by later command line options. --check-dirname-level N See the above section Directory name checking for an explanation of this option. --check-dirname-regex regex See the above section Directory name checking for an explanation of this option."
        },
        {
            "flag": "-d",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-D",
            "long": null,
            "arg": null,
            "description": ""
        }
    ],
    "examples": [
        "To build your own package, simply run debuild from inside the source  tree.   dpkg-buildpack‐‐",
        "age(1) options may be given on the command line.",
        "The  typical  command  line  options  to build only the binary package(s) without signing the",
        ".changes file (or the non-existent .dsc file):",
        "debuild -i -us -uc -b",
        "Change the -b to -S to build only a source package.",
        "An example using lintian to check the resulting packages and passing options to it:",
        "debuild --lintian-opts -i",
        "Note the order of options here: the debuild options come first,  then  the  dpkg-buildpackage",
        "ones,  then  finally  the  checker options.  (And lintian is called by default.)  If you find",
        "yourself using  the  same  dpkg-buildpackage  options  repeatedly,  consider  using  the  DE‐‐",
        "BUILDDPKGBUILDPACKAGEOPTS configuration file option as described above.",
        "To  build  a package for a sponsored upload, given foobar1.0-1.dsc and the respective source",
        "files, run something like the following commands:",
        "dpkg-source -x foobar1.0-1.dsc",
        "cd foobar-1.0",
        "debuild -k0x12345678",
        "where 0x12345678 is replaced by your GPG key ID or other key identifier such  as  your  email",
        "address.  Again, you could also use the DEBUILDDPKGBUILDPACKAGEOPTS configuration file op‐",
        "tion as described above to avoid having to type the -k option each time you  do  a  sponsored",
        "upload."
    ],
    "see_also": [
        {
            "name": "chmod",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/chmod/1/json"
        },
        {
            "name": "debsign",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/debsign/1/json"
        },
        {
            "name": "dpkg-buildpackage",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dpkg-buildpackage/1/json"
        },
        {
            "name": "dpkg-checkbuilddeps",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dpkg-checkbuilddeps/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": "su",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/su/1/json"
        },
        {
            "name": "sudo",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/sudo/1/json"
        },
        {
            "name": "super",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/super/1/json"
        },
        {
            "name": "devscripts.conf",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/devscripts.conf/5/json"
        },
        {
            "name": "dpkg-statoverride",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/dpkg-statoverride/8/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Build a Debian package from source.",
        "examples": [
            {
                "description": "Build the package in the current directory",
                "command": "debuild"
            },
            {
                "description": "Build a binary package only",
                "command": "debuild -b"
            },
            {
                "description": "Do not run lintian after building the package",
                "command": "debuild --no-lintian"
            }
        ]
    }
}