Skip to content

Commit fb5e790

Browse files
authored
Merge pull request #1 from jianxiaoguo/main
feat(stacks): add mariadb postgis postgresql redis
2 parents f0c4c8d + 6075604 commit fb5e790

4 files changed

Lines changed: 233 additions & 0 deletions

File tree

stacks/mariadb/build.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# Load stack utils
4+
. /usr/bin/stack-utils
5+
6+
# Implement build function
7+
function build() {
8+
cat << EOF > /workspace/"${TARNAME}"/meta/dependencies
9+
libncurses6
10+
EOF
11+
12+
install-packages \
13+
cmake \
14+
15+
# Generate binary
16+
curl -sSL "https://downloads.mariadb.org/interstitial/mariadb-${STACK_VERSION}/source/mariadb-${STACK_VERSION}.tar.gz" | tar -xz && \
17+
cd mariadb-"${STACK_VERSION}" && \
18+
pcre_version=$(< cmake/pcre.cmake grep 'ftp.pcre.org' |awk -F 'pcre2-' '{print $2}' | awk -F '.zip' '{print $1}')
19+
sed -i -e "s|http://ftp.pcre.org/pub/pcre|https://github.com/PhilipHazel/pcre2/releases/download/pcre2-${pcre_version}|g" cmake/pcre.cmake
20+
cmake . -DCMAKE_INSTALL_PREFIX=/opt/drycc/mariadb \
21+
-DMYSQL_DATADIR=/opt/drycc/mariadb/data \
22+
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
23+
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
24+
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
25+
-DWITH_READLINE=1 \
26+
-DWITH_SSL=system \
27+
-DWITH_ZLIB=system \
28+
-DWITH_LIBWRAP=0 \
29+
-DMYSQL_UNIX_ADDR=/tmp/mariadb.sock \
30+
-DDEFAULT_CHARSET=utf8 \
31+
-DDEFAULT_COLLATION=utf8_general_ci \
32+
&& \
33+
make install
34+
35+
mkdir -p "${PROFILE_DIR}"
36+
cat << EOF > "${PROFILE_DIR}/${STACK_NAME}.sh"
37+
export PATH="/opt/drycc/mariadb/bin:\$PATH"
38+
EOF
39+
40+
cp -rf /opt/drycc/mariadb/* "${DATA_DIR}"
41+
}
42+
43+
# call build stack
44+
build-stack "${1}"

stacks/postgis/build.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Load stack utils
4+
. /usr/bin/stack-utils
5+
6+
# Implement build function
7+
function build() {
8+
# Generate binary
9+
POSTGIS_VER=${STACK_VERSION} # 3.1.4
10+
11+
install-packages \
12+
libgdal-dev \
13+
libgeos-dev \
14+
libjson-c-dev \
15+
libmysqlclient-dev \
16+
libproj-dev \
17+
libprotobuf-c-dev \
18+
libxml2-dev \
19+
protobuf-c-compiler
20+
21+
curl -sSL "https://download.osgeo.org/postgis/source/postgis-"${POSTGIS_VER}".tar.gz" | tar -xz && \
22+
cd postgis-"${POSTGIS_VER}" && \
23+
./configure \
24+
--prefix=/opt/drycc/postgis/"${POSTGIS_VER}" \
25+
--with-pgconfig=/opt/drycc/postgresql/"${PG_MAJOR}"/bin/pg_config \
26+
&& \
27+
make && \
28+
make install
29+
30+
cp -rf /opt/drycc/postgresql "${DATA_DIR}"
31+
}
32+
33+
# call build stack
34+
build-stack "${1}"

stacks/postgresql/build.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
# Load stack utils
4+
. /usr/bin/stack-utils
5+
6+
# Implement build function
7+
function build() {
8+
# Generate binary
9+
PG_VER=${STACK_VERSION}
10+
PG_MAJOR=$(echo "${STACK_VERSION}"|cut -d"." -f1)
11+
12+
cat << EOF > /workspace/"${TARNAME}"/meta/dependencies
13+
binutils \
14+
gdal-bin \
15+
libproj-dev
16+
EOF
17+
18+
install-packages \
19+
clang \
20+
dirmngr \
21+
gnupg \
22+
libclang-dev \
23+
libicu-dev \
24+
libipc-run-perl \
25+
libkrb5-dev \
26+
libldap2-dev \
27+
liblz4-dev \
28+
libpam-dev \
29+
libperl-dev \
30+
libpython3-dev \
31+
libreadline-dev \
32+
libssl-dev \
33+
libxml2-dev \
34+
libxslt1-dev \
35+
llvm \
36+
llvm-dev \
37+
locales \
38+
python3-dev \
39+
tcl-dev \
40+
uuid-dev \
41+
pkg-config
42+
43+
curl -sSL "https://ftp.postgresql.org/pub/source/v${PG_VER}/postgresql-${PG_VER}.tar.gz" | tar -xz && \
44+
cd postgresql-"${PG_VER}" && \
45+
./configure \
46+
--prefix=/opt/drycc/postgresql/"${PG_MAJOR}" \
47+
--enable-integer-datetimes \
48+
--enable-thread-safety \
49+
--enable-tap-tests \
50+
--with-uuid=e2fs \
51+
--with-gnu-ld \
52+
--with-pgport=5432 \
53+
--with-system-tzdata=/usr/share/zoneinfo \
54+
--with-includes=/usr/local/include \
55+
--with-libraries=/usr/local/lib \
56+
--with-krb5 \
57+
--with-gssapi \
58+
--with-ldap \
59+
--with-pam \
60+
--with-tcl \
61+
--with-perl \
62+
--with-python \
63+
--with-openssl \
64+
--with-libxml \
65+
--with-libxslt \
66+
--with-icu \
67+
--with-llvm \
68+
--with-lz4 \
69+
&& \
70+
# we can change from world to world-bin in newer releases
71+
make world && \
72+
make install-world
73+
74+
mkdir -p "${PROFILE_DIR}"
75+
cat << EOF > "${PROFILE_DIR}/${STACK_NAME}.sh"
76+
export PATH="/opt/drycc/postgresql/$PG_MAJOR/bin:\$PATH"
77+
EOF
78+
79+
cp -rf /opt/drycc/postgresql/* "${DATA_DIR}"
80+
}
81+
82+
# call build stack
83+
build-stack "${1}"

stacks/redis/build.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
# Load stack utils
4+
. /usr/bin/stack-utils
5+
6+
# Implement build function
7+
function build() {
8+
# Generate binary
9+
REDIS_DOWNLOAD_URL="http://download.redis.io/releases/redis-${STACK_VERSION}.tar.gz"
10+
savedAptMark="$(apt-mark showmanual)"; \
11+
curl -fsSL -o redis.tar.gz "$REDIS_DOWNLOAD_URL"; \
12+
mkdir -p /usr/src/redis; \
13+
tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \
14+
rm redis.tar.gz; \
15+
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \
16+
sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \
17+
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \
18+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
19+
extraJemallocConfigureFlags="--build=$gnuArch"; \
20+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
21+
dpkgArch="$(dpkg --print-architecture)"; \
22+
case "${dpkgArch##*-}" in \
23+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
24+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
25+
esac; \
26+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
27+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
28+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
29+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
30+
\
31+
export BUILD_TLS=yes; \
32+
make -C /usr/src/redis -j "$(nproc)" all; \
33+
make -C /usr/src/redis PREFIX=/opt/drycc/redis install; \
34+
\
35+
# TODO https://github.com/redis/redis/pull/3494 (deduplicate "redis-server" copies)
36+
serverMd5="$(md5sum /opt/drycc/redis/bin/redis-server | cut -d' ' -f1)"; export serverMd5; \
37+
find /opt/drycc/redis/bin/redis* -maxdepth 0 \
38+
-type f -not -name redis-server \
39+
-exec sh -eux -c ' \
40+
md5="$(md5sum "$1" | cut -d" " -f1)"; \
41+
test "$md5" = "$serverMd5"; \
42+
' -- '{}' ';' \
43+
-exec ln -svfT 'redis-server' '{}' ';' \
44+
; \
45+
\
46+
rm -r /usr/src/redis; \
47+
\
48+
apt-mark auto '.*' > /dev/null; \
49+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \
50+
find /opt/drycc/redis/bin -type f -executable -exec ldd '{}' ';' \
51+
| awk '/=>/ { print $(NF-1) }' \
52+
| sort -u \
53+
| xargs -r dpkg-query --search \
54+
| cut -d: -f1 \
55+
| sort -u \
56+
| xargs -r apt-mark manual \
57+
; \
58+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
59+
\
60+
/opt/drycc/redis/bin/redis-cli --version; \
61+
/opt/drycc/redis/bin/redis-server --version
62+
63+
chmod +x /opt/drycc/redis/bin/redis*
64+
mkdir -p "${PROFILE_DIR}"
65+
cat << EOF > "${PROFILE_DIR}/${STACK_NAME}.sh"
66+
export PATH="/opt/drycc/redis/bin:\$PATH"
67+
EOF
68+
cp -rf /opt/drycc/redis/* "${DATA_DIR}"
69+
}
70+
71+
# call build stack
72+
build-stack "${1}"

0 commit comments

Comments
 (0)