eclipse-archived / packagedrone

Eclipse Package Drone
http://eclipse.org/package-drone
Eclipse Public License 1.0
66 stars 39 forks source link

Support for long package names (longer than 66 bytes) #136

Closed dertseha closed 5 years ago

dertseha commented 5 years ago

Using the library as part of ctron/rpm-builder, I came across an exception Name exceeds 66 bytes from RpmWriter.writeLead(). While the RPM lead allows for (encoded) names only up to 66 bytes, it is possible to store longer names in RPMs using tags. See: http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html

After some cursory investigation, here some ideas on how to address this: a) Handled within this library: Investigating how the lead is being created, LeadBuilder.build() creates a Lead instance based on RpmLead.toLeadName(). Either the builder, or possibly the toLeadName() function, should truncate the string. Though, since this is before charset encoding (happening in RpmWriter.writeLead()), this might not be the best place. Perhaps simply truncate the (encoded) name in RpmWriter.writeLead() instead of throwing an exception; And somewhere the RpmTag.NAME is filled. (I know too little of the responsibilities of builder, writer, ... at this point.)

b) Handled within user-library: Should ctron/rpm-builder pass in a truncated name and provide a header customizer in RpmBuilder that sets the RpmTag.NAME element?

I'd vote for a solution within this library, as b) would require the knowledge of the internal limitations of the data structures, as well as causing duplication in all using code...

How to address this?

ctron commented 5 years ago

I agree, a) should be the solution.

Now what happens to the name in the lead section? Will it simply be truncated?

dertseha commented 5 years ago

Hello there and thank you for your answer.

I looked at some long-named RPMs that I created with rpmbuild. The name field in the lead is simply truncated. If the encoded name would take 100 bytes, only 65 are taken from that, and the last byte is 0x00 in the lead.

ctron commented 5 years ago

Ok ... I guess this should be a quick change.

Do you want to do that?

dertseha commented 5 years ago

Thank you for the offer. My mind would be currently willing, though other factors hinder me right now (avoiding TMI). I could do it, would take some time (hopefully measured in days), and I'd need a pointer where the tag should be set (which class is responsible for doing that?)

ctron commented 5 years ago

Well, there is no hurry :grin: …

I think the first thing to do is to limit the number of bytes written in the method org.eclipse.packagedrone.utils.rpm.build.RpmWriter.writeLead(). However you need to take into account the number of bytes (vs chars). So I guess writing a specific method, returning no more than 66 bytes would be the right thing. Including a unit test, testing for multi byte UTF-8 cases. And removing the exception, of course.

And that should be about is, as the name is already put into the tags: https://github.com/eclipse/packagedrone/blob/3869c1643cdc6f7cb8b26097a7b6994683b13d7e/bundles/org.eclipse.packagedrone.utils.rpm/src/org/eclipse/packagedrone/utils/rpm/build/RpmBuilder.java#L817

dertseha commented 5 years ago

To give an update: The company I'm working in is still checking their legal stuff regarding the contribution guidelines. It'll be longer than a few days as initially thought :/

ctron commented 5 years ago

No worries, I am currently in the process of migrating the RPM code to a new Eclipse project (Eclipse Packager) which should be the home of stuff creating software packages, which would be RPM and APT.

So I will need a little bit of time myself to do that, but when it is done, it should be a much simpler project structure and should make it much easier to provide and test a PR.

dwalluck commented 5 years ago

Added to eclipse packager https://github.com/eclipse/packager/pull/1