From a18557635d6e845c9765d2cbc1cebca1fdeb41b3 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Mon, 20 May 2013 16:37:36 +0200 Subject: [PATCH] JCLOUDS-67: Filtered license headers from script fragments --- .../test/resources/initscript_with_java.sh | 98 +----------- .../test/resources/initscript_with_jetty.sh | 98 +----------- compute/src/test/resources/runscript.sh | 98 +----------- .../test/resources/runscript_adminUpdate.sh | 48 ------ pom.xml | 8 - .../functionloader/CurrentFunctionLoader.java | 5 +- .../filters/LicenseHeaderFilter.java | 145 ++++++++++++++++++ .../src/test/resources/test_find_pid.cmd | 32 ---- .../src/test/resources/test_find_pid.sh | 32 ---- scriptbuilder/src/test/resources/test_init.sh | 48 ------ .../src/test/resources/test_init_script.sh | 82 +--------- .../test_install_chef_gems_scriptbuilder.sh | 48 ------ .../test_install_git_scriptbuilder.sh | 98 +----------- .../test_install_jdk_scriptbuilder.sh | 98 +----------- .../test_install_ruby_scriptbuilder.sh | 98 +----------- .../test_install_rubygems_scriptbuilder.sh | 48 ------ .../src/test/resources/test_script.cmd | 16 -- .../src/test/resources/test_script.sh | 16 -- .../test/resources/test_seek_and_destroy.cmd | 32 ---- .../test/resources/test_seek_and_destroy.sh | 32 ---- 20 files changed, 156 insertions(+), 1024 deletions(-) create mode 100644 scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java diff --git a/compute/src/test/resources/initscript_with_java.sh b/compute/src/test/resources/initscript_with_java.sh index 8582e138d6..99d05645c6 100644 --- a/compute/src/test/resources/initscript_with_java.sh +++ b/compute/src/test/resources/initscript_with_java.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function bootstrap { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { @@ -127,42 +79,10 @@ END_OF_JCLOUDS_SCRIPT export LOG_DIR='$LOG_DIR' END_OF_JCLOUDS_SCRIPT cat >> $INSTANCE_HOME/bootstrap.sh <<-'END_OF_JCLOUDS_SCRIPT' - # -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -function abort { + function abort { echo "aborting: $@" 1>&2 exit 1 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# alias apt-get-update="apt-get update -qq" alias apt-get-install="apt-get install -f -y -qq --force-yes" alias yum-install="yum --quiet --nogpgcheck -y install" @@ -222,22 +142,6 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# # adds JAVA_HOME and into PATH in global and user-specific profiles function setupJavaHomeInProfile() { PROFILES=(/etc/bashrc $HOME/.bashrc /etc/skel/.bashrc) diff --git a/compute/src/test/resources/initscript_with_jetty.sh b/compute/src/test/resources/initscript_with_jetty.sh index 612dbad719..d5a5e3d1b8 100644 --- a/compute/src/test/resources/initscript_with_jetty.sh +++ b/compute/src/test/resources/initscript_with_jetty.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function configure-jetty { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { @@ -127,42 +79,10 @@ END_OF_JCLOUDS_SCRIPT export LOG_DIR='$LOG_DIR' END_OF_JCLOUDS_SCRIPT cat >> $INSTANCE_HOME/configure-jetty.sh <<-'END_OF_JCLOUDS_SCRIPT' - # -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -function abort { + function abort { echo "aborting: $@" 1>&2 exit 1 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# alias apt-get-update="apt-get update -qq" alias apt-get-install="apt-get install -f -y -qq --force-yes" alias yum-install="yum --quiet --nogpgcheck -y install" @@ -222,22 +142,6 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# # adds JAVA_HOME and into PATH in global and user-specific profiles function setupJavaHomeInProfile() { PROFILES=(/etc/bashrc $HOME/.bashrc /etc/skel/.bashrc) diff --git a/compute/src/test/resources/runscript.sh b/compute/src/test/resources/runscript.sh index 00dc492b3d..b7d261e6bf 100644 --- a/compute/src/test/resources/runscript.sh +++ b/compute/src/test/resources/runscript.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function runScriptWithCreds { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { @@ -127,42 +79,10 @@ END_OF_JCLOUDS_SCRIPT export LOG_DIR='$LOG_DIR' END_OF_JCLOUDS_SCRIPT cat >> $INSTANCE_HOME/runScriptWithCreds.sh <<-'END_OF_JCLOUDS_SCRIPT' - # -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -function abort { + function abort { echo "aborting: $@" 1>&2 exit 1 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# alias apt-get-update="apt-get update -qq" alias apt-get-install="apt-get install -f -y -qq --force-yes" alias yum-install="yum --quiet --nogpgcheck -y install" @@ -222,22 +142,6 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# # adds JAVA_HOME and into PATH in global and user-specific profiles function setupJavaHomeInProfile() { PROFILES=(/etc/bashrc $HOME/.bashrc /etc/skel/.bashrc) diff --git a/compute/src/test/resources/runscript_adminUpdate.sh b/compute/src/test/resources/runscript_adminUpdate.sh index d4a030fdd8..f3aa82e8e0 100644 --- a/compute/src/test/resources/runscript_adminUpdate.sh +++ b/compute/src/test/resources/runscript_adminUpdate.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function adminUpdate { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { diff --git a/pom.xml b/pom.xml index 9e2ac858e7..c2739b762d 100644 --- a/pom.xml +++ b/pom.xml @@ -78,10 +78,6 @@ **/README.md **/README.txt - - **/*sh - **/*cmd - **/*json **/*readme @@ -150,10 +146,6 @@ **/README.md **/README.txt - - **/*sh - **/*cmd - **/*json **/*readme diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/CurrentFunctionLoader.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/CurrentFunctionLoader.java index 92d23e89f8..5310457e82 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/CurrentFunctionLoader.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/CurrentFunctionLoader.java @@ -18,6 +18,8 @@ package org.jclouds.scriptbuilder.functionloader; import java.util.concurrent.atomic.AtomicReference; +import org.jclouds.scriptbuilder.functionloader.filters.LicenseHeaderFilter; + import com.google.common.util.concurrent.Atomics; /** @@ -29,7 +31,8 @@ public class CurrentFunctionLoader { BasicFunctionLoader.INSTANCE); public static FunctionLoader get() { - return ref.get(); + // Filter out license headers in function scripts + return new LicenseHeaderFilter(ref.get()); } public static FunctionLoader set(FunctionLoader loader) { diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java new file mode 100644 index 0000000000..c84e42e5e3 --- /dev/null +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.scriptbuilder.functionloader.filters; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.io.CharStreams.newReaderSupplier; +import static com.google.common.io.CharStreams.readLines; + +import java.io.IOException; + +import org.jclouds.scriptbuilder.domain.OsFamily; +import org.jclouds.scriptbuilder.domain.ShellToken; +import org.jclouds.scriptbuilder.functionloader.FunctionLoader; +import org.jclouds.scriptbuilder.functionloader.FunctionNotFoundException; + +import com.google.common.io.LineProcessor; + +/** + * FunctionLoader decorator to filters out license header comments from a file. + * + * @author Ignasi Barrera + */ +public class LicenseHeaderFilter implements FunctionLoader { + + /** The target function loader. */ + private final FunctionLoader delegate; + + public LicenseHeaderFilter(FunctionLoader delegate) { + this.delegate = checkNotNull(delegate, "delegate"); + } + + @Override + public String loadFunction(String function, OsFamily family) throws FunctionNotFoundException { + return filter(delegate.loadFunction(function, family), family); + } + + /** + * Filters out license header comments from a file. + * @param lines The lines to filter. + * @param family The {@link OsFamily} of the file. + * @return The filtered file. + */ + public String filter(String lines, OsFamily family) { + try { + return readLines(newReaderSupplier(checkNotNull(lines, "lines")), + new LicenseHeaderProcessor(checkNotNull(family, "family"))); + } catch (IOException e) { + // Don't fail; just return the original text with the comments + return lines; + } + } + + /** + * Line by line processor. + * + * @author Ignasi Barrera + */ + private static class LicenseHeaderProcessor implements LineProcessor { + + /** Search token used to identify license header comments beginning. */ + private static final String LICENSE_TOKEN_START = "Licensed to the Apache Software Foundation"; + + /** Search token used to identify license header comments end. */ + private static final String LICENSE_TOKEN_END = "limitations under the License"; + + /** The resulting text, without the license header comments. */ + private final StringBuilder builder; + + /** The comment token for the given OsFamily */ + private final String commentToken; + + /** The line termination token for the given OsFamily */ + private final String lineTerminationToken; + + /** Flag to indicate that a license header comment is being processed. */ + private boolean isLicenseComment; + + public LicenseHeaderProcessor(OsFamily family) { + builder = new StringBuilder(); + commentToken = ShellToken.REM.to(family); + lineTerminationToken = ShellToken.LF.to(family); + isLicenseComment = false; + } + + @Override + public boolean processLine(String line) throws IOException { + String trimmed = line.trim(); + boolean isComment = isCommentLine(trimmed); + + if (isComment && line.contains(LICENSE_TOKEN_START)) { + // License found, start skipping following comment lines + isLicenseComment = true; + } + + // Remove empty comment lines (licenses are prefixed and suffixed with + // empty comments) + if (!isLicenseComment && !isEmptyCommentLine(trimmed)) { + builder.append(line); + builder.append(lineTerminationToken); + } + + if (isLicenseComment && line.contains(LICENSE_TOKEN_END)) { + // Reset the license flag to avoid filtering other comments + isLicenseComment = false; + } + + return true; // Continue processing lines + } + + @Override + public String getResult() { + return builder.toString(); + } + + /** + * Checks if the given line is an empty comment line. + */ + private boolean isEmptyCommentLine(String line) { + // ShellToken.REM.to(WINDOWS) has a '@' prefix but not all comments do + return line.equals(commentToken) || line.equals("REM"); + } + + /** + * Checks if the given line is a comment line. + */ + private boolean isCommentLine(String line) { + // ShellToken.REM.to(WINDOWS) has a '@' prefix but not all comments do + return line.startsWith(commentToken) || line.startsWith("REM"); + } + } + +} diff --git a/scriptbuilder/src/test/resources/test_find_pid.cmd b/scriptbuilder/src/test/resources/test_find_pid.cmd index 58aad1e81e..99a931b53c 100644 --- a/scriptbuilder/src/test/resources/test_find_pid.cmd +++ b/scriptbuilder/src/test/resources/test_find_pid.cmd @@ -3,41 +3,9 @@ set PATH= set JAVA_HOME= set PATH= GOTO FUNCTION_END -REM -REM Licensed to the Apache Software Foundation (ASF) under one or more -REM contributor license agreements. See the NOTICE file distributed with -REM this work for additional information regarding copyright ownership. -REM The ASF licenses this file to You under the Apache License, Version 2.0 -REM (the "License"); you may not use this file except in compliance with -REM the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. -REM :abort echo aborting: %EXCEPTION% exit /b 1 -REM -REM Licensed to the Apache Software Foundation (ASF) under one or more -REM contributor license agreements. See the NOTICE file distributed with -REM this work for additional information regarding copyright ownership. -REM The ASF licenses this file to You under the Apache License, Version 2.0 -REM (the "License"); you may not use this file except in compliance with -REM the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. -REM :findPid set FOUND_PID= set _expression=%1 diff --git a/scriptbuilder/src/test/resources/test_find_pid.sh b/scriptbuilder/src/test/resources/test_find_pid.sh index aa3c12386f..30206c2cce 100644 --- a/scriptbuilder/src/test/resources/test_find_pid.sh +++ b/scriptbuilder/src/test/resources/test_find_pid.sh @@ -3,42 +3,10 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { diff --git a/scriptbuilder/src/test/resources/test_init.sh b/scriptbuilder/src/test/resources/test_init.sh index aea4e58148..81f3c356ec 100644 --- a/scriptbuilder/src/test/resources/test_init.sh +++ b/scriptbuilder/src/test/resources/test_init.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -33,22 +17,6 @@ function mkebsboot { export TMP_DIR="/mnt/tmp" return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -64,22 +32,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { diff --git a/scriptbuilder/src/test/resources/test_init_script.sh b/scriptbuilder/src/test/resources/test_init_script.sh index c43b64162e..be2cecc0c5 100644 --- a/scriptbuilder/src/test/resources/test_init_script.sh +++ b/scriptbuilder/src/test/resources/test_init_script.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function testcall { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { @@ -128,42 +80,10 @@ END_OF_JCLOUDS_SCRIPT export LOG_DIR='$LOG_DIR' END_OF_JCLOUDS_SCRIPT cat >> $INSTANCE_HOME/testcall.sh <<-'END_OF_JCLOUDS_SCRIPT' - # -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -function abort { + function abort { echo "aborting: $@" 1>&2 exit 1 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function sourceEnvFile { [ $# -eq 1 ] || { abort "sourceEnvFile requires a parameter of the file to source" diff --git a/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh index 7a3526ec05..d08f1cd055 100644 --- a/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function install_chef_gems { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { diff --git a/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh index bf35edd006..eb1b71d23d 100644 --- a/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function install_git { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { @@ -127,42 +79,10 @@ END_OF_JCLOUDS_SCRIPT export LOG_DIR='$LOG_DIR' END_OF_JCLOUDS_SCRIPT cat >> $INSTANCE_HOME/install_git.sh <<-'END_OF_JCLOUDS_SCRIPT' - # -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -function abort { + function abort { echo "aborting: $@" 1>&2 exit 1 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# alias apt-get-update="apt-get update -qq" alias apt-get-install="apt-get install -f -y -qq --force-yes" alias yum-install="yum --quiet --nogpgcheck -y install" @@ -222,22 +142,6 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function installGit() { if which dpkg &> /dev/null; then ensure_cmd_or_install_package_apt git git-core diff --git a/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh index 0da56c5307..5157490c10 100644 --- a/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function install_jdk { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { @@ -127,42 +79,10 @@ END_OF_JCLOUDS_SCRIPT export LOG_DIR='$LOG_DIR' END_OF_JCLOUDS_SCRIPT cat >> $INSTANCE_HOME/install_jdk.sh <<-'END_OF_JCLOUDS_SCRIPT' - # -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -function abort { + function abort { echo "aborting: $@" 1>&2 exit 1 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# alias apt-get-update="apt-get update -qq" alias apt-get-install="apt-get install -f -y -qq --force-yes" alias yum-install="yum --quiet --nogpgcheck -y install" @@ -222,22 +142,6 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# # adds JAVA_HOME and into PATH in global and user-specific profiles function setupJavaHomeInProfile() { PROFILES=(/etc/bashrc $HOME/.bashrc /etc/skel/.bashrc) diff --git a/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh index d98bbe7950..0ae5aaba52 100644 --- a/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function install_ruby { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { @@ -127,42 +79,10 @@ END_OF_JCLOUDS_SCRIPT export LOG_DIR='$LOG_DIR' END_OF_JCLOUDS_SCRIPT cat >> $INSTANCE_HOME/install_ruby.sh <<-'END_OF_JCLOUDS_SCRIPT' - # -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -function abort { + function abort { echo "aborting: $@" 1>&2 exit 1 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# alias apt-get-update="apt-get update -qq" alias apt-get-install="apt-get install -f -y -qq --force-yes" alias yum-install="yum --quiet --nogpgcheck -y install" @@ -222,22 +142,6 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function installRuby() { if ! hash ruby 2>/dev/null; then if which dpkg &> /dev/null; then diff --git a/scriptbuilder/src/test/resources/test_install_rubygems_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_rubygems_scriptbuilder.sh index 232e6eade9..1c4bb5f8c5 100644 --- a/scriptbuilder/src/test/resources/test_install_rubygems_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_rubygems_scriptbuilder.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 @@ -32,22 +16,6 @@ export LOG_DIR="$INSTANCE_HOME" function install_rubygems { return $? } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || { @@ -63,22 +31,6 @@ function findPid { return 1 } } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function forget { unset FOUND_PID; [ $# -eq 3 ] || { diff --git a/scriptbuilder/src/test/resources/test_script.cmd b/scriptbuilder/src/test/resources/test_script.cmd index b64d443a99..287fcf9327 100644 --- a/scriptbuilder/src/test/resources/test_script.cmd +++ b/scriptbuilder/src/test/resources/test_script.cmd @@ -4,22 +4,6 @@ set JAVA_HOME= set PATH= set RUNTIME= GOTO FUNCTION_END -REM -REM Licensed to the Apache Software Foundation (ASF) under one or more -REM contributor license agreements. See the NOTICE file distributed with -REM this work for additional information regarding copyright ownership. -REM The ASF licenses this file to You under the Apache License, Version 2.0 -REM (the "License"); you may not use this file except in compliance with -REM the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. -REM :abort echo aborting: %EXCEPTION% exit /b 1 diff --git a/scriptbuilder/src/test/resources/test_script.sh b/scriptbuilder/src/test/resources/test_script.sh index 66d8fe04d1..ea7e1de915 100644 --- a/scriptbuilder/src/test/resources/test_script.sh +++ b/scriptbuilder/src/test/resources/test_script.sh @@ -3,22 +3,6 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH RUNTIME -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 diff --git a/scriptbuilder/src/test/resources/test_seek_and_destroy.cmd b/scriptbuilder/src/test/resources/test_seek_and_destroy.cmd index 5e87516500..79c41c166e 100644 --- a/scriptbuilder/src/test/resources/test_seek_and_destroy.cmd +++ b/scriptbuilder/src/test/resources/test_seek_and_destroy.cmd @@ -3,41 +3,9 @@ set PATH= set JAVA_HOME= set PATH= GOTO FUNCTION_END -REM -REM Licensed to the Apache Software Foundation (ASF) under one or more -REM contributor license agreements. See the NOTICE file distributed with -REM this work for additional information regarding copyright ownership. -REM The ASF licenses this file to You under the Apache License, Version 2.0 -REM (the "License"); you may not use this file except in compliance with -REM the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. -REM :abort echo aborting: %EXCEPTION% exit /b 1 -REM -REM Licensed to the Apache Software Foundation (ASF) under one or more -REM contributor license agreements. See the NOTICE file distributed with -REM this work for additional information regarding copyright ownership. -REM The ASF licenses this file to You under the Apache License, Version 2.0 -REM (the "License"); you may not use this file except in compliance with -REM the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. -REM :findPid set FOUND_PID= set _expression=%1 diff --git a/scriptbuilder/src/test/resources/test_seek_and_destroy.sh b/scriptbuilder/src/test/resources/test_seek_and_destroy.sh index 2b8a7c4e96..3f8d68c701 100644 --- a/scriptbuilder/src/test/resources/test_seek_and_destroy.sh +++ b/scriptbuilder/src/test/resources/test_seek_and_destroy.sh @@ -3,42 +3,10 @@ set +u shopt -s xpg_echo shopt -s expand_aliases unset PATH JAVA_HOME LD_LIBRARY_PATH -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function abort { echo "aborting: $@" 1>&2 exit 1 } -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# function findPid { unset FOUND_PID; [ $# -eq 1 ] || {