Skip to content

Commit

Permalink
Merge pull request #79 from whiteinge/dev-envs-linux-osx
Browse files Browse the repository at this point in the history
Dev env tweaks for Linux & OS X
  • Loading branch information
whiteinge authored Mar 11, 2019
2 parents 592526a + 9719727 commit ac16f1f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/pubs.opengroup.org
/.image
/.busybox
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ maintainability of the script.

### Development Environment

A development environment can be quickly created if you have Docker installed
by running `make dev` from the main repo directory. This will drop you into
a shell with the local directory mounted as a volume.
There are two ways to quickly create a consistent development environment.
Although busybox is not completely POSIX compliant it's the closest out-of-box
environment that I know of.

- OS X (requires Docker): run `make docker` to drop you into an Alpine/busybox
shell with the local directory mounted as a volume.
- Linux (requires busybox): run `make busybox` to create and populate
a directory of busybox symlinks and drop you into a shell with that path set.

### POSIX Documentation

Expand Down
28 changes: 22 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,40 @@ DESTDIR ?= $(HOME)
DESTDIRB ?= /
VERSION :=

.PHONY: dev
dev : .image
.PHONY: test
test :
make -C tests all

.PHONY: docker
docker : .image
docker run -it --rm -v $$PWD:/oksh oksh

# Remove this file to trigger a rebuild.
.image :
docker build -t oksh .
touch $@

.PHONY: busybox
busybox : .busybox
env -i -- PATH=$$PWD/.busybox SHELL=sh $$PWD/.busybox/sh

.busybox :
mkdir -p $$PWD/.busybox
busybox --install -s $$PWD/.busybox
ln -s $$(which curl) $$PWD/.busybox/curl
ln -s $$(which jq) $$PWD/.busybox/jq
ln -s $$(which make) $$PWD/.busybox/make
ln -s $$(which socat) $$PWD/.busybox/socat

clean :
rm -f .image

install : $(PROGRAM)
cp $(PROGRAM) "$(DESTDIR)/bin/"
chmod 755 "$(DESTDIR)/bin/$(PROGRAM)"
cp $(PROGRAM) "$(DESTDIRB)bin/"
chmod 777 "$(DESTDIRB)bin/$(PROGRAM)"

.PHONY: test
test :
make -C tests all

.PHONY: version
version : readme
sed -i -e "s/VERSION=.*/VERSION='$(VERSION)'/g" $(PROGRAM)
Expand Down

0 comments on commit ac16f1f

Please sign in to comment.