Skip to content

Commit

Permalink
Merge pull request #161 from fpco/ubuntu-packages
Browse files Browse the repository at this point in the history
Add code to create signed debian/ubuntu packages & host them on s3
  • Loading branch information
snoyberg committed Jun 2, 2015
2 parents 563a931 + 1083a93 commit 769c264
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.cabal-sandbox
/cabal*.config
/dist
/target
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ cabal.sandbox.config
/.cabal-sandbox/
.shake/
.stack-work/
/target/
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PKG_VERSION := $(shell cat stack.cabal|grep -e '^version:'|cut -d':' -f2|sed 's/\s//g')
GIT_REV_COUNT := $(shell git rev-list HEAD --count)
GIT_SHA := $(shell PAGER=cat git log --pretty=%h HEAD~1..HEAD)
UBUNTU_VERSION ?= 15.04

default: $(DIR)/target/ubuntu-$(UBUNTU_VERSION)/stack_$(PKG_VERSION)-$(GIT_REV_COUNT)-$(GIT_SHA)_amd64.deb

$(DIR)/target/ubuntu-$(UBUNTU_VERSION):
@mkdir -p $(DIR)/target/ubuntu-$(UBUNTU_VERSION)

$(DIR)/target/ubuntu-$(UBUNTU_VERSION)/stack_$(PKG_VERSION)-$(GIT_REV_COUNT)-$(GIT_SHA)_amd64.deb: | $(DIR)/target/ubuntu-$(UBUNTU_VERSION)
@cp $(DIR)/etc/Dockerfile $(DIR)/Dockerfile
@perl -p -i -e "s/<<UBUNTU_VERSION>>/$(UBUNTU_VERSION)/g" $(DIR)/Dockerfile
@perl -p -i -e "s/<<PKG_VERSION>>/$(PKG_VERSION)/g" $(DIR)/Dockerfile
@perl -p -i -e "s/<<GIT_REV_COUNT>>/$(GIT_REV_COUNT)/g" $(DIR)/Dockerfile
@perl -p -i -e "s/<<GIT_SHA>>/$(GIT_SHA)/g" $(DIR)/Dockerfile
@docker build --rm=false --tag=stack-$(UBUNTU_VERSION):$(PKG_VERSION)-$(GIT_REV_COUNT)-$(GIT_SHA) $(DIR)
@docker run --rm -v $(DIR)/target/ubuntu-$(UBUNTU_VERSION):/mnt stack-$(UBUNTU_VERSION):$(PKG_VERSION)-$(GIT_REV_COUNT)-$(GIT_SHA)

clean:
@rm -f $(DIR)/Dockerfile $(DIR)/target

.PHONY: clean default
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,44 @@ For more details on how stack works internally, please see [the architecture
document](ARCHITECTURE.md). **FIXME more correct link once moved to final repo
location**

### Install

* Ubuntu 15.04 (amd64)

```sh
wget -q -O- https://fpco.s3.amazonaws.com/fpco.key | sudo apt-key add -
echo 'deb http://fpco.s3.amazonaws.com/ubuntu/vivid stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
sudo apt-get update
sudo apt-get install stack -y
```

* Ubuntu 14.10 (amd64)

```sh
wget -q -O- https://fpco.s3.amazonaws.com/fpco.key | sudo apt-key add -
echo 'deb http://fpco.s3.amazonaws.com/ubuntu/utopic stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
sudo apt-get update
sudo apt-get install stack -y
```

* Ubuntu 14.04 (amd64)

```sh
wget -q -O- https://fpco.s3.amazonaws.com/fpco.key | sudo apt-key add -
echo 'deb http://fpco.s3.amazonaws.com/ubuntu/trusty stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
sudo apt-get update
sudo apt-get install stack -y
```

* Ubuntu 12.04 (amd64)

```sh
wget -q -O- https://fpco.s3.amazonaws.com/fpco.key | sudo apt-key add -
echo 'deb http://fpco.s3.amazonaws.com/ubuntu/precise stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
sudo apt-get update
sudo apt-get install stack -y
```

### Usage

1. Download stack following the instructions at **FIXME** and place it on your `PATH`
Expand Down
56 changes: 56 additions & 0 deletions etc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#-*- mode:conf; -*-

FROM ubuntu:<<UBUNTU_VERSION>>

ENV DEBIAN_FRONTEND noninteractive
ENV LANG en_US.UTF-8
RUN locale-gen $LANG

# NOTE: This next block can speed up your repeat assembly times
# significantly. Uncomment to allow. Requires apt-cacher-ng running on
# the docker host.
RUN apt-get update
RUN apt-get install -y net-tools
RUN echo "Acquire::http { Proxy \"http://$(netstat -nr|grep '^0\.0\.0\.0'|awk '{print $2}'):3142\"; };" \
| tee /etc/apt/apt.conf.d/02proxy

# HASKELL
ENV GHCVER=7.8.4
ENV CABALVER=1.20
RUN apt-get update
RUN apt-get install -y python-software-properties
RUN apt-add-repository -y ppa:hvr/ghc
RUN apt-get update
RUN apt-get install -y ghc-$GHCVER cabal-install-$CABALVER zlib1g-dev wget
ENV PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH

# RUBY & FPM
RUN apt-get install -y ruby-dev rubygems libffi-dev make
RUN gem install fpm

# BUILD
ADD ./ /usr/src/
WORKDIR /usr/src/
RUN rm -rf .cabal-sandbox cabal*config dist
RUN wget http://www.stackage.org/lts/cabal.config
RUN cabal update
RUN cabal sandbox init
RUN cabal install -j --ghc-options='-rtsopts -threaded -with-rtsopts=-N' cpphs .

# DEB PKG
RUN mkdir -p /var/tmp/fpm/stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>>/usr/bin
RUN cp .cabal-sandbox/bin/stack /var/tmp/fpm/stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>>/usr/bin/
RUN fpm \
-s dir \
-t deb \
-n stack \
-v <<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>> \
-d libc6 \
-d libgmp10 \
-C /var/tmp/fpm/stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>> \
-p /stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>>_amd64.deb \
usr

# SHIP THE DEB TO THE HOST O.S.
VOLUME /mnt
CMD cp /stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>>_amd64.deb /mnt/

0 comments on commit 769c264

Please sign in to comment.