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

more package friendly and fix tests #49

Merged
merged 1 commit into from
Jul 11, 2015
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
6 changes: 3 additions & 3 deletions actions/uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ remove()
rm -rf ${pgvm_environments}/*
if [ $purge -eq 1 ]
then
rm -rf $pgvm_home/src/*
rm -rf $pgvm_src/*
fi
break
elif [ -d $pgvm_home/environments/$version ]
Expand All @@ -105,7 +105,7 @@ remove()

if [ $purge -eq 1 ]
then
rm -rf $pgvm_home/src/postgresql-$version*
rm -rf $pgvm_src/postgresql-$version*
fi
break
else
Expand All @@ -119,7 +119,7 @@ remove()
uninstall()
{
VERSIONS=$($LS -1 $pgvm_home/environments/ 2> /dev/null | grep -v current)
SOURCES=$($LS -1 $pgvm_home/src/ 2> /dev/null)
SOURCES=$($LS -1 $pgvm_src/ 2> /dev/null)

version=$1
shift
Expand Down
1 change: 1 addition & 0 deletions bin/pgvm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

source $pgvm_home/include/helpers

verify_env_vars
load_conf

action=$1
Expand Down
15 changes: 14 additions & 1 deletion bin/pgvm-self-install
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ clone_repo()

}

copy_repo()
{
from_dir=${1}
cp -a $from_dir $pgvm_home
}

update_repo()
{
cd $pgvm_home
Expand Down Expand Up @@ -73,11 +79,12 @@ set_bash_env()

cat > ${pgvm_home}/pgvm_env <<EOF
pgvm_home=${pgvm_home}
pgvm_src=${pgvm_src}
pgvm_logs=${pgvm_logs}
pgvm_clusters=${pgvm_clusters}
pgvm_environments=${pgvm_environments}

export pgvm_home pgvm_logs pgvm_environments pgvm_clusters
export pgvm_home pgvm_src pgvm_logs pgvm_environments pgvm_clusters

export PATH=\${pgvm_home}/bin:\$PATH
export PATH=\${pgvm_environments}/current/bin:\$PATH
Expand Down Expand Up @@ -109,6 +116,7 @@ parse_options()
parse_options $*

pgvm_home=${opt_pgvm_home:-"$HOME/.pgvm"}
pgvm_src=${opt_pgvm_src:-"\${pgvm_home}/src"}
pgvm_logs=${opt_logs_dir:-"\${pgvm_home}/logs"}
pgvm_clusters=${opt_clusters_dir:-"\${pgvm_home}/clusters"}
pgvm_environments=${opt_environments_dir:-"\${pgvm_home}/environments"}
Expand All @@ -128,7 +136,12 @@ then
exit 1
fi
else
if [ -n $opt_from_dir ]
then
copy_repo $opt_from_dir
else
clone_repo
fi
fi

set_bash_env
20 changes: 14 additions & 6 deletions include/helpers
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ execute_action()
fi
}

verify_env_vars()
{
[[ -z $pgvm_environments ]] || [[ -z $pgvm_clusters ]] || [[ -z $pgvm_logs ]] && {
echo 'Could not continue. Variables $pgvm_environments, $pgvm_clusters, $pgvm_logs are not set.'
exit 1
}
}

parse_options()
{
for opt in $*
Expand Down Expand Up @@ -153,22 +161,22 @@ seems_to_be_from_repo()

local_repo_exists()
{
pg_dest_dir=$pgvm_home/src/postgresql-clone
pg_dest_dir=$pgvm_src/postgresql-clone
cd $pg_dest_dir 2>/dev/null && grep -i postgresql README &>/dev/null && git status &>/dev/null
}

checkout_postgres()
{
version=$1
pg_clone_dir=$pgvm_home/src/postgresql-clone
pg_clone_dir=$pgvm_src/postgresql-clone
cd $pg_clone_dir && git checkout $version &>/dev/null && git clean -f &>/dev/null

[[ $? -eq 1 ]] && echo "the branch '$version' seems to be invalid." && exit 1
}

clone_postgres()
{
pg_dest_dir=$pgvm_home/src
pg_dest_dir=$pgvm_src
pg_url=$(git_repo_url $version)

echo "getting postgres from '$pg_url'"
Expand All @@ -191,7 +199,7 @@ get_postgres()
version=$(download http://www.postgresql.org/versions.rss - | grep "is the latest release in the" | sed -E "s/^.*([0-9]\.[0-9]+\.[0-9]+) is the latest release in the ([0-9]\.[0-9]+).*/\1/" |grep ^"$version"|head -n1)
fi

pg_dest_dir=$pgvm_home/src
pg_dest_dir=$pgvm_src
pg_url=$(postgres_download_url $version)

mkdir -p $pg_dest_dir
Expand All @@ -216,7 +224,7 @@ get_postgres()
extract_postgres()
{
version=${1:-$version}
pg_dest_dir=$pgvm_home/src
pg_dest_dir=$pgvm_src

cd $pg_dest_dir

Expand All @@ -231,7 +239,7 @@ compile_and_install_postgres()
version=${1:-$version}
configure_options=${CONFIG_OPTS}
make_options=${MAKE_OPTS}
pg_dest_dir=$pgvm_home/src
pg_dest_dir=$pgvm_src

if seems_to_be_from_repo $version
then
Expand Down
Loading