Skip to content

Conversation

@mspncp
Copy link
Contributor

@mspncp mspncp commented Jan 7, 2018

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

 ./util/openssl-update-copyright

with no arguments.

Update all OpenSSL Copyright statements to 2018

Automatically converted by the shell script ./util/openssl-update-copyright

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2018

The build failure of the clang Travis job seems to be unrelated:

$ if $make; then echo -e '+\057\057\057 MAKE OK'; else echo -e '+\057\057\057 MAKE FAILED'; false; fi;
make: *** No targets specified and no makefile found.  Stop.
+/// MAKE FAILED
The command "if $make; then echo -e '+/// MAKE OK'; else echo -e '+/// MAKE FAILED'; false; fi;" exited with 1.

https://travis-ci.org/openssl/openssl/jobs/325932772

@levitte
Copy link
Member

levitte commented Jan 7, 2018

The Travis error is a Travis glitch. I've restarted that particular build, just to make sure

@levitte
Copy link
Member

levitte commented Jan 7, 2018

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...

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2018

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.

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 $Id$ Markers of RCS/CVS.

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. ;-)

@t-j-h
Copy link
Member

t-j-h commented Jan 7, 2018

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.

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2018

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.

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2018

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.

@levitte
Copy link
Member

levitte commented Jan 7, 2018

@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?

@richsalz
Copy link
Contributor

richsalz commented Jan 7, 2018

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.

@levitte
Copy link
Member

levitte commented Jan 7, 2018

IBM's policy was small changes did not justify a copyright change.

Which would make sense for us as well for anything that's deemed "legally trivial" (i.e. non-copyrightable)

@mspncp mspncp mentioned this pull request Jan 7, 2018
1 task
@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2018

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.

@richsalz
Copy link
Contributor

richsalz commented Jan 7, 2018

Don't apologize!! You brought up something that's important that we haven't thought about.

Thanks for doing this.

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2018

that should be easy to verify in a commit hook.

IBM's policy was small changes did not justify a copyright change.

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?

@FdaSilvaYY
Copy link
Contributor

Suggestion : not trivial when there is more than 3, 5 or 8 line of diff in a file ?

@levitte
Copy link
Member

levitte commented Jan 7, 2018

But distinguishing a trivial from a non-trivial commit automatically is not so easy.

Wellll, we have our CLA: trivial commit message line, so in our case, it's actually very easy to detect ;-)

I assume you have some helper scripts to add these „reviewed-by“ and „merged from“ annotations to the final commits.

Yes. It's addrev, which relies on gitaddrev
(and we have a git hook on our server that controls that the reviewer lines are valid or that there is a CLA: trivial, for each pushed commit)

Something similar could definitely be done for copyright notices, as you suggest.

Copy link
Member

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

Copy link
Contributor

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?

Copy link
Member

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

@levitte
Copy link
Member

levitte commented Jan 7, 2018

I'm thinking that the script itself has value regardless, and would rather have a review and approval of that alone.

@levitte
Copy link
Member

levitte commented Jan 7, 2018

... which means I'd like to see the bulk copyright change commit removed from this PR ;-)

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2018

Ok, agreed. Just give me some hours.

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2018

Wellll, we have our CLA: trivial commit message line, so in our case, it's actually very easy to detect ;-)

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)

@levitte
Copy link
Member

levitte commented Jan 7, 2018

D'oh. You're right, of course...

@levitte
Copy link
Member

levitte commented Jan 7, 2018

Ok, agreed. Just give me some hours.

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>
@mspncp mspncp force-pushed the pr-openssl-update-copyright branch from bfdab62 to 473650f Compare January 8, 2018 00:52
@mspncp
Copy link
Contributor Author

mspncp commented Jan 8, 2018

Removed the bulk copyright update and reworked the script.

Instead of adding an --all option, I added support for recursing directories automatically. So in order to update the copyright statements for all source files, run the shell script

    util/openssl-update-copyright .

from the OpenSSL source directory.

@mspncp
Copy link
Contributor Author

mspncp commented Jan 8, 2018

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" {} +
Copy link
Member

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?

Copy link
Contributor Author

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'.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, thanks

Copy link
Contributor

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.

Copy link
Member

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

@@ -0,0 +1,58 @@
#!/bin/bash
#
# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
Copy link
Contributor Author

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.

@mspncp
Copy link
Contributor Author

mspncp commented Jan 8, 2018

@levitte will you do the autosquashing when it's going to be merged, or shall I do it right now?

@levitte
Copy link
Member

levitte commented Jan 8, 2018

I can do it.

However, this needs a second review and approval...

@levitte levitte added the approval: review pending This pull request needs review by a committer label Jan 8, 2018
Copy link
Contributor

@richsalz richsalz left a 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.

@levitte
Copy link
Member

levitte commented Jan 8, 2018

That's all right ;-)

Merged. b26d696

@levitte levitte closed this Jan 8, 2018
levitte pushed a commit that referenced this pull request Jan 8, 2018
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)
@levitte levitte added branch: master Applies to master branch and removed approval: review pending This pull request needs review by a committer labels Jan 8, 2018
@mspncp mspncp deleted the pr-openssl-update-copyright branch January 8, 2018 14:11
@mspncp
Copy link
Contributor Author

mspncp commented Jan 8, 2018

Thanks for reviewing!

;;
*)
if [ -f "$arg" ]; then
sed -i "s/${search}/${replace}/g" "$arg"
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@mspncp mspncp restored the pr-openssl-update-copyright branch January 9, 2018 15:57
@mspncp mspncp deleted the pr-openssl-update-copyright branch January 9, 2018 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants