-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathsync.sh
executable file
·119 lines (104 loc) · 4.19 KB
/
sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
#
# Copyright (c) 2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# convert upstream che repo to midstream devspaces-images repo using yq, sed
set -e
SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
# defaults
CSV_VERSION=3.y.0 # csv 3.y.0
DS_VERSION=${CSV_VERSION%.*} # tag 3.y
UPSTM_NAME="operator"
MIDSTM_NAME="operator"
DEV_WORKSPACE_CONTROLLER="" # main or 0.y.x
DEV_HEADER_REWRITE_TRAEFIK_PLUGIN="" # main or v0.y.z
usage () {
echo "
Usage: $0 -v [DS CSV_VERSION] -s [/path/to/${UPSTM_NAME}] -t [/path/to/generated] [--dwob DEV_WORKSPACE_CONTROLLER branch] [--hrtpb DEV_HEADER_REWRITE_TRAEFIK_PLUGIN branch]
Example: $0 -v 3.y.0 -s ${HOME}/projects/${UPSTM_NAME} -t /tmp/ds-${MIDSTM_NAME} --dwob v0.13.0 --hrtpb v0.1.2
Example: $0 -v 3.y.0 -s ${HOME}/projects/${UPSTM_NAME} -t /tmp/ds-${MIDSTM_NAME} --dwob main --hrtpb main"
exit
}
if [[ $# -lt 6 ]]; then usage; fi
while [[ "$#" -gt 0 ]]; do
case $1 in
'-v') CSV_VERSION="$2"; DS_VERSION="${CSV_VERSION%.*}"; shift 1;;
# paths to use for input and output
'-s') SOURCEDIR="$2"; SOURCEDIR="${SOURCEDIR%/}"; shift 1;;
'-t') TARGETDIR="$2"; TARGETDIR="${TARGETDIR%/}"; shift 1;;
'--dwob'|'--dwcv') DEV_WORKSPACE_CONTROLLER="$2"; shift 1;;
'--hrtpb'|'--hrtpv') DEV_HEADER_REWRITE_TRAEFIK_PLUGIN="$2"; shift 1;;
'--help'|'-h') usage;;
esac
shift 1
done
if [[ ! -d "${SOURCEDIR}" ]]; then usage; fi
if [[ ! -d "${TARGETDIR}" ]]; then usage; fi
if [[ "${CSV_VERSION}" == "3.y.0" ]]; then usage; fi
# ignore changes in these files
echo ".github/
.git/
.gitignore
.dockerignore
.ci/
.vscode/
build/
devfiles.yaml
/container.yaml
/content_sets.*
/cvp.yml
/cvp-owners.yml
PROJECT
README.md
RELEASE.md
REQUIREMENTS
get-source*.sh
tests/basic-test.yaml
make-release.sh
build/scripts/insert-related-images-to-csv.sh
helmcharts/
" > /tmp/rsync-excludes
echo "Rsync ${SOURCEDIR} to ${TARGETDIR}"
rsync -azrlt --checksum --exclude-from /tmp/rsync-excludes --delete "${SOURCEDIR}"/ "${TARGETDIR}"/
rm -f /tmp/rsync-excludes
# ensure shell scripts are executable
find "${TARGETDIR}"/ -name "*.sh" -exec chmod +x {} \;
# NOTE!!! upstream Dockerfile in the root folder is NOT the same as the one used downstream, with cachito
# SO when updating upstream ./Dockerfile, must ALSO update downstream ./build/dockerfiles/Dockerfile
cp "${TARGETDIR}/build/dockerfiles/Dockerfile" "${TARGETDIR}/Dockerfile"
cat << EOT >> "${TARGETDIR}"/Dockerfile
ENV SUMMARY="Red Hat OpenShift Dev Spaces ${MIDSTM_NAME} container" \\
DESCRIPTION="Red Hat OpenShift Dev Spaces ${MIDSTM_NAME} container" \\
PRODNAME="devspaces" \\
COMPNAME="${MIDSTM_NAME}"
LABEL com.redhat.delivery.appregistry="false" \\
summary="\$SUMMARY" \\
description="\$DESCRIPTION" \\
io.k8s.description="\$DESCRIPTION" \\
io.k8s.display-name="\$DESCRIPTION" \\
io.openshift.tags="\$PRODNAME,\$COMPNAME" \\
com.redhat.component="\$PRODNAME-rhel8-\$COMPNAME-container" \\
name="\$PRODNAME/\$COMPNAME" \\
version="${DS_VERSION}" \\
license="EPLv2" \\
maintainer="Anatolii Bazko <[email protected]>, Dmytro Nochevnov <[email protected]>, Samantha Dawley <[email protected]>, Nick Boldt <[email protected]>" \\
io.openshift.expose-services="" \\
usage=""
EOT
echo "Converted Dockerfile"
curl -sSL https://raw.githubusercontent.com/redhat-developer/devspaces/${MIDSTM_BRANCH}/product/getLatestImageTags.sh --output /tmp/getLatestImageTags.sh
if [[ $(cat /tmp/getLatestImageTags.sh) == *"404"* ]] || [[ $(cat /tmp/getLatestImageTags.sh) == *"Not Found"* ]]; then
echo "[ERROR] Could not load https://raw.githubusercontent.com/redhat-developer/devspaces/${MIDSTM_BRANCH}/product/getLatestImageTags.sh"
exit 1
fi
chmod +x /tmp/getLatestImageTags.sh
UBI_TAG=$(/tmp/getLatestImageTags.sh -c ubi8/ubi-minimal --tag "8."); UBI_TAG=${UBI_TAG##*:}
"${TARGETDIR}"/build/scripts/sync-che-operator.sh -v "${CSV_VERSION}" -s "${SOURCEDIR}/" -t "${TARGETDIR}/" --ubi-tag "${UBI_TAG}"