sdocker: usb access
This commit is contained in:
parent
da9cb958ab
commit
d6b80c2bb4
@ -29,6 +29,7 @@ RUN chmod 755 /usr/local/bin/*
|
||||
|
||||
# All builds will be done by user aosp
|
||||
RUN groupadd -g ${GROUP_ID} aosp && useradd --create-home aosp -u ${USER_ID} -g ${GROUP_ID} -s /bin/bash && echo "aosp:aosp" | chpasswd && adduser aosp sudo
|
||||
RUN adduser aosp dialout && adduser aosp plugdev
|
||||
#ADD gitconfig /home/aosp/.gitconfig
|
||||
RUN sudo -u aosp -H git config --global user.name "AOSP Docker"
|
||||
RUN sudo -u aosp -H git config --global user.email "aosp@docker.local"
|
||||
@ -51,6 +52,7 @@ RUN sudo -u aosp -H GNUPGHOME=~/.repoconfig/gnupg gpg --keyserver keyserver.ubun
|
||||
VOLUME ["/tmp/ccache", "/aosp"]
|
||||
|
||||
# Improve rebuild performance by enabling compiler cache
|
||||
# Not supported by AOSP anymore
|
||||
ENV USE_CCACHE 1
|
||||
ENV CCACHE_DIR /tmp/ccache
|
||||
|
||||
|
12
sdocker
12
sdocker
@ -19,17 +19,22 @@ sdocker (){
|
||||
AOSP_ARGS=${AOSP_ARGS:--it}
|
||||
img=$(docker ps | grep $1 | awk '{print $1}');
|
||||
if [ -z $img ]; then
|
||||
img=$(docker ps -a | grep $1 | awk '{print $1}') | head -1;
|
||||
img=$(docker ps -a | grep $1 | awk '{print $1}' | head -1);
|
||||
if [ -z $img ]; then
|
||||
echo "Running a new container"
|
||||
docker run ${AOSP_ARGS} ${=SSH_AUTH_ARGS} -v ${AOSP_IMAGE}:/aosp/Project $1
|
||||
# Instead of using --privileged for accessing a device you can use --device-cgroup-rule
|
||||
# For giving access to /dev/ttyS0
|
||||
# ls -la /dev/ttyS0
|
||||
# crw-rw---- 1 root uucp 4, 64 12 mars 22:53 /dev/ttyS0 # Char dev with major number 4. Check /proc/devices for more device
|
||||
# use --device-cgroup-rule='c 4:* rmw' with r: read, m: mknod, w: write. and bind -v /dev:/dev
|
||||
docker run ${AOSP_ARGS} ${=SSH_AUTH_ARGS} -h $(hostname) -e DISPLAY=${DISPLAY} --privileged -v /dev/bus/usb:/dev/bus/usb -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v ${AOSP_IMAGE}:/aosp/Project -v $HOME/Sources/:/aosp/Sources/ --user="$(id -u):$(id -g)" $1
|
||||
else
|
||||
echo "Starting $img"
|
||||
docker start -i -a $img
|
||||
fi
|
||||
else
|
||||
echo "Attach to $img"
|
||||
docker exec -it $img /bin/bash
|
||||
eval docker exec ${DOCKER_EXEC_ARGS} -it $img /bin/bash
|
||||
fi
|
||||
}
|
||||
|
||||
@ -40,3 +45,4 @@ _sdocker () {
|
||||
}
|
||||
|
||||
complete -o default -F _sdocker sdocker
|
||||
complete -o default -F _sdocker sudocker
|
||||
|
Loading…
Reference in New Issue
Block a user