Use official Postgresql package repositories #189

Closed
wants to merge 13 commits into
from

3 participants

@jsuchal

This patch resolves issue #187 of using old 9.1 postgres on newest Ubuntu 13.04 by using official Postgres repos for installation. I've added a fallback to install postgresql from OS default repos when there was no matching official repo found.

I've also added postgresql-contrib since it has too many great extensions that we almost always need in development. Foreign data wrappers, pg_trgm or unaccent to name a few. Also it adds pgadmin3 which is an indispensable tool for tuning query plans and advanced administration even if the GUI takes a while to get used to.

What do you think?

@pbrisbin pbrisbin and 1 other commented on an outdated diff Jan 21, 2014
@@ -54,8 +54,23 @@ fancy_echo "Installing base ruby build dependencies ..."
fancy_echo "Installing libraries for common gem dependencies ..."
sudo aptitude install -y libxslt1-dev libcurl4-openssl-dev libksba8 libksba-dev libqtwebkit-dev libreadline-dev
+fancy_echo "Trying to find official Postgres package repository..."
+ codename=`lsb_release -c | cut -f 2`
@pbrisbin
pbrisbin added a line comment Jan 21, 2014

Please use ="$( ... )"

@pbrisbin
pbrisbin added a line comment Jan 21, 2014

Also, @djcp did you mention something before about lsb_release not being reliably present across all the distros we support?

@jsuchal
jsuchal added a line comment Jan 21, 2014

@pbrisbin Not sure, but for debian-based that you mention here https://github.com/thoughtbot/laptop#linux it should be ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pbrisbin pbrisbin commented on an outdated diff Jan 21, 2014
@@ -54,8 +54,23 @@ fancy_echo "Installing base ruby build dependencies ..."
fancy_echo "Installing libraries for common gem dependencies ..."
sudo aptitude install -y libxslt1-dev libcurl4-openssl-dev libksba8 libksba-dev libqtwebkit-dev libreadline-dev
+fancy_echo "Trying to find official Postgres package repository..."
+ codename=`lsb_release -c | cut -f 2`
+
+ case $codename in
@pbrisbin
pbrisbin added a line comment Jan 21, 2014

Quotes around "$codename".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pbrisbin pbrisbin commented on an outdated diff Jan 21, 2014
@@ -54,8 +54,23 @@ fancy_echo "Installing base ruby build dependencies ..."
fancy_echo "Installing libraries for common gem dependencies ..."
sudo aptitude install -y libxslt1-dev libcurl4-openssl-dev libksba8 libksba-dev libqtwebkit-dev libreadline-dev
+fancy_echo "Trying to find official Postgres package repository..."
+ codename=`lsb_release -c | cut -f 2`
+
+ case $codename in
+ precise|quantal|raring|saucy) postgres_codename=precise;;
+ wheezy) postgres_codename=wheezy;;
+ *) fancy_echo "Official Postgres package repository for codename '$codename' not found."
+ esac
+
+ if [ $postgres_codename ]; then
@pbrisbin
pbrisbin added a line comment Jan 21, 2014

Please use [ -n "$postgres_codename" ] or [ "$postgres_codename" != "" ].

@pbrisbin
pbrisbin added a line comment Jan 21, 2014

Or [[ $postgres_codename ]] since these are being zsh-interpreted anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jsuchal

@pbrisbin I've pushed the fixes you suggested. Thanks!

@pbrisbin

Thanks for the fixes! I'll let @djcp comment on merge-ability as he's the Debian expert.

@jsuchal

One minor issue i see in the diff. Seem I've somehow managed to get 223cd50 commit into this branch. However it was approved in #186 if you don't want to cherrypick.

@djcp djcp and 1 other commented on an outdated diff Feb 7, 2014
linux-components/debian-derivative-packages
@@ -7,8 +7,23 @@ fancy_echo "Installing base ruby build dependencies ..."
fancy_echo "Installing libraries for common gem dependencies ..."
sudo aptitude install -y libxslt1-dev libcurl4-openssl-dev libksba8 libksba-dev libqtwebkit-dev libreadline-dev
+fancy_echo "Trying to find official Postgres package repository..."
+ codename="$(lsb_release -c | cut -f 2)"
+
+ case "$codename" in
+ precise|quantal|raring|saucy) postgres_codename=precise;;
+ wheezy) postgres_codename=wheezy;;
+ *) fancy_echo "Official Postgres package repository for codename '$codename' not found."
+ esac
+
+ if [ -n "$postgres_codename" ]; then
+ echo "deb http://apt.postgresql.org/pub/repos/apt/ $postgres_codename-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list > /dev/null
@djcp
djcp added a line comment Feb 7, 2014

Can we change pdgd.list to something more descriptive? postgres_official_releases.list? Maybe there's a better name. . .

@jsuchal
jsuchal added a line comment Feb 7, 2014

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@djcp

Sorry for the delay. Please rebase onto origin/master (you might be up to date, dunno). My only issue is pgadmin3, we've tried to install only the tools most broadly used by our team and I'm not sure that pgadmin3 is broadly used enough.

jsuchal and others added some commits Feb 7, 2014
@jsuchal jsuchal Fix repo name in non-generated file 4bc3190
Dan Collis-Puro Improve idempotency in the linux laptop script
These changes allow the laptop script to run more than once and can be
tested through ./test/runner.sh.  The only significant side effects are:

* Gems (pg, rails, unicorn) will be updated
* ruby $RUBY_VERSION will be set as the global ruby if it wasn't already
* rubygems proper will be updated to the latest release
* hub will be updated
* the heroku toolbelt will be updated.
83917d8
Adarsh Pandit Update license to 2014 395c548
Matthew Sumner Use correct thoughtbot/homebrew-formulae repo 3639207
@jsuchal jsuchal Remove pgadmin3 for now ea7c0f3
@djcp djcp closed this Feb 7, 2014
@jsuchal

@djcp hmm i've removed pgadmin3, done the rebase but not sure if it's ok.

@djcp djcp reopened this Feb 7, 2014
@djcp

Oops, I didn't mean to close this. Thanks! Looking one more time.

@djcp djcp added the linux label Apr 4, 2014
@djcp

I'm sorry I've sat on this for so long, but I think I'd prefer that these kinds of customizations happen via the newish "~/.laptop.local" facilities introduced in 0893848

I'm not comfortable maintaining an external dependency on how the postgres project manages packages and what distros they support for how long - after all, we'll have to maintain it long term.

@djcp djcp closed this Jun 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment