From 519a0f103f732b34a2d51329da40d386e6273465 Mon Sep 17 00:00:00 2001 From: iory Date: Wed, 3 Aug 2022 19:51:02 +0900 Subject: [PATCH] [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 c5ee076c54..b95e48029b 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 3 --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 14c084d737..fa77182b0f 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 \