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

Workaround for python3-debian bug about collecting control file #7215

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion python/uyuni/common/rhn_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import tempfile

from debian import debfile
from debian.deb822 import Deb822

from uyuni.common.usix import raise_with_tb
from uyuni.common import checksum
Expand All @@ -34,6 +35,25 @@

class deb_Header:

# this is a workaround for issue in python-debian
# https://www.mail-archive.com/pkg-python-debian-maint@alioth-lists.debian.net/msg00598.html
# after the issue is fixed, remove this function
def get_file(self, control, fname):
if fname.startswith('./'):
fname = fname[2:]
elif fname.startswith('/'):
fname = fname[1:]

try:
fobj = control.tgz().extractfile(fname)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only potential problem I see that at least Debian 11 is using control.tar.xz inside deb files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing it! I think it should be able to open also tar xz files https://salsa.debian.org/python-debian-team/python-debian/-/blob/master/lib/debian/debfile.py?ref_type=heads#L159

    def tgz(self):
        # type: () -> tarfile.TarFile
        """Return a TarFile object corresponding to this part of a .deb
        package.

        Despite the name, this method gives access to various kind of
        compressed tar archives, not only gzipped ones.
        """

I'll try to sync some debian 11 deb and see what happens

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe they just confusing with the method name. But it's better to double check for sure. Thanks for taking care of it 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vzhestkov , Is control.tar.xz in all Debian 11 packages ? I'm not sure how to check it, but I tried to sync https://deb.nodesource.com/node_18.x/dists/bullseye/main/binary-amd64/
and the changes worked as expected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I extracted the deb package and it has control.tar.gz..do you know some repo with packages with control.tar.xz ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking 👍

except KeyError:
raise debfile.DebError("control.tar.* not found inside package")

if fobj is None:
raise debfile.DebError("control.tar.* not found inside package")

return fobj

"Wrapper class for an deb header - we need to store a flag is_source"

def __init__(self, stream):
Expand All @@ -50,7 +70,14 @@ def __init__(self, stream):

try:
# Fill info about package
debcontrol = self.deb.debcontrol()
try:
debcontrol = self.deb.debcontrol()
except debfile.DebError:
# this is a workaround for issue in python-debian
# https://www.mail-archive.com/pkg-python-debian-maint@alioth-lists.debian.net/msg00598.html
debcontrol = Deb822(self.get_file(self.deb.control, 'control'))


self.hdr = {
'name': debcontrol.get_as_string('Package'),
'arch': debcontrol.get_as_string('Architecture') + '-deb',
Expand Down
1 change: 1 addition & 0 deletions python/uyuni/uyuni-common-libs.changes.mbussolotto.fix_deb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Workaround for python3-debian bug about collecting control file (bsc#1211525, bsc#1208692)