Replace rpmbuild dependency with new rpmwriter module#1005
Replace rpmbuild dependency with new rpmwriter module#1005giuseppe wants to merge 7 commits intoprojectatomic:masterfrom
Conversation
|
@cgwalters @baude this is the WIP for replacing rpmbuild, I need to add tests |
464c98a to
bc385e9
Compare
|
I've adapted the tests to work with the new module. There are quite a few tests to cover the rpm generation. Dropping the WIP and ready for review |
|
The CI failure is unrelated to the PR |
|
|
Related: ostreedev/ostree#859 |
bc385e9 to
d2bca31
Compare
|
rebased on master so that the storage test is disabled ⬆️ |
|
How did you come up with Down the line...I'd like to change things so that the "synthesize an RPM" code lives in For now though this seems pretty sane to me. |
|
@cgwalters I've used the documentation here as a starting point: http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html I got stuck a few times so I added more debug messages to |
Atomic/rpmwriter.py
Outdated
| RPMTAG_REQUIRENAME = 1049 | ||
| RPMTAG_REQUIREVERSION = 1050 | ||
| RPMTAG_CONFLICTFLAGS = 1053 | ||
| RPMTAG_CONFLICTNAME = 1054 |
There was a problem hiding this comment.
micro nit. You've an extra tab it looks like between the variable and the equals for a few of these definitions. I personally like this style and would ask that you do the same for the group of variables above too (lines 40->62)
There was a problem hiding this comment.
I've pushed a fixup patch to use the same style for all variables
Atomic/rpmwriter.py
Outdated
|
|
||
| def add_header(self, tag, typ, count, value, pad=1): | ||
| try: | ||
| # this fails on python3 |
There was a problem hiding this comment.
Should a TODO comment be added to fix in python3?
There was a problem hiding this comment.
no, this is the desired behavior. The try inhibits the exception to be raised as there is no unicode in python3
There was a problem hiding this comment.
Ah, I read it to mean you were having unexpected issues here. Perhaps change the comment to something like:
"The next line is expected to always fail under python3, in that case just continue."
or something similar. Another nit, not a hold the merge comment.
| @@ -0,0 +1,369 @@ | |||
| import os | |||
There was a problem hiding this comment.
Do you need to have a shebang here declaring the version of python you're supporting? Perhaps:
#!/usr/bin/env python2
Given your python3 issue noted below?
There was a problem hiding this comment.
atomic must support both versions. On RHEL we have python2, on Fedora python3
There was a problem hiding this comment.
Sounds good, I misunderstood your comment on the python3 failure. Given that it would stlll be good to have some kind of shebang statement at the top of the file. Perhaps:
#!/usr/bin/env python
But certainly not a comment to hold the merge for.
There was a problem hiding this comment.
What's the point of having shebang if the file is not meant to be run directly?
3dafbd5 to
637647f
Compare
Atomic/rpm_host_install.py
Outdated
| rpm_name = "atomic-container-%s" % name | ||
| rpm_out = os.path.join(result_dir, "%s.rpm" % rpm_name) | ||
| def split_name_version(pkg): | ||
| r = r"([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-\._\+]+)(.*)" |
There was a problem hiding this comment.
nit: This regex could be shortened to ([a-zA-Z0-9_\-\.\+]+)(.*)
There was a problem hiding this comment.
thanks, pushed a fixup patch.
Atomic/rpm_host_install.py
Outdated
| rpm_file = RPMHostInstall.find_rpm(rpm_root) | ||
| if rpm_file: | ||
| dest_path = os.path.join(destination, "container.rpm") | ||
| orig_name = "atomic-container-%s.rpm" % name |
There was a problem hiding this comment.
nit: I recommend using {} and format with string formatting unless there is a need to hold compatibility with very old Python versions.
There was a problem hiding this comment.
change included in the fixup patch
| def add_conflict(self, name, version): | ||
| self.conflict.append([name, version]) | ||
|
|
||
| def __init__(self, out, root, name, version, release, summary='', description='', license_='gpl2', changelog='', url='', group='', stderr=sys.stderr, whitelist=None): |
There was a problem hiding this comment.
I ❤️ GPL but why default to gpl2 if no license is provided?
There was a problem hiding this comment.
rpm complains if no license is specified, so I've just used the same license of atomic itself
637647f to
271ebdb
Compare
|
LGTM, assuming happy test results. Thanks for the nit touch ups. |
|
@rhatdan what do you think of this change? |
|
@giuseppe Can this handle dependencies? IE Can I build a "spec" file that says it requires "foobar" package be installed? |
|
@rhatdan the rpmwriter doesn't use a spec file to build the
We support: I'll document this once the PR looks fine. |
| # The complete list is available here: | ||
| # https://github.com/rpm-software-management/rpm/blob/master/lib/rpmtag.h | ||
|
|
||
| class RpmWriter(object): |
There was a problem hiding this comment.
My opinion is that this module should be a separate project. If you look at it, it's not tight to atomic in any way. I think that plenty of other users and projects could benefit from a lightweight and friendler user-experience interaction with rpm builds. Even further, it would be awesome if rpm team reviewed this piece of code and ack'd it.
There was a problem hiding this comment.
We're not building here though. More like just repacking binaries. What other use cases are there where one isn't using a spec file? Or without wanting a dependency on rpmbuild?
There was a problem hiding this comment.
I've created a separate repository here: https://github.com/giuseppe/tinyrpmbuild, if someone is really interested in it.
I agree with @cgwalters, this is not a replacement for rpmbuild, it is really implementing the minimum necessary to get an installable .rpm file. Not sure how many other users will have the same requirement of building an .rpm on the fly without using rpmbuild.
| def try_read(stdout, gzip_out): | ||
| written = 0 | ||
| while True: | ||
| readable, _, _ = select.select([stdout], [], [], 0) |
There was a problem hiding this comment.
Wow, is select needed here? I would assume that simple pipe with reads and writes is just enough.
There was a problem hiding this comment.
I want it to not block on _try_read, just read as much as it is available. In this way I can feed more data to the cpio process through cpio_process.stdin.write(filename.encode() + b"\n")
| import shutil | ||
|
|
||
| # More information on the RPM file format can be found here: | ||
| # http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html |
There was a problem hiding this comment.
Is this spec backwards and forward compatible?
|
🙀 |
|
🔒 Merge conflict |
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: projectatomic#981 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Since we don't use it anymore, run all the tests Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
271ebdb to
be51f9c
Compare
|
@baude thanks for the r+, I've manually fixed the conflicts with the fixup patches. Pushed a new version ⬆️ |
|
@rh-atomic-bot retry |
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1005 Approved by: rhatdan
Since we don't use it anymore, run all the tests Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1005 Approved by: rhatdan
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1005 Approved by: rhatdan
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1005 Approved by: rhatdan
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1005 Approved by: rhatdan
|
☀️ Test successful - status-redhatci |
Description
Replace rpmbuild dependency with a simpler module to write directly an RPM file.
We lose the capability of building an RPM from a spec file, but this was really an over-engineered solution, so better drop it before it is too late.
Users who want a more complex RPM file, then they must provide it as part of the image itself '/exports/container.rpm'
Related Issue Numbers
#981