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

Feature verify flags #43

Merged
merged 8 commits into from
Sep 18, 2019
Merged

Feature verify flags #43

merged 8 commits into from
Sep 18, 2019

Conversation

OliverMatz
Copy link
Contributor

see ctron#42

Signed-off-by: Oliver Matz <oliver.matz@dataport.de>
Signed-off-by: Oliver Matz <oliver.matz@dataport.de>
Requires modifications from eclipse/packager#6

Fix for ctron#41.

Signed-off-by: Oliver Matz <oliver.matz@dataport.de>
Signed-off-by: Oliver Matz <oliver.matz@dataport.de>
Signed-off-by: Oliver Matz <oliver.matz@dataport.de>
Copy link
Owner

@ctron ctron left a comment

Choose a reason for hiding this comment

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

Only a few minor issues. But in general it looks good. Thank you!

I already changed the master branch to use 0.16.0, which is released now. So you might want to rebase.

@@ -0,0 +1,159 @@
package de.dentrassi.rpm.builder;
Copy link
Owner

Choose a reason for hiding this comment

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

Please add a license header.

private Boolean linkto;
private Boolean user;
private Boolean group;
private Boolean mtime;
Copy link
Owner

Choose a reason for hiding this comment

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

I would prefer more "human readable" fields here. As they would be visible in the documentation and POM file I assume.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These members and there corresponding bean properties correspond to the fields in the rpmVerifyFlags_e, see http://ftp.rpm.org/api/4.14.0/group__rpmvf.html. They also correspond to the rpm command line switches:
[--nolinkto] [--nofiledigest] [--nosize] [--nouser]
[--nogroup] [--nomtime] [--nomode] [--nordev]
[--nocaps]

I have just renamed the member md5 to fileDigest, as the corresponding command line switch --nofiledigest is now prefered against the obsolete --md5.
As far as the other names are concerned, I have no idea how to improve them.


/**
* @see EntryDetails#apply(org.eclipse.packager.rpm.build.FileInformation)
* @return true if at least one flag has been set.
Copy link
Owner

Choose a reason for hiding this comment

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

This method doesn't seem to return anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops. Fixed.

* See https://github.com/ctron/rpm-builder/issues/41
*/
public final class VerifyDetails {
private Boolean md5;
Copy link
Owner

Choose a reason for hiding this comment

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

Wouldn't it be easier to use a boolean here, and default to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I copied the pattern from de.dentrassi.rpm.builder.EntryDetails. I assumed that there was some reason for that pattern?!
That pattern does have and issue though, see #42.
I am fine with changing the types in VerifyDetails it to primitive type boolean if you say so, but then what about EntryDetails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have just changed to the type to boolean and fixed silly javadoc warnings.

Copy link
Owner

Choose a reason for hiding this comment

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

Hm … interesting. The idea of EntryDetails was that it would override the current entry it processes. So if the value set, it will be set. If the value is "null" it will not change it.

Your original code is close to that, and now I understand what you had in mind.

I think it good to keep the Boolean, but change the "transfer" steps into a way, that they do process on the existing set. If I understand your code correctly, then this would provide the same behavior. If the entry is set, it will be applied (set or unset), if the value is "null", it won't change the flag.

Copy link
Contributor Author

@OliverMatz OliverMatz Sep 17, 2019

Choose a reason for hiding this comment

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

As far as the boolean flags in a bitmap are concerned, we do not have the option of "not changing" something. Either it is set or it is not. So the three values (null, true, false) will be mapped to two values (0,1). My cristisim for #42 is that for EntryDetails.readmy etc, that mapping is counterintuitive.

In this pull-request, there is one bitmap (org.eclipse.packager.rpm.build.RpmBuilder.FileEntry#verifyFlags).
In the old implementation, its value had the hard-coded value -1, so every flag was set.
My proposed change (or, rather, your proposal the way I understood it) is that the programmer has two options:

  1. He/she does not specify anything about verify-flags, then the behaviour is unchanged, all flags will be set and everthing will be verified; or
  2. He/she specifies a (possibly empty) list of those flags that shall be verified, then only those will be set in the bitmap and only the corresponding aspects will be verified.

Now it is not clear what exactly is meant by "if the value is 'null', it won't change the flag".

I am open to completely reconsider the question of how the programmer shall specify the verify-flags. It is a considerable idea to let the programmer specify a negative-list rather than a positive-list. This way, the default for each flag would be 'true' (or 1, respectively), and the user would specify the flags that shall be excluded from the bitmap.
However, while this might seem logical from the programmer's perspective, I consider it non-intuitive for the programmer.

BTW, I think that only very few combinations of these flags are relevant for practical purposes. If the user had to specify all flags to exclude if he/she wishes to exclude any, then this would IMHO severly complicate the usage.
My primary use-case (which is, in fact, the only one I can think of) is to customize the specification for configuration files. For such a file, the administrator of the target system may edit the file, which will change size, mtime, and digest at the same time.

So yet another approach to let the programmer specify the verify-flags would be to let him/her specify one of two or three bitmasks that actually make sense.

In conclusion: the current proposal (implemented with boolean rather than Boolean) is a reasonable approach, and for the sake of simplicitly I would favour to keep it that way.

Copy link
Owner

Choose a reason for hiding this comment

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

Hm, I see your point … so, you consider the set of flags an entity by itself.

For the entry details, the idea was that every step would have the possibility to contribute to the final file entry. So you could have a rule, which matches e.g. /etc/ and flags all of those files as "configuration". But doesn't set any other attributes of the file.

Now I could imagine that someone might want to do a similar thing with the verification flags. Then again, no one asked for that 😀

So just let me know if your are fine with the current state, and I will merge it.

Copy link
Contributor Author

@OliverMatz OliverMatz Sep 17, 2019

Choose a reason for hiding this comment

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

I am satisfied with the current state and would appreciate your merging.

Signed-off-by: Oliver Matz <oliver.matz@dataport.de>
@ctron
Copy link
Owner

ctron commented Sep 17, 2019

I just saw your change. Looks good to me. I only don't understand using Boolean vs boolean in the fields.

Signed-off-by: Oliver Matz <oliver.matz@dataport.de>
dadaistic javadoc to suppress warnings

Signed-off-by: Oliver Matz <oliver.matz@dataport.de>
@ctron ctron merged commit 6ce869e into ctron:master Sep 18, 2019
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.

2 participants