-
Notifications
You must be signed in to change notification settings - Fork 171
/
build-utils-common-functions.sh
92 lines (83 loc) · 2.55 KB
/
build-utils-common-functions.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
# Common functions used by build-docker-image.sh and publish-neo4j-admin-image.sh
function contains_element
{
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}
function get_series_from_version
{
local version=$1
local major=$(echo "${version}" | sed -E 's/^([0-9]+)\.([0-9]+)\..*/\1/')
local minor=$(echo "${version}" | sed -E 's/^([0-9]+)\.([0-9]+)\..*/\2/')
if [[ "${major}" -ge "5" ]]; then
echo "${major}"
else
echo "${major}.${minor}"
fi
}
function get_compatible_dockerfile_for_os_or_error
{
local version=${1}
local requested_os=${2}
local major=$(echo "${version}" | sed -E 's/^([0-9]+)\.([0-9]+)\..*/\1/')
local minor=$(echo "${version}" | sed -E 's/^([0-9]+)\.([0-9]+)\..*/\2/')
case ${major} in
# Version is calver
2024)
local SUPPORTED_IMAGE_OS=("debian" "ubi9")
if contains_element ${requested_os} "${SUPPORTED_IMAGE_OS[@]}"; then
echo "Dockerfile-${requested_os}"
return 0
fi
;;
5)
local SUPPORTED_IMAGE_OS=("debian" "ubi9")
if contains_element ${requested_os} "${SUPPORTED_IMAGE_OS[@]}"; then
echo "Dockerfile-${requested_os}"
return 0
fi
;;
4)
case ${minor} in
4)
local SUPPORTED_IMAGE_OS=("debian" "ubi9")
if contains_element ${requested_os} "${SUPPORTED_IMAGE_OS[@]}"; then
echo "Dockerfile-${requested_os}"
return 0
fi
;;
esac
esac
if [[ ${requested_os} = "debian" ]]; then
echo "Dockerfile"
return 0
fi
echo >&2 "${IMAGE_OS} is not a supported operating system for ${version}."
usage
DOCKERFILE_NAME
}
function tarball_name
{
local version=${1}
local edition=${2}
echo "neo4j-${2}-${1}-unix.tar.gz"
}
function cached_tarball
{
local version=${1}
local edition=${2}
echo "${TAR_CACHE}/$(tarball_name ${version} ${edition})"
}
function fetch_tarball
{
local version=${1}
local edition=${2}
local tar_name=$(tarball_name "${version}" "${edition}")
mkdir -p ${TAR_CACHE}
if [[ ! -f $(cached_tarball "${version}" "${edition}") ]]; then
echo "Downloading ${tar_name} from ${DISTRIBUTION_SITE} to $(cached_tarball ${version} ${edition})"
wget ${DISTRIBUTION_SITE}/${tar_name} -O "$(cached_tarball ${version} ${edition})"
fi
}