Skip to content

Commit

Permalink
[jsk_unitree_startup/cross] Add OPTIONS to passthrough user id for ma…
Browse files Browse the repository at this point in the history
…c compatibility
  • Loading branch information
iory authored and k-okada committed Oct 9, 2023
1 parent 5b17723 commit da4409a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
15 changes: 13 additions & 2 deletions jsk_unitree_robot/cross/build_ros1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 \
Expand Down
12 changes: 10 additions & 2 deletions jsk_unitree_robot/cross/build_ros1_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
11 changes: 10 additions & 1 deletion jsk_unitree_robot/cross/build_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
11 changes: 10 additions & 1 deletion jsk_unitree_robot/cross/run_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit da4409a

Please sign in to comment.