Skip to content

Commit

Permalink
[soil] Refactor image deps
Browse files Browse the repository at this point in the history
Now we have

    deps-apt: apt packages
    deps-py and deps-R: PyPI and CRAN packages
    deps-tar going into /app/oil_DEPS

The /app/oil_DEPS thing works on the 'cpp' task.  Now need to fix
'ovm-tarball'.
  • Loading branch information
Andy C committed Dec 11, 2021
1 parent 370de7b commit 808a697
Show file tree
Hide file tree
Showing 13 changed files with 238 additions and 246 deletions.
25 changes: 0 additions & 25 deletions build/codegen.sh
Expand Up @@ -21,37 +21,12 @@ set -o errexit

source build/common.sh

REPO_ROOT=$(cd $(dirname $0)/.. && pwd)
readonly REPO_ROOT

export PYTHONPATH='.:vendor/'

if test -z "${IN_NIX_SHELL:-}"; then
source build/dev-shell.sh # to run 're2c'
fi

readonly DEPS_DIR=$PWD/../oil_DEPS

# TODO: Delete these once soil/image-deps.sh handles it
download-re2c() {
# local cache of remote files
mkdir -p _cache
wget --no-clobber --directory _cache \
https://github.com/skvadrik/re2c/releases/download/1.0.3/re2c-1.0.3.tar.gz
}

build-re2c() {
cd $REPO_ROOT/_cache
tar -x -z < re2c-1.0.3.tar.gz
mkdir -p $DEPS_DIR/re2c
cd $DEPS_DIR/re2c
$REPO_ROOT/_cache/re2c-1.0.3/configure
make
}

# TODO: remove this
install-re2c() { build-re2c "$@"; }

download-clang() {
wget --no-clobber --directory _deps \
http://releases.llvm.org/5.0.1/clang+llvm-5.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz
Expand Down
6 changes: 3 additions & 3 deletions devtools/release.sh
Expand Up @@ -963,12 +963,12 @@ tarball-build-deps() {
build/prepare.sh build-python
fi

local d1='_deps/re2c-1.0.3'
local d1='../oil_DEPS/re2c-1.0.3'
if test -d $d1; then
echo "$d1 exists: skipping re2c"
else
build/codegen.sh download-re2c
build/codegen.sh install-re2c
soil/deps-tar.sh download-re2c
soil/deps-tar.sh build-re2c
fi

local d2='_deps/cmark-0.29.0' # CMARK_VERSION
Expand Down
15 changes: 10 additions & 5 deletions soil/Dockerfile.cpp
Expand Up @@ -2,12 +2,17 @@ FROM debian:buster-slim

RUN apt-get update

# Copy this file into the container so we can run it.
WORKDIR /app
COPY soil/image-deps.sh .
WORKDIR /app/tmp

RUN ./image-deps.sh cpp
# Copy build scripts into the container and run them

RUN ./image-deps.sh cpp-source-deps
COPY soil/deps-apt.sh /app/tmp/soil/deps-apt.sh
RUN soil/deps-apt.sh cpp

# We're in /app/tmp, so this will create /app/oil_DEPS, which will be
# a sibling of the runtime bind mount /app/oil.
COPY soil/deps-tar.sh /app/tmp/soil/deps-tar.sh
RUN soil/deps-tar.sh cpp
CMD ["sh", "-c", "echo 'hello from oilshell/soil-cpp buildkit'"]
12 changes: 7 additions & 5 deletions soil/Dockerfile.dev-minimal
Expand Up @@ -2,12 +2,14 @@ FROM debian:buster-slim

RUN apt-get update

# Copy this file into the container so we can run it.
WORKDIR /app
COPY soil/image-deps.sh .
WORKDIR /app/tmp

RUN ./image-deps.sh dev-minimal
# Copy build scripts into the container and run them

RUN ./image-deps.sh dev-minimal-py
COPY soil/deps-apt.sh /app/tmp/soil/deps-apt.sh
RUN soil/deps-apt.sh dev-minimal

COPY soil/deps-py.sh /app/tmp/soil/deps-py.sh
RUN soil/deps-py.sh dev-minimal

CMD ["sh", "-c", "echo 'hello from oilshell/soil-dev-minimal buildkit'"]
10 changes: 6 additions & 4 deletions soil/Dockerfile.dummy
Expand Up @@ -2,9 +2,11 @@ FROM debian:buster-slim

RUN apt-get update

# Copy this file into the container so we can run it.
WORKDIR /app
COPY soil/image-deps.sh .
RUN ./image-deps.sh dummy
WORKDIR /app/tmp

# Copy build scripts file into the container and run them

COPY soil/deps-apt.sh /app/tmp/soil/deps-apt.sh
RUN soil/deps-apt.sh dummy

CMD ["sh", "-c", "echo 'hello from oilshell/soil-dummy buildkit'"]
12 changes: 7 additions & 5 deletions soil/Dockerfile.other-tests
Expand Up @@ -2,12 +2,14 @@ FROM debian:buster-slim

RUN apt-get update

# Copy this file into the container so we can run it.
WORKDIR /app
COPY soil/image-deps.sh .
WORKDIR /app/tmp

RUN ./image-deps.sh other-tests
# Copy build scripts into the container and run them

RUN ./image-deps.sh other-tests-R
COPY soil/deps-apt.sh /app/tmp/soil/deps-apt.sh
RUN soil/deps-apt.sh other-tests

COPY soil/deps-R.sh /app/tmp/soil/deps-R.sh
RUN soil/deps-R.sh other-tests

CMD ["sh", "-c", "echo 'hello from oilshell/soil-other-tests buildkit'"]
12 changes: 7 additions & 5 deletions soil/Dockerfile.ovm-tarball
Expand Up @@ -2,12 +2,14 @@ FROM debian:buster-slim

RUN apt-get update

# Copy this file into the container so we can run it.
WORKDIR /app
COPY soil/image-deps.sh .
WORKDIR /app/tmp

RUN ./image-deps.sh ovm-tarball
# Copy build scripts into the container and run them

RUN ./image-deps.sh ovm-tarball-source-deps
COPY soil/deps-apt.sh /app/tmp/soil/deps-apt.sh
RUN soil/deps-apt.sh ovm-tarball

COPY soil/deps-tar.sh /app/tmp/soil/deps-tar.sh
RUN soil/deps-tar.sh ovm-tarball

CMD ["sh", "-c", "echo 'hello from oilshell/ovm-tarball buildkit'"]
22 changes: 22 additions & 0 deletions soil/deps-R.sh
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
#
# Usage:
# ./deps-R.sh <function name>

set -o nounset
set -o pipefail
set -o errexit

other-tests() {
readonly R_PATH=~/R # duplicates what's in test/common.sh

# Install to a directory that doesn't require root. This requires setting
# R_LIBS_USER. Or library(dplyr, lib.loc = "~/R", but the former is preferable.
mkdir -p ~/R

# Note: dplyr 1.0.3 as of January 2021 made these fail on Xenial. See R 4.0
# installation below.
INSTALL_DEST=$R_PATH Rscript -e 'install.packages(c("dplyr", "tidyr", "stringr"), lib=Sys.getenv("INSTALL_DEST"), repos="https://cloud.r-project.org")'
}

"$@"
113 changes: 113 additions & 0 deletions soil/deps-apt.sh
@@ -0,0 +1,113 @@
#!/usr/bin/env bash
#
# Usage:
# ./deps-apt.sh <function name>

set -o nounset
set -o pipefail
set -o errexit

dummy() {
# gcc: time-helper is needed
# git: for checking out code
# python2: for various tools
apt-get install -y gcc git python2
}

dev-minimal() {
local -a packages=(
# common
git python2

libreadline-dev
procps # pgrep used by test/interactive
gawk

python2-dev # for building Python extensions

python-pip # flake8 typing
python3-setuptools # mypy
python3-pip

# Note: osh-minimal task needs shells; not using spec-bin for now
busybox-static mksh zsh
)

apt-get install -y "${packages[@]}"

}

other-tests() {
local -a packages=(
# common
git python2

libreadline-dev
python2-dev # osh2oil needs build/dev.sh minimal

python3 # for py3-parse

r-base-core # for r-libs
)

apt-get install -y "${packages[@]}"
}

cpp() {
local -a packages=(
# common
git python2

# retrieving deps -- TODO: move to build time
wget

# line_input.so needs this
libreadline-dev
python2-dev

python3-pip
# for MyPy virtualenv for requirements.txt -- TODO: move to build time.
python3-venv

ninja-build
# to create mycpp/_ninja/index.html
gawk

# for stable benchmarks
valgrind
# the shell benchmarks compare shells
busybox-static mksh zsh
)

apt-get install -y "${packages[@]}"
}

ovm-tarball() {
local -a packages=(
# common
gcc git python2

# This is a separate package needed for re2c. TODO: remove when we've
# built it into the image.
g++

# line_input.so needs this
libreadline-dev
python2-dev

# retrieving deps -- TODO: move to build time
wget
# for syscall measurements
strace

# for cmark and yajl
cmake

# test/spec-runner.sh needs this
gawk
)

apt-get install -y "${packages[@]}"
}

"$@"
20 changes: 20 additions & 0 deletions soil/deps-py.sh
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# Usage:
# ./deps-py.sh <function name>

set -o nounset
set -o pipefail
set -o errexit

dev-minimal() {
# Python 2 packages for linting linting Python 2 code.
pip install --user flake8 typing

# Python 3 packages
# - MyPy requires Python 3
# - pexpect is for test/interactive.py
pip3 install --user mypy pexpect
}

"$@"
43 changes: 43 additions & 0 deletions soil/deps-tar.sh
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
#
# Usage:
# ./deps-tar.sh <function name>

set -o nounset
set -o pipefail
set -o errexit

REPO_ROOT=$(cd $(dirname $0)/.. && pwd)
readonly REPO_ROOT

DEPS_DIR=$REPO_ROOT/../oil_DEPS
readonly DEPS_DIR

download-re2c() {
# local cache of remote files
mkdir -p _cache
wget --no-clobber --directory _cache \
https://github.com/skvadrik/re2c/releases/download/1.0.3/re2c-1.0.3.tar.gz
}

build-re2c() {
cd $REPO_ROOT/_cache
tar -x -z < re2c-1.0.3.tar.gz

mkdir -p $DEPS_DIR/re2c
cd $DEPS_DIR/re2c
$REPO_ROOT/_cache/re2c-1.0.3/configure
make
}

cpp() {
download-re2c
build-re2c
}

ovm-tarball() {
download-re2c
build-re2c
}

"$@"

0 comments on commit 808a697

Please sign in to comment.