From 1083a9331b0a51918644668e226c3f77cc870494 Mon Sep 17 00:00:00 2001 From: Tim Dysinger Date: Mon, 1 Jun 2015 15:10:28 -1000 Subject: [PATCH] Add code to create signed debian packages & host them on s3 --- .dockerignore | 4 ++++ .gitignore | 1 + Makefile | 24 ++++++++++++++++++++++ README.md | 38 ++++++++++++++++++++++++++++++++++ etc/Dockerfile | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 .dockerignore create mode 100644 Makefile create mode 100644 etc/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..33d9665ecb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +/.cabal-sandbox +/cabal*.config +/dist +/target diff --git a/.gitignore b/.gitignore index 1a81c3294f..ccd871b4ac 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ cabal.sandbox.config /.cabal-sandbox/ .shake/ .stack-work/ +/target/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..2369399eb6 --- /dev/null +++ b/Makefile @@ -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)/g" $(DIR)/Dockerfile + @perl -p -i -e "s/<>/$(PKG_VERSION)/g" $(DIR)/Dockerfile + @perl -p -i -e "s/<>/$(GIT_REV_COUNT)/g" $(DIR)/Dockerfile + @perl -p -i -e "s/<>/$(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 diff --git a/README.md b/README.md index a020247919..2e60df24de 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/etc/Dockerfile b/etc/Dockerfile new file mode 100644 index 0000000000..589c39ba30 --- /dev/null +++ b/etc/Dockerfile @@ -0,0 +1,56 @@ +#-*- mode:conf; -*- + +FROM ubuntu:<> + +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_<>-<>-<>/usr/bin +RUN cp .cabal-sandbox/bin/stack /var/tmp/fpm/stack_<>-<>-<>/usr/bin/ +RUN fpm \ + -s dir \ + -t deb \ + -n stack \ + -v <>-<>-<> \ + -d libc6 \ + -d libgmp10 \ + -C /var/tmp/fpm/stack_<>-<>-<> \ + -p /stack_<>-<>-<>_amd64.deb \ + usr + +# SHIP THE DEB TO THE HOST O.S. +VOLUME /mnt +CMD cp /stack_<>-<>-<>_amd64.deb /mnt/