-
Notifications
You must be signed in to change notification settings - Fork 72
/
fpm-entrypoint.sh
executable file
·116 lines (100 loc) · 3.47 KB
/
fpm-entrypoint.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
#!/bin/bash
set -o errexit
cd /tmp/build
if [ -z "$KONG_PACKAGE_NAME" ]
then
KONG_PACKAGE_NAME=kong
fi
if [ -z "$PACKAGE_CONFLICTS" ]
then
PACKAGE_CONFLICTS=kong-enterprise-edition
fi
if [ -z "$PACKAGE_PROVIDES" ]
then
PACKAGE_PROVIDES=kong-community-edition
fi
if [ -z "$PACKAGE_REPLACES" ]
then
PACKAGE_REPLACES=kong-community-edition
fi
if [ "$KONG_PACKAGE_NAME" = "kong" ];
then
PACKAGE_CONFLICTS=kong-enterprise-edition
PACKAGE_CONFLICTS_2=kong-enterprise-edition-fips
PACKAGE_REPLACES=kong-community-edition
PACKAGE_REPLACES_2=kong-enterprise-edition-fips
elif [ "$KONG_PACKAGE_NAME" = "kong-enterprise-edition" ]
then
PACKAGE_CONFLICTS=kong-community-edition
PACKAGE_CONFLICTS_2=kong-enterprise-edition-fips
PACKAGE_REPLACES=kong-community-edition
PACKAGE_REPLACES_2=kong-enterprise-edition-fips
elif [ "$KONG_PACKAGE_NAME" = "kong-enterprise-edition-fips" ] || [ "$SSL_PROVIDER" = "boringssl" ]
then
KONG_PACKAGE_NAME=kong-enterprise-edition-fips
PACKAGE_CONFLICTS=kong-community-edition
PACKAGE_CONFLICTS_2=kong-enterprise-edition
PACKAGE_REPLACES=kong-community-edition
PACKAGE_REPLACES_2=kong-enterprise-edition
fi
FPM_PARAMS=""
if [ "$PACKAGE_TYPE" == "deb" ]; then
FPM_PARAMS="-d libpcre3 -d perl -d zlib1g-dev"
OUTPUT_FILE_SUFFIX=".${RESTY_IMAGE_TAG}"
elif [ "$PACKAGE_TYPE" == "rpm" ]; then
FPM_PARAMS="-d pcre -d perl -d perl-Time-HiRes -d zlib -d zlib-devel"
OUTPUT_FILE_SUFFIX=".rhel${RESTY_IMAGE_TAG%%.*}"
if [ "$RESTY_IMAGE_TAG" == "7" ]; then
FPM_PARAMS="$FPM_PARAMS -d hostname"
fi
if [ "$RESTY_IMAGE_BASE" == "amazonlinux" ]; then
OUTPUT_FILE_SUFFIX=".aws"
FPM_PARAMS="$FPM_PARAMS -d /usr/sbin/useradd -d /usr/sbin/groupadd"
if [ "$RESTY_IMAGE_TAG" == "2022" ]; then
FPM_PARAMS="$FPM_PARAMS -d libxcrypt-compat"
fi
fi
if [ "$RESTY_IMAGE_BASE" == "centos" ]; then
OUTPUT_FILE_SUFFIX=".el${RESTY_IMAGE_TAG}"
fi
fi
OUTPUT_FILE_SUFFIX="${OUTPUT_FILE_SUFFIX}."$(echo ${TARGETPLATFORM} | awk -F "/" '{ print $2}')
ROCKSPEC_VERSION=`basename /tmp/build/build/usr/local/lib/luarocks/rocks/kong/*`
if [ "$PACKAGE_TYPE" == "apk" ]; then
pushd /tmp/build
mkdir /output
tar -zcvf /output/${KONG_PACKAGE_NAME}-${KONG_RELEASE_LABEL}${OUTPUT_FILE_SUFFIX}.apk.tar.gz usr etc
popd
else
fpm -f -s dir \
-t $PACKAGE_TYPE \
-m '[email protected]' \
-n $KONG_PACKAGE_NAME \
-v $KONG_RELEASE_LABEL \
$FPM_PARAMS \
--description 'Kong is a distributed gateway for APIs and Microservices, focused on high performance and reliability.' \
--vendor 'Kong Inc.' \
--license "ASL 2.0" \
--conflicts $PACKAGE_CONFLICTS \
--conflicts $PACKAGE_CONFLICTS_2 \
--provides $PACKAGE_PROVIDES \
--replaces $PACKAGE_REPLACES \
--after-install '/after-install.sh' \
--url 'https://getkong.org/' usr etc lib \
&& mkdir /output/ \
&& mv kong*.* /output/${KONG_PACKAGE_NAME}-${KONG_RELEASE_LABEL}${OUTPUT_FILE_SUFFIX}.${PACKAGE_TYPE}
set -x
if [ "$PACKAGE_TYPE" == "rpm" ] && [ ! -z "$PRIVATE_KEY_PASSPHRASE" ]; then
apt-get update
apt-get install -y expect
mkdir -p ~/.gnupg/
touch ~/.gnupg/gpg.conf
echo use-agent >> ~/.gnupg/gpg.conf
echo pinentry-mode loopback >> ~/.gnupg/gpg.conf
echo allow-loopback-pinentry >> ~/.gnupg/gpg-agent.conf
echo RELOADAGENT | gpg-connect-agent
cp /.rpmmacros ~/
gpg --batch --import /kong.private.asc
/sign-rpm.exp /output/${KONG_PACKAGE_NAME}-${KONG_RELEASE_LABEL}${OUTPUT_FILE_SUFFIX}.${PACKAGE_TYPE}
fi
fi