diff --git a/stacks/mariadb/build.sh b/stacks/mariadb/build.sh new file mode 100755 index 0000000..9320bbc --- /dev/null +++ b/stacks/mariadb/build.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Load stack utils +. /usr/bin/stack-utils + +# Implement build function +function build() { + cat << EOF > /workspace/"${TARNAME}"/meta/dependencies +libncurses6 +EOF + + install-packages \ + cmake \ + + # Generate binary + curl -sSL "https://downloads.mariadb.org/interstitial/mariadb-${STACK_VERSION}/source/mariadb-${STACK_VERSION}.tar.gz" | tar -xz && \ + cd mariadb-"${STACK_VERSION}" && \ + pcre_version=$(< cmake/pcre.cmake grep 'ftp.pcre.org' |awk -F 'pcre2-' '{print $2}' | awk -F '.zip' '{print $1}') + sed -i -e "s|http://ftp.pcre.org/pub/pcre|https://github.com/PhilipHazel/pcre2/releases/download/pcre2-${pcre_version}|g" cmake/pcre.cmake + cmake . -DCMAKE_INSTALL_PREFIX=/opt/drycc/mariadb \ + -DMYSQL_DATADIR=/opt/drycc/mariadb/data \ + -DWITH_INNOBASE_STORAGE_ENGINE=1 \ + -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ + -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ + -DWITH_READLINE=1 \ + -DWITH_SSL=system \ + -DWITH_ZLIB=system \ + -DWITH_LIBWRAP=0 \ + -DMYSQL_UNIX_ADDR=/tmp/mariadb.sock \ + -DDEFAULT_CHARSET=utf8 \ + -DDEFAULT_COLLATION=utf8_general_ci \ + && \ + make install + + mkdir -p "${PROFILE_DIR}" + cat << EOF > "${PROFILE_DIR}/${STACK_NAME}.sh" +export PATH="/opt/drycc/mariadb/bin:\$PATH" +EOF + + cp -rf /opt/drycc/mariadb/* "${DATA_DIR}" +} + +# call build stack +build-stack "${1}" \ No newline at end of file diff --git a/stacks/postgis/build.sh b/stacks/postgis/build.sh new file mode 100755 index 0000000..3e909ad --- /dev/null +++ b/stacks/postgis/build.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Load stack utils +. /usr/bin/stack-utils + +# Implement build function +function build() { + # Generate binary + POSTGIS_VER=${STACK_VERSION} # 3.1.4 + + install-packages \ + libgdal-dev \ + libgeos-dev \ + libjson-c-dev \ + libmysqlclient-dev \ + libproj-dev \ + libprotobuf-c-dev \ + libxml2-dev \ + protobuf-c-compiler + + curl -sSL "https://download.osgeo.org/postgis/source/postgis-"${POSTGIS_VER}".tar.gz" | tar -xz && \ + cd postgis-"${POSTGIS_VER}" && \ + ./configure \ + --prefix=/opt/drycc/postgis/"${POSTGIS_VER}" \ + --with-pgconfig=/opt/drycc/postgresql/"${PG_MAJOR}"/bin/pg_config \ + && \ + make && \ + make install + + cp -rf /opt/drycc/postgresql "${DATA_DIR}" +} + +# call build stack +build-stack "${1}" diff --git a/stacks/postgresql/build.sh b/stacks/postgresql/build.sh new file mode 100755 index 0000000..76ea172 --- /dev/null +++ b/stacks/postgresql/build.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# Load stack utils +. /usr/bin/stack-utils + +# Implement build function +function build() { + # Generate binary + PG_VER=${STACK_VERSION} + PG_MAJOR=$(echo "${STACK_VERSION}"|cut -d"." -f1) + + cat << EOF > /workspace/"${TARNAME}"/meta/dependencies +binutils \ +gdal-bin \ +libproj-dev +EOF + + install-packages \ + clang \ + dirmngr \ + gnupg \ + libclang-dev \ + libicu-dev \ + libipc-run-perl \ + libkrb5-dev \ + libldap2-dev \ + liblz4-dev \ + libpam-dev \ + libperl-dev \ + libpython3-dev \ + libreadline-dev \ + libssl-dev \ + libxml2-dev \ + libxslt1-dev \ + llvm \ + llvm-dev \ + locales \ + python3-dev \ + tcl-dev \ + uuid-dev \ + pkg-config + + curl -sSL "https://ftp.postgresql.org/pub/source/v${PG_VER}/postgresql-${PG_VER}.tar.gz" | tar -xz && \ + cd postgresql-"${PG_VER}" && \ + ./configure \ + --prefix=/opt/drycc/postgresql/"${PG_MAJOR}" \ + --enable-integer-datetimes \ + --enable-thread-safety \ + --enable-tap-tests \ + --with-uuid=e2fs \ + --with-gnu-ld \ + --with-pgport=5432 \ + --with-system-tzdata=/usr/share/zoneinfo \ + --with-includes=/usr/local/include \ + --with-libraries=/usr/local/lib \ + --with-krb5 \ + --with-gssapi \ + --with-ldap \ + --with-pam \ + --with-tcl \ + --with-perl \ + --with-python \ + --with-openssl \ + --with-libxml \ + --with-libxslt \ + --with-icu \ + --with-llvm \ + --with-lz4 \ + && \ + # we can change from world to world-bin in newer releases + make world && \ + make install-world + + mkdir -p "${PROFILE_DIR}" + cat << EOF > "${PROFILE_DIR}/${STACK_NAME}.sh" +export PATH="/opt/drycc/postgresql/$PG_MAJOR/bin:\$PATH" +EOF + + cp -rf /opt/drycc/postgresql/* "${DATA_DIR}" +} + +# call build stack +build-stack "${1}" \ No newline at end of file diff --git a/stacks/redis/build.sh b/stacks/redis/build.sh new file mode 100755 index 0000000..4006b17 --- /dev/null +++ b/stacks/redis/build.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# Load stack utils +. /usr/bin/stack-utils + +# Implement build function +function build() { + # Generate binary + REDIS_DOWNLOAD_URL="http://download.redis.io/releases/redis-${STACK_VERSION}.tar.gz" + savedAptMark="$(apt-mark showmanual)"; \ + curl -fsSL -o redis.tar.gz "$REDIS_DOWNLOAD_URL"; \ + mkdir -p /usr/src/redis; \ + tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ + rm redis.tar.gz; \ + grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \ + sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \ + grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \ + gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ + extraJemallocConfigureFlags="--build=$gnuArch"; \ + # https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23 + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \ + *) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \ + esac; \ + extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \ + grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \ + sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \ + grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \ + \ + export BUILD_TLS=yes; \ + make -C /usr/src/redis -j "$(nproc)" all; \ + make -C /usr/src/redis PREFIX=/opt/drycc/redis install; \ + \ + # TODO https://github.com/redis/redis/pull/3494 (deduplicate "redis-server" copies) + serverMd5="$(md5sum /opt/drycc/redis/bin/redis-server | cut -d' ' -f1)"; export serverMd5; \ + find /opt/drycc/redis/bin/redis* -maxdepth 0 \ + -type f -not -name redis-server \ + -exec sh -eux -c ' \ + md5="$(md5sum "$1" | cut -d" " -f1)"; \ + test "$md5" = "$serverMd5"; \ + ' -- '{}' ';' \ + -exec ln -svfT 'redis-server' '{}' ';' \ + ; \ + \ + rm -r /usr/src/redis; \ + \ + apt-mark auto '.*' > /dev/null; \ + [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \ + find /opt/drycc/redis/bin -type f -executable -exec ldd '{}' ';' \ + | awk '/=>/ { print $(NF-1) }' \ + | sort -u \ + | xargs -r dpkg-query --search \ + | cut -d: -f1 \ + | sort -u \ + | xargs -r apt-mark manual \ + ; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + \ + /opt/drycc/redis/bin/redis-cli --version; \ + /opt/drycc/redis/bin/redis-server --version + + chmod +x /opt/drycc/redis/bin/redis* + mkdir -p "${PROFILE_DIR}" + cat << EOF > "${PROFILE_DIR}/${STACK_NAME}.sh" +export PATH="/opt/drycc/redis/bin:\$PATH" +EOF + cp -rf /opt/drycc/redis/* "${DATA_DIR}" +} + +# call build stack +build-stack "${1}" \ No newline at end of file