Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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?

linux
@@ -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`

Please use ="$( ... )"

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

@jsuchal
jsuchal added a note

@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
linux
@@ -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

Quotes around "$codename".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
linux
@@ -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

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

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.

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 note

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

@jsuchal
jsuchal added a note

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
@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
@jsuchal

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

@djcp djcp reopened this
@djcp

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

@djcp djcp added the linux label
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 14, 2014
  1. @jsuchal
  2. @jsuchal
Commits on Jan 21, 2014
  1. @jsuchal
  2. @jsuchal

    Add postgresql-contrib package and pgadmin3

    jsuchal authored
    This add postgresql-contrib package by default since there are extensions that are so useful in most for our development workflow. pg_trgm, fdw, unaccent. Also pgadmin which is indispensable tool for tuning queries and advanced development.
  3. @jsuchal
  4. @jsuchal
  5. @jsuchal

    Fix quoting around parameters

    jsuchal authored
Commits on Feb 7, 2014
  1. @jsuchal
  2. @jsuchal
  3. @jsuchal

    Improve idempotency in the linux laptop script

    Dan Collis-Puro authored jsuchal committed
    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.
  4. @jsuchal

    Update license to 2014

    Adarsh Pandit authored jsuchal committed
  5. @jsuchal

    Use correct thoughtbot/homebrew-formulae repo

    Matthew Sumner authored jsuchal committed
  6. @jsuchal

    Remove pgadmin3 for now

    jsuchal authored
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -1 +1,2 @@
*.swp
+.vagrant
View
2  LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2011-2012 thoughtbot, inc.
+Copyright (c) 2011-2014 thoughtbot, inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
1  Manifest.linux
@@ -10,5 +10,6 @@ linux-components/silver-searcher-from-source
linux-components/rbenv
common-components/ruby-environment
linux-components/bundler
+common-components/default-gems
linux-components/heroku
linux-components/rcm
View
1  Manifest.mac
@@ -10,5 +10,6 @@ mac-components/rbenv
mac-components/compiler-and-libraries
common-components/ruby-environment
mac-components/bundler
+common-components/default-gems
mac-components/heroku
mac-components/rcm
View
2  README.md
@@ -96,5 +96,5 @@ Please see [CONTRIBUTING.md](https://github.com/thoughtbot/laptop/blob/master/CO
License
-------
-Laptop is © 2011-2013 thoughtbot, inc. It is free software, and may be
+Laptop is © 2011-2014 thoughtbot, inc. It is free software, and may be
redistributed under the terms specified in the LICENSE file.
View
5 TESTING.md
@@ -35,6 +35,11 @@ The following are the assertions:
3. The VM reports the correct `$SHELL`
4. The VM reports the correct ruby
+You can test idempotency (allowing you to run the script multiple times in the
+same environment) by exporting `KEEP_VM` before running `./test/runner.sh` thusly:
+
+ KEEP_VM=1 ./test/runner.sh
+
## OSX Testing
Adding additional linux tests via this framework should be easy: simply
View
4 common-components/check-home-bin
@@ -2,6 +2,10 @@ if [ ! -d "$HOME/.bin/" ]; then
mkdir "$HOME/.bin"
fi
+if [ ! -f "$HOME/.zshrc" ]; then
+ touch $HOME/.zshrc
+fi
+
if [[ ":$PATH:" != *":$HOME/.bin:"* ]]; then
echo 'export PATH="$HOME/.bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
View
2  common-components/default-gems
@@ -0,0 +1,2 @@
+fancy_echo "Installing Rails ..."
+ gem install rails --no-document
View
3  common-components/ruby-environment
@@ -13,9 +13,6 @@ fancy_echo "Updating to latest Rubygems version ..."
fancy_echo "Installing Bundler to install project-specific Ruby gems ..."
gem install bundler --no-document --pre
-fancy_echo "Installing Rails ..."
- gem install rails --no-document
-
fancy_echo "Installing GitHub CLI client ..."
curl http://hub.github.com/standalone -sLo ~/.bin/hub
chmod +x ~/.bin/hub
View
76 linux
@@ -17,6 +17,10 @@ if [ ! -d "$HOME/.bin/" ]; then
mkdir "$HOME/.bin"
fi
+if [ ! -f "$HOME/.zshrc" ]; then
+ touch $HOME/.zshrc
+fi
+
if [[ ":$PATH:" != *":$HOME/.bin:"* ]]; then
echo 'export PATH="$HOME/.bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
@@ -54,8 +58,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/postgres_official_releases.list > /dev/null
+ wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
+ sudo aptitude update
+ fi
+
fancy_echo "Installing Postgres, a good open source relational database ..."
- sudo aptitude install -y postgresql postgresql-server-dev-all
+ sudo aptitude install -y postgresql postgresql-contrib postgresql-server-dev-all
fancy_echo "Installing Redis, a good key-value database ..."
sudo aptitude install -y redis-server
@@ -76,33 +95,41 @@ fancy_echo "Installing watch, to execute a program periodically and show the out
sudo aptitude install -y watch
### end linux-components/debian-derivative-packages
-fancy_echo "Installing The Silver Searcher (better than ack or grep) to search the contents of files ..."
- git clone git://github.com/ggreer/the_silver_searcher.git /tmp/the_silver_searcher
- sudo aptitude install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
- sh /tmp/the_silver_searcher/build.sh
- cd /tmp/the_silver_searcher
- sh build.sh
- sudo make install
- cd
- rm -rf /tmp/the_silver_searcher
+if [[ $+commands[ag] -ne 1 ]]; then
+ fancy_echo "Installing The Silver Searcher (better than ack or grep) to search the contents of files ..."
+ git clone git://github.com/ggreer/the_silver_searcher.git /tmp/the_silver_searcher
+ sudo aptitude install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
+ sh /tmp/the_silver_searcher/build.sh
+ cd /tmp/the_silver_searcher
+ sh build.sh
+ sudo make install
+ cd
+ rm -rf /tmp/the_silver_searcher
+fi
### end linux-components/silver-searcher-from-source
-fancy_echo "Installing rbenv, to change Ruby versions ..."
- git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
+if [[ ! -d "$HOME/.rbenv" ]]; then
+ fancy_echo "Installing rbenv, to change Ruby versions ..."
+ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
- if ! grep -qs "rbenv init" ~/.zshrc; then
- echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
+ if ! grep -qs "rbenv init" ~/.zshrc; then
+ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
- echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
- fi
+ echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
+ fi
- source ~/.zshrc
+ source ~/.zshrc
+fi
-fancy_echo "Installing rbenv-gem-rehash so the shell automatically picks up binaries after installing gems with binaries..."
- git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
+if [[ ! -d "$HOME/.rbenv/plugins/rbenv-gem-rehash" ]]; then
+ fancy_echo "Installing rbenv-gem-rehash so the shell automatically picks up binaries after installing gems with binaries..."
+ git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
+fi
-fancy_echo "Installing ruby-build, to install Rubies ..."
- git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
+if [[ ! -d "$HOME/.rbenv/plugins/ruby-build" ]]; then
+ fancy_echo "Installing ruby-build, to install Rubies ..."
+ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
+fi
### end linux-components/rbenv
RUBY_VERSION="2.1.0"
@@ -120,9 +147,6 @@ fancy_echo "Updating to latest Rubygems version ..."
fancy_echo "Installing Bundler to install project-specific Ruby gems ..."
gem install bundler --no-document --pre
-fancy_echo "Installing Rails ..."
- gem install rails --no-document
-
fancy_echo "Installing GitHub CLI client ..."
curl http://hub.github.com/standalone -sLo ~/.bin/hub
chmod +x ~/.bin/hub
@@ -133,6 +157,10 @@ fancy_echo "Configuring Bundler for faster, parallel gem installation ..."
bundle config --global jobs `expr $number_of_cores - 1`
### end linux-components/bundler
+fancy_echo "Installing Rails ..."
+ gem install rails --no-document
+### end common-components/default-gems
+
fancy_echo "Installing Heroku CLI client ..."
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
View
17 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/postgres_official_releases.list > /dev/null
+ wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
+ sudo aptitude update
+ fi
+
fancy_echo "Installing Postgres, a good open source relational database ..."
- sudo aptitude install -y postgresql postgresql-server-dev-all
+ sudo aptitude install -y postgresql postgresql-contrib postgresql-server-dev-all
fancy_echo "Installing Redis, a good key-value database ..."
sudo aptitude install -y redis-server
View
14 linux-components/debian-prerequisites
@@ -4,8 +4,14 @@ fancy_echo "Installing curl ..."
fancy_echo "Installing zsh ..."
sudo aptitude install -y zsh
-fancy_echo "Changing your shell to zsh ..."
- chsh -s `which zsh`
+ZSH_PATH=`which zsh`
-fancy_echo "Your shell will now restart to apply changes."
- exec `which zsh` -l
+if [[ $SHELL == $ZSH_PATH ]]; then
+ fancy_echo "Already using zsh as your login shell. Huzzah!"
+else
+ fancy_echo "Changing your shell to zsh ..."
+ chsh -s $ZSH_PATH
+
+ fancy_echo "Your shell will now restart to apply changes."
+ exec $ZSH_PATH -l
+fi
View
28 linux-components/rbenv
@@ -1,16 +1,22 @@
-fancy_echo "Installing rbenv, to change Ruby versions ..."
- git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
+if [[ ! -d "$HOME/.rbenv" ]]; then
+ fancy_echo "Installing rbenv, to change Ruby versions ..."
+ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
- if ! grep -qs "rbenv init" ~/.zshrc; then
- echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
+ if ! grep -qs "rbenv init" ~/.zshrc; then
+ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
- echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
- fi
+ echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
+ fi
- source ~/.zshrc
+ source ~/.zshrc
+fi
-fancy_echo "Installing rbenv-gem-rehash so the shell automatically picks up binaries after installing gems with binaries..."
- git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
+if [[ ! -d "$HOME/.rbenv/plugins/rbenv-gem-rehash" ]]; then
+ fancy_echo "Installing rbenv-gem-rehash so the shell automatically picks up binaries after installing gems with binaries..."
+ git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
+fi
-fancy_echo "Installing ruby-build, to install Rubies ..."
- git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
+if [[ ! -d "$HOME/.rbenv/plugins/ruby-build" ]]; then
+ fancy_echo "Installing ruby-build, to install Rubies ..."
+ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
+fi
View
20 linux-components/silver-searcher-from-source
@@ -1,9 +1,11 @@
-fancy_echo "Installing The Silver Searcher (better than ack or grep) to search the contents of files ..."
- git clone git://github.com/ggreer/the_silver_searcher.git /tmp/the_silver_searcher
- sudo aptitude install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
- sh /tmp/the_silver_searcher/build.sh
- cd /tmp/the_silver_searcher
- sh build.sh
- sudo make install
- cd
- rm -rf /tmp/the_silver_searcher
+if [[ $+commands[ag] -ne 1 ]]; then
+ fancy_echo "Installing The Silver Searcher (better than ack or grep) to search the contents of files ..."
+ git clone git://github.com/ggreer/the_silver_searcher.git /tmp/the_silver_searcher
+ sudo aptitude install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
+ sh /tmp/the_silver_searcher/build.sh
+ cd /tmp/the_silver_searcher
+ sh build.sh
+ sudo make install
+ cd
+ rm -rf /tmp/the_silver_searcher
+fi
View
14 linux-prerequisites
@@ -41,10 +41,16 @@ fancy_echo "Installing curl ..."
fancy_echo "Installing zsh ..."
sudo aptitude install -y zsh
-fancy_echo "Changing your shell to zsh ..."
- chsh -s `which zsh`
+ZSH_PATH=`which zsh`
-fancy_echo "Your shell will now restart to apply changes."
- exec `which zsh` -l
+if [[ $SHELL == $ZSH_PATH ]]; then
+ fancy_echo "Already using zsh as your login shell. Huzzah!"
+else
+ fancy_echo "Changing your shell to zsh ..."
+ chsh -s $ZSH_PATH
+
+ fancy_echo "Your shell will now restart to apply changes."
+ exec $ZSH_PATH -l
+fi
### end linux-components/debian-prerequisites
View
13 mac
@@ -17,6 +17,10 @@ if [ ! -d "$HOME/.bin/" ]; then
mkdir "$HOME/.bin"
fi
+if [ ! -f "$HOME/.zshrc" ]; then
+ touch $HOME/.zshrc
+fi
+
if [[ ":$PATH:" != *":$HOME/.bin:"* ]]; then
echo 'export PATH="$HOME/.bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
@@ -125,9 +129,6 @@ fancy_echo "Updating to latest Rubygems version ..."
fancy_echo "Installing Bundler to install project-specific Ruby gems ..."
gem install bundler --no-document --pre
-fancy_echo "Installing Rails ..."
- gem install rails --no-document
-
fancy_echo "Installing GitHub CLI client ..."
curl http://hub.github.com/standalone -sLo ~/.bin/hub
chmod +x ~/.bin/hub
@@ -138,6 +139,10 @@ fancy_echo "Configuring Bundler for faster, parallel gem installation ..."
bundle config --global jobs `expr $number_of_cores - 1`
### end mac-components/bundler
+fancy_echo "Installing Rails ..."
+ gem install rails --no-document
+### end common-components/default-gems
+
fancy_echo "Installing Heroku CLI client ..."
brew install heroku-toolbelt
@@ -146,7 +151,7 @@ fancy_echo "Installing the heroku-config plugin to pull config variables locally
### end mac-components/heroku
fancy_echo "Installing rcm, to manage your dotfiles ..."
- brew tap thoughtbot/rcm
+ brew tap thoughtbot/formulae
brew install rcm
### end mac-components/rcm
View
4 test/runner.sh
@@ -9,7 +9,9 @@ failure() {
}
vagrant_destroy() {
- vagrant destroy --force &>/dev/null
+ if [ -z "$KEEP_VM" ]; then
+ vagrant destroy --force &>/dev/null
+ fi
}
message "Building latest scripts"
Something went wrong with that request. Please try again.