Skip to content

Commit e2f1d59

Browse files
committed
[OPENJDK-3975] refactor rsync calls into common function
Refactor the three rsync calls into a common function, adopting the fix from OPENJDK-2850 to avoid trying to change the permissions on destination directories. Signed-off-by: Jonathan Dowland <[email protected]>
1 parent 10cd5e0 commit e2f1d59

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

modules/s2i/bash/artifacts/opt/jboss/container/java/s2i/maven-s2i-overrides

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
source "${JBOSS_CONTAINER_UTIL_LOGGING_MODULE}/logging.sh"
3+
source "${JBOSS_CONTAINER_S2I_CORE_MODULE}/s2i-core"
34

45
# inject our overridden maven_*() functions
56
function maven_s2i_source_maven_overrides() {
@@ -30,11 +31,7 @@ function maven_s2i_custom_binary_build() {
3031
fi
3132
log_info "Copying binaries from ${binary_dir} to ${S2I_TARGET_DEPLOYMENTS_DIR} ..."
3233

33-
( # OPENJDK-2850: use glob (dotglob to match hidden files) to stop rsync altering
34-
# timestamps of S2I_TARGET_DEPLOYMENTS_DIR. Don't alter parent shell's dotglob.
35-
shopt -s dotglob
36-
rsync --archive --out-format='%n' "${binary_dir}"/* "${S2I_TARGET_DEPLOYMENTS_DIR}"
37-
)
34+
recursive_copy_files "${binary_dir}" "${S2I_TARGET_DEPLOYMENTS_DIR}"
3835
}
3936

4037
function maven_s2i_deploy_artifacts_override() {

modules/s2i/bash/module.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ modules:
1616
- name: jboss.container.maven.s2i
1717
- name: jboss.container.java.run
1818
- name: jboss.container.util.logging
19+
- name: jboss.container.s2i.core
1920

2021
packages:
2122
install:

modules/s2i/core/artifacts/opt/jboss/container/s2i/core/s2i-core

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ function s2i_core_env_init_hook() {
4141
:
4242
}
4343

44+
# Copy files from a source path to a destination path
45+
# Do not attempt to change metadata of the destination path, which we
46+
# may not own
47+
function recursive_copy_files() {
48+
src="$1"
49+
dst="$2"
50+
( # OPENJDK-2850: use glob (dotglob to match hidden files) to stop rsync altering
51+
# timestamps of $dst, which we might not own. Subshell to not alter parent shell's
52+
# dotglob setting.
53+
shopt -s dotglob
54+
rsync --archive --out-format='%n' "${src}"/* "${dst}"
55+
)
56+
}
57+
4458
# copy configuration files
4559
# $1 - the base directory to which $S2I_SOURCE_CONFIGURATION_DIR is appended
4660
function s2i_core_copy_configuration() {
@@ -53,7 +67,7 @@ function s2i_core_copy_configuration() {
5367
mkdir -pm 775 "${S2I_TARGET_CONFIGURATION_DIR}"
5468
fi
5569
log_info "Copying configuration from $(realpath --relative-to ${S2I_SOURCE_DIR} ${1}/${S2I_SOURCE_CONFIGURATION_DIR}) to ${S2I_TARGET_CONFIGURATION_DIR}..."
56-
rsync --archive --out-format='%n' "${1}/${S2I_SOURCE_CONFIGURATION_DIR}"/ "${S2I_TARGET_CONFIGURATION_DIR}"
70+
recursive_copy_files "${1}/${S2I_SOURCE_CONFIGURATION_DIR}" "${S2I_TARGET_CONFIGURATION_DIR}"
5771
fi
5872
fi
5973
}
@@ -70,7 +84,7 @@ function s2i_core_copy_data() {
7084
mkdir -pm 775 "${S2I_TARGET_DATA_DIR}"
7185
fi
7286
log_info "Copying app data from $(realpath --relative-to ${S2I_SOURCE_DIR} ${1}/${S2I_SOURCE_DATA_DIR}) to ${S2I_TARGET_DATA_DIR}..."
73-
rsync --archive --out-format='%n' "${1}/${S2I_SOURCE_DATA_DIR}"/ "${S2I_TARGET_DATA_DIR}"
87+
recursive_copy_files "${1}/${S2I_SOURCE_DATA_DIR}" "${S2I_TARGET_DATA_DIR}"
7488
# s2i used to be more forgiving, but the build will fail if this call
7589
# fails. emit a warning and allow the build to succeed
7690
chmod -R g+rwX "${S2I_TARGET_DATA_DIR}" || log_warning "Errors occurred while adding read/write permissions to S2I_TARGET_DATA_DIR ($S2I_TARGET_DATA_DIR)."

0 commit comments

Comments
 (0)