image_builder: migrate from build.Jenkinsfile to manual.sh

This commit is contained in:
Artem Smirnov
2018-08-20 23:38:20 +03:00
parent 2e27485e3b
commit 5e5247aee1

View File

@@ -4,41 +4,65 @@ DEBIAN_FRONTEND='noninteractive'
LANG='C.UTF-8' LANG='C.UTF-8'
LC_ALL='C.UTF-8' LC_ALL='C.UTF-8'
# 1. добавить проверку архитектуры is_set() {
# 2. решить проблему с тем что если уже подмонтированно все if ! [[ -z $$1 ]];
# then $1="NOT_SET"
# mount: binfmt_misc is already mounted or /proc/sys/fs/binfmt_misc busy fi
# binfmt_misc is already mounted on /proc/sys/fs/binfmt_misc }
# ./manual.sh: line 9: echo: write error: File exists
# TARGET_REPO_URL='https://github.com/urpylka/clever.git'
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc TARGET_REPO_REF='qemu_test_2'
echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register TARGET_REPO_PATH='image_builder'
IMAGE_NAME='clever_docker.img'
CLEVER_VERSION='NO_VERSION'
SOURCE_IMAGE='https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-12-01/2017-11-29-raspbian-stretch-lite.zip'
NUMBER_THREADS=4
DISCOVER_ROS_PACKAGES=False
SHRINK=True
set -e set -e
apt install unzip wget apt-get install unzip wget parted apt-utils git ca-certificates
BUILD_DIR=$(pwd) git clone ${TARGET_REPO_URL} --single-branch --branch ${TARGET_REPO_REF} --depth 1 'repo_tmp'
IMAGE_NAME="clever_qemu.img" if [[ -d repo_tmp${TARGET_REPO_PATH} ]];
then cd repo_tmp${TARGET_REPO_PATH}
else echo "Error TARGET_REPO_PATH incorrect!" && return 1
fi
RPI_DONWLOAD_URL="https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-12-01/2017-11-29-raspbian-stretch-lite.zip" BUILD_DIR=$(pwd)/image
./image_config.sh get_image ${BUILD_DIR} ${RPI_DONWLOAD_URL} ${IMAGE_NAME}
./image_config.sh resize_fs ${BUILD_DIR}/${IMAGE_NAME} "7G" ./image_config.sh get_image ${BUILD_DIR} ${SOURCE_IMAGE} ${IMAGE_NAME}
./image_config.sh copy_to_chroot ${BUILD_DIR}/${IMAGE_NAME} "qemu-arm-resin" "/usr/bin/qemu-arm-static" ./image_config.sh resize_fs ${BUILD_DIR}/${IMAGE_NAME} '7G'
./image_config.sh copy_to_chroot ${BUILD_DIR}/${IMAGE_NAME} "scripts/init_rpi.sh" "/root/" if [[ $(arch) != 'armv7l' ]]; then
./image_config.sh copy_to_chroot ${BUILD_DIR}/${IMAGE_NAME} "scripts/hardware_setup.sh" "/root/" if ! [[ -d '/proc/sys/fs/binfmt_misc' ]]; then
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register
fi
fi
./image_config.sh copy_to_chroot ${BUILD_DIR}/${IMAGE_NAME} './qemu-arm-resin' '/usr/bin/qemu-arm-static'
./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} "scripts/init_image.sh" "qemu_build_20082018" "raspbian_nov_2017" ./image_config.sh copy_to_chroot ${BUILD_DIR}/${IMAGE_NAME} './scripts/init_rpi.sh' '/root/'
./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} "scripts/software_install.sh" ./image_config.sh copy_to_chroot ${BUILD_DIR}/${IMAGE_NAME} './scripts/hardware_setup.sh' '/root/'
./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} "scripts/network_setup.sh"
#./image_config.sh copy_to_chroot ${BUILD_DIR}/${IMAGE_NAME} "kinetic-ros-coex.rosinstall" "/home/pi/ros_catkin_ws/" ./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} './scripts/init_image.sh' ${CLEVER_VERSION} ${SOURCE_IMAGE}
#./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} scripts/ros_install.sh https://github.com/CopterExpress/clever.git master True ./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} './scripts/software_install.sh'
./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} './scripts/network_setup.sh'
#./image_config.sh copy_to_chroot ${BUILD_DIR}/${IMAGE_NAME} "scripts" "/" #./image_config.sh copy_to_chroot ${BUILD_DIR}/${IMAGE_NAME} 'kinetic-ros-coex.rosinstall' '/home/pi/ros_catkin_ws/'
#./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME}
./autosizer.sh ${BUILD_DIR}/${IMAGE_NAME} #
./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} "scripts/change_boot_part.sh" # Не совсем корректно тк такого параметра быть не должно,
# вообще здесь не должно быть ветки как параметра, она должна задаваться непосредственно в файл ros_install
#
#./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} './scripts/ros_install.sh' https://github.com/CopterExpress/clever.git master True
if SHRINK; then
./autosizer.sh ${BUILD_DIR}/${IMAGE_NAME}
# Наверное вставить в autosizer, тк отдельно (внутри образа) это все равно никто не будет запускать
# и не нужно его запускать через execute
./image_config.sh execute ${BUILD_DIR}/${IMAGE_NAME} './scripts/change_boot_part.sh'
fi