Skip to content

Commit

Permalink
Add build script for nano
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-d authored and adunham-stripe committed Sep 2, 2016
1 parent 9c05814 commit a2a87e7
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
18 changes: 18 additions & 0 deletions nano/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM debian:jessie
MAINTAINER Andrew Dunham <andrew@du.nham.ca>

# Install build tools
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -yy && \
DEBIAN_FRONTEND=noninteractive apt-get install -yy \
automake \
build-essential \
curl \
git \
pkg-config

RUN mkdir /build
ADD . /build

# This builds the program and copies it to /output
CMD /build/build.sh
91 changes: 91 additions & 0 deletions nano/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

set -e
set -o pipefail
set -x


BUILD_DIR=/build
OUTPUT_DIR=/output

MUSL_VERSION=1.1.15
NANO_VERSION=2.7.0
NCURSES_VERSION=5.9


function build_musl() {
cd ${BUILD_DIR}

# Download
curl -LO http://www.musl-libc.org/releases/musl-${MUSL_VERSION}.tar.gz
tar zxvf musl-${MUSL_VERSION}.tar.gz
cd musl-${MUSL_VERSION}

# Build
./configure
make -j4
make install
}

function build_ncurses() {
cd ${BUILD_DIR}

# Download
curl -LO http://invisible-island.net/datafiles/release/ncurses.tar.gz
tar zxvf ncurses.tar.gz
cd ncurses-${NCURSES_VERSION}

# Build
CC='/usr/local/musl/bin/musl-gcc -static' CFLAGS='-fPIC' ./configure \
--prefix=/usr \
--disable-shared \
--enable-static \
--with-normal \
--without-debug \
--without-ada \
--with-default-terminfo=/usr/share/terminfo \
--with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo:/usr/lib/terminfo"

mkdir "${BUILD_DIR}/ncurses-install"
make DESTDIR="${BUILD_DIR}/ncurses-install" \
install.libs install.includes
}

function build_nano() {
cd ${BUILD_DIR}

# Download
curl -LO https://www.nano-editor.org/dist/v${NANO_VERSION%.*}/nano-${NANO_VERSION}.tar.xz
tar xJvf nano-${NANO_VERSION}.tar.xz
cd nano-${NANO_VERSION}

CC='/usr/local/musl/bin/musl-gcc -static' \
CFLAGS="-fPIC" \
CPPFLAGS="-I${BUILD_DIR}/ncurses-install/usr/include" \
LDFLAGS="-L${BUILD_DIR}/ncurses-install/usr/lib" \
./configure \
--disable-nls \
--disable-dependency-tracking

make -j4
strip src/nano
}

function doit() {
build_musl
build_ncurses
build_nano

# Copy to output
if [ -d ${OUTPUT_DIR} ]
then
OUT_DIR=${OUTPUT_DIR}/`uname | tr 'A-Z' 'a-z'`/`uname -m`
mkdir -p $OUT_DIR
cp ${BUILD_DIR}/nano-${NANO_VERSION}/src/nano $OUT_DIR/
echo "** Finished **"
else
echo "** ${OUTPUT_DIR} does not exist **"
fi
}

doit

0 comments on commit a2a87e7

Please sign in to comment.