From 5872d929ad68c270a7778f3fbb1e23d34b80b5dd Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Mon, 20 May 2013 18:14:32 +0200 Subject: [PATCH] JCLOUDS-67: Filtered license headers from script fragments --- compute/src/test/resources/initscript_with_java.sh | 98 +------------- .../src/test/resources/initscript_with_jetty.sh | 98 +------------- compute/src/test/resources/runscript.sh | 98 +------------- .../src/test/resources/runscript_adminUpdate.sh | 48 ------- .../test_export_ip_address_from_vm_named.sh | 32 ----- pom.xml | 8 -- .../functionloader/CurrentFunctionLoader.java | 5 +- .../filters/LicenseHeaderFilter.java | 146 +++++++++++++++++++++ scriptbuilder/src/test/resources/test_ebs.sh | 48 ------- scriptbuilder/src/test/resources/test_find_pid.cmd | 32 ----- scriptbuilder/src/test/resources/test_find_pid.sh | 32 ----- scriptbuilder/src/test/resources/test_init.sh | 48 ------- .../src/test/resources/test_init_script.sh | 82 +----------- .../resources/test_install_git_scriptbuilder.sh | 98 +------------- .../resources/test_install_jdk_scriptbuilder.sh | 98 +------------- scriptbuilder/src/test/resources/test_script.cmd | 16 --- scriptbuilder/src/test/resources/test_script.sh | 16 --- .../src/test/resources/test_seek_and_destroy.cmd | 32 ----- .../src/test/resources/test_seek_and_destroy.sh | 32 ----- 19 files changed, 156 insertions(+), 911 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 e2369af..4d60764 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" @@ -214,22 +134,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 1ca2345..7881e9e 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" @@ -214,22 +134,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 5da35dd..52f622d 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" @@ -214,22 +134,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 d4a030f..f3aa82e 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/labs/virtualbox/src/test/resources/test_export_ip_address_from_vm_named.sh b/labs/virtualbox/src/test/resources/test_export_ip_address_from_vm_named.sh index 3ac040c..52fd3b9 100644 --- a/labs/virtualbox/src/test/resources/test_export_ip_address_from_vm_named.sh +++ b/labs/virtualbox/src/test/resources/test_export_ip_address_from_vm_named.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 exportIpAddressFromVmNamed { unset FOUND_IP_ADDRESS; [ $# -eq 1 ] || { diff --git a/pom.xml b/pom.xml index 724c4da..a4ec4ce 100644 --- a/pom.xml +++ b/pom.xml @@ -79,10 +79,6 @@ **/README.md **/README.txt - - **/*sh - **/*cmd - **/*json **/*readme @@ -154,10 +150,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 ff22e3f..85eeb75 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; + /** * Means to access the current {@link FunctionLoader} instance; */ @@ -27,7 +29,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 0000000..670f49c --- /dev/null +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java @@ -0,0 +1,146 @@ +/* + * 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_ebs.sh b/scriptbuilder/src/test/resources/test_ebs.sh index dbfae0a..58d1ebc 100644 --- a/scriptbuilder/src/test/resources/test_ebs.sh +++ b/scriptbuilder/src/test/resources/test_ebs.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 @@ -35,22 +19,6 @@ export EBS_DEVICE="/dev/sdh" export EBS_MOUNT_POINT="/mnt/ebs" 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 ] || { @@ -66,22 +34,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_find_pid.cmd b/scriptbuilder/src/test/resources/test_find_pid.cmd index 58aad1e..99a931b 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 aa3c123..30206c2 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 aea4e58..81f3c35 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 c43b641..be2cecc 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_git_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh index ef9303b..7539de4 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" @@ -214,22 +134,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 d66b450..b9dae5e 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" @@ -214,22 +134,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_script.cmd b/scriptbuilder/src/test/resources/test_script.cmd index b64d443..287fcf9 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 66d8fe0..ea7e1de 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 5e87516..79c41c1 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 2b8a7c4..3f8d68c 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 ] || { -- 1.7.12.4 (Apple Git-37)