Reindent
This commit is contained in:
parent
202b89c381
commit
26cb8314f7
1 changed files with 385 additions and 357 deletions
140
pg-env
140
pg-env
|
@ -12,11 +12,13 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
create_pgenv() {
|
create_pgenv() {
|
||||||
|
|
||||||
cat >../${2}/.pg-env <<EOF
|
cat >../${2}/.pg-env <<EOF
|
||||||
export PGV=${1}
|
export PGV=${1}
|
||||||
PG_DEV_NAME=${2}
|
PG_DEV_NAME=${2}
|
||||||
export SKIP_MESON_BUILD=1
|
export SKIP_MESON_BUILD=1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
commitfest() {
|
commitfest() {
|
||||||
|
@ -32,18 +34,18 @@ commitfest() {
|
||||||
echo "or"
|
echo "or"
|
||||||
echo "Usage: $0 commitfest CommitFestID EntryID <PG_RELEASED_BRANCH_NAME>"
|
echo "Usage: $0 commitfest CommitFestID EntryID <PG_RELEASED_BRANCH_NAME>"
|
||||||
fi
|
fi
|
||||||
if [ ! -f src/include/postgres.h ] || [ ! -d .git ] ; then
|
if [ ! -f src/include/postgres.h ] || [ ! -d .git ]; then
|
||||||
EXIT_VALUE=1
|
EXIT_VALUE=1
|
||||||
echo "Run this command from PostgreSQL git checkout"
|
echo "Run this command from PostgreSQL git checkout"
|
||||||
fi
|
fi
|
||||||
git remote show -n commitfest > /dev/null
|
git remote show -n commitfest >/dev/null
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Adding commitfest as remote using https://github.com/postgresql-cfbot/postgresql.git"
|
echo "Adding commitfest as remote using https://github.com/postgresql-cfbot/postgresql.git"
|
||||||
git remote add commitfest https://github.com/postgresql-cfbot/postgresql.git
|
git remote add commitfest https://github.com/postgresql-cfbot/postgresql.git
|
||||||
fi
|
fi
|
||||||
git fetch commitfest ${branch_name}
|
git fetch commitfest ${branch_name}
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 2 ]; then
|
||||||
IsBranchPresent=$( git worktree list | grep "${branch_name}" )
|
IsBranchPresent=$(git worktree list | grep "${branch_name}")
|
||||||
#else
|
#else
|
||||||
# IsBranchPresent=$( git worktree list | grep "${branch_name}_${3}\]" )
|
# IsBranchPresent=$( git worktree list | grep "${branch_name}_${3}\]" )
|
||||||
fi
|
fi
|
||||||
|
@ -80,14 +82,14 @@ branch() {
|
||||||
echo "or"
|
echo "or"
|
||||||
echo "Usage: $0 branch <Name of new Branch <PG_RELEASED_BRANCH_NAME>"
|
echo "Usage: $0 branch <Name of new Branch <PG_RELEASED_BRANCH_NAME>"
|
||||||
fi
|
fi
|
||||||
if [ ! -f src/include/postgres.h ] || [ ! -d .git ] ; then
|
if [ ! -f src/include/postgres.h ] || [ ! -d .git ]; then
|
||||||
EXIT_VALUE=1
|
EXIT_VALUE=1
|
||||||
echo "Run this command from PostgreSQL git checkout"
|
echo "Run this command from PostgreSQL git checkout"
|
||||||
fi
|
fi
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 2 ]; then
|
||||||
IsBranchPresent=$( git worktree list | grep '\[${branch_name}\]' )
|
IsBranchPresent=$(git worktree list | grep '\[${branch_name}\]')
|
||||||
else
|
else
|
||||||
IsBranchPresent=$( git worktree list | grep '\[${branch_name}_${2}\]' )
|
IsBranchPresent=$(git worktree list | grep '\[${branch_name}_${2}\]')
|
||||||
fi
|
fi
|
||||||
if [ ! -z "${IsBranchPresent}" ]; then
|
if [ ! -z "${IsBranchPresent}" ]; then
|
||||||
EXIT_VALUE=1
|
EXIT_VALUE=1
|
||||||
|
@ -192,23 +194,51 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
distclean() {
|
distclean() {
|
||||||
resetinst "$@"
|
resetinst "$@"
|
||||||
pushd ${PG_DEV_SRC}
|
pushd ${PG_DEV_SRC}
|
||||||
make clean
|
make clean
|
||||||
make distclean
|
make distclean
|
||||||
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
||||||
(cd build; ninja clean)
|
(
|
||||||
|
cd build
|
||||||
|
ninja clean
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
compile() {
|
compile() {
|
||||||
pushd ${PG_DEV_SRC}
|
pushd ${PG_DEV_SRC}
|
||||||
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
||||||
(time ./configure --prefix=${PG_DEV_INST} --enable-injection-points --enable-debug --with-pgport=${PGPORT} --with-systemd --with-lz4 --with-ssl=openssl --with-python --with-perl --enable-debug --enable-cassert --enable-tap-tests CFLAGS="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}") |& tee /tmp/pg_compile.log
|
(
|
||||||
|
time ./configure \
|
||||||
|
--prefix=${PG_DEV_INST} \
|
||||||
|
--enable-injection-points \
|
||||||
|
--enable-debug \
|
||||||
|
--with-pgport=${PGPORT} \
|
||||||
|
--with-systemd --with-lz4 \
|
||||||
|
--with-ssl=openssl \
|
||||||
|
--with-python --with-perl \
|
||||||
|
--enable-debug --enable-cassert \
|
||||||
|
--enable-tap-tests \
|
||||||
|
CFLAGS="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}"
|
||||||
|
) |& tee /tmp/pg_compile.log
|
||||||
else
|
else
|
||||||
(time meson setup build --prefix=${PG_DEV_INST} -Dpgport=${PGPORT} -Dlz4=enabled -Dssl=openssl -Dplpython=enabled -Dsystemd -Dplperl=enabled -Ddebug=true -Dcassert=true -Dtap_tests=enabled -Dc_args="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}") |& tee /tmp/pg_compile.log
|
(
|
||||||
|
time meson setup build \
|
||||||
|
--prefix=${PG_DEV_INST} \
|
||||||
|
-Dpgport=${PGPORT} \
|
||||||
|
-Dlz4=enabled \
|
||||||
|
-Dssl=openssl \
|
||||||
|
-Dplpython=enabled \
|
||||||
|
-Dsystemd \
|
||||||
|
-Dplperl=enabled \
|
||||||
|
-Ddebug=true \
|
||||||
|
-Dcassert=true \
|
||||||
|
-Dtap_tests=enabled \
|
||||||
|
-Dc_args="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}" \
|
||||||
|
) |& tee /tmp/pg_compile.log
|
||||||
fi
|
fi
|
||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
||||||
|
@ -218,18 +248,23 @@ compile() {
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
||||||
(time make install) |& tee -a /tmp/pg_compile.log
|
(
|
||||||
|
time make install \
|
||||||
|
) |& tee -a /tmp/pg_compile.log
|
||||||
else
|
else
|
||||||
(cd build; time ninja -v install) |& tee -a /tmp/pg_compile.log
|
(
|
||||||
|
cd build
|
||||||
|
time ninja -v install
|
||||||
|
) |& tee -a /tmp/pg_compile.log
|
||||||
fi
|
fi
|
||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
echo "make install failed"
|
echo "make install failed"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_contrib() {
|
compile_contrib() {
|
||||||
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
if [ -z ${MESON_BUILD_PRESENT} ]; then
|
||||||
pushd ${PG_DEV_SRC}/contrib
|
pushd ${PG_DEV_SRC}/contrib
|
||||||
(time make install) |& tee -a /tmp/pg_compile.log
|
(time make install) |& tee -a /tmp/pg_compile.log
|
||||||
|
@ -238,56 +273,52 @@ compile_contrib() {
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
startdb(){
|
startdb() {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
[ -d "${PGDATA}" ] && pg_ctl start
|
[ -d "${PGDATA}" ] && pg_ctl start
|
||||||
else
|
else
|
||||||
for NodeN in $@
|
for NodeN in $@; do
|
||||||
do
|
|
||||||
echo "Starting pg_ctl start -D ${PGDATA}-${NodeN}"
|
echo "Starting pg_ctl start -D ${PGDATA}-${NodeN}"
|
||||||
[ -d "${PGDATA}-${NodeN}" ] && pg_ctl start -D ${PGDATA}-${NodeN}
|
[ -d "${PGDATA}-${NodeN}" ] && pg_ctl start -D ${PGDATA}-${NodeN}
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
stopdb(){
|
stopdb() {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
[ -d "${PGDATA}" ] && pg_ctl stop
|
[ -d "${PGDATA}" ] && pg_ctl stop
|
||||||
else
|
else
|
||||||
for NodeN in $@
|
for NodeN in $@; do
|
||||||
do
|
|
||||||
[ -d "${PGDATA}-${NodeN}" ] && pg_ctl stop -D ${PGDATA}-${NodeN}
|
[ -d "${PGDATA}-${NodeN}" ] && pg_ctl stop -D ${PGDATA}-${NodeN}
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
restartdb(){
|
restartdb() {
|
||||||
stopdb "$@"
|
stopdb "$@"
|
||||||
startdb "$@"
|
startdb "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
cleandb(){
|
cleandb() {
|
||||||
stopdb "$@"
|
stopdb "$@"
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
[ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
|
[ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
|
||||||
rm -rf $PGDATA/*
|
rm -rf $PGDATA/*
|
||||||
else
|
else
|
||||||
for NodeN in $@
|
for NodeN in $@; do
|
||||||
do
|
|
||||||
[ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
|
[ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
|
||||||
rm -rf ${PGDATA}-${NodeN}/*
|
rm -rf ${PGDATA}-${NodeN}/*
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
### TODO ###
|
### TODO ###
|
||||||
pexec(){
|
pexec() {
|
||||||
args=""
|
args=""
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]; do
|
||||||
do
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--PEXEC_CMD=*|PEXEC_CMD=*)
|
--PEXEC_CMD=* | PEXEC_CMD=*)
|
||||||
PEXEC_CMD=${1#*=}
|
PEXEC_CMD=${1#*=}
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -301,56 +332,54 @@ pexec(){
|
||||||
echo psql -U ${USER} ${PEXEC_CMD}
|
echo psql -U ${USER} ${PEXEC_CMD}
|
||||||
psql -U ${USER} ${PEXEC_CMD}
|
psql -U ${USER} ${PEXEC_CMD}
|
||||||
else
|
else
|
||||||
for NodeN in $@
|
for NodeN in $@; do
|
||||||
do
|
|
||||||
cmd="psql -U ${USER} -p ${NodeN}${PGPORT} ${PEXEC_CMD}"
|
cmd="psql -U ${USER} -p ${NodeN}${PGPORT} ${PEXEC_CMD}"
|
||||||
echo $cmd
|
echo $cmd
|
||||||
$cmd
|
$cmd
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupdb(){
|
setupdb() {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
initdb --data-checksums --username=${USER}
|
initdb --data-checksums --username=${USER}
|
||||||
echo "include = '${GIT_DIR}/pgconfigs/pg${PGV}.conf'" >> ${PGDATA}/postgresql.conf
|
echo "include = '${GIT_DIR}/pgconfigs/pg${PGV}.conf'" >>${PGDATA}/postgresql.conf
|
||||||
if [ -f "$(pwd)/.pg${PGV}.conf" ]; then
|
if [ -f "$(pwd)/.pg${PGV}.conf" ]; then
|
||||||
echo "include = '$(pwd)/.pg${PGV}.conf'" >> ${PGDATA}/postgresql.conf
|
echo "include = '$(pwd)/.pg${PGV}.conf'" >>${PGDATA}/postgresql.conf
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
for NodeN in $@
|
for NodeN in $@; do
|
||||||
do
|
|
||||||
initdb --data-checksums --username=${USER} -D ${PGDATA}-${NodeN}
|
initdb --data-checksums --username=${USER} -D ${PGDATA}-${NodeN}
|
||||||
echo "include = '${GIT_DIR}/pgconfigs/pg${PGV}-${NodeN}.conf'" >> ${PGDATA}-${NodeN}/postgresql.conf
|
echo "include = '${GIT_DIR}/pgconfigs/pg${PGV}-${NodeN}.conf'" >>${PGDATA}-${NodeN}/postgresql.conf
|
||||||
if [ -f "$(pwd)/.pg${PGV}-${NodeN}.conf" ]; then
|
if [ -f "$(pwd)/.pg${PGV}-${NodeN}.conf" ]; then
|
||||||
echo "include = '$(pwd)/.pg${PGV}-${NodeN}.conf'" >> ${PGDATA}-${NodeN}/postgresql.conf
|
echo "include = '$(pwd)/.pg${PGV}-${NodeN}.conf'" >>${PGDATA}-${NodeN}/postgresql.conf
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
resetdb() {
|
resetdb() {
|
||||||
stopdb "$@"
|
stopdb "$@"
|
||||||
cleandb "$@"
|
cleandb "$@"
|
||||||
setupdb "$@"
|
setupdb "$@"
|
||||||
startdb "$@"
|
startdb "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
resetinst() {
|
resetinst() {
|
||||||
stopdb "$@"
|
stopdb "$@"
|
||||||
[ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
|
[ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
|
||||||
rm -rf $PG_DEV_INST/*
|
rm -rf $PG_DEV_INST/*
|
||||||
}
|
}
|
||||||
|
|
||||||
resetall() {
|
resetall() {
|
||||||
distclean
|
distclean
|
||||||
compile
|
compile
|
||||||
compile_contrib
|
compile_contrib
|
||||||
resetdb "$@"
|
resetdb "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
deactivate() {
|
deactivate() {
|
||||||
stopdb
|
stopdb
|
||||||
stopdb 1 2 3
|
stopdb 1 2 3
|
||||||
export PATH=${SAVED_PATH}
|
export PATH=${SAVED_PATH}
|
||||||
|
@ -413,9 +442,8 @@ deactivate() {
|
||||||
unset SAVED_PGV
|
unset SAVED_PGV
|
||||||
unset PG_DEV_NAME
|
unset PG_DEV_NAME
|
||||||
unset GIT_DIR
|
unset GIT_DIR
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
echo "Already in pg-env VENV"
|
echo "Already in pg-env VENV"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue