-
-
Notifications
You must be signed in to change notification settings - Fork 11k
Update OpenSSL Copyright statements automatically using a bash script #5027
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
Conversation
|
The build failure of the clang Travis job seems to be unrelated: |
|
The Travis error is a Travis glitch. I've restarted that particular build, just to make sure |
|
This isn't quite the right approach... Files should get their copyright year range updated for sure... when there is an actual change in said file. Changing the whole source in one big swoop isn't the approach we've followed so far. However, it's true that it's easy to forget to do those updates manually whenever (I just realised I've forgotten in recent changes I've made)... so we should probably have something that reminds us we need to do this, or that possibly does it for us on changed files every time we commit. I haven't looked much into the webhooks possibilities for github, but that could be one way... |
Maybe you are right about the bulk changes. In this case, feel free to close the PR. But similar arguments can be applied against your alternative approach of automatically updating the copyright note on a change. It forces unrelated diffs into a patch set and misuses the copyright note as a last-modification-marker. It creates unnecessary "diff noise", reminiscent of the good old So I doubt this alternative would be better. Maybe the best solution would have been to add a 'timeless' end marker such as "Copyright 1995-20xx" wich does not have to be updated. But I don't know whether this form is legally allowed. The last alternative would be to simply leave everything as it is and simply ignore outdated years. ;-) |
|
Technically changing the copyright date is a change ... so all options are open - but we really should decide (and record) what we actually mean to do for this circumstance. |
|
Personally, I prefer a single separate commit doing a complete update. But it‘s a matter of taste and the OMC is free to choose its preferred method. |
|
I can also offer to just contribute the script and discard the second commit, such that the actual copyright change can be carried out by an OMC member. |
|
@t-j-h while I agree with you, it becomes a bit silly to update the year range just because we... update the year range (and looking at it the other way around, to make a change of year range just so we can update the year tange feels equally absurd). Wouldn't you say? |
|
It seems to me that when a file is changed, the copyright should be changed; that should be easy to verify in a commit hook. IBM's policy was small changes did not justify a copyright change. IBM takes copyright and patents and licenses very seriously and has many lawyers. |
Which would make sense for us as well for anything that's deemed "legally trivial" (i.e. non-copyrightable) |
|
Sorry for breaking loose such a fundamental discussion. I just thought my script might be useful. I will step back for the moment and await your decision. |
|
Don't apologize!! You brought up something that's important that we haven't thought about. Thanks for doing this. |
Having a commit hook that updates the license year is easy. But distinguishing a trivial from a non-trivial commit automatically is not so easy. I assume you have some helper scripts to add these „reviewed-by“ and „merged from“ annotations to the final commits. Maybe one could add support for updating the license there? |
|
Suggestion : not trivial when there is more than 3, 5 or 8 line of diff in a file ? |
Wellll, we have our
Yes. It's addrev, which relies on gitaddrev Something similar could definitely be done for copyright notices, as you suggest. |
util/openssl-update-copyright
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you use bashisms, this should be #!/bin/bash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#!/bin/bash is not portable; how about /usr/bin/env bash?
util/openssl-update-copyright
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be remade so the default is to get file names on the command line, but that --all will give all files? I'm guessing a poor man's implementation could be something like this:
if [ "$1" = "--all" ]; then
set -- $(grep -rlE "Copyright ${some_year}.*The OpenSSL Project" "$ossldir")
fi
for f in "$@"; do
|
I'm thinking that the script itself has value regardless, and would rather have a review and approval of that alone. |
|
... which means I'd like to see the bulk copyright change commit removed from this PR ;-) |
|
Ok, agreed. Just give me some hours. |
Nope, things are not that simple. People who already have signed a CLA. don’t add these „CLA: trivial“ markers. (And IMHO they are an ugly workaround) |
|
D'oh. You're right, of course... |
No problem. |
usage: openssl-update-copyright [-h|--help] [file|directory] ... Updates the year ranges of all OpenSSL copyright statements in the given files or directories. (Directories are traversed recursively.) Only copyright statements containing the string 'The OpenSSL Project' are affected. The copyright time range is adjusted to include the current year. If only a single year was specified, it is replaced by a time range starting at that year and ending at the current year. All '(c)' and '(C)' signs are preserved. Signed-off-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
bfdab62 to
473650f
Compare
|
Removed the bulk copyright update and reworked the script. Instead of adding an from the OpenSSL source directory. |
|
Once again, Travis did not find its Makefile: https://travis-ci.org/openssl/openssl/jobs/326192727 |
| if [ -f "$arg" ]; then | ||
| sed -i "s/${search}/${replace}/g" "$arg" | ||
| elif [ -d "$arg" ]; then | ||
| find "$arg" -name '.[a-z]*' -prune -o -type f -exec sed -i "s/${search}/${replace}/g" {} + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's that + at the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plus terminates the -exec command and is an alternative to the semicolon (which is generally quoted as \;) . The difference is that instead of calling one instance of sed for every path argument, the args are gathered at {} in xargs-style. See 'man find'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it's almost the same like find .... | xargs, but it doesn't suffer the space-in-path problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not used to +, but am used to print0. But since it only matters for our build platforms, I'm okay with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was that an approval, @richsalz? Make it official, then
util/openssl-update-copyright
Outdated
| @@ -0,0 +1,58 @@ | |||
| #!/bin/bash | |||
| # | |||
| # Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact: wrong copyright year in the copyright script: It should be 2018 instead of 2015-2018. (Header was copy&pasted from openssl-format-source). Will be fixed.
|
@levitte will you do the autosquashing when it's going to be merged, or shall I do it right now? |
|
I can do it. However, this needs a second review and approval... |
richsalz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, thought i had approved.
|
That's all right ;-) Merged. b26d696 |
usage: openssl-update-copyright [-h|--help] [file|directory] ... Updates the year ranges of all OpenSSL copyright statements in the given files or directories. (Directories are traversed recursively.) Only copyright statements containing the string 'The OpenSSL Project' are affected. The copyright time range is adjusted to include the current year. If only a single year was specified, it is replaced by a time range starting at that year and ending at the current year. All '(c)' and '(C)' signs are preserved. Signed-off-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from #5027)
|
Thanks for reviewing! |
| ;; | ||
| *) | ||
| if [ -f "$arg" ]; then | ||
| sed -i "s/${search}/${replace}/g" "$arg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This form of sed -i expression with no extension for a backup file is something of a GNU-ism, and is not necessarily portable to BSD sed.
This is probably not a fatal flaw, since this is expected to be a maintainer-only tool and we can deal with it; I just wanted to note the nonportability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I googled it, the only way to satisfy GNU and BSD sed is to add the backup extension without a space, like -i.bak, right?
It's a pity that your comments came too late for this PR. If the two portability issues (this one and the shebang line) disturb you then feel free to change them, I won't mind. Since I don't have a BSD system lying around, I can't test it myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's right about -i.bak, yes.
But I do not plan to submit a follow-up; so far as I know all the people who might need to run this script have access to a system where it should work without modification.
This PR consists of two commits: The first one adds a helper script for updating the years of all OpenSSL copyright statements, the second commit is the result of executing it.
Add util/openssl-update-copyright shell script
Updates the year ranges of all OpenSSL copyright statements such that it ends at the current year. If only a single year was given, that year is converted to a range. Any
(c)and(C)signs are preserved.To update the copyright statements for all source files, run the shell script
with no arguments.
Update all OpenSSL Copyright statements to 2018
Automatically converted by the shell script
./util/openssl-update-copyright