dev-tools: Simple tool wihch automates rebasing LZ4 compat library
PATCH 1/1 dev-tools: Simple tool wihch automates rebasing LZ4 compat library
This tool depends on a cloned upstream LZ4 git repository and a checked out release tag. Then run the script like this:
$ ./dev-tools/lz4-rebaser.sh /path/to/lz4.git
To see the result before committing, use: git diff --cached
--- dev-tools/lz4-rebaser.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 dev-tools/lz4-rebaser.sh
dev-tools/lz4-rebaser.sh new file +69 -0
@@ -0,0 +1,69 @@ +#!/bin/sh +# lz4-rebaser.sh - Does the LZ4 rebase process in an automated fashion +# +# Copyright (C) 2017 David Sommerseth <[email protected]...> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# Basic shell sanity +set -eu + +# Simple argument control +if [ $# -ne 1 ]; then + echo "Usage: $0 <Path to upstream LZ4 source tree>" + exit 1 +fi + +# Check that we have the files we need before starting the rebase +LZ4_C="$1/lib/lz4.c" +LZ4_H="$1/lib/lz4.h" +if [ ! -r "$LZ4_C" -o ! -r "$LZ4_H" ]; then + echo "Could not locate $LZ4_H and/or $LZ4_C" + exit 1 +fi + +# Extract the upstream LZ4 commit base +lz4_tag="$(git --git-dir $1/.git tag --contains HEAD)" +lz4_commit="$(git --git-dir $1/.git rev-parse --short=20 HEAD)" + +# Do the rebase +srcroot="$(git rev-parse --show-toplevel)" +echo "* Copying upstream lz4.h to compat-lz4.h" +cp "$LZ4_H" "${srcroot}/src/compat/compat-lz4.h" + +echo "* Porting upstream lz4.c to compat-lz4.c" +{ + cat <<EOF +/* This file have been backported by $0 + * from upstream lz4 commit $lz4_commit ($lz4_tag) + */ +ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif + +#ifdef NEED_COMPAT_LZ4 +EOF + sed '/"lz4\.h"/s/\(#include "\)lz4\.h\("\+\)/\1compat-lz4.h\2/' "$LZ4_C" +cat <<EOF +#endif /* NEED_COMPAT_LZ4 */ +EOF +} > "${srcroot}/src/compat/compat-lz4.c" + +echo "* Running 'git add'" +git add src/compat/compat-lz4.[ch] +
Signature · 1 line
2.11.0
Hi,
Quoted 6 lines · David Sommerseth
This tool depends on a cloned upstream LZ4 git repository and a checked out release tag. Then run the script like this:
$ ./dev-tools/lz4-rebaser.sh /path/to/lz4.gitTo see the result before committing, use: git diff --cached
All willing to give this an ACK, alas, it's penguin-tainted :-) - read, won't work with a FreeBSD sed.
dev-tools/lz4-rebaser.sh line 62
Quoted 4 lines
dev-tools/lz4-rebaser.sh new file +4
-0+#ifdef NEED_COMPAT_LZ4 +EOF + sed '/"lz4\.h"/s/\(#include "\)lz4\.h\("\+\)/\1compat-lz4.h\2/' "$LZ4_C" +cat <<EOF
Not sure why this is not working here, but it looks like having too much bells and whistles :-9 - I replaced this with
sed 's/\"lz4\.h\"/\"compat-lz4.h"/' "$LZ4_C"
and ran it against a local copy of lz4 v131, and that produced the expected result - no significant changes to compat-lz4.c/compat-lz4.h (the "#ifdef HAVE_CONFIG_H" block moves to the top of the file, but that is purely cosmetic - the block itself is fine)
So, any objections against the much simpler sed command there? "lz4.h" with double quotes never shows up elsewhere in the file today - and when importing, we need to run a compile test anyway, so if it should ever garble the .c file, we fix the script...
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Quoted 21 lines · Gert Doering
Hi,
Quoted 6 lines · David Sommerseth
This tool depends on a cloned upstream LZ4 git repository and a checked out release tag. Then run the script like this:
$ ./dev-tools/lz4-rebaser.sh /path/to/lz4.gitTo see the result before committing, use: git diff --cached
All willing to give this an ACK, alas, it's penguin-tainted :-) - read, won't work with a FreeBSD sed.
dev-tools/lz4-rebaser.sh line 62
Quoted 4 lines
dev-tools/lz4-rebaser.sh new file +4
-0+#ifdef NEED_COMPAT_LZ4 +EOF + sed '/"lz4\.h"/s/\(#include "\)lz4\.h\("\+\)/\1compat-lz4.h\2/' "$LZ4_C" +cat <<EOFNot sure why this is not working here, but it looks like having too much bells and whistles :-9 - I replaced this with
Quoted 6 lines
sed 's/\"lz4\.h\"/\"compat-lz4.h"/' "$LZ4_C"and ran it against a local copy of lz4 v131, and that produced the expected result - no significant changes to
compat-lz4.c/compat-lz4.h(the "#ifdefHAVE_CONFIG_H" block moves to the top of the file, but that is purely cosmetic - the block itself is fine)
I /did/ consider to do some clever sed hacks here too ... but I wasn't in mood for that complexity, and I actually feared how *BSD would explode in my face :) But as it turned out, the BSD explosion trigger was even lower than that ....... ;-)
Quoted 4 lines
So, any objections against the much simpler sed command there? "
lz4.h" with double quotes never shows up elsewhere in the file today - and when importing, we need to run a compile test anyway, so if it should ever garble the .c file, we fix the script...
This is purely my "match a precise as possible" approach I default to. I have no issues making this simpler if that is what is required.
New patch or fix at commit time?
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Hi,
Quoted 8 lines · David Sommerseth
Quoted 4 lines
and ran it against a local copy of lz4 v131, and that produced the expected result - no significant changes to
compat-lz4.c/compat-lz4.h(the "#ifdefHAVE_CONFIG_H" block moves to the top of the file, but that is purely cosmetic - the block itself is fine)I /did/ consider to do some clever sed hacks here too ... but I wasn't in mood for that complexity, and I actually feared how *BSD would explode in my face :)
We'll always get you ;-)
Quoted 2 lines
But as it turned out, the BSD explosion trigger
was even lower than that ....... ;-)
GNU sed enables "more complex" matching by default, but I can never remember which sed version does what, and when I need to turn on -E ("extended regex") to make sed do what I want :-)
Quoted 7 lines
Quoted 4 lines
So, any objections against the much simpler sed command there? "
lz4.h" with double quotes never shows up elsewhere in the file today - and when importing, we need to run a compile test anyway, so if it should ever garble the .c file, we fix the script...This is purely my "match a precise as possible" approach I default to. I have no issues making this simpler if that is what is required.
Understood, but in this particular case, I think "simple is good enough"
Quoted 1 line
New patch or fix at commit time?
Whatever you prefer. It's your code :)
(And since this is not "main openvpn code", the rules are not as strict anyway - the actual lz4 commit change would need to be reviewed anyway)
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...ACK.
Your patch has been applied to the master branch.
Some comments:
- I'm not putting this into release/2.4 branch, as we're only ever going to use it in master - lz4 changes get applied to master, and then cherrypicked to other branches.
- the sed statement has been fix-on-commit'ed as discussed on the list
- a small grammatical mistake in the comment added to the newly imported compat-lz4.c has been fixed ("This file *has* been...")
- typo in the commit message fixed ("wihch")
commit fce9d75b2c44c354457522643eddc914e41f2d84
Author: David Sommerseth Date: Wed Jan 25 21:53:02 2017 +0100
dev-tools: Simple tool which automates rebasing LZ4 compat library
Signed-off-by: David Sommerseth <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg13962.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering