(debian-policy.info)debian/rules and Rules-Requires-Root


Prev: debian/rules and DEB_BUILD_OPTIONS Up: Main building script debian/rules
Enter node , (file) or (file)node

4.9.2 ‘debian/rules’ and ‘Rules-Requires-Root’
----------------------------------------------

Depending on the value of the Note: Rules-Requires-Root. field, the
package builder (e.g.  dpkg-buildpackage) may run the ‘debian/rules’
target as an unprivileged user and provide a ‘gain root command’.  This
command allows the ‘debian/rules’ target to run particular subcommands
under (fake)root.

The ‘gain root command’ is passed to the build script via the
‘DEB_GAIN_ROOT_CMD’ environment variable.  The contents of this variable
is a space separated list, the first entry of which is the command, and
the proceeding entries of which are arguments to the command.  The ‘gain
root command’ must be available via PATH. The ‘gain root command’ must
not rely on shell features because it will not necessarily be invoked
via a shell.

The ‘gain root command’ must not run interactively, including prompting
for any user input.  It must be possible to prepend the ‘gain root
command’ to an existing command and its arguments, without needing to
alter or quote the existing command and its arguments.  Furthermore, the
‘gain root command’ must preserve all environment variables without the
caller having to explicitly request any preservation.

The following are examples of valid gain root commands (in syntax of
sh), assuming the tools used are available and properly configured:

     # Command "sudo", with arguments "-nE" and "--"
     export DEB_GAIN_ROOT_CMD='sudo -nE --'
     # Command "fakeroot" with the single argument "--"
     export DEB_GAIN_ROOT_CMD='fakeroot --'

Examples of valid use of the ‘gain root command’:

     # sh-syntax (assumes set -e semantics for error handling)
     $DEB_GAIN_ROOT_CMD some-cmd --which-requires-root

     # perl
     my @cmd = ('some-cmd', '--which-requires-root');
     unshift(@cmd, split(' ', $ENV{DEB_GAIN_ROOT_CMD})) if $ENV{DEB_GAIN_ROOT_CMD};
     system(@cmd) == or die("@cmd failed");


automatically generated by info2www version 1.2.2.9