python3.4 breaks installing deb files

Bug #1306543 reported by Kiwinote
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
App Grid
Fix Released
Undecided
Unassigned
Aptdaemon
New
Undecided
Unassigned
python-apt (Ubuntu)
Confirmed
Undecided
Unassigned
software-center (Ubuntu)
Fix Released
Critical
Unassigned

Bug Description

[If you're facing this issue, please use bug 1290228 , so that we can use this bug for the implementation of the fix - thanks!]

Steps to reproduce:
- run trusty (updated sometime in the last ~month)
- open ?any? deb file with an aptdaemon client (software-center, appgrid, etc)
- installation will fail (bug 1290228 etc)

After trailing through aptdaemon and python-apt code it seems that there might be multiple manifestations of this bug
python-apt: progress/base.py: InstallProgress.run()
>>> os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", str(self.write_stream.fileno()), "-i", obj))
aptdaemon: progress.py: DaemonDpkgInstallProgress._child()
>>> args = [apt_pkg.config["Dir::Bin::DPkg"], "--status-fd", str(self.status_child_fd)] #(...)
>>> os.execlp(apt_pkg.config["Dir::Bin::DPkg"], *args)
I think there are likely to be other points of failure too.

Noteworthy is the following:
pgg@four:~$ sudo python3.4 -c "import os; (statusfd, writefd) = os.pipe(); write_stream = os.fdopen(writefd, 'w'); print(write_stream.fileno()); r = os.execlp('/usr/bin/dpkg', '/usr/bin/dpkg', '--status-fd', str(write_stream.fileno()), '-i', '/home/pgg/Downloads/appgrid_0.1.100~trusty_all.deb'); print(r)"
4
dpkg: error: unable to read filedescriptor flags for <package status and progress file descriptor>: Bad file descriptor

pgg@four:~$ sudo python3.3 -c "import os; (statusfd, writefd) = os.pipe(); write_stream = os.fdopen(writefd, 'w'); print(write_stream.fileno()); r = os.execlp('/usr/bin/dpkg', '/usr/bin/dpkg', '--status-fd', str(write_stream.fileno()), '-i', '/home/pgg/Downloads/appgrid_0.1.100~trusty_all.deb'); print(r)"
4
(Reading database ... 227994 files and directories currently installed.)
Preparing to unpack .../appgrid_0.1.100~trusty_all.deb (etc, installs properly)

This lead me to http://legacy.python.org/dev/peps/pep-0446/ which means that file descriptors can't be inherited in python 3.4.

My knowledge of python-apt and aptdaemon isn't really good enough to know what the best way forward is to resolve this in the least disruptive and safest way, but it would be nice if people could install deb files in 14.04. I've subscribed a few people who might have ideas.

Revision history for this message
Barry Warsaw (barry) wrote : Re: [Bug 1306543] [NEW] python3.4 breaks installing deb files

On Apr 11, 2014, at 11:13 AM, Launchpad Bug Tracker wrote:

>dpkg: error: unable to read filedescriptor flags for <package status and
>progress file descriptor>: Bad file descriptor

In Python 3.4, file descriptors are not inherited by child processes by
default. You need to use os.set_inheritable().

https://docs.python.org/3/library/os.html#fd-inheritance

Revision history for this message
Kiwinote (kiwinote) wrote :

Thanks for that info Barry! Looks like mvo has a fix over at https://code.launchpad.net/~aptdaemon-developers/aptdaemon/ubuntu-trusty

Revision history for this message
Mateusz Stachowski (stachowski-mateusz) wrote :

Looks like the newest aptdaemon (1.1.1-1ubuntu5) resolved this bug and bug 1290228.

I didn't have any problem with installing two external packages using Software Center.

pgg (pgg)
Changed in appgrid:
status: New → Fix Released
Changed in software-center (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-apt (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.