Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
sources: Add RPM source #870
Conversation
|
Thanks for this! |
| @@ -2,6 +2,7 @@ configparser==3.5.0 | ||
| docopt==0.6.2 | ||
| file-magic==0.3.0 | ||
| jsonschema==2.5.1 | ||
| +libarchive-c==2.5 |
Conan-Kudo
Oct 19, 2016
Contributor
@elopio I ignored the debian/control file because I saw #834 pending. Should I still add python3-libarchive-c dependency to debian/control?
elopio
Oct 19, 2016
Member
Yes please. I think that your PR will land before mine, because I still have work to do on the snapcraft/debian branch.
| @@ -53,6 +53,7 @@ | ||
| install_requires=[ | ||
| 'pyxdg', | ||
| 'requests', | ||
| + 'libarchive-c', |
elopio
Oct 19, 2016
Member
I don't really understand which deps should be in install_requires and which should be in the requirements file.
Conan-Kudo
Oct 19, 2016
Contributor
Well, ideally, install_requires should be using requirements.txt. I wasn't sure what to do here...
|
El 19/10/16 a las 10:17, Neal Gompa (ニール・ゴンパ) escribió:
You want both https://packaging.python.org/requirements/ |
|
@sergiusens So, I did both in this case. I suppose a separate pull request is required to address the mismatch between |
Conan-Kudo
and others
added some commits
Oct 18, 2016
|
I don't understand why I could update the branch for your repo, but I just did! |
sergiusens
requested changes
Oct 30, 2016
Looks good, just two minor changes I would like to see here.
| + os.makedirs(dst) | ||
| + shutil.move(tmp_rpm, rpm_file) | ||
| + # Check if dst has a trailing slash and ensure it doesn't | ||
| + if dst.endswith('/'): |
| + for rpm_file_entry in rpm: | ||
| + # Binary RPM archive data has paths starting with ./ to support | ||
| + # relocation if enabled in the building of RPMs | ||
| + if rpm_file_entry.pathname.startswith('./'): |
sergiusens
Oct 30, 2016
•
Collaborator
This would be better to write as
rpm_file_entry.pathname = os.path.join(dst, rpm_file_entry.pathname.lstrip('./'))
sergiusens
Oct 30, 2016
Collaborator
Maybe then
rpm_file_path = rpm_file_entry.pathname.lstrip('./')
rpm_file_path = rpm_file_path.lstrip('/')
rpm_file_entry.pathname = os.path.join(dst, rpm_file_path)|
@sergiusens The reason you were able to do that is that GitHub silently launched a new feature that allows people to allow maintainers to manipulate the branch of a pull request. They activated it by default, and expect users to switch it off if it's not wanted. You'd see the flag at the bottom right corner of the pull request, under the (un)subscribe button. |
|
@elopio @sergiusens The only thing I'm missing is the unit test, but I'm not sure how to write it. I don't really understand what's going on in the |
|
@elopio mind helping @Conan-Kudo out? |
| + rpm_file_entrypath = rpm_file_entrypath.lstrip('/') | ||
| + rpm_file_entry.pathname = os.path.join(dst, rpm_file_entrypath) | ||
| + # A bug in libarchive somewhere causes it to crash when | ||
| + # attempting to have more than one item in the list |
Conan-Kudo
Nov 2, 2016
Contributor
I've just filed the bug with python-libarchive-c. Do you want me to mention it in the code itself?
elopio
Nov 2, 2016
•
Member
yes, please. Something like:
# XXX: A bug in libarchive ...
# Reported in https://github.com/Changaco/python-libarchive-c/issues/43
Conan-Kudo
Nov 2, 2016
Contributor
Done. Though apparently it's less of a bug and more undocumented limitation of libarchive, according to the author.
| + rpm_file_entry.pathname = os.path.join(dst, rpm_file_entrypath) | ||
| + # A bug in libarchive somewhere causes it to crash when | ||
| + # attempting to have more than one item in the list | ||
| + libarchive.extract.extract_entries([rpm_file_entry]) |
elopio
Nov 2, 2016
Member
I'm not quite sure I understand this.
Looking at the sourcecode ( https://github.com/Changaco/python-libarchive-c/blob/master/libarchive/extract.py#L42 ) it says that extract_entries extracts the files in the current directory.
How is it that changing pathname makes it extract in a different directory?
elopio
Nov 2, 2016
•
Member
extract_entries feels like internal to me. Is this a bad idea for some reason?
https://paste.ubuntu.com/23418276/
(it would need to be smarter about not using the abspath when the source is a url)
Conan-Kudo
Nov 2, 2016
Contributor
@elopio It's not really internal, but libarchive is a really raw library. This is the only way to alter the path to extract to an alternative base path, since libarchive assumes a "tar-like" extraction model (it follows the path associated with a blob blindly to write out data).
| +parts: | ||
| + rpm: | ||
| + plugin: dump | ||
| + source: small-0.1-1.noarch.rpm |
|
@Conan-Kudo I'm sorry it took so long to review your tests here. This is the kind of unit tests I would like to see:
The idea is that we make an rpm file with all the interesting details that might cause it to fail, and pull it. However, this is failing for me, I'm still a little lost in this libarchive. But does it make sense? |
|
ok, this one works: https://paste.ubuntu.com/23418469/ |
Conan-Kudo
and others
added some commits
Nov 2, 2016
|
Cheers |
|
@elopio So I'm not crazy and I didn't break it by not touching anything? |
Conan-Kudo
added some commits
Nov 4, 2016
| + # Binary RPM archive data has paths starting with ./ to support | ||
| + # relocation if enabled in the building of RPMs | ||
| + rpm_file_entrypath = rpm_file_entry.pathname.lstrip('./') | ||
| + rpm_file_entrypath = rpm_file_entrypath.lstrip('/') |
elopio
Nov 4, 2016
Member
Not crazy until proven otherwise :)
Thanks for adding the tests. I'm wondering about these two lines.
Is there a way to make libarchive.file_writer to include entries with ./ and / ?
sergiusens
Nov 4, 2016
Collaborator
This was my suggestion as it felt nice than what was originally there, I'd leave it as a TODO in any case.
|
One last error:
|
|
@sergiusens I'm not sure why this test is failing. I think I've written the test wrong, since the part of Rpm() class it is failing on is exactly the same as the Deb() class, and the corresponding test written for the Deb source works fine. |
| + | ||
| + rpm_source = sources.Rpm(rpm_file_path, dest_dir) | ||
| + rpm_source.provision(dst=dest_dir, keep_rpm=True) | ||
| + rpm_source.pull() |
elopio
Nov 4, 2016
Member
You shouldn't call pull after provision. That will result on provision being called twice.
|
Got it: http://paste.ubuntu.com/23432601/ |
|
Woo! All the tests pass! @sergiusens Does it look good to merge now? |
|
Actually we had a glitch in how we tested :-( (switched systems but managed to always trigger tests from PRs but ran on master) This is the status now:
|
|
@sergiusens I've pushed a fixup commit to switch to that. |
Conan-Kudo commentedOct 18, 2016
Signed-off-by: Neal Gompa ngompa13@gmail.com