Skip to content

Commit 1083a93

Browse files
committed
Add code to create signed debian packages & host them on s3
1 parent 4a72f8d commit 1083a93

5 files changed

Lines changed: 123 additions & 0 deletions

File tree

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.cabal-sandbox
2+
/cabal*.config
3+
/dist
4+
/target

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ cabal.sandbox.config
1313
/.cabal-sandbox/
1414
.shake/
1515
.stack-work/
16+
/target/

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2+
PKG_VERSION := $(shell cat stack.cabal|grep -e '^version:'|cut -d':' -f2|sed 's/\s//g')
3+
GIT_REV_COUNT := $(shell git rev-list HEAD --count)
4+
GIT_SHA := $(shell PAGER=cat git log --pretty=%h HEAD~1..HEAD)
5+
UBUNTU_VERSION ?= 15.04
6+
7+
default: $(DIR)/target/ubuntu-$(UBUNTU_VERSION)/stack_$(PKG_VERSION)-$(GIT_REV_COUNT)-$(GIT_SHA)_amd64.deb
8+
9+
$(DIR)/target/ubuntu-$(UBUNTU_VERSION):
10+
@mkdir -p $(DIR)/target/ubuntu-$(UBUNTU_VERSION)
11+
12+
$(DIR)/target/ubuntu-$(UBUNTU_VERSION)/stack_$(PKG_VERSION)-$(GIT_REV_COUNT)-$(GIT_SHA)_amd64.deb: | $(DIR)/target/ubuntu-$(UBUNTU_VERSION)
13+
@cp $(DIR)/etc/Dockerfile $(DIR)/Dockerfile
14+
@perl -p -i -e "s/<<UBUNTU_VERSION>>/$(UBUNTU_VERSION)/g" $(DIR)/Dockerfile
15+
@perl -p -i -e "s/<<PKG_VERSION>>/$(PKG_VERSION)/g" $(DIR)/Dockerfile
16+
@perl -p -i -e "s/<<GIT_REV_COUNT>>/$(GIT_REV_COUNT)/g" $(DIR)/Dockerfile
17+
@perl -p -i -e "s/<<GIT_SHA>>/$(GIT_SHA)/g" $(DIR)/Dockerfile
18+
@docker build --rm=false --tag=stack-$(UBUNTU_VERSION):$(PKG_VERSION)-$(GIT_REV_COUNT)-$(GIT_SHA) $(DIR)
19+
@docker run --rm -v $(DIR)/target/ubuntu-$(UBUNTU_VERSION):/mnt stack-$(UBUNTU_VERSION):$(PKG_VERSION)-$(GIT_REV_COUNT)-$(GIT_SHA)
20+
21+
clean:
22+
@rm -f $(DIR)/Dockerfile $(DIR)/target
23+
24+
.PHONY: clean default

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,44 @@ For more details on how stack works internally, please see [the architecture
1010
document](ARCHITECTURE.md). **FIXME more correct link once moved to final repo
1111
location**
1212

13+
### Install
14+
15+
* Ubuntu 15.04 (amd64)
16+
17+
```sh
18+
wget -q -O- https://fpco.s3.amazonaws.com/fpco.key | sudo apt-key add -
19+
echo 'deb http://fpco.s3.amazonaws.com/ubuntu/vivid stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
20+
sudo apt-get update
21+
sudo apt-get install stack -y
22+
```
23+
24+
* Ubuntu 14.10 (amd64)
25+
26+
```sh
27+
wget -q -O- https://fpco.s3.amazonaws.com/fpco.key | sudo apt-key add -
28+
echo 'deb http://fpco.s3.amazonaws.com/ubuntu/utopic stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
29+
sudo apt-get update
30+
sudo apt-get install stack -y
31+
```
32+
33+
* Ubuntu 14.04 (amd64)
34+
35+
```sh
36+
wget -q -O- https://fpco.s3.amazonaws.com/fpco.key | sudo apt-key add -
37+
echo 'deb http://fpco.s3.amazonaws.com/ubuntu/trusty stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
38+
sudo apt-get update
39+
sudo apt-get install stack -y
40+
```
41+
42+
* Ubuntu 12.04 (amd64)
43+
44+
```sh
45+
wget -q -O- https://fpco.s3.amazonaws.com/fpco.key | sudo apt-key add -
46+
echo 'deb http://fpco.s3.amazonaws.com/ubuntu/precise stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
47+
sudo apt-get update
48+
sudo apt-get install stack -y
49+
```
50+
1351
### Usage
1452

1553
1. Download stack following the instructions at **FIXME** and place it on your `PATH`

etc/Dockerfile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#-*- mode:conf; -*-
2+
3+
FROM ubuntu:<<UBUNTU_VERSION>>
4+
5+
ENV DEBIAN_FRONTEND noninteractive
6+
ENV LANG en_US.UTF-8
7+
RUN locale-gen $LANG
8+
9+
# NOTE: This next block can speed up your repeat assembly times
10+
# significantly. Uncomment to allow. Requires apt-cacher-ng running on
11+
# the docker host.
12+
RUN apt-get update
13+
RUN apt-get install -y net-tools
14+
RUN echo "Acquire::http { Proxy \"http://$(netstat -nr|grep '^0\.0\.0\.0'|awk '{print $2}'):3142\"; };" \
15+
| tee /etc/apt/apt.conf.d/02proxy
16+
17+
# HASKELL
18+
ENV GHCVER=7.8.4
19+
ENV CABALVER=1.20
20+
RUN apt-get update
21+
RUN apt-get install -y python-software-properties
22+
RUN apt-add-repository -y ppa:hvr/ghc
23+
RUN apt-get update
24+
RUN apt-get install -y ghc-$GHCVER cabal-install-$CABALVER zlib1g-dev wget
25+
ENV PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
26+
27+
# RUBY & FPM
28+
RUN apt-get install -y ruby-dev rubygems libffi-dev make
29+
RUN gem install fpm
30+
31+
# BUILD
32+
ADD ./ /usr/src/
33+
WORKDIR /usr/src/
34+
RUN rm -rf .cabal-sandbox cabal*config dist
35+
RUN wget http://www.stackage.org/lts/cabal.config
36+
RUN cabal update
37+
RUN cabal sandbox init
38+
RUN cabal install -j --ghc-options='-rtsopts -threaded -with-rtsopts=-N' cpphs .
39+
40+
# DEB PKG
41+
RUN mkdir -p /var/tmp/fpm/stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>>/usr/bin
42+
RUN cp .cabal-sandbox/bin/stack /var/tmp/fpm/stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>>/usr/bin/
43+
RUN fpm \
44+
-s dir \
45+
-t deb \
46+
-n stack \
47+
-v <<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>> \
48+
-d libc6 \
49+
-d libgmp10 \
50+
-C /var/tmp/fpm/stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>> \
51+
-p /stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>>_amd64.deb \
52+
usr
53+
54+
# SHIP THE DEB TO THE HOST O.S.
55+
VOLUME /mnt
56+
CMD cp /stack_<<PKG_VERSION>>-<<GIT_REV_COUNT>>-<<GIT_SHA>>_amd64.deb /mnt/

0 commit comments

Comments
 (0)