From 3e6c950e12c5cdaa0a5e17915fc75ccd6e3648c2 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 6 Jan 2015 02:04:06 +0900 Subject: [PATCH] Build i386 binary as well --- install | 14 ++++----- src/Dockerfile | 33 -------------------- src/Dockerfile.arch | 25 +++++++++++++++ src/Dockerfile.centos | 25 +++++++++++++++ src/Dockerfile.ubuntu | 30 ++++++++++++++++++ src/Makefile | 71 +++++++++++++++++++++++++++---------------- src/README.md | 4 +-- 7 files changed, 133 insertions(+), 69 deletions(-) delete mode 100644 src/Dockerfile create mode 100644 src/Dockerfile.arch create mode 100644 src/Dockerfile.centos create mode 100644 src/Dockerfile.ubuntu diff --git a/install b/install index b454715..b83920f 100755 --- a/install +++ b/install @@ -55,13 +55,13 @@ download() { archi=$(uname -sm) binary_available=1 binary_error="" -if [ "$archi" = "Darwin x86_64" ]; then - download fzf-$version-darwin_amd64 -elif [ "$archi" = "Linux x86_64" ]; then - download fzf-$version-linux_amd64 -else - binary_available=0 -fi +case "$archi" in + "Darwin x86_64") download fzf-$version-darwin_amd64 ;; +# "Darwin i[36]86") download fzf-$version-darwin_386 ;; + "Linux x86_64") download fzf-$version-linux_amd64 ;; +# "Linux i[36]86") download fzf-$version-linux_386 ;; + *) binary_available=0 ;; +esac cd "$fzf_base" if [ -n "$binary_error" ]; then diff --git a/src/Dockerfile b/src/Dockerfile deleted file mode 100644 index 3c062ee..0000000 --- a/src/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Junegunn Choi - -# apt-get -RUN apt-get update && apt-get -y upgrade -RUN apt-get install -y --force-yes git vim-nox curl procps sudo \ - build-essential libncurses-dev - -# Setup jg user with sudo privilege -RUN useradd -s /bin/bash -m jg && echo 'jg:jg' | chpasswd && \ - echo 'jg ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/jg - -# Setup dotfiles -USER jg -RUN cd ~ && git clone https://github.com/junegunn/dotfiles.git && \ - dotfiles/install > /dev/null - -# Install Go 1.4 -RUN cd ~ && curl https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | tar -xz && \ - mv go go1.4 && \ - echo 'export GOROOT=~/go1.4' >> ~/dotfiles/bashrc-extra && \ - echo 'export PATH=~/go1.4/bin:$PATH' >> ~/dotfiles/bashrc-extra - -# Symlink fzf directory -RUN mkdir -p ~jg/go/src/github.com/junegunn && \ - ln -s /fzf ~jg/go/src/github.com/junegunn/fzf - -# Volume -VOLUME /fzf - -# Default CMD -CMD cd ~jg/go/src/github.com/junegunn/fzf/src && /bin/bash -l - diff --git a/src/Dockerfile.arch b/src/Dockerfile.arch new file mode 100644 index 0000000..9fa4ea3 --- /dev/null +++ b/src/Dockerfile.arch @@ -0,0 +1,25 @@ +FROM base/archlinux:2014.07.03 +MAINTAINER Junegunn Choi + +# apt-get +RUN pacman-db-upgrade && pacman -Syu --noconfirm base-devel git + +# Install Go 1.4 +RUN cd / && curl \ + https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | \ + tar -xz && mv go go1.4 + +ENV GOPATH /go +ENV GOROOT /go1.4 +ENV PATH /go1.4/bin:$PATH + +# Symlink fzf directory +RUN mkdir -p /go/src/github.com/junegunn && \ + ln -s /fzf /go/src/github.com/junegunn/fzf + +# Volume +VOLUME /fzf + +# Default CMD +CMD cd /go/src/github.com/junegunn/fzf/src && /bin/bash + diff --git a/src/Dockerfile.centos b/src/Dockerfile.centos new file mode 100644 index 0000000..e791dc6 --- /dev/null +++ b/src/Dockerfile.centos @@ -0,0 +1,25 @@ +FROM centos:centos7 +MAINTAINER Junegunn Choi + +# yum +RUN yum install -y git gcc make tar ncurses-devel + +# Install Go 1.4 +RUN cd / && curl \ + https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | \ + tar -xz && mv go go1.4 + +ENV GOPATH /go +ENV GOROOT /go1.4 +ENV PATH /go1.4/bin:$PATH + +# Symlink fzf directory +RUN mkdir -p /go/src/github.com/junegunn && \ + ln -s /fzf /go/src/github.com/junegunn/fzf + +# Volume +VOLUME /fzf + +# Default CMD +CMD cd /go/src/github.com/junegunn/fzf/src && /bin/bash + diff --git a/src/Dockerfile.ubuntu b/src/Dockerfile.ubuntu new file mode 100644 index 0000000..b7f6232 --- /dev/null +++ b/src/Dockerfile.ubuntu @@ -0,0 +1,30 @@ +FROM ubuntu:14.04 +MAINTAINER Junegunn Choi + +# apt-get +RUN apt-get update && apt-get -y upgrade && \ + apt-get install -y --force-yes git curl build-essential libncurses-dev + +# Install Go 1.4 +RUN cd / && curl \ + https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | \ + tar -xz && mv go go1.4 + +ENV GOPATH /go +ENV GOROOT /go1.4 +ENV PATH /go1.4/bin:$PATH + +# For i386 build +RUN apt-get install -y lib32ncurses5-dev && \ + cd $GOROOT/src && GOARCH=386 ./make.bash + +# Symlink fzf directory +RUN mkdir -p /go/src/github.com/junegunn && \ + ln -s /fzf /go/src/github.com/junegunn/fzf + +# Volume +VOLUME /fzf + +# Default CMD +CMD cd /go/src/github.com/junegunn/fzf/src && /bin/bash + diff --git a/src/Makefile b/src/Makefile index a7235bc..037fb61 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,51 +1,68 @@ UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) - SUFFIX := darwin + GOOS := darwin else ifeq ($(UNAME_S),Linux) - SUFFIX := linux + GOOS := linux endif -UNAME_M := $(shell uname -m) -ifeq ($(UNAME_M),x86_64) - SUFFIX := $(SUFFIX)_amd64 -else ifneq ($(filter i386 i686,$(UNAME_M)),) - SUFFIX := $(SUFFIX)_386 -else # TODO -$(error "$(UNAME_M) is not supported, yet.") +ifneq ($(shell uname -m),x86_64) +$(error "Build on $(UNAME_M) is not supported, yet.") endif -BINARY := fzf-$(SUFFIX) -BINDIR := ../bin -SOURCES := $(wildcard *.go fzf/*.go) -RELEASE = fzf-$(shell fzf/$(BINARY) --version)-$(SUFFIX) +SOURCES := $(wildcard *.go fzf/*.go) +BINDIR := ../bin + +BINARY32 := fzf-$(GOOS)_386 +BINARY64 := fzf-$(GOOS)_amd64 +RELEASE32 = fzf-$(shell fzf/$(BINARY64) --version)-$(GOOS)_386 +RELEASE64 = fzf-$(shell fzf/$(BINARY64) --version)-$(GOOS)_amd64 all: release release: build cd fzf && \ - cp $(BINARY) $(RELEASE) && \ - tar -czf $(RELEASE).tgz $(RELEASE) && \ - rm $(RELEASE) + cp $(BINARY32) $(RELEASE32) && tar -czf $(RELEASE32).tgz $(RELEASE32) && \ + cp $(BINARY64) $(RELEASE64) && tar -czf $(RELEASE64).tgz $(RELEASE64) && \ + rm $(RELEASE32) $(RELEASE64) -build: fzf/$(BINARY) +build: fzf/$(BINARY32) fzf/$(BINARY64) -fzf/$(BINARY): $(SOURCES) +test: $(SOURCES) go get go test -v - cd fzf && go build -o $(BINARY) -install: fzf/$(BINARY) +fzf/$(BINARY32): test + cd fzf && GOARCH=386 CGO_ENABLED=1 go build -o $(BINARY32) + +fzf/$(BINARY64): test + cd fzf && go build -o $(BINARY64) + +install: fzf/$(BINARY64) mkdir -p $(BINDIR) - cp -f fzf/$(BINARY) $(BINDIR)/fzf + cp -f fzf/$(BINARY64) $(BINDIR)/fzf clean: - cd fzf && rm -f $(BINARY) $(RELEASE).tgz + cd fzf && rm -f $(BINARY32) $(BINARY64) $(RELEASE32).tgz $(RELEASE64).tgz + +DISTRO := ubuntu docker: - docker build -t junegunn/ubuntu-sandbox . + docker build -t junegunn/$(DISTRO)-sandbox - < Dockerfile.$(DISTRO) -linux64: docker - docker run -i -t -u jg -v $(shell cd ..; pwd):/fzf junegunn/ubuntu-sandbox \ - /bin/bash -ci 'cd ~jg/go/src/github.com/junegunn/fzf/src; make' +linux: docker + docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/$(DISTRO)-sandbox \ + /bin/bash -ci 'cd /go/src/github.com/junegunn/fzf/src; make' -.PHONY: build release install linux64 clean docker +$(DISTRO): docker + docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/$(DISTRO)-sandbox \ + sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash' + +arch: docker + docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/arch-sandbox \ + sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash' + +centos: docker + docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/centos-sandbox \ + sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash' + +.PHONY: build release install linux clean docker $(DISTRO) diff --git a/src/README.md b/src/README.md index 7c47759..70b2c1d 100644 --- a/src/README.md +++ b/src/README.md @@ -22,8 +22,8 @@ make # Install the executable to ../bin directory make install -# Build executable for Linux x86_64 using Docker -make linux64 +# Build executables for Linux using Docker +make linux ``` System requirements