From e5f92835eec55431d11d5c2db52c52f9887747cc Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Wed, 18 Oct 2023 16:21:19 +0100 Subject: [PATCH] ioc-pmac building under new framework --- .devcontainer/.bashrc | 84 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 75 +++++++++++++++++++++++++++++ .devcontainer/initializeCommand | 15 ++++++ .devcontainer/postCreateCommand | 30 ++++++++++++ Dockerfile | 16 +++++-- build | 3 +- ibek-support | 1 + 7 files changed, 218 insertions(+), 6 deletions(-) create mode 100644 .devcontainer/.bashrc create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/initializeCommand create mode 100644 .devcontainer/postCreateCommand create mode 160000 ibek-support diff --git a/.devcontainer/.bashrc b/.devcontainer/.bashrc new file mode 100644 index 0000000..1a3a80e --- /dev/null +++ b/.devcontainer/.bashrc @@ -0,0 +1,84 @@ +################################################################################ +# epics-containers developer shell configuration. +# This is a standard ubuntu .bashrc plus a PS1 prompt with container name +# and a call to .bashrc_dev_container in the user's home directory on the +# host machine. +################################################################################ + +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines in the history. See bash(1) for more options +# ... or force ignoredups and ignorespace +HISTCONTROL=ignoredups:ignorespace + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +function parse_git_branch { + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' +} + +# make a useful prompt, including current container name +EC_PROJECT=${EC_PROJECT:-container} +PS1="\[\e[32m\]\$(parse_git_branch)\[\e[m\][\[\e[34m\]\[\e[m\]\W]\$ " +export PS1="[\[\e[31m\]${EC_PROJECT#'ioc-'}\[\e[m\]]${PS1}" + +# ibek cli completion +source <(ibek --show-completion bash) + +# add user's custom .bashrc_dev_container +if [ -f ~/.bashrc_dev_container ]; then + . ~/.bashrc_dev_container +fi + + + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..54278ae --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,75 @@ +// For format details, see https://containers.dev/implementors/json_reference/ +{ + "name": "epics-containers IOC devcontainer", + "build": { + "dockerfile": "../Dockerfile", + "target": "developer", + "args": { + "TARGET_ARCHITECTURE": "linux" + } + }, + "remoteEnv": { + // allows X11 apps to run inside the container + "DISPLAY": "${localEnv:DISPLAY}", + // provides a name for epics-containers to use in bash prompt etc. + "EC_PROJECT": "${localWorkspaceFolderBasename}" + }, + "features": { + // adds standard common-utils features - see + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": false, + "installOhMyZsh": false, + "installOhMyZshConfig": false, + "upgradePackages": false + } + }, + // IMPORTANT for this devcontainer to work with docker EC_REMOTE_USER must be + // set to vscode. For podman it should be left blank. + "remoteUser": "${localEnv:EC_REMOTE_USER}", + "customizations": { + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.vscode-pylance", + "tamasfe.even-better-toml", + "redhat.vscode-yaml", + "ryanluker.vscode-coverage-gutters", + "epicsdeb.vscode-epics", + "ms-python.black-formatter" + ] + }, + "settings": { + // global python venv created in epics-base + "python.defaultInterpreterPath": "/venv/bin/python" + } + }, + // Make sure the files we are mapping into the container exist on the host + // You can place any other outside of the container before-launch commands here + "initializeCommand": "bash .devcontainer/initializeCommand ${devcontainerId}", + // Hooks the global .bashprofile_dev_container but also can add any other commands + // to run in the container at creation in here + "postCreateCommand": "bash .devcontainer/postCreateCommand ${devcontainerId}", + "runArgs": [ + // Allow the container to access the host X11 display and EPICS CA + "--net=host", + // Make sure SELinux does not disable with access to host filesystems like tmp + "--security-opt=label=disable" + ], + "workspaceMount": "source=${localWorkspaceFolder},target=/epics/${localWorkspaceFolderBasename},type=bind", + "workspaceFolder": "/epics/${localWorkspaceFolderBasename}", + "mounts": [ + // Mount some useful local files from the user's home directory + // By mounting the parent of the workspace we can work on multiple peer projects + "source=${localWorkspaceFolder}/../,target=/repos,type=bind", + // this provides eternal bash history in and out of the container + "source=${localEnv:HOME}/.bash_eternal_history,target=/root/.bash_eternal_history,type=bind", + // this bashrc hooks up the .bashrc_dev_container in the following mount + "source=${localWorkspaceFolder}/.devcontainer/.bashrc,target=/root/.bashrc,type=bind", + // provides a place for you to put your shell customizations for all your dev containers + "source=${localEnv:HOME}/.bashrc_dev_container,target=/root/.bashrc_dev_container,type=bind", + // provides a place to install any packages you want to have across all your dev containers + "source=${localEnv:HOME}/.bashprofile_dev_container,target=/root/.bashprofile_dev_container,type=bind", + // provides the same command line editing experience as your host + "source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind" + ] +} \ No newline at end of file diff --git a/.devcontainer/initializeCommand b/.devcontainer/initializeCommand new file mode 100644 index 0000000..4f32aa2 --- /dev/null +++ b/.devcontainer/initializeCommand @@ -0,0 +1,15 @@ +#!/bin/bash + +# make sure all the files we mount into the container exist +for i in \ + .bash_eternal_history \ + .bashrc_dev_container \ + .bashprofile_dev_container \ + .inputrc + do + if [ ! -f $HOME/$i ] ; then + touch $HOME/$i; + fi +done + +echo "devcontainerID ${1}" diff --git a/.devcontainer/postCreateCommand b/.devcontainer/postCreateCommand new file mode 100644 index 0000000..2beb11a --- /dev/null +++ b/.devcontainer/postCreateCommand @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################ +# When using docker we will not be root inside the container +# the following steps are then required +################################################################################ + +if [[ $USER != "root" ]] ; then + # make sure the non-root user can build iocs and (mounted in) support modules + sudo chown -R ${USER}:${USER} /epics/links + sudo chown -h ${USER}:${USER} /epics /epics/ioc + + # also give non-root user access to the same bash config we use in podman + sudo chmod a+rx /root + for f in .inputrc .bash_eternal_history .bashrc .bashrc_dev_container; do + sudo chmod a+rw /root/$f + ln -sf /root/$f $HOME/$f + done +fi + +################################################################################ +# Custom install script for each developer to add whatever they like to +# all epics-containers devcontainers +################################################################################ + + +# add user's custom profile container creation script +if [ -f ~/.bashprofile_dev_container ]; then + . ~/.bashprofile_dev_container +fi diff --git a/Dockerfile b/Dockerfile index 1d986cc..4c60599 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN pip install --upgrade ibek==1.4.0 # The devcontainer mounts the project root to /epics/ioc-adsimdetector. Using # the same location here makes devcontainer/runtime differences transparent. -WORKDIR /epics/ioc-adsimdetector/ibek-support +WORKDIR /epics/ioc-pmac/ibek-support # copy the global ibek files COPY ibek-support/_global/ _global @@ -28,11 +28,17 @@ RUN autosave/install.sh R5-10-2 COPY ibek-support/busy/ busy/ RUN busy/install.sh R1-7-3 -COPY ibek-support/ADCore/ ADCore/ -RUN ADCore/install.sh R3-12-1 +COPY ibek-support/sscan/ sscan/ +RUN sscan/install.sh R2-11-6 -COPY ibek-support/ADSimDetector/ ADSimDetector/ -RUN ADSimDetector/install.sh R2-10 +COPY ibek-support/calc/ calc/ +RUN calc/install.sh R3-7-5 + +COPY ibek-support/motor/ motor/ +RUN motor/install.sh R7-2-3b1 + +COPY ibek-support/pmac/ pmac/ +RUN pmac/install.sh 2-4-10 # Generate template IOC source tree / generate Makefile / compile RUN ibek ioc build diff --git a/build b/build index 6a5e635..5a50578 100755 --- a/build +++ b/build @@ -6,6 +6,7 @@ # pass rtems as first argument to build RTEMS on cross-compiler TARGET_ARCHITECTURE=${1:-linux} +shift set -xe @@ -15,7 +16,7 @@ cd $(dirname ${0}) git submodule update --init # build runtime and developer images -ec dev build --arch ${TARGET_ARCHITECTURE} +ec dev build --arch ${TARGET_ARCHITECTURE} "${@}" # get the schema file from the developer container and save it locally ec dev launch-local --execute \ diff --git a/ibek-support b/ibek-support new file mode 160000 index 0000000..1d5bbc8 --- /dev/null +++ b/ibek-support @@ -0,0 +1 @@ +Subproject commit 1d5bbc8ae0506c7461475b0f5e8aaf322871c595