Browse Source

docker: add hook to docker-ubuntu-builder [DO-NOT-MERGE]

Signed-off-by: Alejandro Mery <amery@geeks.cl>
user/amery/stage
Alejandro Mery 4 years ago
parent
commit
f65a981093
5 changed files with 140 additions and 0 deletions
  1. +1
    -0
      .gitignore
  2. +26
    -0
      docker/Dockerfile
  3. +10
    -0
      docker/opensde-profile.sh
  4. +102
    -0
      docker/run.sh
  5. +1
    -0
      run.sh

+ 1
- 0
.gitignore

@ -6,3 +6,4 @@
/package
/tmp
/src.*
/.docker-run-cache

+ 26
- 0
docker/Dockerfile

@ -0,0 +1,26 @@
FROM amery/docker-ubuntu-builder:20.04
# sde get
RUN apt-get update && apt-get install --no-install-recommends -y \
git curl \
&& apt-get clean
# sde config
RUN apt-get update && apt-get install --no-install-recommends -y \
libncurses-dev \
&& apt-get clean
# sde build
RUN apt-get update && apt-get install --no-install-recommends -y \
autopoint \
bc \
texinfo \
&& apt-get clean
# ./debug.sh convenience
RUN apt-get update && apt-get install --no-install-recommends -y \
less \
vim \
&& apt-get clean
COPY opensde-profile.sh /etc/entrypoint.d/

+ 10
- 0
docker/opensde-profile.sh

@ -0,0 +1,10 @@
# ensure $HOME/bin is on PATH
# so `sde` works
#
home_bin='$HOME/bin'
cat <<EOT
[ -d "$home_bin" ] || mkdir "$home_bin"
export PATH="$home_bin:\$PATH"
export SDE_VIA_RUN_SH=yes
EOT
unset home_bin

+ 102
- 0
docker/run.sh

@ -0,0 +1,102 @@
#!/bin/sh
set -eu
# sudo mode explicitly requested
if [ "x${1:-}" = "x-r" ]; then
USER_NEEDS_SUDO=true
shift
else
USER_NEEDS_SUDO=
fi
# no docker? pass through
if [ -z "$(which docker)" ]; then
exec ${USER_NEEDS_SUDO:+sudo} "$@"
fi
# identify workspace
#
BASE="$(dirname "$0")"
if [ -s "$BASE/Dockerfile" ]; then
WS="$(cd "$BASE/.." && pwd -P)"
elif [ -x "$BASE/bin/sde" ]; then
WS="$BASE"
BASE="$BASE/docker"
else
echo "$BASE: failed to identify workspace root" >&2
exit 1
fi
if [ $# -gt 0 ]; then
mode=adhoc
# identify command
case "$1" in
sde|*/sde)
mode=sde
sde_options=
shift
while [ $# -gt 0 ]; do
case "$1" in
--loop) ;;
--) shift; break ;;
-*) sde_options="${sde_options:+$sde_options }$1" ;;
*) break ;;
esac
shift
done
case "${1:-}" in
build|cleanup|clean|reschedule|defer|reown)
USER_NEEDS_SUDO=true
;;
esac
if [ -n "$sde_options" ]; then
set -- $sde_options "$@"
fi
;;
*/*)
if ! expr "$1" : / > /dev/null; then
cmd="$(realpath $PWD/$1)"
else
cmd="$1"
fi
case "$cmd" in
"$WS/scripts"/*)
cmd="./${cmd#$WS/}"
mode=legacy
shift
case "${cmd##*/}" in
Build-Pkg|Build-Target)
USER_NEEDS_SUDO=true
;;
esac
;;
esac
;;
esac
case "$mode" in
sde)
set -- "$WS/bin/sde" "$@"
;;
legacy)
cd "$WS"
set -- "$cmd" "$@"
;;
adhoc)
;;
esac
fi
# jump
export DOCKER_DIR="$BASE"
exec docker-ubuntu-builder ${USER_NEEDS_SUDO:+-r} "$@"

+ 1
- 0
run.sh

@ -0,0 +1 @@
docker/run.sh

Loading…
Cancel
Save