Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebuild command implementation #37

Merged
merged 3 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ running, `clear` will stop it before clearing it.
### pgenv build

Downloads and builds the specified version of PostgreSQL and its contrib
modules, as far back as 8.0.
modules, as far back as version `8.0`.
It is possible to instrument the build process to patch the source tree, see
the section on patching later on.
If the version is already built, it will not be rebuilt; use
Expand Down Expand Up @@ -269,6 +269,18 @@ file. As an example
$ PGENV_PATCH_INDEX=/src/my-patch-list.txt pgenv build 10.5


#### pgenv rebuild

The `rebuild` command allows the rebuilding from sources of a specific
PostgreSQL version. *The `PGDATA` directory will not be deleted if already
initialized via `initdb`*.

The configuration will follow the same rules adopted in `build`, that means
if a configuration file will be present it will be readed and loaded, otherwise
the system will claim about such file proposing to create one.

In the case a specific version has never been built, `rebuild` acts exactly
as `build`.

### pgenv remove

Expand Down
13 changes: 8 additions & 5 deletions bin/pgenv
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The pgenv commands are:
stop Stop the current PostgreSQL server
restart Restart the current PostgreSQL server
build Build a specific version of PostgreSQL
rebuild Re-build a specific version of PostgreSQL
remove Remove a specific version of PostgreSQL
version Show the current PostgreSQL version
current Same as 'version'
Expand Down Expand Up @@ -688,18 +689,20 @@ case $1 in
exit
;;

build)
build|rebuild)
v=$2
# sanity checks before building
pgenv_input_version_or_exit "$v"
pgenv_configuration_load $v
pgenv_check_dependencies


# Skip it if we already have it.
if [ -e "pgsql-$v" ]; then
echo "PostgreSQL $v already built"
exit
# Skip it if we already have it, and are not rebuilding
if [ "$1" != "rebuild" ]; then
if [ -e "pgsql-$v" ]; then
echo "PostgreSQL $v already built (did you mean `rebuild` instead?)"
exit 1
fi
fi

# Switch to the src directory.
Expand Down