From 2e8642d74892b35fc72d5e7376e67b6da42107b3 Mon Sep 17 00:00:00 2001 From: iory Date: Tue, 26 Jul 2022 23:40:53 +0900 Subject: [PATCH 01/15] [jsk_unitree_startup] Use perl instead of 'grep -Po' --- jsk_unitree_robot/cross/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsk_unitree_robot/cross/install.sh b/jsk_unitree_robot/cross/install.sh index 2ac8a123f4..b588ca8e10 100755 --- a/jsk_unitree_robot/cross/install.sh +++ b/jsk_unitree_robot/cross/install.sh @@ -54,7 +54,7 @@ function copy_data () { fi # Check if robot is reachable - reachability=$(LANG=C ping -c4 ${hostname} 2>/dev/null | awk '/---/,0' | grep -Po '[0-9]{1,3}(?=% packet loss)') + reachability=$(LANG=C ping -c4 ${hostname} 2>/dev/null | awk '/---/,0' | perl -nle'print $& while m{[0-9]{1,3}(?=% packet loss)}g') if [ -z "$reachability" ] || [ "$reachability" == 100 ]; then echo "ERROR: ${hostname} unreachable" 1>&2 exit 2 From ec551fbaa45dbc43001af8b5f6c0fc15515012ea Mon Sep 17 00:00:00 2001 From: iory Date: Fri, 29 Jul 2022 14:06:06 +0900 Subject: [PATCH 02/15] [jsk_unitree_startup/cross] Add comment for reachability --- jsk_unitree_robot/cross/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jsk_unitree_robot/cross/install.sh b/jsk_unitree_robot/cross/install.sh index b588ca8e10..d13eba8102 100755 --- a/jsk_unitree_robot/cross/install.sh +++ b/jsk_unitree_robot/cross/install.sh @@ -54,6 +54,8 @@ function copy_data () { fi # Check if robot is reachable + # Use perl instead of `grep -Po '[0-9]{1,3}(?=% packet loss)'` for Mac environment. + # See https://stackoverflow.com/questions/16658333/grep-p-no-longer-works-how-can-i-rewrite-my-searches/16658690#16658690 reachability=$(LANG=C ping -c4 ${hostname} 2>/dev/null | awk '/---/,0' | perl -nle'print $& while m{[0-9]{1,3}(?=% packet loss)}g') if [ -z "$reachability" ] || [ "$reachability" == 100 ]; then echo "ERROR: ${hostname} unreachable" 1>&2 From df7af5968583fbf721b2cabd5a535216fabbf9e3 Mon Sep 17 00:00:00 2001 From: iory Date: Wed, 3 Aug 2022 19:51:02 +0900 Subject: [PATCH 03/15] [jsk_unitree_startup/cross] Add OPTIONS to passthrough user id for mac compatibility --- jsk_unitree_robot/cross/build_ros1.sh | 15 +++++++++++++-- .../cross/build_ros1_dependencies.sh | 12 ++++++++++-- jsk_unitree_robot/cross/build_user.sh | 11 ++++++++++- jsk_unitree_robot/cross/run_user.sh | 11 ++++++++++- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/jsk_unitree_robot/cross/build_ros1.sh b/jsk_unitree_robot/cross/build_ros1.sh index e7d1cde8e0..fbd2a03d13 100755 --- a/jsk_unitree_robot/cross/build_ros1.sh +++ b/jsk_unitree_robot/cross/build_ros1.sh @@ -33,7 +33,9 @@ mkdir -p ${HOST_INSTALL_ROOT}/ros1_inst if [ ${UPDATE_SOURCE_ROOT} -eq 1 ]; then vcs import --force --retry 10 --shallow ${SOURCE_ROOT}/src < repos/roseus_no_window.repos for dir in euslisp jskeus; do ls ${SOURCE_ROOT}/src/$dir/patches/; rsync -avz ${SOURCE_ROOT}/src/$dir/patches/ ${SOURCE_ROOT}/src/$dir; done - sed -i s@:{version}@0.0.0@ ${SOURCE_ROOT}/src/euslisp/package.xml ${SOURCE_ROOT}/src/jskeus/package.xml + # linux can use sed -i'.bak' and latest mac also supports same syntax. + # https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux/14813278#14813278 + sed -i.bak s@:{version}@0.0.0@ ${SOURCE_ROOT}/src/euslisp/package.xml ${SOURCE_ROOT}/src/jskeus/package.xml fi wget https://patch-diff.githubusercontent.com/raw/PR2/pr2_mechanism/pull/346.diff -O ${SOURCE_ROOT}/pr2_mechanism-346.diff @@ -46,8 +48,17 @@ JSK_ROBOT_UTILS="jsk_network_tools" DIAGNOSTIC_AGGREGATOR="diagnostic_aggregator" # jsk_XXX_startup usually depends on diagnostic_aggregator PR2EUS="pr2eus" +case ${OSTYPE} in + linux*) + OPTIONS="-u $(id -u $USER)" + ;; + darwin*) + OPTIONS="" + ;; +esac + docker run -it --rm \ - -u $(id -u $USER) \ + ${OPTIONS} \ -e INSTALL_ROOT=${INSTALL_ROOT} \ -e MAKEFLAGS=${MAKEFLAGS} \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ diff --git a/jsk_unitree_robot/cross/build_ros1_dependencies.sh b/jsk_unitree_robot/cross/build_ros1_dependencies.sh index 05f70d65ad..8813b24958 100755 --- a/jsk_unitree_robot/cross/build_ros1_dependencies.sh +++ b/jsk_unitree_robot/cross/build_ros1_dependencies.sh @@ -26,8 +26,17 @@ cp repos/ros1_dependencies.repos ${SOURCE_ROOT}/ mkdir -p ${HOST_INSTALL_ROOT}/Python cp repos/go1_requirements.txt ${SOURCE_ROOT}/go1_requirements.txt +case ${OSTYPE} in + linux*) + OPTIONS="-u $(id -u $USER)" + ;; + darwin*) + OPTIONS="" + ;; +esac + docker run -it --rm \ - -u $(id -u $USER) \ + ${OPTIONS} \ -e INSTALL_ROOT=${INSTALL_ROOT} \ -e MAKEFLAGS=${MAKEFLAGS} \ -v ${PWD}/ros1_dependencies_build_scripts:/home/user/ros1_dependencies_build_scripts:ro \ @@ -43,7 +52,6 @@ docker run -it --rm \ /home/user/ros1_dependencies_build_scripts/\$script_file || exit 1; done && \ pip install -U --user pip && \ - export PYTHONPATH=\"/opt/jsk/System/ros1_dependencies/lib/python2.7/site-packages\" && \ export PKG_CONFIG_PATH=\"/opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/pkgconfig\" && \ ~/.local/bin/pip install --prefix=/opt/jsk/${INSTALL_ROOT}/Python -r /home/user/ros1_dependencies_sources/go1_requirements.txt \ " 2>&1 | tee ${TARGET_MACHINE}_build_ros1_dependencies.log diff --git a/jsk_unitree_robot/cross/build_user.sh b/jsk_unitree_robot/cross/build_user.sh index f18831c411..956147f133 100755 --- a/jsk_unitree_robot/cross/build_user.sh +++ b/jsk_unitree_robot/cross/build_user.sh @@ -41,9 +41,18 @@ done # See https://github.com/k-okada/jsk_robot/issues/61 docker run -it --rm ros1-unitree:${TARGET_MACHINE} bash -c 'exit' || docker run --rm --privileged multiarch/qemu-user-static --reset -p yes +case ${OSTYPE} in + linux*) + OPTIONS="-u $(id -u $USER)" + ;; + darwin*) + OPTIONS="" + ;; +esac + # run on docker docker run -it --rm \ - -u $(id -u $USER) \ + ${OPTIONS} \ -e INSTALL_ROOT=${INSTALL_ROOT} \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/Python:/opt/jsk/${INSTALL_ROOT}/Python:ro \ diff --git a/jsk_unitree_robot/cross/run_user.sh b/jsk_unitree_robot/cross/run_user.sh index 07c9f39652..b4c80ed932 100755 --- a/jsk_unitree_robot/cross/run_user.sh +++ b/jsk_unitree_robot/cross/run_user.sh @@ -7,10 +7,19 @@ SOURCE_ROOT=${TARGET_MACHINE}_User set -xeuf -o pipefail +case ${OSTYPE} in + linux*) + OPTIONS="-u $(id -u $USER)" + ;; + darwin*) + OPTIONS="" + ;; +esac + # -v ${PWD}/${TARGET_MACHINE}_ws_system:/home/user/${TARGET_MACHINE}_ws_system:rw \ # run on docker docker run -it --rm \ - -u $(id -u $USER) \ + ${OPTIONS} \ -e INSTALL_ROOT=${INSTALL_ROOT} \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/Python:/opt/jsk/${INSTALL_ROOT}/Python:ro \ From 6883e3c6a7f95081d5b2bab6971df49e5b019b61 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Thu, 12 Oct 2023 17:57:49 +0900 Subject: [PATCH 04/15] Enable to share single image with multiple users. Create user in run-time to use same UDI/GID as host user. See https://qiita.com/ktamido/items/8d7b7eddbd88bd1bbf99 --- jsk_unitree_robot/cross/build_ros1.sh | 14 +++-------- .../cross/build_ros1_dependencies.sh | 14 +++-------- jsk_unitree_robot/cross/build_user.sh | 16 ++++--------- .../cross/docker/Dockerfile_ros1 | 12 ++++------ jsk_unitree_robot/cross/docker/entrypoint.sh | 23 +++++++++++++++++++ .../cross/prepare_requirements_ros1.sh | 3 ++- jsk_unitree_robot/cross/run_user.sh | 14 +++-------- 7 files changed, 42 insertions(+), 54 deletions(-) create mode 100644 jsk_unitree_robot/cross/docker/entrypoint.sh diff --git a/jsk_unitree_robot/cross/build_ros1.sh b/jsk_unitree_robot/cross/build_ros1.sh index fbd2a03d13..6b9634f272 100755 --- a/jsk_unitree_robot/cross/build_ros1.sh +++ b/jsk_unitree_robot/cross/build_ros1.sh @@ -1,5 +1,6 @@ #!/bin/bash +IMAGE_NAME="${IMAGE_NAME:-ros1-unitree}" TARGET_MACHINE="${TARGET_MACHINE:-arm64v8}" HOST_INSTALL_ROOT="${BASE_ROOT:-${PWD}}/"${TARGET_MACHINE}_System INSTALL_ROOT=System @@ -48,24 +49,15 @@ JSK_ROBOT_UTILS="jsk_network_tools" DIAGNOSTIC_AGGREGATOR="diagnostic_aggregator" # jsk_XXX_startup usually depends on diagnostic_aggregator PR2EUS="pr2eus" -case ${OSTYPE} in - linux*) - OPTIONS="-u $(id -u $USER)" - ;; - darwin*) - OPTIONS="" - ;; -esac - docker run -it --rm \ - ${OPTIONS} \ + -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) \ -e INSTALL_ROOT=${INSTALL_ROOT} \ -e MAKEFLAGS=${MAKEFLAGS} \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:rw \ -v ${PWD}/${SOURCE_ROOT}:/home/user/${SOURCE_ROOT}:rw \ - ros1-unitree:${TARGET_MACHINE} \ + ${IMAGE_NAME}:${TARGET_MACHINE} \ bash -c "\ source /opt/jsk/System/ros1_dependencies_setup.bash && \ source /opt/ros/melodic/setup.bash && \ diff --git a/jsk_unitree_robot/cross/build_ros1_dependencies.sh b/jsk_unitree_robot/cross/build_ros1_dependencies.sh index 8813b24958..079d34cd14 100755 --- a/jsk_unitree_robot/cross/build_ros1_dependencies.sh +++ b/jsk_unitree_robot/cross/build_ros1_dependencies.sh @@ -1,5 +1,6 @@ #!/bin/bash +IMAGE_NAME="${IMAGE_NAME:-ros1-unitree}" TARGET_MACHINE="${TARGET_MACHINE:-arm64v8}" HOST_INSTALL_ROOT="${BASE_ROOT:-${PWD}}/"${TARGET_MACHINE}_System INSTALL_ROOT=System @@ -26,24 +27,15 @@ cp repos/ros1_dependencies.repos ${SOURCE_ROOT}/ mkdir -p ${HOST_INSTALL_ROOT}/Python cp repos/go1_requirements.txt ${SOURCE_ROOT}/go1_requirements.txt -case ${OSTYPE} in - linux*) - OPTIONS="-u $(id -u $USER)" - ;; - darwin*) - OPTIONS="" - ;; -esac - docker run -it --rm \ - ${OPTIONS} \ + -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) \ -e INSTALL_ROOT=${INSTALL_ROOT} \ -e MAKEFLAGS=${MAKEFLAGS} \ -v ${PWD}/ros1_dependencies_build_scripts:/home/user/ros1_dependencies_build_scripts:ro \ -v ${PWD}/${SOURCE_ROOT}:/home/user/ros1_dependencies_sources:rw \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk//${INSTALL_ROOT}/ros1_dependencies:rw \ -v ${HOST_INSTALL_ROOT}/Python:/opt/jsk/${INSTALL_ROOT}/Python:rw \ - ros1-unitree:${TARGET_MACHINE} \ + ${IMAGE_NAME}:${TARGET_MACHINE} \ bash -c "\ set -xeuf -o pipefail && \ cd /home/user/ros1_dependencies_sources && \ diff --git a/jsk_unitree_robot/cross/build_user.sh b/jsk_unitree_robot/cross/build_user.sh index 956147f133..b692debab2 100755 --- a/jsk_unitree_robot/cross/build_user.sh +++ b/jsk_unitree_robot/cross/build_user.sh @@ -1,5 +1,6 @@ #!/bin/bash +IMAGE_NAME="${IMAGE_NAME:-ros1-unitree}" TARGET_MACHINE="${TARGET_MACHINE:-arm64v8}" HOST_INSTALL_ROOT="${BASE_ROOT:-${PWD}}/"${TARGET_MACHINE}_System INSTALL_ROOT=System @@ -39,20 +40,11 @@ done # check if /proc/sys/fs/binfmt_misc/qemu-* is updated # See https://github.com/k-okada/jsk_robot/issues/61 -docker run -it --rm ros1-unitree:${TARGET_MACHINE} bash -c 'exit' || docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - -case ${OSTYPE} in - linux*) - OPTIONS="-u $(id -u $USER)" - ;; - darwin*) - OPTIONS="" - ;; -esac +docker run -it --rm -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) ${IMAGE_NAME}:${TARGET_MACHINE} bash -c 'exit' || docker run --rm --privileged multiarch/qemu-user-static --reset -p yes # run on docker docker run -it --rm \ - ${OPTIONS} \ + -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) \ -e INSTALL_ROOT=${INSTALL_ROOT} \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/Python:/opt/jsk/${INSTALL_ROOT}/Python:ro \ @@ -61,7 +53,7 @@ docker run -it --rm \ -v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \ -v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \ -v ${PWD}/rosinstall_generator_unreleased.py:/home/user/rosinstall_generator_unreleased.py:ro \ - ros1-unitree:${TARGET_MACHINE} \ + ${IMAGE_NAME}:${TARGET_MACHINE} \ bash -c "\ source /opt/jsk/System/system_setup.bash && \ env && \ diff --git a/jsk_unitree_robot/cross/docker/Dockerfile_ros1 b/jsk_unitree_robot/cross/docker/Dockerfile_ros1 index 7de759b9d3..dd2ff90fdd 100644 --- a/jsk_unitree_robot/cross/docker/Dockerfile_ros1 +++ b/jsk_unitree_robot/cross/docker/Dockerfile_ros1 @@ -31,19 +31,15 @@ RUN git clone https://github.com/k-okada/rosinstall_generator /tmp/rosinstall_ge RUN pip install /tmp/rosinstall_generator RUN apt install -y python3-vcstool # -# Setup Users +# add tool for users # -ARG UID=1000 RUN apt-get install -y sudo -RUN useradd --uid $UID -ms /bin/bash -G sudo user -RUN newgrp -RUN echo user:user | chpasswd # # Remove packages is not found on 161 # RUN dpkg -r --force-depends cython gir1.2-gstreamer-1.0 libtinyxml-dev python-attr python-autobahn python-automat python-cbor python-concurrent.futures python-constantly python-constantly python-incremental python-lz4 python-nacl python-pyasn1 python-pyasn1-modules python-qrcode python-service-identity python-snappy python-trie python-trollius python-twisted-bin python-twisted-core python-twisted python-txaio python-ubjson python-u-msgpack python-wsaccel python-zope.interface # # -# -WORKDIR /home/user -USER user +ADD entrypoint.sh / +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/jsk_unitree_robot/cross/docker/entrypoint.sh b/jsk_unitree_robot/cross/docker/entrypoint.sh new file mode 100644 index 0000000000..3eb14445d9 --- /dev/null +++ b/jsk_unitree_robot/cross/docker/entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +function fail { + printf '\033[31m%s\033[0m\n' "$1" >&2 ## Send message to stderr. + exit "${2-1}" ## Return a code specified by $2, or 1 by default. +} +[ -z "${HOST_UID}" ] && fail "ERROR: HOST_UID is requried, add '-e HOST_UID=$(id -u)' to your docker commandline option" +[ -z "${HOST_GID}" ] && fail "ERROR: HOST_GID is requried, add '-e HOST_GID=$(id -g)' to your docker commandline option" + +# create user with same UID as the host user +# -g The numerical value of the group's ID. +groupadd -g $HOST_GID user +# -u The numerical value of the user's ID. +# -o Allow the creation of a user account with a duplicate (non-unique) UID. +# -m Create the user's home directory if it does not exist. +# -g The group name or number of the user's initial login group. +# -s The name of the user's login shell. +useradd -u $HOST_UID -o -m -g $HOST_GID -s /usr/bin user +export HOME=/home/user +chown $HOST_UID:$HOST_GID $HOME +cd $HOME + +runuser -u user -- "$@" diff --git a/jsk_unitree_robot/cross/prepare_requirements_ros1.sh b/jsk_unitree_robot/cross/prepare_requirements_ros1.sh index 110d88651c..2aae00838c 100755 --- a/jsk_unitree_robot/cross/prepare_requirements_ros1.sh +++ b/jsk_unitree_robot/cross/prepare_requirements_ros1.sh @@ -1,5 +1,6 @@ #!/bin/bash +IMAGE_NAME="${IMAGE_NAME:-ros1-unitree}" TARGET_MACHINE="${TARGET_MACHINE:-arm64v8}" HOST_INSTALL_ROOT="${BASE_ROOT:-${PWD}}/"System INSTALL_ROOT=System @@ -14,4 +15,4 @@ if [ -e /proc/sys/fs/binfmt_misc/qemu-aarch64 ] && [ ! "$(docker images -q mult docker run --rm --privileged multiarch/qemu-user-static --reset -p yes fi -docker buildx build $@ --progress plain -t ros1-unitree:${TARGET_MACHINE} --build-arg TARGET_MACHINE=${TARGET_MACHINE} --build-arg UID=$(id -u $USER) -f docker/Dockerfile_ros1 docker/ 2>&1 | tee ${TARGET_MACHINE}_prepare_requirements_ros1.log +docker buildx build $@ --progress plain -t ${IMAGE_NAME}:${TARGET_MACHINE} --build-arg TARGET_MACHINE=${TARGET_MACHINE} --build-arg UID=$(id -u $USER) -f docker/Dockerfile_ros1 docker/ 2>&1 | tee ${TARGET_MACHINE}_prepare_requirements_ros1.log diff --git a/jsk_unitree_robot/cross/run_user.sh b/jsk_unitree_robot/cross/run_user.sh index b4c80ed932..2b6acbc48e 100755 --- a/jsk_unitree_robot/cross/run_user.sh +++ b/jsk_unitree_robot/cross/run_user.sh @@ -1,5 +1,6 @@ #!/bin/bash +IMAGE_NAME="${IMAGE_NAME:-ros1-unitree}" TARGET_MACHINE="${TARGET_MACHINE:-arm64v8}" HOST_INSTALL_ROOT="${BASE_ROOT:-${PWD}}/"${TARGET_MACHINE}_System INSTALL_ROOT=System @@ -7,19 +8,10 @@ SOURCE_ROOT=${TARGET_MACHINE}_User set -xeuf -o pipefail -case ${OSTYPE} in - linux*) - OPTIONS="-u $(id -u $USER)" - ;; - darwin*) - OPTIONS="" - ;; -esac - # -v ${PWD}/${TARGET_MACHINE}_ws_system:/home/user/${TARGET_MACHINE}_ws_system:rw \ # run on docker docker run -it --rm \ - ${OPTIONS} \ + -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) \ -e INSTALL_ROOT=${INSTALL_ROOT} \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/Python:/opt/jsk/${INSTALL_ROOT}/Python:ro \ @@ -27,7 +19,7 @@ docker run -it --rm \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ -v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \ -v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \ - ros1-unitree:${TARGET_MACHINE} \ + ${IMAGE_NAME}:${TARGET_MACHINE} \ bash -c "echo 'source /opt/jsk/User/user_setup.bash; env; cd /opt/jsk/User' > ~/.bashrc; exec \"\$0\"" # https://stackoverflow.com/questions/59814742/docker-run-bash-init-file From 8ba0744f47edafdbeafb9a861efd5000ab8399de Mon Sep 17 00:00:00 2001 From: iory Date: Tue, 26 Jul 2022 11:41:25 +0900 Subject: [PATCH 05/15] [jsk_unitree_startup/cross] Use sitecustomize.py instead of setting PYTHONPATH [jsk_unitree_startup/cross] Install sitecustomize.py for real unitree robot [jsk_unitree_startup/cross] Recursively append python site/dist-package paths [jsk_unitree_startup/cross] Passthrough password --- jsk_unitree_robot/cross/build_ros1.sh | 3 ++ jsk_unitree_robot/cross/build_user.sh | 4 +- jsk_unitree_robot/cross/install.sh | 6 +++ jsk_unitree_robot/cross/run_user.sh | 2 + .../ros1_dependencies_setup.bash | 6 ++- .../cross/startup_scripts/sitecustomize.py | 39 +++++++++++++++++++ 6 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 jsk_unitree_robot/cross/startup_scripts/sitecustomize.py diff --git a/jsk_unitree_robot/cross/build_ros1.sh b/jsk_unitree_robot/cross/build_ros1.sh index 6b9634f272..80e53036ba 100755 --- a/jsk_unitree_robot/cross/build_ros1.sh +++ b/jsk_unitree_robot/cross/build_ros1.sh @@ -55,6 +55,8 @@ docker run -it --rm \ -e MAKEFLAGS=${MAKEFLAGS} \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ + -v ${PWD}/startup_scripts/sitecustomize.py:/usr/lib/python2.7/sitecustomize.py:ro \ + -v ${PWD}/startup_scripts/sitecustomize.py:/usr/lib/python3.6/sitecustomize.py:ro \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:rw \ -v ${PWD}/${SOURCE_ROOT}:/home/user/${SOURCE_ROOT}:rw \ ${IMAGE_NAME}:${TARGET_MACHINE} \ @@ -74,3 +76,4 @@ docker run -it --rm \ " 2>&1 | tee ${TARGET_MACHINE}_build_ros1.log cp ${PWD}/startup_scripts/system_setup.bash ${HOST_INSTALL_ROOT}/ +cp ${PWD}/startup_scripts/sitecustomize.py ${HOST_INSTALL_ROOT}/ diff --git a/jsk_unitree_robot/cross/build_user.sh b/jsk_unitree_robot/cross/build_user.sh index b692debab2..01cef3b22a 100755 --- a/jsk_unitree_robot/cross/build_user.sh +++ b/jsk_unitree_robot/cross/build_user.sh @@ -51,6 +51,8 @@ docker run -it --rm \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ -v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \ + -v ${HOST_INSTALL_ROOT}/sitecustomize.py:/usr/lib/python2.7/sitecustomize.py:ro \ + -v ${HOST_INSTALL_ROOT}/sitecustomize.py:/usr/lib/python3.6/sitecustomize.py:ro \ -v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \ -v ${PWD}/rosinstall_generator_unreleased.py:/home/user/rosinstall_generator_unreleased.py:ro \ ${IMAGE_NAME}:${TARGET_MACHINE} \ @@ -60,7 +62,7 @@ docker run -it --rm \ set -xeuf -o pipefail && \ cd /opt/jsk/User && \ [ ${UPDATE_SOURCE_ROOT} -eq 0 ] || ROS_PACKAGE_PATH=src:\${ROS_PACKAGE_PATH} /home/user/rosinstall_generator_unreleased.py jsk_${TARGET_ROBOT}_startup ${TARGET_ROBOT}eus --rosdistro melodic --exclude RPP --exclude mongodb_store | tee user.repos && \ - [ ${UPDATE_SOURCE_ROOT} -eq 0 -o -z \"\$(cat user.repos)\" ] || PYTHONPATH= vcs import src < user.repos && \ + [ ${UPDATE_SOURCE_ROOT} -eq 0 -o -z \"\$(cat user.repos)\" ] || vcs import src < user.repos && \ catkin build jsk_${TARGET_ROBOT}_startup ${TARGET_ROBOT}eus -s -vi \ --cmake-args -DCATKIN_ENABLE_TESTING=FALSE \ " 2>&1 | tee ${TARGET_MACHINE}_build_user.log diff --git a/jsk_unitree_robot/cross/install.sh b/jsk_unitree_robot/cross/install.sh index d13eba8102..1891383734 100755 --- a/jsk_unitree_robot/cross/install.sh +++ b/jsk_unitree_robot/cross/install.sh @@ -66,6 +66,12 @@ function copy_data () { ssh-keygen -f "${HOME}/.ssh/known_hosts" -R "${hostname}" || echo "OK" sshpass -p $PASS ssh -o StrictHostKeyChecking=no ${user}@${hostname} exit + if [[ "${TARGET_DIRECTORY}" == "System" ]]; then + sshpass -p 123 scp ${TARGET_MACHINE}_${TARGET_DIRECTORY}/sitecustomize.py ${user}@${hostname}:/tmp/sitecustomize.py + sshpass -p $PASS ssh -t ${user}@${hostname} "echo $PASS | sudo -S cp -f /tmp/sitecustomize.py /usr/lib/python2.7/sitecustomize.py" + sshpass -p $PASS ssh -t ${user}@${hostname} "echo $PASS | sudo -S cp -f /tmp/sitecustomize.py /usr/lib/python3/sitecustomize.py" + fi + # cehck disk space echo "Copy ${TARGET_MACHINE}_${TARGET_DIRECTORY} ...." echo "===" diff --git a/jsk_unitree_robot/cross/run_user.sh b/jsk_unitree_robot/cross/run_user.sh index 2b6acbc48e..593e85702d 100755 --- a/jsk_unitree_robot/cross/run_user.sh +++ b/jsk_unitree_robot/cross/run_user.sh @@ -16,6 +16,8 @@ docker run -it --rm \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/Python:/opt/jsk/${INSTALL_ROOT}/Python:ro \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:ro \ + -v ${PWD}/startup_scripts/sitecustomize.py:/usr/lib/python2.7/sitecustomize.py:ro \ + -v ${PWD}/startup_scripts/sitecustomize.py:/usr/lib/python3.6/sitecustomize.py:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ -v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \ -v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \ diff --git a/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash b/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash index bb83142ace..2ab07f4d83 100755 --- a/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash +++ b/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash @@ -5,14 +5,16 @@ export CMAKE_PREFIX_PATH="/opt/jsk/System/ros1_dependencies:${CMAKE_PREFIX_PATH}" export PKG_CONFIG_PATH="/opt/jsk/System/ros1_dependencies/lib/pkgconfig:${PKG_CONFIG_PATH}" export LD_LIBRARY_PATH="/opt/jsk/System/ros1_dependencies/lib:${LD_LIBRARY_PATH}" -export PYTHONPATH="/opt/jsk/System/ros1_dependencies/lib/python2.7/site-packages:${PYTHONPATH}" +# Python's sys.path is automatically set in /usr/lib/python2.7/sitecustomize.py +# export PYTHONPATH="/opt/jsk/System/ros1_dependencies/lib/python2.7/site-packages:${PYTHONPATH}" # GI : for gir1.2-gstreamer-1.0, which is installed by ros1_dependencies_build_scripts/0006-gstreamer export GI_TYPELIB_PATH="/opt/jsk/System/ros1_dependencies/lib/girepository-1.0" # Python export LD_LIBRARY_PATH="/opt/jsk/System/Python/lib:${LD_LIBRARY_PATH}" -export PYTHONPATH="/opt/jsk/System/Python/lib/python2.7/site-packages:${PYTHONPATH}" +# Python's sys.path is automatically set in /usr/lib/python2.7/sitecustomize.py +# export PYTHONPATH="/opt/jsk/System/Python/lib/python2.7/site-packages:${PYTHONPATH}" export PATH="/opt/jsk/System/Python/bin:${PATH}" diff --git a/jsk_unitree_robot/cross/startup_scripts/sitecustomize.py b/jsk_unitree_robot/cross/startup_scripts/sitecustomize.py new file mode 100644 index 0000000000..6e0abdf861 --- /dev/null +++ b/jsk_unitree_robot/cross/startup_scripts/sitecustomize.py @@ -0,0 +1,39 @@ +# install the apport exception handler if available +import site +import sys +import os +import os.path as osp + +site.PREFIXES += [ + '/opt/jsk/System/Python/', + '/opt/jsk/System/ros1_dependencies/', + '/opt/jsk/System/ros1_inst/', +] + + +def recursively_listup_paths(path): + paths = [] + for sub_path in os.listdir(path): + sub_full_path = osp.join(path, sub_path) + if osp.isdir(sub_full_path) and (sub_path.endswith('.egg-info') or sub_path.endswith('.egg')): + paths.append(sub_full_path) + return paths + + +paths = [] +for path in site.getsitepackages(): + if osp.exists(path): + paths.append(path) + paths.extend(recursively_listup_paths(path)) + site_package = osp.join(osp.dirname(path), 'site-packages') + if site_package != path and osp.exists(site_package): + paths.append(site_package) + paths.extend(recursively_listup_paths(site_package)) + +sys.path.extend(paths) +try: + import apport_python_hook +except ImportError: + pass +else: + apport_python_hook.install() From 413be94f3971bcd6ed5570befce0e2873573afd4 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 13 Oct 2023 11:05:54 +0900 Subject: [PATCH 06/15] install catkin_virtualenv in build_ros1.sh and install rospkg-modules in build_ros1_dependencies.sh --- jsk_unitree_robot/cross/build_ros1.sh | 1 + .../cross/repos/catkin_virtualenv.repos | 18 ++++++++++++++++ .../cross/repos/ros1_dependencies.repos | 18 ++++++++++++++++ .../1045-python3-pyparsing | 21 +++++++++++++++++++ .../1046-python3-catkin-pkg-modules | 21 +++++++++++++++++++ .../1047-python3-rospkg-modules | 21 +++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 jsk_unitree_robot/cross/repos/catkin_virtualenv.repos create mode 100755 jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-python3-pyparsing create mode 100755 jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1046-python3-catkin-pkg-modules create mode 100755 jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1047-python3-rospkg-modules diff --git a/jsk_unitree_robot/cross/build_ros1.sh b/jsk_unitree_robot/cross/build_ros1.sh index 80e53036ba..faad1b0822 100755 --- a/jsk_unitree_robot/cross/build_ros1.sh +++ b/jsk_unitree_robot/cross/build_ros1.sh @@ -32,6 +32,7 @@ mkdir -p ${SOURCE_ROOT}/src mkdir -p ${HOST_INSTALL_ROOT}/ros1_inst if [ ${UPDATE_SOURCE_ROOT} -eq 1 ]; then + vcs import --force --retry 10 --shallow ${SOURCE_ROOT}/src < repos/catkin_virtualenv.repos vcs import --force --retry 10 --shallow ${SOURCE_ROOT}/src < repos/roseus_no_window.repos for dir in euslisp jskeus; do ls ${SOURCE_ROOT}/src/$dir/patches/; rsync -avz ${SOURCE_ROOT}/src/$dir/patches/ ${SOURCE_ROOT}/src/$dir; done # linux can use sed -i'.bak' and latest mac also supports same syntax. diff --git a/jsk_unitree_robot/cross/repos/catkin_virtualenv.repos b/jsk_unitree_robot/cross/repos/catkin_virtualenv.repos new file mode 100644 index 0000000000..1352315ced --- /dev/null +++ b/jsk_unitree_robot/cross/repos/catkin_virtualenv.repos @@ -0,0 +1,18 @@ +repositories: + catkin_virtualenv: + type: git + url: https://github.com/locusrobotics/catkin_virtualenv + version: 0.9.0 + # + # 0.9.0 contains following two patches, but not release on ROS1 + # catkin_virtualenv depends on python3-rospkg-modules (and others). It is installed in build_ros1_dependencies.sh + # + # At current, if we do a catkin build with CATKIN_ENABLE_TESTING=FALSE, + # we get the error 'Unknown CMake command "catkin_run_tests_target"' + # when calling catkin_generate_virtualenv. The following PR fixes this error. + # https://github.com/locusrobotics/catkin_virtualenv/pull/89 + # + # Some python environments may not have ensurepip installed. + # Also, some users may not be able to use sudo apt install to install python3-venv (sudo command), etc. + # The following PR will enable catkin_virtualenv in environments without ensurepip by doing get-pip.py within venv. + # https://github.com/locusrobotics/catkin_virtualenv/pull/90 diff --git a/jsk_unitree_robot/cross/repos/ros1_dependencies.repos b/jsk_unitree_robot/cross/repos/ros1_dependencies.repos index d69c626402..749dd317ee 100644 --- a/jsk_unitree_robot/cross/repos/ros1_dependencies.repos +++ b/jsk_unitree_robot/cross/repos/ros1_dependencies.repos @@ -262,3 +262,21 @@ repositories: type: tar url: http://archive.ubuntu.com/ubuntu/pool/universe/libc/libccd/libccd_2.0-1.debian.tar.xz # fcl depends on ccd + python3-pyparsing: + type: tar + url: http://archive.ubuntu.com/ubuntu/pool/main/p/pyparsing/pyparsing_2.2.0+dfsg1.orig.tar.gz + python3-pyparsing/debian: + type: tar + url: http://archive.ubuntu.com/ubuntu/pool/main/p/pyparsing/pyparsing_2.2.0+dfsg1-2.debian.tar.xz + python3-catkin-pkg-modules: + type: tar + url: http://packages.ros.org/ros/ubuntu/pool/main/p/python3-catkin-pkg-modules/python3-catkin-pkg-modules_0.5.2.orig.tar.gz + python3-catkin-pkg-modules/debian: + type: tar + url: http://packages.ros.org/ros/ubuntu/pool/main/p/python3-catkin-pkg-modules/python3-catkin-pkg-modules_0.5.2-1.debian.tar.xz + python3-rospkg-modules: + type: tar + url: http://packages.ros.org/ros/ubuntu/pool/main/p/python3-rospkg-modules/python3-rospkg-modules_1.5.0.orig.tar.gz + python3-rospkg-modules/debian: + type: tar + url: http://packages.ros.org/ros/ubuntu/pool/main/p/python3-rospkg-modules/python3-rospkg-modules_1.5.0-1.debian.tar.xz diff --git a/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-python3-pyparsing b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-python3-pyparsing new file mode 100755 index 0000000000..6ab82d8494 --- /dev/null +++ b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-python3-pyparsing @@ -0,0 +1,21 @@ +#!/bin/bash +set -xeuf -o pipefail + +DEBIAN_DIR=/home/user/ros1_dependencies_sources/src/python3-pyparsing/debian/debian +SOURCE_DIR=/home/user/ros1_dependencies_sources/src/python3-pyparsing/pyparsing-2.2.0+dfsg1 + +# cd ${DEBIAN_DIR}/patches +# for patch_file in $(grep -v ^# series); do +# OUT="$(patch -p1 --forward --directory ${SOURCE_DIR} < ${patch_file} | tee /dev/tty)" || echo "${OUT}" | grep "Skipping patch" -q || (echo "$OUT" && false) || echo "OK" +# done + +cd ${SOURCE_DIR} + +mkdir -p /opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python3.6/site-packages/ +SKIP_PYTHON_SCRIPTS=1 \ +PYTHONPATH="/opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python3.6/site-packages" \ + python3 \ + setup.py install \ + --force --root=/opt/jsk/${INSTALL_ROOT}/ros1_dependencies \ + --no-compile -O0 --single-version-externally-managed --prefix=./ +# --prefix /opt/jsk/${INSTALL_ROOT}/ros1_dependencies diff --git a/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1046-python3-catkin-pkg-modules b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1046-python3-catkin-pkg-modules new file mode 100755 index 0000000000..da470da7cd --- /dev/null +++ b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1046-python3-catkin-pkg-modules @@ -0,0 +1,21 @@ +#!/bin/bash +set -xeuf -o pipefail + +DEBIAN_DIR=/home/user/ros1_dependencies_sources/src/python3-catkin-pkg-modules/debian/debian +SOURCE_DIR=/home/user/ros1_dependencies_sources/src/python3-catkin-pkg-modules/catkin_pkg_modules-0.5.2 + +# cd ${DEBIAN_DIR}/patches +# for patch_file in $(grep -v ^# series); do +# OUT="$(patch -p1 --forward --directory ${SOURCE_DIR} < ${patch_file} | tee /dev/tty)" || echo "${OUT}" | grep "Skipping patch" -q || (echo "$OUT" && false) || echo "OK" +# done + +cd ${SOURCE_DIR} + +mkdir -p /opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python3.6/site-packages/ +SKIP_PYTHON_SCRIPTS=1 \ +PYTHONPATH="/opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python3.6/site-packages" \ + python3 \ + setup.py install \ + --force --root=/opt/jsk/${INSTALL_ROOT}/ros1_dependencies \ + --no-compile -O0 --single-version-externally-managed --prefix=./ +# --prefix /opt/jsk/${INSTALL_ROOT}/ros1_dependencies diff --git a/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1047-python3-rospkg-modules b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1047-python3-rospkg-modules new file mode 100755 index 0000000000..8af6e48c05 --- /dev/null +++ b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1047-python3-rospkg-modules @@ -0,0 +1,21 @@ +#!/bin/bash +set -xeuf -o pipefail + +DEBIAN_DIR=/home/user/ros1_dependencies_sources/src/python3-rospkg-modules/debian/debian +SOURCE_DIR=/home/user/ros1_dependencies_sources/src/python3-rospkg-modules/rospkg_modules-1.5.0 + +# cd ${DEBIAN_DIR}/patches +# for patch_file in $(grep -v ^# series); do +# OUT="$(patch -p1 --forward --directory ${SOURCE_DIR} < ${patch_file} | tee /dev/tty)" || echo "${OUT}" | grep "Skipping patch" -q || (echo "$OUT" && false) || echo "OK" +# done + +cd ${SOURCE_DIR} + +mkdir -p /opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python3.6/site-packages/ +SKIP_PYTHON_SCRIPTS=1 \ +PYTHONPATH="/opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python3.6/site-packages" \ + python3 \ + setup.py install \ + --force --root=/opt/jsk/${INSTALL_ROOT}/ros1_dependencies \ + --no-compile -O0 --single-version-externally-managed --prefix=./ +# --prefix /opt/jsk/${INSTALL_ROOT}/ros1_dependencies \ From 2076eb9b7e099bed8ec513488c5e9377ee85081a Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 13 Oct 2023 11:06:27 +0900 Subject: [PATCH 07/15] build_ros1_dependencies.sh: touch script_file.installed no skip compiled packages --- jsk_unitree_robot/cross/build_ros1_dependencies.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jsk_unitree_robot/cross/build_ros1_dependencies.sh b/jsk_unitree_robot/cross/build_ros1_dependencies.sh index 079d34cd14..1a988ff417 100755 --- a/jsk_unitree_robot/cross/build_ros1_dependencies.sh +++ b/jsk_unitree_robot/cross/build_ros1_dependencies.sh @@ -41,7 +41,9 @@ docker run -it --rm \ cd /home/user/ros1_dependencies_sources && \ vcs import --skip-existing --retry 10 --shallow src < ros1_dependencies.repos && \ for script_file in \$(ls /home/user/ros1_dependencies_build_scripts/|sort); do + [ -e /home/user/ros1_dependencies_sources/\$script_file.installed ] && continue; /home/user/ros1_dependencies_build_scripts/\$script_file || exit 1; + touch /home/user/ros1_dependencies_sources/\$script_file.installed; done && \ pip install -U --user pip && \ export PKG_CONFIG_PATH=\"/opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/pkgconfig\" && \ From 499ba650417b773a0be1b54722392bc6839f5918 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Sun, 15 Oct 2023 16:03:55 +0900 Subject: [PATCH 08/15] add virtualenv and cython for catkin_virutalenv - catkin_virtualenv depends on python3-venv and virtualenv, so we added these packages on ros1_dependencies_build_scripts, because they are not found on actual robots. - not sure why, but catkin_virtualenv (test_catkin_virutalenv_python2) depends on cython, But with 1049-cython, it fails to instal PyYAML, so we force add cython dep packages in Dockerfile_ros1 --- .../cross/docker/Dockerfile_ros1 | 3 ++ .../cross/repos/ros1_dependencies.repos | 12 +++++ .../1045-virtualenv | 21 +++++++++ ...thon3-pyparsing => 1046-python3-pyparsing} | 0 ...odules => 1047-python3-catkin-pkg-modules} | 0 ...kg-modules => 1048-python3-rospkg-modules} | 0 .../1049-cython | 46 +++++++++++++++++++ 7 files changed, 82 insertions(+) create mode 100755 jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-virtualenv rename jsk_unitree_robot/cross/ros1_dependencies_build_scripts/{1045-python3-pyparsing => 1046-python3-pyparsing} (100%) rename jsk_unitree_robot/cross/ros1_dependencies_build_scripts/{1046-python3-catkin-pkg-modules => 1047-python3-catkin-pkg-modules} (100%) rename jsk_unitree_robot/cross/ros1_dependencies_build_scripts/{1047-python3-rospkg-modules => 1048-python3-rospkg-modules} (100%) create mode 100755 jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1049-cython diff --git a/jsk_unitree_robot/cross/docker/Dockerfile_ros1 b/jsk_unitree_robot/cross/docker/Dockerfile_ros1 index dd2ff90fdd..0936a7d68f 100644 --- a/jsk_unitree_robot/cross/docker/Dockerfile_ros1 +++ b/jsk_unitree_robot/cross/docker/Dockerfile_ros1 @@ -39,6 +39,9 @@ RUN apt-get install -y sudo # RUN dpkg -r --force-depends cython gir1.2-gstreamer-1.0 libtinyxml-dev python-attr python-autobahn python-automat python-cbor python-concurrent.futures python-constantly python-constantly python-incremental python-lz4 python-nacl python-pyasn1 python-pyasn1-modules python-qrcode python-service-identity python-snappy python-trie python-trollius python-twisted-bin python-twisted-core python-twisted python-txaio python-ubjson python-u-msgpack python-wsaccel python-zope.interface # +# Add cython, which we need to compile packages with catkin_virtualenv, not sure why 1049-cython works... +RUN (cd /tmp; apt download cython && dpkg --force-depends -i cython_*.deb) +# # ADD entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/jsk_unitree_robot/cross/repos/ros1_dependencies.repos b/jsk_unitree_robot/cross/repos/ros1_dependencies.repos index 749dd317ee..71648aaceb 100644 --- a/jsk_unitree_robot/cross/repos/ros1_dependencies.repos +++ b/jsk_unitree_robot/cross/repos/ros1_dependencies.repos @@ -262,6 +262,12 @@ repositories: type: tar url: http://archive.ubuntu.com/ubuntu/pool/universe/libc/libccd/libccd_2.0-1.debian.tar.xz # fcl depends on ccd + virtualenv: + type: tar + url: http://archive.ubuntu.com/ubuntu/ubuntu/pool/universe/p/python-virtualenv/python-virtualenv_15.1.0+ds.orig.tar.gz + virtualenv/debian: + type: tar + url: http://archive.ubuntu.com/ubuntu/ubuntu/pool/universe/p/python-virtualenv/python-virtualenv_15.1.0+ds-1.1.debian.tar.xz python3-pyparsing: type: tar url: http://archive.ubuntu.com/ubuntu/pool/main/p/pyparsing/pyparsing_2.2.0+dfsg1.orig.tar.gz @@ -280,3 +286,9 @@ repositories: python3-rospkg-modules/debian: type: tar url: http://packages.ros.org/ros/ubuntu/pool/main/p/python3-rospkg-modules/python3-rospkg-modules_1.5.0-1.debian.tar.xz + cython: + type: tar + url: http://archive.ubuntu.com/ubuntu/ubuntu/pool/universe/c/cython/cython_0.26.1.orig.tar.gz + cython/debian: + type: tar + url: http://archive.ubuntu.com/ubuntu/ubuntu/pool/universe/c/cython/cython_0.26.1-0.4.debian.tar.xz diff --git a/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-virtualenv b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-virtualenv new file mode 100755 index 0000000000..6f2f02e50b --- /dev/null +++ b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-virtualenv @@ -0,0 +1,21 @@ +#!/bin/bash +set -xeuf -o pipefail + +DEBIAN_DIR=/home/user/ros1_dependencies_sources/src/virtualenv/debian/debian +SOURCE_DIR=/home/user/ros1_dependencies_sources/src/virtualenv/virtualenv-15.1.0 + +cd ${DEBIAN_DIR}/patches +for patch_file in $(grep -v ^# series); do + OUT="$(patch -p1 --forward --directory ${SOURCE_DIR} < ${patch_file} | tee /dev/tty)" || echo "${OUT}" | grep "Skipping patch" -q || (echo "$OUT" && false) || echo "OK" +done + +cd ${SOURCE_DIR} + +mkdir -p /opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python3.6/site-packages/ +SKIP_PYTHON_SCRIPTS=1 \ +PYTHONPATH="/opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python3.6/site-packages" \ + python3 \ + setup.py install \ + --force --root=/opt/jsk/${INSTALL_ROOT}/ros1_dependencies \ + --no-compile -O0 --single-version-externally-managed --prefix=./ +# --prefix /opt/jsk/${INSTALL_ROOT}/ros1_dependencies diff --git a/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-python3-pyparsing b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1046-python3-pyparsing similarity index 100% rename from jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1045-python3-pyparsing rename to jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1046-python3-pyparsing diff --git a/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1046-python3-catkin-pkg-modules b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1047-python3-catkin-pkg-modules similarity index 100% rename from jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1046-python3-catkin-pkg-modules rename to jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1047-python3-catkin-pkg-modules diff --git a/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1047-python3-rospkg-modules b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1048-python3-rospkg-modules similarity index 100% rename from jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1047-python3-rospkg-modules rename to jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1048-python3-rospkg-modules diff --git a/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1049-cython b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1049-cython new file mode 100755 index 0000000000..fd38c9c307 --- /dev/null +++ b/jsk_unitree_robot/cross/ros1_dependencies_build_scripts/1049-cython @@ -0,0 +1,46 @@ +#!/bin/bash +set -xeu -o pipefail + +DEBIAN_DIR=/home/user/ros1_dependencies_sources/src/cython/debian/debian +SOURCE_DIR=/home/user/ros1_dependencies_sources/src/cython/Cython-0.26.1 + +cd ${DEBIAN_DIR}/patches +for patch_file in $(grep -v ^# series); do + OUT="$(patch -p1 --forward --directory ${SOURCE_DIR} < ${patch_file} | tee /dev/tty)" || echo "${OUT}" | grep "Skipping patch" -q || (echo "$OUT" && false) || echo "OK" +done + +cd ${SOURCE_DIR} + +# mkdir -p /opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python2.7/site-packages/ +# PYTHONPATH="/opt/jsk/${INSTALL_ROOT}/ros1_dependencies/lib/python2.7/site-packages" \ +# python2 \ +# setup.py install \ +# --force --root=/opt/jsk/${INSTALL_ROOT}/ros1_dependencies \ +# --no-compile -O0 --single-version-externally-managed --prefix=./ + +# fix shebang +#sed -i -e '1 s,#!.*python.*,#!/usr/bin/python,' /opt/jsk/${INSTALL_ROOT}/ros1_dependencies/bin/cython +#sed -i -e '1 s,#!.*python.*,#!/usr/bin/python,' /opt/jsk/${INSTALL_ROOT}/ros1_dependencies/bin/cygdb +#sed -i -e '1 s,#!.*python.*,#!/usr/bin/python,' /opt/jsk/${INSTALL_ROOT}/ros1_dependencies/bin/cythonize + +### +### catkin_virtualenv failed with PyYAML, +### We still do not find the root couse but it fails with source install +### add following code in docker/Dockerfile_ros1, but it is exceptional. +### RUN (cd /tmp; apt download cython && dpkg --force-depends -i cython_*.deb) +### Dockerfile_ros1 is designed to reproduce dog's internal PC and we install cython just to pass build_ros1.sh + + # [ 20%] Lock input requirements if they don't exist [ 40%] Install requirements to /home/user/arm64v8_ws_system/build_isolated/test_catkin_virtualenv_python2/venv ERROR: Command errored out with exit status 1: command: /home/user/arm64v8_ws_system/build_isolated/test_catkin_virtualenv_python2/venv/bin/python /home/user/arm64v8_ws_system/build_isolated/test_catkin_virtualenv_python2/venv/local/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmplXEZlo cwd: /tmp/pip-install-YKwwFS/pyyaml + # Complete output (46 lines): running egg_info creating lib/PyYAML.egg-info + # writing lib/PyYAML.egg-info/PKG-INFO + # writing top-level names to lib/PyYAML.egg-info/top_level.txt + # writing dependency_links to lib/PyYAML.egg-info/dependency_links.txt + # writing manifest file 'lib/PyYAML.egg-info/SOURCES.txt' + # Traceback (most recent call last): File "/home/user/arm64v8_ws_system/build_isolated/test_catkin_virtualenv_python2/venv/local/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in main() + # File "/home/user/arm64v8_ws_system/build_isolated/test_catkin_virtualenv_python2/venv/local/lib/python2.7/site-packages/setuptools/command/py36compat.py", line 120, in _add_defaults_ext + # self.filelist.extend(build_ext.get_source_files()) File "setup.py", line 201, in get_source_files + # self.cython_sources(ext.sources, ext) + # File "/usr/lib/python2.7/distutils/cmd.py", line 105, in __getattr__ + # raise AttributeError, attr + # AttributeError: cython_sources + # ---------------------------------------- From 2554dc02453eddef1f29b509986a662a8fcd194b Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Sun, 15 Oct 2023 16:04:41 +0900 Subject: [PATCH 09/15] docker/entrypoint.sh: add sudo and passwrd --- jsk_unitree_robot/cross/docker/entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsk_unitree_robot/cross/docker/entrypoint.sh b/jsk_unitree_robot/cross/docker/entrypoint.sh index 3eb14445d9..52e76e91f8 100644 --- a/jsk_unitree_robot/cross/docker/entrypoint.sh +++ b/jsk_unitree_robot/cross/docker/entrypoint.sh @@ -15,7 +15,8 @@ groupadd -g $HOST_GID user # -m Create the user's home directory if it does not exist. # -g The group name or number of the user's initial login group. # -s The name of the user's login shell. -useradd -u $HOST_UID -o -m -g $HOST_GID -s /usr/bin user +useradd -u $HOST_UID -o -m -g $HOST_GID -s /usr/bin user -G sudo +echo user:user | chpasswd export HOME=/home/user chown $HOST_UID:$HOST_GID $HOME cd $HOME From a167146780884b53b143d6dcf277cd6470b6891d Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Sun, 15 Oct 2023 16:06:02 +0900 Subject: [PATCH 10/15] Revert "[jsk_unitree_startup/cross] Use sitecustomize.py instead of setting PYTHONPATH" This reverts commit cd1e3305b6ef7ce83207b83de619f2f5a6b71be8. --- jsk_unitree_robot/cross/build_ros1.sh | 3 -- jsk_unitree_robot/cross/build_user.sh | 4 +- jsk_unitree_robot/cross/install.sh | 6 --- jsk_unitree_robot/cross/run_user.sh | 2 - .../ros1_dependencies_setup.bash | 6 +-- .../cross/startup_scripts/sitecustomize.py | 39 ------------------- 6 files changed, 3 insertions(+), 57 deletions(-) delete mode 100644 jsk_unitree_robot/cross/startup_scripts/sitecustomize.py diff --git a/jsk_unitree_robot/cross/build_ros1.sh b/jsk_unitree_robot/cross/build_ros1.sh index faad1b0822..7d1495cd19 100755 --- a/jsk_unitree_robot/cross/build_ros1.sh +++ b/jsk_unitree_robot/cross/build_ros1.sh @@ -56,8 +56,6 @@ docker run -it --rm \ -e MAKEFLAGS=${MAKEFLAGS} \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ - -v ${PWD}/startup_scripts/sitecustomize.py:/usr/lib/python2.7/sitecustomize.py:ro \ - -v ${PWD}/startup_scripts/sitecustomize.py:/usr/lib/python3.6/sitecustomize.py:ro \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:rw \ -v ${PWD}/${SOURCE_ROOT}:/home/user/${SOURCE_ROOT}:rw \ ${IMAGE_NAME}:${TARGET_MACHINE} \ @@ -77,4 +75,3 @@ docker run -it --rm \ " 2>&1 | tee ${TARGET_MACHINE}_build_ros1.log cp ${PWD}/startup_scripts/system_setup.bash ${HOST_INSTALL_ROOT}/ -cp ${PWD}/startup_scripts/sitecustomize.py ${HOST_INSTALL_ROOT}/ diff --git a/jsk_unitree_robot/cross/build_user.sh b/jsk_unitree_robot/cross/build_user.sh index 01cef3b22a..b692debab2 100755 --- a/jsk_unitree_robot/cross/build_user.sh +++ b/jsk_unitree_robot/cross/build_user.sh @@ -51,8 +51,6 @@ docker run -it --rm \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ -v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \ - -v ${HOST_INSTALL_ROOT}/sitecustomize.py:/usr/lib/python2.7/sitecustomize.py:ro \ - -v ${HOST_INSTALL_ROOT}/sitecustomize.py:/usr/lib/python3.6/sitecustomize.py:ro \ -v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \ -v ${PWD}/rosinstall_generator_unreleased.py:/home/user/rosinstall_generator_unreleased.py:ro \ ${IMAGE_NAME}:${TARGET_MACHINE} \ @@ -62,7 +60,7 @@ docker run -it --rm \ set -xeuf -o pipefail && \ cd /opt/jsk/User && \ [ ${UPDATE_SOURCE_ROOT} -eq 0 ] || ROS_PACKAGE_PATH=src:\${ROS_PACKAGE_PATH} /home/user/rosinstall_generator_unreleased.py jsk_${TARGET_ROBOT}_startup ${TARGET_ROBOT}eus --rosdistro melodic --exclude RPP --exclude mongodb_store | tee user.repos && \ - [ ${UPDATE_SOURCE_ROOT} -eq 0 -o -z \"\$(cat user.repos)\" ] || vcs import src < user.repos && \ + [ ${UPDATE_SOURCE_ROOT} -eq 0 -o -z \"\$(cat user.repos)\" ] || PYTHONPATH= vcs import src < user.repos && \ catkin build jsk_${TARGET_ROBOT}_startup ${TARGET_ROBOT}eus -s -vi \ --cmake-args -DCATKIN_ENABLE_TESTING=FALSE \ " 2>&1 | tee ${TARGET_MACHINE}_build_user.log diff --git a/jsk_unitree_robot/cross/install.sh b/jsk_unitree_robot/cross/install.sh index 1891383734..d13eba8102 100755 --- a/jsk_unitree_robot/cross/install.sh +++ b/jsk_unitree_robot/cross/install.sh @@ -66,12 +66,6 @@ function copy_data () { ssh-keygen -f "${HOME}/.ssh/known_hosts" -R "${hostname}" || echo "OK" sshpass -p $PASS ssh -o StrictHostKeyChecking=no ${user}@${hostname} exit - if [[ "${TARGET_DIRECTORY}" == "System" ]]; then - sshpass -p 123 scp ${TARGET_MACHINE}_${TARGET_DIRECTORY}/sitecustomize.py ${user}@${hostname}:/tmp/sitecustomize.py - sshpass -p $PASS ssh -t ${user}@${hostname} "echo $PASS | sudo -S cp -f /tmp/sitecustomize.py /usr/lib/python2.7/sitecustomize.py" - sshpass -p $PASS ssh -t ${user}@${hostname} "echo $PASS | sudo -S cp -f /tmp/sitecustomize.py /usr/lib/python3/sitecustomize.py" - fi - # cehck disk space echo "Copy ${TARGET_MACHINE}_${TARGET_DIRECTORY} ...." echo "===" diff --git a/jsk_unitree_robot/cross/run_user.sh b/jsk_unitree_robot/cross/run_user.sh index 593e85702d..2b6acbc48e 100755 --- a/jsk_unitree_robot/cross/run_user.sh +++ b/jsk_unitree_robot/cross/run_user.sh @@ -16,8 +16,6 @@ docker run -it --rm \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/Python:/opt/jsk/${INSTALL_ROOT}/Python:ro \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:ro \ - -v ${PWD}/startup_scripts/sitecustomize.py:/usr/lib/python2.7/sitecustomize.py:ro \ - -v ${PWD}/startup_scripts/sitecustomize.py:/usr/lib/python3.6/sitecustomize.py:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ -v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \ -v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \ diff --git a/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash b/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash index 2ab07f4d83..bb83142ace 100755 --- a/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash +++ b/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash @@ -5,16 +5,14 @@ export CMAKE_PREFIX_PATH="/opt/jsk/System/ros1_dependencies:${CMAKE_PREFIX_PATH}" export PKG_CONFIG_PATH="/opt/jsk/System/ros1_dependencies/lib/pkgconfig:${PKG_CONFIG_PATH}" export LD_LIBRARY_PATH="/opt/jsk/System/ros1_dependencies/lib:${LD_LIBRARY_PATH}" -# Python's sys.path is automatically set in /usr/lib/python2.7/sitecustomize.py -# export PYTHONPATH="/opt/jsk/System/ros1_dependencies/lib/python2.7/site-packages:${PYTHONPATH}" +export PYTHONPATH="/opt/jsk/System/ros1_dependencies/lib/python2.7/site-packages:${PYTHONPATH}" # GI : for gir1.2-gstreamer-1.0, which is installed by ros1_dependencies_build_scripts/0006-gstreamer export GI_TYPELIB_PATH="/opt/jsk/System/ros1_dependencies/lib/girepository-1.0" # Python export LD_LIBRARY_PATH="/opt/jsk/System/Python/lib:${LD_LIBRARY_PATH}" -# Python's sys.path is automatically set in /usr/lib/python2.7/sitecustomize.py -# export PYTHONPATH="/opt/jsk/System/Python/lib/python2.7/site-packages:${PYTHONPATH}" +export PYTHONPATH="/opt/jsk/System/Python/lib/python2.7/site-packages:${PYTHONPATH}" export PATH="/opt/jsk/System/Python/bin:${PATH}" diff --git a/jsk_unitree_robot/cross/startup_scripts/sitecustomize.py b/jsk_unitree_robot/cross/startup_scripts/sitecustomize.py deleted file mode 100644 index 6e0abdf861..0000000000 --- a/jsk_unitree_robot/cross/startup_scripts/sitecustomize.py +++ /dev/null @@ -1,39 +0,0 @@ -# install the apport exception handler if available -import site -import sys -import os -import os.path as osp - -site.PREFIXES += [ - '/opt/jsk/System/Python/', - '/opt/jsk/System/ros1_dependencies/', - '/opt/jsk/System/ros1_inst/', -] - - -def recursively_listup_paths(path): - paths = [] - for sub_path in os.listdir(path): - sub_full_path = osp.join(path, sub_path) - if osp.isdir(sub_full_path) and (sub_path.endswith('.egg-info') or sub_path.endswith('.egg')): - paths.append(sub_full_path) - return paths - - -paths = [] -for path in site.getsitepackages(): - if osp.exists(path): - paths.append(path) - paths.extend(recursively_listup_paths(path)) - site_package = osp.join(osp.dirname(path), 'site-packages') - if site_package != path and osp.exists(site_package): - paths.append(site_package) - paths.extend(recursively_listup_paths(site_package)) - -sys.path.extend(paths) -try: - import apport_python_hook -except ImportError: - pass -else: - apport_python_hook.install() From c0e17b005b1d0e41a96f45014519efc01a569cca Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Sun, 15 Oct 2023 16:34:15 +0900 Subject: [PATCH 11/15] use usercustomize.py in .local/lib/python*/site-packages to set custom sys.path for both python2 and python3 --- jsk_unitree_robot/cross/build_ros1.sh | 7 ++++++- jsk_unitree_robot/cross/build_user.sh | 2 ++ jsk_unitree_robot/cross/install.sh | 6 ++++++ jsk_unitree_robot/cross/run_user.sh | 2 ++ .../cross/startup_scripts/ros1_dependencies_setup.bash | 7 +++++-- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/jsk_unitree_robot/cross/build_ros1.sh b/jsk_unitree_robot/cross/build_ros1.sh index 7d1495cd19..c9ed426547 100755 --- a/jsk_unitree_robot/cross/build_ros1.sh +++ b/jsk_unitree_robot/cross/build_ros1.sh @@ -56,6 +56,8 @@ docker run -it --rm \ -e MAKEFLAGS=${MAKEFLAGS} \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ + -v ${PWD}/startup_scripts/usercustomize.py:/home/user/.local/lib/python2.7/site-packages/usercustomize.py:ro \ + -v ${PWD}/startup_scripts/usercustomize.py:/home/user/.local/lib/python3.6/site-packages/usercustomize.py:ro \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:rw \ -v ${PWD}/${SOURCE_ROOT}:/home/user/${SOURCE_ROOT}:rw \ ${IMAGE_NAME}:${TARGET_MACHINE} \ @@ -74,4 +76,7 @@ docker run -it --rm \ -DEUSLISP_WITHOUT_DISPLAY=TRUE -DDISABLE_DOCUMENTATION=1 \ " 2>&1 | tee ${TARGET_MACHINE}_build_ros1.log -cp ${PWD}/startup_scripts/system_setup.bash ${HOST_INSTALL_ROOT}/ +for file in system_setup.bash usercustomize.py; do + [ -d ${HOST_INSTALL_ROOT}/$file ] && rmdir ${HOST_INSTALL_ROOT}/$file + cp ${PWD}/startup_scripts/$file ${HOST_INSTALL_ROOT}/ +done diff --git a/jsk_unitree_robot/cross/build_user.sh b/jsk_unitree_robot/cross/build_user.sh index b692debab2..2dcd963351 100755 --- a/jsk_unitree_robot/cross/build_user.sh +++ b/jsk_unitree_robot/cross/build_user.sh @@ -51,6 +51,8 @@ docker run -it --rm \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ -v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \ + -v ${PWD}/startup_scripts/usercustomize.py:/home/user/.local/lib/python2.7/site-packages/usercustomize.py:ro \ + -v ${PWD}/startup_scripts/usercustomize.py:/home/user/.local/lib/python3.6/site-packages/usercustomize.py:ro \ -v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \ -v ${PWD}/rosinstall_generator_unreleased.py:/home/user/rosinstall_generator_unreleased.py:ro \ ${IMAGE_NAME}:${TARGET_MACHINE} \ diff --git a/jsk_unitree_robot/cross/install.sh b/jsk_unitree_robot/cross/install.sh index d13eba8102..03d3d64a28 100755 --- a/jsk_unitree_robot/cross/install.sh +++ b/jsk_unitree_robot/cross/install.sh @@ -66,6 +66,12 @@ function copy_data () { ssh-keygen -f "${HOME}/.ssh/known_hosts" -R "${hostname}" || echo "OK" sshpass -p $PASS ssh -o StrictHostKeyChecking=no ${user}@${hostname} exit + if [[ "${TARGET_DIRECTORY}" == "System" ]]; then + sshpass -p 123 scp ${TARGET_MACHINE}_${TARGET_DIRECTORY}/usercustomize.py ${user}@${hostname}:/tmp/usercustomize.py + sshpass -p $PASS ssh -t ${user}@${hostname} "mkdir -p ~/.local/lib/python2.7/site-packages/; cp -f /tmp/usercustomize.py .local/lib/python2.7/site-packages/" + sshpass -p $PASS ssh -t ${user}@${hostname} "mkdir -p ~/.local/lib/python3.6/site-packages/; cp -f /tmp/usercustomize.py .local/lib/python3.6/site-packages/" + fi + # cehck disk space echo "Copy ${TARGET_MACHINE}_${TARGET_DIRECTORY} ...." echo "===" diff --git a/jsk_unitree_robot/cross/run_user.sh b/jsk_unitree_robot/cross/run_user.sh index 2b6acbc48e..e53cb068e0 100755 --- a/jsk_unitree_robot/cross/run_user.sh +++ b/jsk_unitree_robot/cross/run_user.sh @@ -18,6 +18,8 @@ docker run -it --rm \ -v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:ro \ -v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ -v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \ + -v ${HOST_INSTALL_ROOT}/usercustomize.py:/home/user/.local/lib/python2.7/site-packages/usercustomize.py:ro \ + -v ${HOST_INSTALL_ROOT}/usercustomize.py:/home/user/.local/lib/python3.6/site-packages/usercustomize.py:ro \ -v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \ ${IMAGE_NAME}:${TARGET_MACHINE} \ bash -c "echo 'source /opt/jsk/User/user_setup.bash; env; cd /opt/jsk/User' > ~/.bashrc; exec \"\$0\"" diff --git a/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash b/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash index bb83142ace..c03e083861 100755 --- a/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash +++ b/jsk_unitree_robot/cross/startup_scripts/ros1_dependencies_setup.bash @@ -5,14 +5,17 @@ export CMAKE_PREFIX_PATH="/opt/jsk/System/ros1_dependencies:${CMAKE_PREFIX_PATH}" export PKG_CONFIG_PATH="/opt/jsk/System/ros1_dependencies/lib/pkgconfig:${PKG_CONFIG_PATH}" export LD_LIBRARY_PATH="/opt/jsk/System/ros1_dependencies/lib:${LD_LIBRARY_PATH}" -export PYTHONPATH="/opt/jsk/System/ros1_dependencies/lib/python2.7/site-packages:${PYTHONPATH}" +export PATH="/opt/jsk/System/ros1_dependencies/bin:${PATH}" +# Python's sys.path is automatically set in ~/.local/lib/python2.7/usercustomize.py +# export PYTHONPATH="/opt/jsk/System/ros1_dependencies/lib/python2.7/site-packages:${PYTHONPATH}" # GI : for gir1.2-gstreamer-1.0, which is installed by ros1_dependencies_build_scripts/0006-gstreamer export GI_TYPELIB_PATH="/opt/jsk/System/ros1_dependencies/lib/girepository-1.0" # Python export LD_LIBRARY_PATH="/opt/jsk/System/Python/lib:${LD_LIBRARY_PATH}" -export PYTHONPATH="/opt/jsk/System/Python/lib/python2.7/site-packages:${PYTHONPATH}" +# Python's sys.path is automatically set in ~/.local/lib/python2.7/usercustomize.py +# export PYTHONPATH="/opt/jsk/System/Python/lib/python2.7/site-packages:${PYTHONPATH}" export PATH="/opt/jsk/System/Python/bin:${PATH}" From 518dd0dd953f30754123d8e49ecefd864dc702e1 Mon Sep 17 00:00:00 2001 From: iory Date: Thu, 4 Aug 2022 00:04:03 +0900 Subject: [PATCH 12/15] [jsk_unitree_startup/cross] Add compress command --- jsk_unitree_robot/cross/Makefile | 3 +++ jsk_unitree_robot/cross/compress.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 jsk_unitree_robot/cross/compress.sh diff --git a/jsk_unitree_robot/cross/Makefile b/jsk_unitree_robot/cross/Makefile index e942246cf6..7a05f06953 100644 --- a/jsk_unitree_robot/cross/Makefile +++ b/jsk_unitree_robot/cross/Makefile @@ -20,6 +20,9 @@ user: install: ./install.sh +compress: + ./compress.sh + clean: rm -fr ${TARGET_MACHINE}_ws_* diff --git a/jsk_unitree_robot/cross/compress.sh b/jsk_unitree_robot/cross/compress.sh new file mode 100755 index 0000000000..e506ab71d8 --- /dev/null +++ b/jsk_unitree_robot/cross/compress.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +if [ -e "arm64v8_User" ]; then + if [ -e "arm64v8_User.tgz" ]; then + echo "WARNING: Compressed arm64v8_User.tgz is found." + read -p "WARNING: Are you sure to continue [y/N] ? " -n 1 -r + echo # (optional) move to a new line + if [[ $REPLY =~ ^[Yy]$ ]]; then + tar -zcvf arm64v8_User.tgz arm64v8_User + fi + else + tar -zcvf arm64v8_User.tgz arm64v8_User + fi +fi + +if [ -e "arm64v8_System" ]; then + if [ -e "arm64v8_System.tgz" ]; then + echo "WARNING: Compressed arm64v8_System.tgz is found." + read -p "WARNING: Are you sure to continue [y/N] ? " -n 1 -r + echo # (optional) move to a new line + if [[ $REPLY =~ ^[Yy]$ ]]; then + chmod 644 arm64v8_System/ros1_inst/share/pr2eus/*.l + tar -zcvf arm64v8_System.tgz arm64v8_System + fi + else + chmod 644 arm64v8_System/ros1_inst/share/pr2eus/*.l + tar -zcvf arm64v8_System.tgz arm64v8_System + fi +fi From 8254bd327f8c99dcdb77520993615b32c8c0c180 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Tue, 17 Oct 2023 17:38:37 +0900 Subject: [PATCH 13/15] install.sh: we need to add /sbin to PATH to use ifconfig --- jsk_unitree_robot/cross/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsk_unitree_robot/cross/install.sh b/jsk_unitree_robot/cross/install.sh index 03d3d64a28..a1f852dc03 100755 --- a/jsk_unitree_robot/cross/install.sh +++ b/jsk_unitree_robot/cross/install.sh @@ -123,7 +123,7 @@ function copy_data () { # enable Internet with USB LTE module if [[ "${hostname}" == "192.168.123.161" ]]; then - sshpass -p $PASS ssh -t ${user}@${hostname} "source /opt/jsk/User/user_setup.bash; sudo cp -f \$(rospack find jsk_unitree_startup)/config/dhcpcd.conf /etc/dhcpcd.conf" + sshpass -p $PASS ssh -t ${user}@${hostname} "export PATH=\$PATH:/sbin; source /opt/jsk/User/user_setup.bash; sudo cp -f \$(rospack find jsk_unitree_startup)/config/dhcpcd.conf /etc/dhcpcd.conf" sshpass -p $PASS ssh -t ${user}@${hostname} "sudo systemctl restart dhcpcd" fi set +x From 56ed83f16adfb2d43aebf17a49ae17cd816bee61 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Thu, 19 Oct 2023 11:04:05 +0900 Subject: [PATCH 14/15] pass before sudo --- jsk_unitree_robot/cross/install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jsk_unitree_robot/cross/install.sh b/jsk_unitree_robot/cross/install.sh index a1f852dc03..4ef698f5af 100755 --- a/jsk_unitree_robot/cross/install.sh +++ b/jsk_unitree_robot/cross/install.sh @@ -116,15 +116,15 @@ function copy_data () { # update udev # respeaker_ros - sshpass -p $PASS ssh -t ${user}@${hostname} "source /opt/jsk/User/user_setup.bash; sudo cp -f \$(rospack find respeaker_ros)/config/60-respeaker.rules /etc/udev/rules.d/60-respeaker.rules" + sshpass -p $PASS ssh -t ${user}@${hostname} "source /opt/jsk/User/user_setup.bash; echo $PASS | sudo cp -f \$(rospack find respeaker_ros)/config/60-respeaker.rules /etc/udev/rules.d/60-respeaker.rules" # - sshpass -p $PASS ssh -t ${user}@${hostname} "ls -al /etc/udev/rules.d/; sudo systemctl restart udev" + sshpass -p $PASS ssh -t ${user}@${hostname} "ls -al /etc/udev/rules.d/; echo $PASS | sudo systemctl restart udev" fi # enable Internet with USB LTE module if [[ "${hostname}" == "192.168.123.161" ]]; then - sshpass -p $PASS ssh -t ${user}@${hostname} "export PATH=\$PATH:/sbin; source /opt/jsk/User/user_setup.bash; sudo cp -f \$(rospack find jsk_unitree_startup)/config/dhcpcd.conf /etc/dhcpcd.conf" - sshpass -p $PASS ssh -t ${user}@${hostname} "sudo systemctl restart dhcpcd" + sshpass -p $PASS ssh -t ${user}@${hostname} "export PATH=\$PATH:/sbin; source /opt/jsk/User/user_setup.bash; echo $PASS | sudo cp -f \$(rospack find jsk_unitree_startup)/config/dhcpcd.conf /etc/dhcpcd.conf" + sshpass -p $PASS ssh -t ${user}@${hostname} "echo $PASS | sudo systemctl restart dhcpcd" fi set +x } From 3064dcaccd2898c802f28d1d8041a234e40f1a15 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Sat, 21 Oct 2023 11:59:10 +0900 Subject: [PATCH 15/15] add usercutomize.py --- .../cross/startup_scripts/usercustomize.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 jsk_unitree_robot/cross/startup_scripts/usercustomize.py diff --git a/jsk_unitree_robot/cross/startup_scripts/usercustomize.py b/jsk_unitree_robot/cross/startup_scripts/usercustomize.py new file mode 100644 index 0000000000..b292e21a43 --- /dev/null +++ b/jsk_unitree_robot/cross/startup_scripts/usercustomize.py @@ -0,0 +1,42 @@ +import site +import sys +import os +import os.path as osp + +site.PREFIXES += [ + '/opt/jsk/System/Python/', + '/opt/jsk/System/ros1_dependencies/' +] + +# https://www.programcreek.com/python/?code=Pylons%2Fhupper%2Fhupper-master%2Fsrc%2Fhupper%2Fcompat.py +def get_site_packages(): + try: + paths = [] + for path in site.getsitepackages(): + if osp.exists(path): + paths.append(path) + site_package = osp.join(osp.dirname(path), 'site-packages') + if site_package != path and osp.exists(site_package): + paths.append(site_package) + + return paths + + # virtualenv does not ship with a getsitepackages impl so we fallback + # to using distutils if we can + # https://github.com/pypa/virtualenv/issues/355 + except Exception: + try: + paths = [] + for base_path in site.PREFIXES: + for python_path in ['lib/python{}'.format(sys.version_info[0]), + 'lib/python{}.{}'.format(sys.version_info[0], sys.version_info[1])]: + site_package = osp.join(base_path, python_path, 'site-packages') + if osp.exists(site_package): + paths.append(site_package) + return paths + + # just incase, don't fail here, it's not worth it + except Exception as e: + return [] + +sys.path.extend(get_site_packages())