forked from ppc64le-cloud/docker-ce-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push-COS.sh
executable file
·130 lines (114 loc) · 5.18 KB
/
push-COS.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
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
##
# Script to push to the COS buckets
##
set -u
set -o allexport
source env.list
PATH_COS="/mnt"
PATH_PASSWORD="/root/.s3fs_cos_secret"
PATH_DISTROS_MISSING="/workspace/distros-missing.txt"
echo "- Push to ibm-docker-builds -"
# Mount the ibm-docker-builds COS bucket
mkdir -p ${PATH_COS}/s3_${COS_BUCKET_SHARED}
s3fs ${COS_BUCKET_SHARED} ${PATH_COS}/s3_${COS_BUCKET_SHARED} -o url=${URL_COS_SHARED} -o passwd_file=${PATH_PASSWORD} -o ibm_iam_auth
# Get the directory name ex: "docker-ce-20.10-11" (version without patch number then build tag)
DIR_DOCKER_TAG=$(eval "echo ${DOCKER_TAG} | cut -d'v' -f2 | cut -d'.' -f1-2")
echo "List of the directories beginning with docker-ce : "
ls -d ${PATH_COS}/s3_${COS_BUCKET_SHARED}/docker-ce-*/
if [[ $? -eq 0 ]]
then
DOCKER_LAST_BUILD_TAG=$(ls -d ${PATH_COS}/s3_${COS_BUCKET_SHARED}/docker-ce-${DIR_DOCKER_TAG}-* | sort --version-sort | tail -1| cut -d'-' -f6)
DOCKER_BUILD_TAG=$((DOCKER_LAST_BUILD_TAG+1))
else
# If there are no directories yet
DOCKER_BUILD_TAG="1"
fi
DIR_DOCKER_SHARED=docker-ce-${DIR_DOCKER_TAG}-${DOCKER_BUILD_TAG}
echo "Build tag : ${DOCKER_BUILD_TAG}"
echo "Copy the docker-ce packages to the COS bucket"
mkdir ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_DOCKER_SHARED}
cp -r /workspace/docker-ce-${DOCKER_TAG}_${DATE}/* ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_DOCKER_SHARED}
if test -d ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_DOCKER_SHARED}
then
echo "${DIR_DOCKER_SHARED} copied"
else
echo "${DIR_DOCKER_SHARED} not copied"
fi
if [[ ${CONTAINERD_BUILD} -eq "1" ]]
then
# We built a new version of containerd
# Get the directory name ex: "containerd-1.4-9" (version without patch number then build tag)
DIR_CONTAINERD_TAG=$(eval "echo ${CONTAINERD_TAG} | cut -d'v' -f2 | cut -d'.' -f1-2")
echo "List of the directories beginning with containerd : "
ls -d ${PATH_COS}/s3_${COS_BUCKET_SHARED}/containerd-*/
if [[ $? -eq 0 ]]
then
CONTAINERD_LAST_BUILD_TAG=$(ls -d ${PATH_COS}/s3_${COS_BUCKET_SHARED}/containerd-${DIR_CONTAINERD_TAG}-* | sort --version-sort | tail -1| cut -d'-' -f5)
CONTAINERD_BUILD_TAG=$((CONTAINERD_LAST_BUILD_TAG+1))
else
# If there are no directories yet
CONTAINERD_BUILD_TAG="1"
fi
DIR_CONTAINERD=containerd-${DIR_CONTAINERD_TAG}-${CONTAINERD_BUILD_TAG}
echo "Build tag : ${CONTAINERD_BUILD_TAG}"
echo "Copy the containerd packages to the COS bucket"
mkdir ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_CONTAINERD}
cp -r /workspace/containerd-${CONTAINERD_TAG}_${DATE}/* ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_CONTAINERD}
if test -d ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_CONTAINERD}
then
echo "${DIR_CONTAINERD} copied"
else
echo "${DIR_CONTAINERD} not copied"
fi
else
# Check if distros-missing.txt exists and if exists, push only the distros mentionned
if test -f ${PATH_DISTROS_MISSING}
then
# distros-missing.txt exists
# Get the directory name ex: "containerd-1.4-9" (version without patch number then build tag)
DIR_CONTAINERD_TAG=$(eval "echo ${CONTAINERD_TAG} | cut -d'v' -f2 | cut -d'.' -f1-2")
echo "List of the directories beginning with containerd : "
ls -d ${PATH_COS}/s3_${COS_BUCKET_SHARED}/containerd-*/
if [[ $? -eq 0 ]]
then
CONTAINERD_LAST_BUILD_TAG=$(ls -d ${PATH_COS}/s3_${COS_BUCKET_SHARED}/containerd-${DIR_CONTAINERD_TAG}-* | sort --version-sort | tail -1| cut -d'-' -f5)
CONTAINERD_BUILD_TAG=$((CONTAINERD_LAST_BUILD_TAG+1))
else
# If there are no directories yet
CONTAINERD_BUILD_TAG="1"
fi
DIR_CONTAINERD=containerd-${DIR_CONTAINERD_TAG}-${CONTAINERD_BUILD_TAG}
echo "Build tag : ${CONTAINERD_BUILD_TAG}"
while read -r line
do
# Copy the containerd package
DISTRO_NAME="$(cut -d':' -f1 <<<"${line}")"
DISTRO_VERS="$(cut -d':' -f2 <<<"${line}")"
if ! test ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_CONTAINERD}
then
echo "Create ${DIR_CONTAINERD}"
# mkdir -p ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_CONTAINERD}
fi
if ! test ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_CONTAINERD}/${DISTRO_NAME}
then
echo "Create ${DIR_CONTAINERD}/${DISTRO_NAME}"
# mkdir -p ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_CONTAINERD}/${DISTRO_NAME}
fi
# cp -r /workspace/containerd-${CONTAINERD_TAG}_${DATE}/${DISTRO_NAME}/${DISTRO_VERS} ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_CONTAINERD}/${DISTRO_NAME}
if test -d ${PATH_COS}/s3_${COS_BUCKET_SHARED}/${DIR_CONTAINERD}/${DISTRO_NAME}/${DISTRO_VERS}
then
echo "${DIR_CONTAINERD} copied"
else
echo "${DIR_CONTAINERD} not copied"
fi
done
fi
fi
echo ""
echo ""
echo "---------------------------------------------------------"
echo "COS bucket directory -> packages version :"
echo "${DIR_CONTAINERD} -> containerd ${CONTAINERD_TAG}"
echo "${DIR_DOCKER_SHARED} -> docker ${DOCKER_TAG}"
echo "---------------------------------------------------------"