Major build scripts cleanup

Including removing echo_stamp, which is not needed
This commit is contained in:
Oleg Kalachev
2024-04-18 06:49:46 +03:00
parent 936efa985d
commit 1b191d9cf0
9 changed files with 75 additions and 240 deletions

View File

@@ -15,52 +15,32 @@
set -e # Exit immidiately on non-zero result set -e # Exit immidiately on non-zero result
echo_stamp() {
# TEMPLATE: echo_stamp <TEXT> <TYPE>
# TYPE: SUCCESS, ERROR, INFO
# More info there https://www.shellhacks.com/ru/bash-colors/
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
TEXT="\e[1m$TEXT\e[0m" # BOLD
case "$2" in
SUCCESS)
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
ERROR)
TEXT="\e[31m${TEXT}\e[0m";; # RED
*)
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
esac
echo -e ${TEXT}
}
################################################## ##################################################
# Configure hardware interfaces # Configure hardware interfaces
################################################## ##################################################
# 1. Enable sshd # 1. Enable sshd
echo_stamp "#1 Turn on sshd" echo "--- Enable sshd"
touch /boot/ssh touch /boot/ssh
# /usr/bin/raspi-config nonint do_ssh 0 # /usr/bin/raspi-config nonint do_ssh 0
# 2. Enable GPIO # 2. Enable GPIO
echo_stamp "#2 GPIO enabled by default" echo "--- GPIO enabled by default"
# 3. Enable I2C # 3. Enable I2C
echo_stamp "#3 Turn on I2C" echo "--- Enable I2C"
/usr/bin/raspi-config nonint do_i2c 0 /usr/bin/raspi-config nonint do_i2c 0
# 4. Enable SPI # 4. Enable SPI
echo_stamp "#4 Turn on SPI" echo "--- Enable SPI"
/usr/bin/raspi-config nonint do_spi 0 /usr/bin/raspi-config nonint do_spi 0
# 5. Enable raspicam # 5. Enable raspicam
echo_stamp "#5 Turn on raspicam" echo "--- Enable raspicam"
/usr/bin/raspi-config nonint do_camera 0 /usr/bin/raspi-config nonint do_camera 0
# 6. Enable hardware UART # 6. Enable hardware UART
echo_stamp "#6 Turn on UART" echo "--- Enable UART"
# Temporary solution # Temporary solution
# https://github.com/RPi-Distro/raspi-config/pull/75 # https://github.com/RPi-Distro/raspi-config/pull/75
/usr/bin/raspi-config nonint do_serial 1 /usr/bin/raspi-config nonint do_serial 1
@@ -74,9 +54,7 @@ systemctl disable hciuart.service
# 7. Enable V4L driver http://robocraft.ru/blog/electronics/3158.html # 7. Enable V4L driver http://robocraft.ru/blog/electronics/3158.html
#echo "bcm2835-v4l2" >> /etc/modules #echo "bcm2835-v4l2" >> /etc/modules
echo_stamp "#7 Turn on v4l2 driver" echo "--- Enable v4l2 driver"
if ! grep -q "^bcm2835-v4l2" /etc/modules; if ! grep -q "^bcm2835-v4l2" /etc/modules;
then printf "bcm2835-v4l2\n" >> /etc/modules then printf "bcm2835-v4l2\n" >> /etc/modules
fi fi
echo_stamp "#8 End of configure hardware interfaces"

View File

@@ -15,28 +15,8 @@
set -e # Exit immidiately on non-zero result set -e # Exit immidiately on non-zero result
echo_stamp() {
# TEMPLATE: echo_stamp <TEXT> <TYPE>
# TYPE: SUCCESS, ERROR, INFO
# More info there https://www.shellhacks.com/ru/bash-colors/
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
TEXT="\e[1m$TEXT\e[0m" # BOLD
case "$2" in
SUCCESS)
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
ERROR)
TEXT="\e[31m${TEXT}\e[0m";; # RED
*)
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
esac
echo -e ${TEXT}
}
NEW_SSID='clover-'$(head -c 100 /dev/urandom | xxd -ps -c 100 | sed -e "s/[^0-9]//g" | cut -c 1-4) NEW_SSID='clover-'$(head -c 100 /dev/urandom | xxd -ps -c 100 | sed -e "s/[^0-9]//g" | cut -c 1-4)
echo_stamp "Setting SSID to ${NEW_SSID}" echo "--- Setting SSID to ${NEW_SSID}"
# TODO: Use wpa_cli insted direct file edit # TODO: Use wpa_cli insted direct file edit
# FIXME: We rely on raspberrypi-net-mods to copy our file to /etc/wpa_supplicant. # FIXME: We rely on raspberrypi-net-mods to copy our file to /etc/wpa_supplicant.
# This is not very reliable, but seems to fix our rfkill problem. # This is not very reliable, but seems to fix our rfkill problem.
@@ -57,19 +37,17 @@ network={
EOF EOF
NEW_HOSTNAME=$(echo ${NEW_SSID} | tr '[:upper:]' '[:lower:]') NEW_HOSTNAME=$(echo ${NEW_SSID} | tr '[:upper:]' '[:lower:]')
echo_stamp "Setting hostname to $NEW_HOSTNAME" echo "--- Setting hostname to $NEW_HOSTNAME"
hostnamectl set-hostname $NEW_HOSTNAME hostnamectl set-hostname $NEW_HOSTNAME
sed -i 's/127\.0\.1\.1.*/127.0.1.1\t'${NEW_HOSTNAME}' '${NEW_HOSTNAME}'.local/g' /etc/hosts sed -i 's/127\.0\.1\.1.*/127.0.1.1\t'${NEW_HOSTNAME}' '${NEW_HOSTNAME}'.local/g' /etc/hosts
# .local (mdns) hostname added to make it accesable when wlan and ethernet interfaces are down # .local (mdns) hostname added to make it accesable when wlan and ethernet interfaces are down
echo_stamp "Enable ROS services" echo "--- Enable ROS services"
systemctl enable roscore systemctl enable roscore
systemctl enable clover systemctl enable clover
echo_stamp "Harware setup" echo "--- Harware setup"
/root/hardware_setup.sh /root/hardware_setup.sh
echo_stamp "Remove init scripts" echo "--- Remove init scripts"
rm /root/init_rpi.sh /root/hardware_setup.sh rm /root/init_rpi.sh /root/hardware_setup.sh
echo_stamp "End of initialization of the image"

View File

@@ -13,7 +13,7 @@
# copies or substantial portions of the Software. # copies or substantial portions of the Software.
# #
set -e # Exit immidiately on non-zero result set -ex # exit on error, echo commands
# https://www.raspberrypi.org/software/operating-systems/#raspberry-pi-os-32-bit # https://www.raspberrypi.org/software/operating-systems/#raspberry-pi-os-32-bit
SOURCE_IMAGE="https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-05-28/2021-05-07-raspios-buster-armhf-lite.zip" SOURCE_IMAGE="https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-05-28/2021-05-07-raspios-buster-armhf-lite.zip"
@@ -22,33 +22,13 @@ export DEBIAN_FRONTEND=${DEBIAN_FRONTEND:='noninteractive'}
export LANG=${LANG:='C.UTF-8'} export LANG=${LANG:='C.UTF-8'}
export LC_ALL=${LC_ALL:='C.UTF-8'} export LC_ALL=${LC_ALL:='C.UTF-8'}
echo_stamp() {
# TEMPLATE: echo_stamp <TEXT> <TYPE>
# TYPE: SUCCESS, ERROR, INFO
# More info there https://www.shellhacks.com/ru/bash-colors/
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
TEXT="\e[1m$TEXT\e[0m" # BOLD
case "$2" in
SUCCESS)
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
ERROR)
TEXT="\e[31m${TEXT}\e[0m";; # RED
*)
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
esac
echo -e ${TEXT}
}
BUILDER_DIR="/builder" BUILDER_DIR="/builder"
REPO_DIR="${BUILDER_DIR}/repo" REPO_DIR="${BUILDER_DIR}/repo"
SCRIPTS_DIR="${REPO_DIR}/builder" SCRIPTS_DIR="${REPO_DIR}/builder"
IMAGES_DIR="${REPO_DIR}/images" IMAGES_DIR="${REPO_DIR}/images"
[[ ! -d ${SCRIPTS_DIR} ]] && (echo_stamp "Directory ${SCRIPTS_DIR} doesn't exist" "ERROR"; exit 1) [[ ! -d ${SCRIPTS_DIR} ]] && (echo "Error: directory ${SCRIPTS_DIR} doesn't exist"; exit 1)
[[ ! -d ${IMAGES_DIR} ]] && mkdir ${IMAGES_DIR} && echo_stamp "Directory ${IMAGES_DIR} was created successful" "SUCCESS" [[ ! -d ${IMAGES_DIR} ]] && mkdir ${IMAGES_DIR} && echo "Directory ${IMAGES_DIR} was created successful"
if [[ -z ${TRAVIS_TAG} ]]; then IMAGE_VERSION="$(cd ${REPO_DIR}; git log --format=%h -1)"; else IMAGE_VERSION="${TRAVIS_TAG}"; fi if [[ -z ${TRAVIS_TAG} ]]; then IMAGE_VERSION="$(cd ${REPO_DIR}; git log --format=%h -1)"; else IMAGE_VERSION="${TRAVIS_TAG}"; fi
# IMAGE_VERSION="${TRAVIS_TAG:=$(cd ${REPO_DIR}; git log --format=%h -1)}" # IMAGE_VERSION="${TRAVIS_TAG:=$(cd ${REPO_DIR}; git log --format=%h -1)}"
@@ -64,15 +44,15 @@ get_image() {
local RPI_IMAGE_NAME=$(echo ${RPI_ZIP_NAME} | sed 's/zip/img/') local RPI_IMAGE_NAME=$(echo ${RPI_ZIP_NAME} | sed 's/zip/img/')
if [ ! -e "${BUILD_DIR}/${RPI_ZIP_NAME}" ]; then if [ ! -e "${BUILD_DIR}/${RPI_ZIP_NAME}" ]; then
echo_stamp "Downloading original Linux distribution" echo "--- Downloading original Linux distribution"
wget --progress=dot:giga -O ${BUILD_DIR}/${RPI_ZIP_NAME} $2 wget --progress=dot:giga -O ${BUILD_DIR}/${RPI_ZIP_NAME} $2
echo_stamp "Downloading complete" "SUCCESS" \ echo "--- Downloading complete" "SUCCESS"
else echo_stamp "Linux distribution already donwloaded"; fi else
echo "Linux distribution already downloaded"
fi
echo_stamp "Unzipping Linux distribution image" \ echo "--- Unzipping Linux distribution image"
&& unzip -p ${BUILD_DIR}/${RPI_ZIP_NAME} ${RPI_IMAGE_NAME} > $1 \ unzip -p ${BUILD_DIR}/${RPI_ZIP_NAME} ${RPI_IMAGE_NAME} > $1
&& echo_stamp "Unzipping complete" "SUCCESS" \
|| (echo_stamp "Unzipping was failed!" "ERROR"; exit 1)
} }
get_image ${IMAGE_PATH} ${SOURCE_IMAGE} get_image ${IMAGE_PATH} ${SOURCE_IMAGE}

View File

@@ -12,50 +12,29 @@
# copies or substantial portions of the Software. # copies or substantial portions of the Software.
# #
set -e # Exit immidiately on non-zero result set -ex # exit on error, echo commands
echo_stamp() {
# TEMPLATE: echo_stamp <TEXT> <TYPE>
# TYPE: SUCCESS, ERROR, INFO
# More info there https://www.shellhacks.com/ru/bash-colors/
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
TEXT="\e[1m$TEXT\e[0m" # BOLD
case "$2" in
SUCCESS)
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
ERROR)
TEXT="\e[31m${TEXT}\e[0m";; # RED
*)
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
esac
echo -e ${TEXT}
}
echo_stamp "Write Clover information"
echo "--- Write Clover information"
# Clover image version # Clover image version
echo "$1" >> /etc/clover_version echo "$1" >> /etc/clover_version
# Origin image file name # Origin image file name
echo "${2%.*}" >> /etc/clover_origin echo "${2%.*}" >> /etc/clover_origin
echo_stamp "Write magic script to /etc/rc.local" echo "--- Write magic script to /etc/rc.local"
MAGIC_SCRIPT="sudo /root/init_rpi.sh; sudo sed -i '/sudo \\\/root\\\/init_rpi.sh/d' /etc/rc.local && sudo reboot" MAGIC_SCRIPT="sudo /root/init_rpi.sh; sudo sed -i '/sudo \\\/root\\\/init_rpi.sh/d' /etc/rc.local && sudo reboot"
sed -i "19a${MAGIC_SCRIPT}" /etc/rc.local sed -i "19a${MAGIC_SCRIPT}" /etc/rc.local
# It needs for autosizer.sh & maybe that is correct # It needs for autosizer.sh & maybe that is correct
echo_stamp "Change boot partition" echo "--- Change boot partition"
sed -i 's/root=[^ ]*/root=\/dev\/mmcblk0p2/' /boot/cmdline.txt sed -i 's/root=[^ ]*/root=\/dev\/mmcblk0p2/' /boot/cmdline.txt
sed -i 's/.* \/boot vfat defaults 0 2$/\/dev\/mmcblk0p1 \/boot vfat defaults 0 2/' /etc/fstab sed -i 's/.* \/boot vfat defaults 0 2$/\/dev\/mmcblk0p1 \/boot vfat defaults 0 2/' /etc/fstab
sed -i 's/.* \/ ext4 defaults,noatime 0 1$/\/dev\/mmcblk0p2 \/ ext4 defaults,noatime 0 1/' /etc/fstab sed -i 's/.* \/ ext4 defaults,noatime 0 1$/\/dev\/mmcblk0p2 \/ ext4 defaults,noatime 0 1/' /etc/fstab
echo_stamp "Set max space for syslogs" echo "--- Set max space for syslogs"
# https://unix.stackexchange.com/questions/139513/how-to-clear-journalctl # https://unix.stackexchange.com/questions/139513/how-to-clear-journalctl
sed -i 's/#SystemMaxUse=/SystemMaxUse=200M/' /etc/systemd/journald.conf sed -i 's/#SystemMaxUse=/SystemMaxUse=200M/' /etc/systemd/journald.conf
echo_stamp "Move /etc/ld.so.preload out of the way" echo "--- Move /etc/ld.so.preload out of the way"
mv /etc/ld.so.preload /etc/ld.so.preload.disabled-for-build mv /etc/ld.so.preload /etc/ld.so.preload.disabled-for-build
echo_stamp "End of init image" echo "--- End of init image"

View File

@@ -12,43 +12,20 @@
# copies or substantial portions of the Software. # copies or substantial portions of the Software.
# #
set -e # Exit immidiately on non-zero result set -ex # exit on error, echo commands
echo_stamp() {
# TEMPLATE: echo_stamp <TEXT> <TYPE>
# TYPE: SUCCESS, ERROR, INFO
# More info there https://www.shellhacks.com/ru/bash-colors/
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
TEXT="\e[1m$TEXT\e[0m" # BOLD
case "$2" in
SUCCESS)
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
ERROR)
TEXT="\e[31m${TEXT}\e[0m";; # RED
*)
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
esac
echo -e ${TEXT}
}
echo_stamp "#1 Write STATIC to /etc/dhcpcd.conf"
echo "--- Write static to /etc/dhcpcd.conf"
cat << EOF >> /etc/dhcpcd.conf cat << EOF >> /etc/dhcpcd.conf
interface wlan0 interface wlan0
static ip_address=192.168.11.1/24 static ip_address=192.168.11.1/24
EOF EOF
echo_stamp "#2 Set wpa_supplicant country" echo "--- Set wpa_supplicant country"
cat << EOF >> /etc/wpa_supplicant/wpa_supplicant.conf cat << EOF >> /etc/wpa_supplicant/wpa_supplicant.conf
country=GB country=GB
EOF EOF
echo_stamp "#3 Write dhcp-config to /etc/dnsmasq.conf" echo "--- Write dhcp-config to /etc/dnsmasq.conf"
cat << EOF >> /etc/dnsmasq.conf cat << EOF >> /etc/dnsmasq.conf
interface=wlan0 interface=wlan0
address=/clover/coex/192.168.11.1 address=/clover/coex/192.168.11.1
@@ -59,5 +36,3 @@ bogus-priv
domain-needed domain-needed
quiet-dhcp6 quiet-dhcp6
EOF EOF
echo_stamp "#4 End of network installation"

View File

@@ -15,35 +15,9 @@
set -ex # exit on error, echo commands set -ex # exit on error, echo commands
REPO=$1
REF=$2
INSTALL_ROS_PACK_SOURCES=$3
DISCOVER_ROS_PACK=$4
NUMBER_THREADS=$5
# Current ROS distribution # Current ROS distribution
ROS_DISTRO=noetic ROS_DISTRO=noetic
echo_stamp() {
# TEMPLATE: echo_stamp <TEXT> <TYPE>
# TYPE: SUCCESS, ERROR, INFO
# More info there https://www.shellhacks.com/ru/bash-colors/
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
TEXT="\e[1m$TEXT\e[0m" # BOLD
case "$2" in
SUCCESS)
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
ERROR)
TEXT="\e[31m${TEXT}\e[0m";; # RED
*)
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
esac
echo -e ${TEXT}
}
# https://gist.github.com/letmaik/caa0f6cc4375cbfcc1ff26bd4530c2a3 # https://gist.github.com/letmaik/caa0f6cc4375cbfcc1ff26bd4530c2a3
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh # https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
my_travis_retry() { my_travis_retry() {
@@ -69,24 +43,24 @@ my_travis_retry() {
} }
# TODO: 'kinetic-rosdep-clover.yaml' should add only if we use our repo? # TODO: 'kinetic-rosdep-clover.yaml' should add only if we use our repo?
echo_stamp "Init rosdep" echo "--- Init rosdep"
my_travis_retry rosdep init my_travis_retry rosdep init
# FIXME: Re-add this after missing packages are built # FIXME: Re-add this after missing packages are built
echo "yaml file:///etc/ros/rosdep/${ROS_DISTRO}-rosdep-clover.yaml" >> /etc/ros/rosdep/sources.list.d/10-clover.list echo "yaml file:///etc/ros/rosdep/${ROS_DISTRO}-rosdep-clover.yaml" >> /etc/ros/rosdep/sources.list.d/10-clover.list
my_travis_retry rosdep update my_travis_retry rosdep update
echo_stamp "Populate rosdep for ROS user" echo "--- Populate rosdep for ROS user"
my_travis_retry sudo -u pi rosdep update my_travis_retry sudo -u pi rosdep update
export ROS_IP='127.0.0.1' # needed for running tests export ROS_IP='127.0.0.1' # needed for running tests
# echo_stamp "Reconfiguring Clover repository for simplier unshallowing" # echo "Reconfiguring Clover repository for simplier unshallowing"
cd /home/pi/catkin_ws/src/clover cd /home/pi/catkin_ws/src/clover
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
# This is sort of a hack to force "custom" packages to be installed - the ones built by COEX, linked against OpenCV 4.2 # This is sort of a hack to force "custom" packages to be installed - the ones built by COEX, linked against OpenCV 4.2
# I **wish** OpenCV would not be such a mess, but, well, here we are. # I **wish** OpenCV would not be such a mess, but, well, here we are.
echo_stamp "Installing OpenCV 4.2-compatible ROS packages" echo "--- Installing OpenCV 4.2-compatible ROS packages"
apt install -y --no-install-recommends \ apt install -y --no-install-recommends \
ros-${ROS_DISTRO}-compressed-image-transport=1.14.0-0buster \ ros-${ROS_DISTRO}-compressed-image-transport=1.14.0-0buster \
ros-${ROS_DISTRO}-cv-bridge=1.15.0-0buster \ ros-${ROS_DISTRO}-cv-bridge=1.15.0-0buster \
@@ -100,10 +74,10 @@ ros-${ROS_DISTRO}-cv-camera \
ros-${ROS_DISTRO}-image-publisher \ ros-${ROS_DISTRO}-image-publisher \
ros-${ROS_DISTRO}-web-video-server ros-${ROS_DISTRO}-web-video-server
echo_stamp "Installing libboost-dev" # https://travis-ci.org/github/CopterExpress/clover/jobs/766318908#L6536 echo "--- Installing libboost-dev" # https://travis-ci.org/github/CopterExpress/clover/jobs/766318908#L6536
my_travis_retry apt-get install -y --no-install-recommends libboost-dev libboost-all-dev my_travis_retry apt-get install -y --no-install-recommends libboost-dev libboost-all-dev
echo_stamp "Build and install Clover" echo "--- Build and install Clover"
cd /home/pi/catkin_ws cd /home/pi/catkin_ws
# Don't try to install gazebo_ros # Don't try to install gazebo_ros
my_travis_retry rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --os=debian:buster \ my_travis_retry rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --os=debian:buster \
@@ -115,12 +89,12 @@ source /opt/ros/${ROS_DISTRO}/setup.bash
catkin_make -j2 -DCMAKE_BUILD_TYPE=RelWithDebInfo catkin_make -j2 -DCMAKE_BUILD_TYPE=RelWithDebInfo
source devel/setup.bash source devel/setup.bash
echo_stamp "Install clever package (for backwards compatibility)" echo "--- Install clever package (for backwards compatibility)"
cd /home/pi/catkin_ws/src/clover/builder/assets/clever cd /home/pi/catkin_ws/src/clover/builder/assets/clever
./setup.py install ./setup.py install
rm -rf build # remove build artifacts rm -rf build # remove build artifacts
echo_stamp "Build Clover documentation" echo "--- Build Clover documentation"
cd /home/pi/catkin_ws/src/clover cd /home/pi/catkin_ws/src/clover
builder/assets/install_gitbook.sh builder/assets/install_gitbook.sh
gitbook install gitbook install
@@ -129,7 +103,7 @@ gitbook build
rm -rf _book/assets && ln -s ../docs/assets _book/assets rm -rf _book/assets && ln -s ../docs/assets _book/assets
touch node_modules/CATKIN_IGNORE docs/CATKIN_IGNORE _book/CATKIN_IGNORE clover/www/CATKIN_IGNORE apps/CATKIN_IGNORE # ignore documentation files by catkin touch node_modules/CATKIN_IGNORE docs/CATKIN_IGNORE _book/CATKIN_IGNORE clover/www/CATKIN_IGNORE apps/CATKIN_IGNORE # ignore documentation files by catkin
echo_stamp "Installing additional ROS packages" echo "--- Installing additional ROS packages"
my_travis_retry apt-get install -y --no-install-recommends \ my_travis_retry apt-get install -y --no-install-recommends \
ros-${ROS_DISTRO}-rosbridge-suite \ ros-${ROS_DISTRO}-rosbridge-suite \
ros-${ROS_DISTRO}-rosserial \ ros-${ROS_DISTRO}-rosserial \
@@ -143,35 +117,35 @@ my_travis_retry apt-get install -y --no-install-recommends \
ros-${ROS_DISTRO}-stereo-msgs ros-${ROS_DISTRO}-stereo-msgs
# TODO move GeographicLib datasets to Mavros debian package # TODO move GeographicLib datasets to Mavros debian package
echo_stamp "Install GeographicLib datasets (needed for mavros)" \ echo "--- Install GeographicLib datasets (needed for mavros)" \
&& wget -qO- https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh | bash && wget -qO- https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh | bash
echo_stamp "Running tests" echo "--- Running tests"
cd /home/pi/catkin_ws cd /home/pi/catkin_ws
# FIXME: Investigate failing tests # FIXME: Investigate failing tests
catkin_make run_tests #&& catkin_test_results catkin_make run_tests #&& catkin_test_results
echo_stamp "Change permissions for catkin_ws" echo "--- Change permissions for catkin_ws"
chown -Rf pi:pi /home/pi/catkin_ws chown -Rf pi:pi /home/pi/catkin_ws
echo_stamp "Update www" echo "--- Update www"
sudo -u pi sh -c ". devel/setup.sh && rosrun clover www" sudo -u pi sh -c ". devel/setup.sh && rosrun clover www"
echo_stamp "Make \$HOME/examples symlink" echo "--- Make \$HOME/examples symlink"
ln -s "$(catkin_find clover examples --first-only)" /home/pi ln -s "$(catkin_find clover examples --first-only)" /home/pi
chown -Rf pi:pi /home/pi/examples chown -Rf pi:pi /home/pi/examples
echo_stamp "Make systemd services symlinks" echo "--- Make systemd services symlinks"
ln -s /home/pi/catkin_ws/src/clover/builder/assets/clover.service /lib/systemd/system/ ln -s /home/pi/catkin_ws/src/clover/builder/assets/clover.service /lib/systemd/system/
ln -s /home/pi/catkin_ws/src/clover/builder/assets/roscore.service /lib/systemd/system/ ln -s /home/pi/catkin_ws/src/clover/builder/assets/roscore.service /lib/systemd/system/
# validate # validate
[ -f /lib/systemd/system/clover.service ] [ -f /lib/systemd/system/clover.service ]
[ -f /lib/systemd/system/roscore.service ] [ -f /lib/systemd/system/roscore.service ]
echo_stamp "Make udev rules symlink" echo "--- Make udev rules symlink"
ln -s "$(catkin_find clover udev --first-only)"/* /lib/udev/rules.d/ ln -s "$(catkin_find clover udev --first-only)"/* /lib/udev/rules.d/
echo_stamp "Setup ROS environment" echo "--- Setup ROS environment"
cat << EOF >> /home/pi/.bashrc cat << EOF >> /home/pi/.bashrc
LANG='C.UTF-8' LANG='C.UTF-8'
LC_ALL='C.UTF-8' LC_ALL='C.UTF-8'
@@ -180,12 +154,5 @@ source /opt/ros/${ROS_DISTRO}/setup.bash
source /home/pi/catkin_ws/devel/setup.bash source /home/pi/catkin_ws/devel/setup.bash
EOF EOF
#echo_stamp "Removing local apt mirror" echo "--- Clean apt cache"
# Restore original sources.list
#mv /var/sources.list.bak /etc/apt/sources.list
# Clean apt cache
apt-get clean -qq > /dev/null apt-get clean -qq > /dev/null
# Remove local mirror repository key
#apt-key del COEX-MIRROR
echo_stamp "END of ROS INSTALLATION"

View File

@@ -12,27 +12,7 @@
# copies or substantial portions of the Software. # copies or substantial portions of the Software.
# #
set -e # Exit immidiately on non-zero result set -ex # exit on error, echo commands
echo_stamp() {
# TEMPLATE: echo_stamp <TEXT> <TYPE>
# TYPE: SUCCESS, ERROR, INFO
# More info there https://www.shellhacks.com/ru/bash-colors/
TEXT="$(date '+[%Y-%m-%d %H:%M:%S]') $1"
TEXT="\e[1m${TEXT}\e[0m" # BOLD
case "$2" in
SUCCESS)
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
ERROR)
TEXT="\e[31m${TEXT}\e[0m";; # RED
*)
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
esac
echo -e ${TEXT}
}
# https://gist.github.com/letmaik/caa0f6cc4375cbfcc1ff26bd4530c2a3 # https://gist.github.com/letmaik/caa0f6cc4375cbfcc1ff26bd4530c2a3
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh # https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
@@ -57,11 +37,10 @@ my_travis_retry() {
return $result return $result
} }
echo_stamp "Increase apt retries" echo "--- Increase apt retries"
echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries
echo_stamp "Install apt keys & repos" echo "--- Install apt keys & repos"
# TODO: This STDOUT consist 'OK' # TODO: This STDOUT consist 'OK'
apt-get update \ apt-get update \
@@ -70,17 +49,17 @@ apt-get update \
echo "deb http://packages.ros.org/ros/ubuntu buster main" > /etc/apt/sources.list.d/ros-latest.list echo "deb http://packages.ros.org/ros/ubuntu buster main" > /etc/apt/sources.list.d/ros-latest.list
wget -O - 'http://packages.coex.tech/key.asc' | apt-key add - wget -O - 'http://packages.coex.tech/key.asc' | apt-key add -
echo 'deb http://packages.coex.tech buster main' >> /etc/apt/sources.list echo 'deb http://packages.coex.tech buster main' >> /etc/apt/sources.list
echo_stamp "Update apt cache" echo "--- Update apt cache"
# TODO: FIX ERROR: /usr/bin/apt-key: 596: /usr/bin/apt-key: cannot create /dev/null: Permission denied # TODO: FIX ERROR: /usr/bin/apt-key: 596: /usr/bin/apt-key: cannot create /dev/null: Permission denied
apt-get update apt-get update
# && apt upgrade -y # && apt upgrade -y
# Let's retry fetching those packages several times, just in case # Let's retry fetching those packages several times, just in case
echo_stamp "Software installing" echo "--- Install software"
my_travis_retry apt-get install --no-install-recommends -y cmake-data=3.13.4-1 cmake=3.13.4-1 # FIXME: using older CMake due to https://travis-ci.org/github/CopterExpress/clover/jobs/764367665#L6984 my_travis_retry apt-get install --no-install-recommends -y cmake-data=3.13.4-1 cmake=3.13.4-1 # FIXME: using older CMake due to https://travis-ci.org/github/CopterExpress/clover/jobs/764367665#L6984
my_travis_retry apt-get install --no-install-recommends -y \ my_travis_retry apt-get install --no-install-recommends -y \
unzip \ unzip \
@@ -121,7 +100,7 @@ python3-opencv
sed -i "s/updates_available//" /usr/share/byobu/status/status sed -i "s/updates_available//" /usr/share/byobu/status/status
# sed -i "s/updates_available//" /home/pi/.byobu/status # sed -i "s/updates_available//" /home/pi/.byobu/status
echo_stamp "Installing pip" echo "--- Installing pip"
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip2.py curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip2.py
python3 get-pip.py python3 get-pip.py
@@ -130,12 +109,12 @@ rm get-pip.py get-pip2.py
#my_travis_retry pip install --upgrade pip #my_travis_retry pip install --upgrade pip
#my_travis_retry pip3 install --upgrade pip #my_travis_retry pip3 install --upgrade pip
echo_stamp "Make sure both pip and pip3 are installed" echo "--- Make sure both pip and pip3 are installed"
pip --version pip --version
pip3 --version pip3 --version
echo_stamp "Install and enable Butterfly (web terminal)" echo "--- Install and enable Butterfly (web terminal)"
echo_stamp "Workaround for tornado >= 6.0 breaking butterfly" echo "Workaround for tornado >= 6.0 breaking butterfly"
export CRYPTOGRAPHY_DONT_BUILD_RUST=1 export CRYPTOGRAPHY_DONT_BUILD_RUST=1
my_travis_retry pip3 install cryptography==3.4.6 # https://stackoverflow.com/a/68472128/6850197 my_travis_retry pip3 install cryptography==3.4.6 # https://stackoverflow.com/a/68472128/6850197
my_travis_retry pip3 install pyOpenSSL==20.0.1 my_travis_retry pip3 install pyOpenSSL==20.0.1
@@ -144,16 +123,16 @@ my_travis_retry pip3 install butterfly
my_travis_retry pip3 install butterfly[systemd] my_travis_retry pip3 install butterfly[systemd]
systemctl enable butterfly.socket systemctl enable butterfly.socket
echo_stamp "Install ws281x library" echo "--- Install ws281x library"
my_travis_retry pip3 install --prefer-binary rpi_ws281x my_travis_retry pip3 install --prefer-binary rpi_ws281x
echo_stamp "Setup Monkey" echo "--- Setup Monkey"
mv /etc/monkey/sites/default /etc/monkey/sites/default.orig mv /etc/monkey/sites/default /etc/monkey/sites/default.orig
mv /root/monkey /etc/monkey/sites/default mv /root/monkey /etc/monkey/sites/default
sed -i 's/SymLink Off/SymLink On/' /etc/monkey/monkey.conf sed -i 's/SymLink Off/SymLink On/' /etc/monkey/monkey.conf
systemctl enable monkey.service systemctl enable monkey.service
echo_stamp "Install Node.js" echo "--- Install Node.js"
cd /home/pi cd /home/pi
wget --no-verbose https://nodejs.org/dist/v10.15.0/node-v10.15.0-linux-armv6l.tar.gz wget --no-verbose https://nodejs.org/dist/v10.15.0/node-v10.15.0-linux-armv6l.tar.gz
tar -xzf node-v10.15.0-linux-armv6l.tar.gz tar -xzf node-v10.15.0-linux-armv6l.tar.gz
@@ -161,28 +140,26 @@ cp -R node-v10.15.0-linux-armv6l/* /usr/local/
rm -rf node-v10.15.0-linux-armv6l/ rm -rf node-v10.15.0-linux-armv6l/
rm node-v10.15.0-linux-armv6l.tar.gz rm node-v10.15.0-linux-armv6l.tar.gz
echo_stamp "Installing ptvsd" echo "--- Installing ptvsd"
my_travis_retry pip install ptvsd my_travis_retry pip install ptvsd
my_travis_retry pip3 install ptvsd my_travis_retry pip3 install ptvsd
echo_stamp "Installing pyzbar" echo "--- Installing pyzbar"
my_travis_retry pip install pyzbar my_travis_retry pip install pyzbar
my_travis_retry pip3 install pyzbar my_travis_retry pip3 install pyzbar
echo_stamp "Add .vimrc" echo "--- Add .vimrc"
cat << EOF > /home/pi/.vimrc cat << EOF > /home/pi/.vimrc
set mouse-=a set mouse-=a
syntax on syntax on
autocmd BufNewFile,BufRead *.launch set syntax=xml autocmd BufNewFile,BufRead *.launch set syntax=xml
EOF EOF
echo_stamp "Change default keyboard layout to US" echo "--- Change default keyboard layout to US"
sed -i 's/XKBLAYOUT="gb"/XKBLAYOUT="us"/g' /etc/default/keyboard sed -i 's/XKBLAYOUT="gb"/XKBLAYOUT="us"/g' /etc/default/keyboard
echo_stamp "Attempting to kill dirmngr" echo "--- Attempting to kill dirmngr"
gpgconf --kill dirmngr gpgconf --kill dirmngr
# dirmngr is only used by apt-key, so we can safely kill it. # dirmngr is only used by apt-key, so we can safely kill it.
# We ignore pkill's exit value as well. # We ignore pkill's exit value as well.
pkill -9 -f dirmngr || true pkill -9 -f dirmngr || true
echo_stamp "End of software installation"

View File

@@ -12,9 +12,10 @@
# copies or substantial portions of the Software. # copies or substantial portions of the Software.
# #
set -ex set -ex # exit on error, echo commands
echo "Run image tests"
echo "--- Run image tests"
export ROS_DISTRO='noetic' export ROS_DISTRO='noetic'
export ROS_IP='127.0.0.1' export ROS_IP='127.0.0.1'
@@ -35,9 +36,9 @@ systemctl stop roscore
apt-cache show gst-rtsp-launch apt-cache show gst-rtsp-launch
apt-cache show openvpn apt-cache show openvpn
echo "Move /etc/ld.so.preload back to its original position" echo "--- Move /etc/ld.so.preload back to its original position"
mv /etc/ld.so.preload.disabled-for-build /etc/ld.so.preload mv /etc/ld.so.preload.disabled-for-build /etc/ld.so.preload
echo "Largest packages installed" echo "--- Largest packages installed"
sudo -E sh -c 'apt-get install -y debian-goodies' sudo -E sh -c 'apt-get install -y debian-goodies'
dpigs -H -n 100 dpigs -H -n 100

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex # exit on error, echo commands
# TODO: validate versions # TODO: validate versions