Bug#964909: Bug#954827: dh-make-perl: please install packages using apt instead of dpkg -i when possible

Paul Wise pabs at debian.org
Sun Jul 12 00:53:36 BST 2020


Control: retitle 964909 dh-make-perl: add support for installing with aptitude & dpkg -i and/or allow to set installation tool

On Sun, 2020-07-12 at 00:58 +0200, gregor herrmann wrote:

> I agree that "apt-get install" makes more sense than "dpkg -i"
> because of dependencies, and I've changed this in git now.

Thanks.

I'd like to suggest a few more fixes to this:

I see this uses the shell instead of exec because you are passing a
string instead of a list to system(). If the install_package function
ever gets passed a filename containing shell metacharacters, weird
things will happen.

When sudo isn't installed, the code will fail. I'd suggest also
allowing to use pkexec or su where possible. Here is some Python code
to do this. It takes an array and returns an array. You can use the
Perl File::Which module to replace the Python which function and the
Perl String::ShellQuote shell_quote function to replace the Python
shlex.quote function.

def root_cmd(cmd):
    if which('sudo'):
        return ['sudo'] + cmd
    elif which('pkexec'):
        return ['pkexec'] + cmd
    elif which('su'):
        return 'su -c'.split() + [' '.join([shlex.quote(arg) for arg in cmd])]
    else:
        return None

> I'm cloning the bug for the further possible change to add support
> for aptitude or for selecting tools etc.

There is probably still scope for using `dpkg -i` in some situations,
so I've retitled the bug to include that.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://alioth-lists.debian.net/pipermail/pkg-perl-maintainers/attachments/20200712/0bd8492f/attachment-0002.sig>


More information about the pkg-perl-maintainers mailing list