mirror of
https://github.com/CopterExpress/clover.git
synced 2026-06-05 00:59:33 +00:00
* builder: Build against Buster * builder: Use correct repository specifications * builder: Move ld.so.preload to have less errors * builder: Use coex repo to install Monkey * builder: Search for buster ROS packages * aruco_pose: Vendor in aruco library from OpenCV 3.4.6 * builder: Move to ROS Melodic * builder: Update kernel version * aruco_pose, clever: Remove opencv3 ROS dependency * builder: Update rosdep * travis: Disable eclint for vendored aruco library * tests: Don't try to locate opencv in ros * roscore: Use melodic distribution * Revert "aruco_pose: Vendor in aruco library from OpenCV 3.4.6" This reverts commit 9c14a8c002bb3396f9a7d9b2ba39969207f066ba. * aruco_pose: Vendor opencv_contrib/aruco again * builder: Add led packages * builder: Remove unused builder code * travis: Add native tests * builder: Set permissions for standalone-install * builder: Use -y for package installation * builder: Add repo for standalone build * builder: Use correct file types for standalone install * aruco_pose: Accept rgb8 map images * builder: Disable mjpg_streamer test * aruco_pose: Allow rgb8 map images (again) * builder: Re-add mjpgstreamer * builder: Install tornado==4.2.1 for rosbridge_suite * builder: Use more recent base image * builder: Use default kernel * builder: Move ld.so.preload back after tests * builder: Disable catkin tests These tests fail on a remote machine but seem to pass just fine on real hardware. Something must have changed between Kinetic and Melodic, and we must investigate more, but for now we just need a working image. * aruco_pose: Remove unused vendored code * selfcheck: Update systemd-analyze regex * builder: Add opencv repository * rosdep: Update package definitions for Melodic * rosdep: Use proper yaml formatting * travis: Remove unnecessary space * docs: Reference Melodic wherever possible
125 lines
5.5 KiB
Bash
Executable File
125 lines
5.5 KiB
Bash
Executable File
#! /usr/bin/env bash
|
|
|
|
#
|
|
# Script for build the image. Used builder script of the target repo.
|
|
# For build: docker run --privileged -it --rm -v /dev:/dev -v $(pwd):/builder/repo smirart/builder
|
|
#
|
|
# Copyright (C) 2018 Copter Express Technologies
|
|
#
|
|
# Author: Artem Smirnov <urpylka@gmail.com>
|
|
#
|
|
# Distributed under MIT License (available at https://opensource.org/licenses/MIT).
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
# copies or substantial portions of the Software.
|
|
#
|
|
|
|
set -e # Exit immidiately on non-zero result
|
|
|
|
SOURCE_IMAGE="https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-09-30/2019-09-26-raspbian-buster-lite.zip"
|
|
|
|
export DEBIAN_FRONTEND=${DEBIAN_FRONTEND:='noninteractive'}
|
|
export LANG=${LANG:='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"
|
|
REPO_DIR="${BUILDER_DIR}/repo"
|
|
SCRIPTS_DIR="${REPO_DIR}/builder"
|
|
IMAGES_DIR="${REPO_DIR}/images"
|
|
|
|
[[ ! -d ${SCRIPTS_DIR} ]] && (echo_stamp "Directory ${SCRIPTS_DIR} doesn't exist" "ERROR"; exit 1)
|
|
[[ ! -d ${IMAGES_DIR} ]] && mkdir ${IMAGES_DIR} && echo_stamp "Directory ${IMAGES_DIR} was created successful" "SUCCESS"
|
|
|
|
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)}"
|
|
REPO_URL="$(cd ${REPO_DIR}; git remote --verbose | grep origin | grep fetch | cut -f2 | cut -d' ' -f1 | sed 's/git@github\.com\:/https\:\/\/github.com\//')"
|
|
REPO_NAME="$(basename -s '.git' ${REPO_URL})"
|
|
IMAGE_NAME="${REPO_NAME}_${IMAGE_VERSION}.img"
|
|
IMAGE_PATH="${IMAGES_DIR}/${IMAGE_NAME}"
|
|
|
|
get_image() {
|
|
# TEMPLATE: get_image <IMAGE_PATH> <RPI_DONWLOAD_URL>
|
|
local BUILD_DIR=$(dirname $1)
|
|
local RPI_ZIP_NAME=$(basename $2)
|
|
local RPI_IMAGE_NAME=$(echo ${RPI_ZIP_NAME} | sed 's/zip/img/')
|
|
|
|
if [ ! -e "${BUILD_DIR}/${RPI_ZIP_NAME}" ]; then
|
|
echo_stamp "Downloading original Linux distribution"
|
|
wget --progress=dot:giga -O ${BUILD_DIR}/${RPI_ZIP_NAME} $2
|
|
echo_stamp "Downloading complete" "SUCCESS" \
|
|
else echo_stamp "Linux distribution already donwloaded"; fi
|
|
|
|
echo_stamp "Unzipping Linux distribution image" \
|
|
&& 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}
|
|
|
|
# Make free space
|
|
${BUILDER_DIR}/image-resize.sh ${IMAGE_PATH} max '7G'
|
|
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/init_rpi.sh' '/root/'
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/hardware_setup.sh' '/root/'
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-init.sh' ${IMAGE_VERSION} ${SOURCE_IMAGE}
|
|
|
|
# Copy cloned repository to the image
|
|
# Include dotfiles in globs (asterisks)
|
|
shopt -s dotglob
|
|
for dir in ${REPO_DIR}/*; do
|
|
# Don't try to copy image into itself
|
|
if [[ $dir != *"images" && $dir != *"imgcache" ]]; then
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy $dir '/home/pi/catkin_ws/src/clever/'
|
|
fi;
|
|
done
|
|
|
|
# Monkey
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/monkey' '/root/'
|
|
|
|
# Butterfly
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/butterfly.service' '/lib/systemd/system/'
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/butterfly.socket' '/lib/systemd/system/'
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/monkey.service' '/lib/systemd/system/'
|
|
# software install
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-software.sh'
|
|
# network setup
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-network.sh'
|
|
|
|
# If RPi then use a one thread to build a ROS package on RPi, else use all
|
|
[[ $(arch) == 'armv7l' ]] && NUMBER_THREADS=1 || NUMBER_THREADS=$(nproc --all)
|
|
# Clever
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/clever.service' '/lib/systemd/system/'
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/roscore.service' '/lib/systemd/system/'
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/melodic-rosdep-clever.yaml' '/etc/ros/rosdep/'
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/ros_python_paths' '/etc/sudoers.d/'
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/pigpiod.service' '/lib/systemd/system/'
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/launch.nanorc' '/usr/share/nano/'
|
|
# ${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/kinetic-ros-clever.rosinstall' '/home/pi/ros_catkin_ws/'
|
|
# Add PX4 udev rules
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${REPO_DIR}'/clever/config/99-px4fmu.rules' '/lib/udev/rules.d/'
|
|
# Add rename script
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-ros.sh' ${REPO_URL} ${IMAGE_VERSION} false false ${NUMBER_THREADS}
|
|
${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-validate.sh'
|
|
|
|
${BUILDER_DIR}/image-resize.sh ${IMAGE_PATH}
|