Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure device nodes can be parsed from contents #22

Merged
merged 1 commit into from Apr 25, 2020
Merged

Ensure device nodes can be parsed from contents #22

merged 1 commit into from Apr 25, 2020

Conversation

MrTam
Copy link
Contributor

@MrTam MrTam commented Apr 15, 2020

Hey @xolox !

Came across an issue parsing the contents of a package using deb_pkg_tools today. Packages which reference device nodes (granted odd and obscure but do exist), populate the size field of these nodes as their block device IDs in ls and dpkg-deb -c:

$ dpkg-deb -c libxenomai1_2.6.4-1_1jessie_1da_i386.deb
crw-r--r-- root/root     150,0 2015-12-07 16:40 ./dev/rtp0
crw-r--r-- root/root     150,1 2015-12-07 16:40 ./dev/rtp1
crw-r--r-- root/root     150,2 2015-12-07 16:40 ./dev/rtp2
crw-r--r-- root/root     150,3 2015-12-07 16:40 ./dev/rtp3
crw-r--r-- root/root     150,4 2015-12-07 16:40 ./dev/rtp4                                 

This causes a ValueError when attempting to coerce the parsed size value as an integer within the inspect_package_contents function:

>>> p.inspect_package_contents("libxenomai1_2.6.4-1_1jessie_1da_i386.deb")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tgibson/cloudsmith/.venv/lib/python3.8/site-packages/deb_pkg_tools/package.py", line 719, in inspect_package_contents
    size = int(fields[2])
ValueError: invalid literal for int() with base 10: '150,0'

Change below simply wraps the assignment and cast in a try/catch and ensures the size is reported zero. It's not quite correct that its zero sized, but it does allow for the cast, and ensures the types remain the same within the ArchiveEntry tuple for other users.

Let me know if you need anything else here.

Thanks!
Tom

@coveralls

This comment has been minimized.

1 similar comment
@coveralls

This comment has been minimized.

@xolox xolox merged commit aa3ce08 into xolox:master Apr 25, 2020
@xolox
Copy link
Owner

xolox commented Apr 25, 2020

Hi Tom and thanks for the contribution! I've merged your pull request and then decided to enhance inspect_package_contents() to properly parse device file type information (because throwing the information away while parsing didn't feel right). These changes are part of deb-pkg-tools 8.1 which was just released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants