-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzip.sh
executable file
·84 lines (79 loc) · 2.13 KB
/
zip.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
#!/bin/bash
# This script adds the file ./bin/rediscompat.so to the zip file with the pattern rediscompt.<Linux|macos>-<osnick>-<arch>.version.zip
version=1.0.0
# Get OS name and architecture
os=$(uname -s)
arch=$(uname -m)
echo $os
echo $arch
# Get OS nick name
if [[ $os = 'Darwin' ]]
then
os='macos'
OS_NICK=$(sw_vers -productVersion)
# get major version
OS_NICK=${OS_NICK%%.*}
else
VERSION=$(grep '^VERSION_ID' /etc/os-release | sed 's/"//g')
VERSION=${VERSION#"VERSION_ID="}
OS_NAME=$(grep '^NAME' /etc/os-release | sed 's/"//g')
OS_NAME=${OS_NAME#"NAME="}
OS_NICK=${OS_NAME,,}${VERSION}
OS_NICK=${OS_NICK// /'_'}
fi
echo $OS_NICK
# Get OS nick name
if [[ $os = 'macos' ]]
then
# Since macos uses bash v3, we cannot use associative arrays
case $OS_NICK in
12)
OS_NICK="monterey"
;;
13)
OS_NICK="ventura"
;;
*)
echo "Unknown MacOS version $OS_NICK"
exit 1
;;
esac
case $arch in
x86_64)
arch="x86_64"
;;
arm64)
arch="aarch64"
;;
*)
echo "Unknown MacOS architecture $arch"
exit 1
;;
esac
else
declare -A LINUX_OSNICKS=(
["rocky_linux9.2"]="rhel9"
["rocky_linux8.8"]="rhel8"
["centos_linux7"]="rhel7"
["ubuntu18.04"]="ubuntu18.04"
["ubuntu20.04"]="ubuntu20.04"
["ubuntu22.04"]="ubuntu22.04"
["amazon_linux2"]="amzn2"
["debian_gnu/linux11"]="bullseye"
)
OS_NICK=${LINUX_OSNICKS[$OS_NICK]}
[[ $OS_NICK == 'monterey' ]] && OS_NICK='catalina' # To be aligned with other modules in redis-stack
declare -A archs=(
["x86_64"]="x86_64"
["aarch64"]="aarch64"
["arm64v8"]="aarch64"
["arm64"]="aarch64"
["ARM64"]="aarch64"
)
arch=${archs[$arch]}
fi
echo $OS_NICK
echo $arch
# Call zip and create the zip file
echo "Creating zip file ./bin/rediscompat.${os}-${OS_NICK}-${arch}.${version}.zip"
zip -j ./bin/rediscompat.${os}-${OS_NICK}-${arch}.${version}.zip ./bin/rediscompat.so