forked from greenplum-db/diskquota-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: work in progress to attempt building a Postgres Quota Plugin f…
…rom the GPDB
- Loading branch information
1 parent
467fcf6
commit e3eaf5a
Showing
8 changed files
with
159 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.env | ||
# Build directory | ||
build*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM pgvector/pgvector:pg14 | ||
|
||
COPY . /tmp/diskquota | ||
RUN cd /tmp/diskquota | ||
RUN mkdir build | ||
|
||
RUN apt-get update && \ | ||
apt-mark hold locales && \ | ||
apt-get install -y --no-install-recommends build-essential git postgresql-server-dev-14 | ||
|
||
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null | ||
RUN echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null | ||
|
||
RUN apt-get update && apt-get install -y cmake | ||
|
||
RUN cd /tmp/diskquota/build | ||
RUN cmake -S /tmp/diskquota -D PG_CONFIG=/usr/bin/pg_config | ||
RUN make install | ||
|
||
RUN mkdir /usr/share/doc/diskquota && \ | ||
cp LICENSE README.md SECURITY.md VERSiON /usr/share/doc/diskquota && \ | ||
rm -r /tmp/diskquota && \ | ||
apt-get remove -y build-essential postgresql-server-dev-$PG_MAJOR && \ | ||
apt-get autoremove -y && \ | ||
apt-mark unhold locales && \ | ||
rm -rf /var/lib/apt/lists/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
version: '3' | ||
|
||
vars: | ||
BASETAG: 14.1 | ||
|
||
env: | ||
NUV_PG_QUOTA_TAG: | ||
sh: git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD | ||
NUV_PG_QUOTA_IMAGE: ghcr.io/nuvolaris/nuvolaris-pg | ||
|
||
dotenv: | ||
- .env | ||
|
||
tasks: | ||
|
||
image-tag: | ||
- git tag -d $(git tag) | ||
- git tag -f {{.P}}{{.BASETAG}}.$(date +%y%m%d%H%M) | ||
- env PAGER= git tag | ||
|
||
docker-login: > | ||
echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_USER --password-stdin | ||
docker-setup: | ||
- docker buildx create --use | ||
- docker run -it --rm --privileged tonistiigi/binfmt --install all | ||
|
||
# Docker image | ||
build-and-push: | ||
cmds: | ||
- task: docker-setup | ||
- task: docker-login | ||
- "docker buildx build --platform linux/amd64,linux/arm64 . -t {{.NUV_PG_QUOTA_IMAGE}}:{{.NUV_PG_QUOTA_TAG}} --push" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Use pg_config to detect postgres dependencies | ||
# | ||
# Variables: | ||
# | ||
# PG_CONFIG - the path to the pg_config executable to be used. this determines the | ||
# version to be built with. | ||
# PG_MAJOR_VERSION - the major version parsed from Postgres source | ||
# PG_VERSION - The PG_VERSION string | ||
# PG_BIN_DIR - location of user executables | ||
# PG_INCLUDE_DIR - location of C header files of the client | ||
# PG_INCLUDE_DIR_SERVER - location of C header files for the server | ||
# PG_LIBS - LIBS value used when PostgreSQL was built | ||
# PG_LIB_DIR - location of object code libraries | ||
# PG_PKG_LIB_DIR - location of dynamically loadable modules | ||
# PG_SHARE_DIR - location of architecture-independent support files | ||
# PG_PGXS - location of extension makefile | ||
# PG_CPP_FLAGS - CPPFLAGS value used when PostgreSQL was built | ||
# PG_C_FLAGS - CFLAGS value used when PostgreSQL was built | ||
# PG_LD_FLAGS - LDFLAGS value used when PostgreSQL was built | ||
# PG_HOME - The installation directory of Greenplum | ||
# PG_SRC_DIR - The directory of the postgres/greenplum source code | ||
|
||
include_guard() | ||
find_program(PG_CONFIG pg_config) | ||
if(PG_CONFIG) | ||
message(STATUS "Use '${PG_CONFIG}'") | ||
else() | ||
message(FATAL_ERROR "Unable to find 'pg_config'") | ||
endif() | ||
exec_program(${PG_CONFIG} ARGS --includedir OUTPUT_VARIABLE PG_INCLUDE_DIR) | ||
exec_program(${PG_CONFIG} ARGS --includedir-server OUTPUT_VARIABLE PG_INCLUDE_DIR_SERVER) | ||
exec_program(${PG_CONFIG} ARGS --pkglibdir OUTPUT_VARIABLE PG_PKG_LIB_DIR) | ||
exec_program(${PG_CONFIG} ARGS --sharedir OUTPUT_VARIABLE PG_SHARE_DIR) | ||
exec_program(${PG_CONFIG} ARGS --bindir OUTPUT_VARIABLE PG_BIN_DIR) | ||
exec_program(${PG_CONFIG} ARGS --cppflags OUTPUT_VARIABLE PG_CPP_FLAGS) | ||
exec_program(${PG_CONFIG} ARGS --cflags OUTPUT_VARIABLE PG_C_FLAGS) | ||
exec_program(${PG_CONFIG} ARGS --ldflags OUTPUT_VARIABLE PG_LD_FLAGS) | ||
exec_program(${PG_CONFIG} ARGS --libs OUTPUT_VARIABLE PG_LIBS) | ||
exec_program(${PG_CONFIG} ARGS --libdir OUTPUT_VARIABLE PG_LIB_DIR) | ||
exec_program(${PG_CONFIG} ARGS --pgxs OUTPUT_VARIABLE PG_PGXS) | ||
get_filename_component(PG_HOME "${PG_BIN_DIR}/.." ABSOLUTE) | ||
if (NOT PG_SRC_DIR) | ||
get_filename_component(pgsx_SRC_DIR ${PG_PGXS} DIRECTORY) | ||
set(makefile_global ${pgsx_SRC_DIR}/../Makefile.global) | ||
# Some magic to find out the source code root from pg's Makefile.global | ||
execute_process( | ||
COMMAND_ECHO STDOUT | ||
COMMAND | ||
grep "^abs_top_builddir" ${makefile_global} | ||
COMMAND | ||
sed s/.*abs_top_builddir.*=\\\(.*\\\)/\\1/ | ||
OUTPUT_VARIABLE PG_SRC_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
string(STRIP ${PG_SRC_DIR} PG_SRC_DIR) | ||
endif() | ||
|
||
# Get the GP_MAJOR_VERSION from header | ||
file(READ ${PG_INCLUDE_DIR}/pg_config.h config_header) | ||
string(REGEX MATCH "#define *PG_MAJORVERSION *\"[0-9]+\"" macrodef "${config_header}") | ||
string(REGEX MATCH "[0-9]+" PG_MAJORVERSION "${macrodef}") | ||
if (PG_MAJORVERSION) | ||
message(STATUS "Build extension for POSTGRESDB ${PG_MAJORVERSION}") | ||
else() | ||
message(FATAL_ERROR "Cannot read PG_MAJORVERSION from '${PG_INCLUDE_DIR}/pg_config.h'") | ||
endif() | ||
string(REGEX MATCH "#define *PG_VERSION *\"[^\"]*\"" macrodef "${config_header}") | ||
string(REGEX REPLACE ".*\"\(.*\)\".*" "\\1" PG_VERSION "${macrodef}") | ||
if (PG_VERSION) | ||
message(STATUS "The exact POSTGRESDB version is '${PG_VERSION}'") | ||
else() | ||
message(FATAL_ERROR "Cannot read PG_VERSION from '${PG_INCLUDE_DIR}/pg_config.h'") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters