From bee257d3e32f62fac8dca9a8b6b574f388e94bd0 Mon Sep 17 00:00:00 2001 From: Boris Pruessmann Date: Wed, 22 Feb 2017 10:36:03 +0100 Subject: [PATCH 1/2] Picked up changes from image-builder-rpi. This commit brings image-builder-odroid-c2 in line with the current version of image-builder-rpi. Still missing is a 4.x linux kernel. --- builder/boot.ini | 85 --------- builder/build.sh | 142 +++++++------- builder/chroot-script.sh | 178 +++++++++++++++--- builder/files/boot/boot.ini | 173 +++++++++++++++++ builder/files/boot/device-init.yaml | 9 + .../files/etc/firstboot.d/10-resize-rootdisk | 54 +++--- builder/files/etc/firstboot.d/99-leds | 6 + builder/files/etc/fstab | 3 + .../system/docker.service.d/10-execstart.conf | 3 + builder/test-integration/.bundle/config | 4 + builder/test-integration/Gemfile.lock | 38 ++-- builder/test-integration/README.md | 33 +++- .../docker-compose_spec.rb.off | 34 ++++ .../spec/hypriotos-docker/docker-node_spec.rb | 2 +- .../hypriotos-docker/docker-swarm_spec.rb | 15 -- .../hypriotos-image/base/bootfiles_spec.rb | 25 +++ .../hypriotos-image/base/device_tree_spec.rb | 5 +- .../hypriotos-image/base/firstboot_spec.rb | 5 + .../spec/hypriotos-image/base/kernel_spec.rb | 6 +- .../hypriotos-image/base/packages_spec.rb | 60 +----- .../spec/hypriotos-image/base/release_spec.rb | 23 ++- .../spec/hypriotos-image/base/users_spec.rb | 36 +--- .../hypriotos-image/cmdline_kernel_spec.rb | 13 ++ .../spec/hypriotos-image/device-init_spec.rb | 28 +++ .../hypriotos-image/docker-compose_spec.rb | 4 +- .../hypriotos-image/docker-machine_spec.rb | 15 +- .../spec/hypriotos-image/docker_spec.rb | 58 ++++-- .../spec/hypriotos-image/filesystems_spec.rb | 7 +- .../spec/hypriotos-image/hypriot-list_spec.rb | 14 +- .../hypriotos-image/kernel_config_spec.rb | 78 -------- .../hypriotos-image/kernel_modules_spec.rb | 0 .../spec/hypriotos-image/odroid-list_spec.rb | 8 + builder/test/image_spec.rb | 22 ++- builder/test/os-release_spec.rb | 4 +- builder/test/spec_helper.rb | 2 +- versions.config | 18 ++ 36 files changed, 744 insertions(+), 466 deletions(-) delete mode 100644 builder/boot.ini create mode 100755 builder/files/boot/boot.ini create mode 100644 builder/files/boot/device-init.yaml create mode 100644 builder/files/etc/firstboot.d/99-leds create mode 100644 builder/files/etc/fstab create mode 100644 builder/files/etc/systemd/system/docker.service.d/10-execstart.conf create mode 100644 builder/test-integration/.bundle/config create mode 100644 builder/test-integration/spec/hypriotos-docker/docker-compose_spec.rb.off delete mode 100644 builder/test-integration/spec/hypriotos-docker/docker-swarm_spec.rb create mode 100644 builder/test-integration/spec/hypriotos-image/base/bootfiles_spec.rb create mode 100644 builder/test-integration/spec/hypriotos-image/base/firstboot_spec.rb create mode 100644 builder/test-integration/spec/hypriotos-image/cmdline_kernel_spec.rb create mode 100644 builder/test-integration/spec/hypriotos-image/device-init_spec.rb delete mode 100644 builder/test-integration/spec/hypriotos-image/kernel_config_spec.rb create mode 100644 builder/test-integration/spec/hypriotos-image/kernel_modules_spec.rb create mode 100644 builder/test-integration/spec/hypriotos-image/odroid-list_spec.rb create mode 100644 versions.config diff --git a/builder/boot.ini b/builder/boot.ini deleted file mode 100644 index 30620bd..0000000 --- a/builder/boot.ini +++ /dev/null @@ -1,85 +0,0 @@ -ODROIDC2-UBOOT-CONFIG - -# Possible screen resolutions -# Uncomment only a single Line! The line with setenv written. -# At least one mode must be selected. - -# 480 Lines (720x480) -# setenv m "480i60hz" # Interlaced 60Hz -# setenv m "480i_rpt" # Interlaced for Rear Projection Televisions 60Hz -# setenv m "480p60hz" # 480 Progressive 60Hz -# setenv m "480p_rpt" # 480 Progressive for Rear Projection Televisions 60Hz - -# 576 Lines (720x576) -# setenv m "576i50hz" # Interlaced 50Hz -# setenv m "576i_rpt" # Interlaced for Rear Projection Televisions 50Hz -# setenv m "576p50hz" # Progressive 50Hz -# setenv m "576p_rpt" # Progressive for Rear Projection Televisions 50Hz - -# 720 Lines (1280x720) -# setenv m "720p50hz" # 50Hz -# setenv m "720p60hz" # 60Hz - -# 1080 Lines (1920x1080) -# setenv m "1080i60hz" # Interlaced 60Hz -setenv m "1080p60hz" # Progressive 60Hz -# setenv m "1080i50hz" # Interlaced 50Hz -# setenv m "1080p50hz" # Progressive 50Hz -# setenv m "1080p24hz" # Progressive 24Hz - -# 4K (3840x2160) -# setenv m "2160p30hz" # Progressive 30Hz -# setenv m "2160p25hz" # Progressive 25Hz -# setenv m "2160p24hz" # Progressive 24Hz -# setenv m "smpte24hz" # Progressive 24Hz SMPTE -# setenv m "2160p50hz" # Progressive 50Hz -# setenv m "2160p60hz" # Progressive 60Hz -# setenv m "2160p50hz420" # Progressive 50Hz with YCbCr 4:2:0 (Requires TV/Monitor that supports it) -# setenv m "2160p60hz420" # Progressive 60Hz with YCbCr 4:2:0 (Requires TV/Monitor that supports it) - -### VESA modes ### -# setenv m "640x480p60hz" -# setenv m "800x480p60hz" -# setenv m "800x600p60hz" -# setenv m "1024x600p60hz" -# setenv m "1024x768p60hz" -# setenv m "1280x800p60hz" -# setenv m "1280x1024p60hz" -# setenv m "1360x768p60hz" -# setenv m "1366x768p60hz" -# setenv m "1440x900p60hz" -# setenv m "1600x900p60hz" -# setenv m "1680x1050p60hz" -# setenv m "1920x1200p60hz" - - -# HDMI BPP Mode -setenv m_bpp "32" -# setenv m_bpp "24" -# setenv m_bpp "16" - -# HDMI DVI/VGA modes -# Uncomment only a single Line! The line with setenv written. -# At least one mode must be selected. -# setenv vout "dvi" -# setenv vout "vga" - -# Default Console Device Setting -setenv condev "console=ttyS0,115200n8 console=tty0" # on both - -########################################### - -# Boot Arguments -setenv bootargs "root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait rw ${condev} no_console_suspend hdmimode=${m} m_bpp=${m_bpp} vout=${vout} fsck.fix=yes" - -# Booting - -setenv loadaddr "0x11000000" -setenv dtb_loadaddr "0x1000000" -setenv initrd_loadaddr "0x13000000" - -ext4load mmc 0:1 ${initrd_loadaddr} /boot/uInitrd -ext4load mmc 0:1 ${loadaddr} /boot/Image -ext4load mmc 0:1 ${dtb_loadaddr} /boot/meson64_odroidc2.dtb - -booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr} diff --git a/builder/build.sh b/builder/build.sh index 6746f9a..d103649 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -1,50 +1,53 @@ #!/bin/bash set -ex + # This script should be run only inside of a Docker container if [ ! -f /.dockerenv ]; then echo "ERROR: script works only in a Docker container!" exit 1 fi +# get versions for software that needs to be installed +source /workspace/versions.config + ### setting up some important variables to control the build process # where to store our created sd-image file BUILD_RESULT_PATH="/workspace" + +# place to build our sd-image BUILD_PATH="/build" -# where to store our base file system -HYPRIOT_OS_VERSION="v0.7.2" -ROOTFS_TAR="rootfs-arm64-${HYPRIOT_OS_VERSION}.tar.gz" +ROOTFS_TAR="rootfs-arm64-debian-${HYPRIOT_OS_VERSION}.tar.gz" ROOTFS_TAR_PATH="$BUILD_RESULT_PATH/$ROOTFS_TAR" -# size of root and boot partion -ROOT_PARTITION_SIZE="800M" +# Show TRAVSI_TAG in travis builds +echo TRAVIS_TAG="${TRAVIS_TAG}" -# device specific settings +# name of the sd-image we gonna create HYPRIOT_IMAGE_VERSION=${VERSION:="dirty"} HYPRIOT_IMAGE_NAME="hypriotos-odroid-c2-${HYPRIOT_IMAGE_VERSION}.img" -IMAGE_ROOTFS_PATH="/image-rootfs.tar.gz" QEMU_ARCH="aarch64" export HYPRIOT_IMAGE_VERSION -# specific versions of kernel/firmware and docker tools -export DOCKER_ENGINE_VERSION="1.9.1-1" -export DOCKER_COMPOSE_VERSION="1.5.2-80" -export DOCKER_MACHINE_VERSION="0.4.1-72" - # create build directory for assembling our image filesystem rm -rf $BUILD_PATH mkdir -p $BUILD_PATH # download our base root file system -if [ ! -f $ROOTFS_TAR_PATH ]; then - wget -q -O $ROOTFS_TAR_PATH https://github.com/hypriot/os-rootfs/releases/download/$HYPRIOT_OS_VERSION/$ROOTFS_TAR +if [ ! -f "$ROOTFS_TAR_PATH" ]; then + wget -q -O "$ROOTFS_TAR_PATH" "https://github.com/hypriot/os-rootfs/releases/download/$HYPRIOT_OS_VERSION/$ROOTFS_TAR" fi +# verify checksum of our root filesystem +echo "${ROOTFS_TAR_CHECKSUM} ${ROOTFS_TAR_PATH}" | sha256sum -c - + # extract root file system -tar -xzf $ROOTFS_TAR_PATH -C $BUILD_PATH +tar -xzf "$ROOTFS_TAR_PATH" -C $BUILD_PATH # register qemu-arm with binfmt +# to ensure that binaries we use in the chroot +# are executed via qemu-arm update-binfmts --enable qemu-$QEMU_ARCH # set up mount points for pseudo filesystems @@ -55,72 +58,73 @@ mount -o bind /dev/pts $BUILD_PATH/dev/pts mount -t proc none $BUILD_PATH/proc mount -t sysfs none $BUILD_PATH/sys -#---modify image--- # modify/add image files directly +# e.g. root partition resize script cp -R /builder/files/* $BUILD_PATH/ -# modify image in chroot environment -chroot $BUILD_PATH /bin/bash "/${HYPRIOT_IMAGE_NAME}" -#FIXME: use latest upstream u-boot files from hardkernel # download current bootloader/u-boot images from hardkernel -wget -q -O - http://dn.odroid.com/S905/BootLoader/ODROID-C2/c2_bootloader.tar.gz | tar -C /tmp -xzvf - -cp /tmp/c2_bootloader/bl1.bin.hardkernel . -cp /tmp/c2_bootloader/u-boot.bin . -cp /tmp/c2_bootloader/sd_fusing.sh . -rm -rf /tmp/c2_bootloader/ - -guestfish < "$BUILD_RESULT_PATH/$HYPRIOT_IMAGE_NAME.zip" +zip "${BUILD_RESULT_PATH}/${HYPRIOT_IMAGE_NAME}.zip" "${HYPRIOT_IMAGE_NAME}" +cd ${BUILD_RESULT_PATH} && sha256sum "${HYPRIOT_IMAGE_NAME}.zip" > "${HYPRIOT_IMAGE_NAME}.zip.sha256" && cd - # test sd-image that we have built VERSION=${HYPRIOT_IMAGE_VERSION} rspec --format documentation --color /builder/test diff --git a/builder/chroot-script.sh b/builder/chroot-script.sh index 51edb42..719aabe 100755 --- a/builder/chroot-script.sh +++ b/builder/chroot-script.sh @@ -1,51 +1,167 @@ #!/bin/bash set -ex +# save HYPRIOT_* content from /etc/os-release. Needs to be done in +# case base-files gets updated during build +< /etc/os-release grep HYPRIOT_ > /tmp/os-release.add + +KEYSERVER="ha.pool.sks-keyservers.net" + +function clean_print(){ + local fingerprint="${2}" + local func="${1}" + + nospaces=${fingerprint//[:space:]/} + tolowercase=${nospaces,,} + KEYID_long=${tolowercase:(-16)} + KEYID_short=${tolowercase:(-8)} + if [[ "${func}" == "fpr" ]]; then + echo "${tolowercase}" + elif [[ "${func}" == "long" ]]; then + echo "${KEYID_long}" + elif [[ "${func}" == "short" ]]; then + echo "${KEYID_short}" + elif [[ "${func}" == "print" ]]; then + if [[ "${fingerprint}" != "${nospaces}" ]]; then + printf "%-10s %50s\n" fpr: "${fingerprint}" + fi + # if [[ "${nospaces}" != "${tolowercase}" ]]; then + # printf "%-10s %50s\n" nospaces: $nospaces + # fi + if [[ "${tolowercase}" != "${KEYID_long}" ]]; then + printf "%-10s %50s\n" lower: "${tolowercase}" + fi + printf "%-10s %50s\n" long: "${KEYID_long}" + printf "%-10s %50s\n" short: "${KEYID_short}" + echo "" + else + echo "usage: function {print|fpr|long|short} GPGKEY" + fi +} + + +function get_gpg(){ + GPG_KEY="${1}" + KEY_URL="${2}" + + clean_print print "${GPG_KEY}" + GPG_KEY=$(clean_print fpr "${GPG_KEY}") + + if [[ "${KEY_URL}" =~ ^https?://* ]]; then + echo "loading key from url" + KEY_FILE=temp.gpg.key + wget -q -O "${KEY_FILE}" "${KEY_URL}" + elif [[ -z "${KEY_URL}" ]]; then + echo "no source given try to load from key server" +# gpg --keyserver "${KEYSERVER}" --recv-keys "${GPG_KEY}" + apt-key adv --keyserver "${KEYSERVER}" --recv-keys "${GPG_KEY}" + return $? + else + echo "keyfile given" + KEY_FILE="${KEY_URL}" + fi + + FINGERPRINT_OF_FILE=$(gpg --with-fingerprint --with-colons "${KEY_FILE}" | grep fpr | rev |cut -d: -f2 | rev) + + if [[ ${#GPG_KEY} -eq 16 ]]; then + echo "compare long keyid" + CHECK=$(clean_print long "${FINGERPRINT_OF_FILE}") + elif [[ ${#GPG_KEY} -eq 8 ]]; then + echo "compare short keyid" + CHECK=$(clean_print short "${FINGERPRINT_OF_FILE}") + else + echo "compare fingerprint" + CHECK=$(clean_print fpr "${FINGERPRINT_OF_FILE}") + fi + + if [[ "${GPG_KEY}" == "${CHECK}" ]]; then + echo "key OK add to apt" + apt-key add "${KEY_FILE}" + rm -f "${KEY_FILE}" + return 0 + else + echo "key invalid" + exit 1 + fi +} + + +## examples: +# clean_print {print|fpr|long|short} {GPGKEYID|FINGERPRINT} +# get_gpg {GPGKEYID|FINGERPRINT} [URL|FILE] + # device specific settings HYPRIOT_DEVICE="ODROID C2" # set up /etc/resolv.conf -echo "nameserver 8.8.8.8" > /etc/resolv.conf +DEST=$(readlink -m /etc/resolv.conf) +export DEST +mkdir -p "$(dirname "${DEST}")" +echo "nameserver 8.8.8.8" > "${DEST}" # set up ODROID repository -apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AB19BAC9 +ODROID_KEY_ID=AB19BAC9 +get_gpg $ODROID_KEY_ID echo "deb http://deb.odroid.in/c2/ xenial main" > /etc/apt/sources.list.d/odroid.list -# # set up Hypriot Schatzkiste repository -# wget -q https://packagecloud.io/gpg.key -O - | apt-key add - -# echo 'deb https://packagecloud.io/Hypriot/Schatzkiste/debian/ wheezy main' > /etc/apt/sources.list.d/hypriot.list +# set up hypriot arm repository for odroid packages +PACKAGECLOUD_FPR=418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB +PACKAGECLOUD_KEY_URL=https://packagecloud.io/gpg.key +get_gpg "${PACKAGECLOUD_FPR}" "${PACKAGECLOUD_KEY_URL}" + +# set up hypriot schatzkiste repository for generic packages +echo 'deb https://packagecloud.io/Hypriot/Schatzkiste/debian/ jessie main' >> /etc/apt/sources.list.d/hypriot.list + +# add armhf as additional architecure (see below) +dpkg --add-architecture armhf # update all apt repository lists export DEBIAN_FRONTEND=noninteractive apt-get update +apt-get upgrade -y + +# define packages to install +packages=( + # as the Odroid C2 does not have a hardware clock we need a fake one + fake-hwclock + + # install device-init + device-init:armhf=${DEVICE_INIT_VERSION} + + # install dependencies for docker-tools + lxc + aufs-tools + cgroupfs-mount + cgroup-bin + apparmor + libltdl7 + + # install docker-compose, and docker-machine + libc6:armhf + zlib1g:armhf + docker-compose:armhf=${DOCKER_COMPOSE_VERSION} + docker-machine:armhf=${DOCKER_MACHINE_VERSION} +) + +apt-get -y install ${packages[*]} + +# install linux kernel for Odroid C2 +apt-get -y install u-boot-tools linux-image-c2 + +# install docker-engine +DOCKER_DEB=$(mktemp) +wget -q -O "$DOCKER_DEB" "$DOCKER_DEB_URL" +echo "${DOCKER_DEB_CHECKSUM} ${DOCKER_DEB}" | sha256sum -c - +dpkg -i "$DOCKER_DEB" + +# Restore os-release additions +cat /tmp/os-release.add >> /etc/os-release -# ---install Docker tools--- - -# # install Hypriot packages for using Docker -# apt-get install -y \ -# "docker-hypriot=${DOCKER_ENGINE_VERSION}" \ -# "docker-compose=${DOCKER_COMPOSE_VERSION}" \ -# "docker-machine=${DOCKER_MACHINE_VERSION}" - -# #FIXME: should be handled in .deb package -# # setup Docker default configuration for ODROID C2 -# rm -f /etc/init.d/docker # we're using a pure systemd init, remove sysvinit script -# rm -f /etc/default/docker -# # --get upstream config -# wget -q -O /etc/default/docker https://github.com/docker/docker/raw/master/contrib/init/sysvinit-debian/docker.default -# # --enable aufs by default -# sed -i "/#DOCKER_OPTS/a \ -# DOCKER_OPTS=\"--storage-driver=aufs -D\"" /etc/default/docker - -# #FIXME: should be handled in .deb package -# # enable Docker systemd service -# systemctl enable docker - -# install ODROID C2 u-boot and kernel -apt-get install -y u-boot-tools initramfs-tools -apt-get install -y linux-image-c2 -ls -al /boot/* +# cleanup APT cache and lists +apt-get clean +rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # set device label and version number echo "HYPRIOT_DEVICE=\"$HYPRIOT_DEVICE\"" >> /etc/os-release echo "HYPRIOT_IMAGE_VERSION=\"$HYPRIOT_IMAGE_VERSION\"" >> /etc/os-release +cp /etc/os-release /boot/os-release diff --git a/builder/files/boot/boot.ini b/builder/files/boot/boot.ini new file mode 100755 index 0000000..8a256cc --- /dev/null +++ b/builder/files/boot/boot.ini @@ -0,0 +1,173 @@ +ODROIDC2-UBOOT-CONFIG + +######################################################################## +# Changes made to this are overwritten every time there's a new upgrade +# To make your changes permanent change it on +# boot.ini.default +# After changing it on boot.ini.default run the bootini command to +# rewrite this file with your personal permanent settings. +# Documentation: http://odroid.com/dokuwiki/doku.php?id=en:c2_persistent_bootini +######################################################################## + +# Possible screen resolutions +# Uncomment only a single Line! The line with setenv written. +# At least one mode must be selected. + +# Custom modeline! +# To use custom modeline you need to disable all the below resolutions +# and setup your own! +# For more information check our wiki: +# http://odroid.com/dokuwiki/doku.php?id=en:c2_hdmi_autosetting +# Example below: +# setenv m "custombuilt" +# setenv modeline "1920,1200,154000,74040,60,1920,1968,2000,2080,1200,1202,1208,1235,1,0,1" + +# 480 Lines (720x480) +# setenv m "480i60hz" # Interlaced 60Hz +# setenv m "480i_rpt" # Interlaced for Rear Projection Televisions 60Hz +# setenv m "480p60hz" # 480 Progressive 60Hz +# setenv m "480p_rpt" # 480 Progressive for Rear Projection Televisions 60Hz + +# 576 Lines (720x576) +# setenv m "576i50hz" # Interlaced 50Hz +# setenv m "576i_rpt" # Interlaced for Rear Projection Televisions 50Hz +# setenv m "576p50hz" # Progressive 50Hz +# setenv m "576p_rpt" # Progressive for Rear Projection Televisions 50Hz + +# 720 Lines (1280x720) +# setenv m "720p50hz" # 50Hz +# setenv m "720p60hz" # 60Hz + +# 1080 Lines (1920x1080) +# setenv m "1080i60hz" # Interlaced 60Hz +setenv m "1080p60hz" # Progressive 60Hz +# setenv m "1080i50hz" # Interlaced 50Hz +# setenv m "1080p50hz" # Progressive 50Hz +# setenv m "1080p24hz" # Progressive 24Hz + +# 4K (3840x2160) +# setenv m "2160p30hz" # Progressive 30Hz +# setenv m "2160p25hz" # Progressive 25Hz +# setenv m "2160p24hz" # Progressive 24Hz +# setenv m "smpte24hz" # Progressive 24Hz SMPTE +# setenv m "2160p50hz" # Progressive 50Hz +# setenv m "2160p60hz" # Progressive 60Hz +# setenv m "2160p50hz420" # Progressive 50Hz with YCbCr 4:2:0 (Requires TV/Monitor that supports it) +# setenv m "2160p60hz420" # Progressive 60Hz with YCbCr 4:2:0 (Requires TV/Monitor that supports it) + +### VESA modes ### +# setenv m "640x480p60hz" +# setenv m "800x480p60hz" +# setenv m "480x800p60hz" +# setenv m "800x600p60hz" +# setenv m "1024x600p60hz" +# setenv m "1024x768p60hz" +# setenv m "1280x800p60hz" +# setenv m "1280x1024p60hz" +# setenv m "1360x768p60hz" +# setenv m "1440x900p60hz" +# setenv m "1600x900p60hz" +# setenv m "1680x1050p60hz" +# setenv m "1600x1200p60hz" +# setenv m "1920x1200p60hz" +# setenv m "2560x1080p60hz" +# setenv m "2560x1440p60hz" +# setenv m "2560x1600p60hz" +# setenv m "3440x1440p60hz" + +# HDMI BPP Mode +setenv m_bpp "32" +# setenv m_bpp "24" +# setenv m_bpp "16" + +# HDMI DVI/VGA modes +# By default its set to HDMI, if needed change below. +# Uncomment only a single Line. +# setenv vout "dvi" +# setenv vout "vga" + +# HDMI HotPlug Detection control +# Allows you to force HDMI thinking that the cable is connected. +# true = HDMI will believe that cable is always connected +# false = will let board/monitor negotiate the connection status +setenv hpd "true" +# setenv hpd "false" + +# Monitor output +# Controls if HDMI PHY should output anything to the monitor +setenv monitor_onoff "false" # true or false + +# Server Mode (aka. No Graphics) +# Setting nographics to 1 will disable all video subsystem +# This mode is ideal of server type usage. (Saves ~300Mb of RAM) +setenv nographics "0" + +# Meson Timer +# 1 - Meson Timer +# 0 - Arch Timer +# Using meson_timer improves the video playback however it breaks KVM (virtualization). +# Using arch timer allows KVM/Virtualization to work however you'll experience poor video +setenv mesontimer "1" + +# UHS (Ultra High Speed) MicroSD mode enable/disable +setenv disableuhs "false" + +# MicroSD Card Detection enable/disable +# Force the MMC controlled to believe that a card is connected. +setenv mmc_removable "true" + +# Default Console Device Setting +setenv condev "console=ttyS0,115200n8 console=tty0" # on both + +# CPU Frequency / Cores control +########################################### +### WARNING!!! WARNING!!! WARNING!!! +# Before changing anything here please read the wiki entry: +# http://odroid.com/dokuwiki/doku.php?id=en:c2_set_cpu_freq +# +# MAX CPU's +# setenv maxcpus "1" +# setenv maxcpus "2" +# setenv maxcpus "3" +setenv maxcpus "4" + +# MAX Frequency +# setenv max_freq "2016" # 2.016GHz +# setenv max_freq "1944" # 1.944GHz +# setenv max_freq "1944" # 1.944GHz +# setenv max_freq "1920" # 1.920GHz +# setenv max_freq "1896" # 1.896GHz +# setenv max_freq "1752" # 1.752GHz +# setenv max_freq "1680" # 1.680GHz +# setenv max_freq "1656" # 1.656GHz +setenv max_freq "1536" # 1.536GHz + + + +########################################### + +# Boot Arguments +if test "${m}" = "custombuilt"; then setenv cmode "modeline=${modeline}"; fi + +setenv bootargs "root=/dev/mmcblk0p2 rootfstype=ext4 rootwait ro ${condev} no_console_suspend hdmimode=${m} ${comde} m_bpp=${m_bpp} vout=${vout} fsck.repair=yes net.ifnames=0 elevator=deadline cgroup_enable=memory cgroup_enable=cpuset swapaccount=1 disablehpd=${hpd} max_freq=${max_freq} maxcpus=${maxcpus} monitor_onoff=${monitor_onoff} disableuhs=${disableuhs} mmc_removable=${mmc_removable}" + +# Booting + +setenv loadaddr "0x11000000" +setenv dtb_loadaddr "0x1000000" +setenv initrd_loadaddr "0x13000000" + +fatload mmc 0:1 ${initrd_loadaddr} uInitrd +fatload mmc 0:1 ${loadaddr} Image +fatload mmc 0:1 ${dtb_loadaddr} meson64_odroidc2.dtb +fdt addr ${dtb_loadaddr} + +if test "${mesontimer}" = "0"; then fdt rm /meson_timer; fdt rm /cpus/cpu@0/timer; fdt rm /cpus/cpu@1/timer; fdt rm /cpus/cpu@2/timer; fdt rm /cpus/cpu@3/timer; fi +if test "${mesontimer}" = "1"; then fdt rm /timer; fi + +if test "${nographics}" = "1"; then fdt rm /reserved-memory; fdt rm /aocec; fi +if test "${nographics}" = "1"; then fdt rm /meson-fb; fdt rm /amhdmitx; fdt rm /picdec; fdt rm /ppmgr; fi +if test "${nographics}" = "1"; then fdt rm /meson-vout; fdt rm /mesonstream; fdt rm /meson-fb; fi +if test "${nographics}" = "1"; then fdt rm /deinterlace; fdt rm /codec_mm; fi + +booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr} diff --git a/builder/files/boot/device-init.yaml b/builder/files/boot/device-init.yaml new file mode 100644 index 0000000..8a1dc97 --- /dev/null +++ b/builder/files/boot/device-init.yaml @@ -0,0 +1,9 @@ +# hostname for your HypriotOS device +hostname: black-pearl + +# optional wireless network settings +wifi: + interfaces: +# wlan0: +# ssid: "MyNetwork" +# password: "secret_password" diff --git a/builder/files/etc/firstboot.d/10-resize-rootdisk b/builder/files/etc/firstboot.d/10-resize-rootdisk index 2be4a81..3977277 100644 --- a/builder/files/etc/firstboot.d/10-resize-rootdisk +++ b/builder/files/etc/firstboot.d/10-resize-rootdisk @@ -1,36 +1,44 @@ #!/bin/bash set -ex -# sd card device name for ODROID C2 -SDCARD_DEVICE="/dev/mmcblk0" +if ! [ -h /dev/disk/by-label/root ]; then + echo "/dev/disk/by-label/root does not exist or is not a symlink. Don't know how to expand" + return 0 +fi -# install parted, if its not there -if [ -z "$(which parted)" ]; then - apt-get update - apt-get install -y parted +ROOT_PART=$(readlink /dev/disk/by-label/root) +PART_NUM=${ROOT_PART#../../mmcblk0p} +if [ "$PART_NUM" = "$ROOT_PART" ]; then + echo "/dev/disk/by-label/root is not an SD card. Don't know how to expand" + return 0 fi -# show disk usage before changes -df -h +# NOTE: the NOOBS partition layout confuses parted. For now, let's only +# agree to work with a sufficiently simple partition layout +if [ "$PART_NUM" -ne 2 ]; then + echo "Your partition layout is not currently supported by this tool. You are probably using NOOBS, in which case your root filesystem is already expanded anyway." + return 0 +fi -# get partition number -PART_NUM=$(parted $SDCARD_DEVICE -ms unit s p | tail -n 1 | cut -f 1 -d:) -echo "$PART_NUM" +LAST_PART_NUM=$(parted /dev/mmcblk0 -ms unit s p | tail -n 1 | cut -f 1 -d:) -# get partition start sector -PART_START=$(parted $SDCARD_DEVICE -ms unit s p | grep "^$PART_NUM" | cut -f 2 -d:) -echo "$PART_START" +if [ "$LAST_PART_NUM" != "$PART_NUM" ]; then + echo "/dev/disk/by-label/root is not the last partition. Don't know how to expand" + return 0 +fi -# remove trailing "s" +# Get the starting offset of the root partition +PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d:) +# remove trailing 's' PART_START=${PART_START::-1} -echo "$PART_START" - -# change partition table for resizing to maximum +[ "$PART_START" ] || return 1 +# Return value will likely be error for fdisk as it fails to reload the +# partition table because the root fs is mounted set +e -fdisk $SDCARD_DEVICE < '/sys/class/leds/blue:heartbeat/trigger' +echo 50 > '/sys/class/leds/blue:heartbeat/delay_on' +echo 1000 > '/sys/class/leds/blue:heartbeat/delay_off' diff --git a/builder/files/etc/fstab b/builder/files/etc/fstab new file mode 100644 index 0000000..d4612bf --- /dev/null +++ b/builder/files/etc/fstab @@ -0,0 +1,3 @@ +proc /proc proc defaults 0 0 +/dev/mmcblk0p1 /boot vfat defaults 0 0 +/dev/mmcblk0p2 / ext4 defaults,noatime 0 1 diff --git a/builder/files/etc/systemd/system/docker.service.d/10-execstart.conf b/builder/files/etc/systemd/system/docker.service.d/10-execstart.conf new file mode 100644 index 0000000..38ab466 --- /dev/null +++ b/builder/files/etc/systemd/system/docker.service.d/10-execstart.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=/usr/bin/docker daemon -H fd:// --log-driver=journald --storage-driver=overlay --icc=false --iptables=true diff --git a/builder/test-integration/.bundle/config b/builder/test-integration/.bundle/config new file mode 100644 index 0000000..131dd70 --- /dev/null +++ b/builder/test-integration/.bundle/config @@ -0,0 +1,4 @@ +--- +BUNDLE_PATH: vendor/bundle +BUNDLE_DISABLE_SHARED_GEMS: '1' +BUNDLE_BIN: bin diff --git a/builder/test-integration/Gemfile.lock b/builder/test-integration/Gemfile.lock index e762ca3..17ec510 100644 --- a/builder/test-integration/Gemfile.lock +++ b/builder/test-integration/Gemfile.lock @@ -2,38 +2,34 @@ GEM remote: https://rubygems.org/ specs: diff-lcs (1.2.5) - multi_json (1.11.2) + multi_json (1.10.1) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (3.0.2) - net-telnet (0.1.1) - rspec (3.4.0) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-core (3.4.1) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + net-ssh (2.9.2) + rspec (3.2.0) + rspec-core (~> 3.2.0) + rspec-expectations (~> 3.2.0) + rspec-mocks (~> 3.2.0) + rspec-core (3.2.0) + rspec-support (~> 3.2.0) + rspec-expectations (3.2.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) + rspec-support (~> 3.2.0) rspec-its (1.2.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.4.1) + rspec-mocks (3.2.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-support (3.4.1) - serverspec (2.29.1) + rspec-support (~> 3.2.0) + rspec-support (3.2.1) + serverspec (2.8.2) multi_json rspec (~> 3.0) rspec-its - specinfra (~> 2.48) - sfl (2.2) - specinfra (2.50.0) + specinfra (~> 2.12) + specinfra (2.14.4) net-scp - net-ssh (>= 2.7, < 3.1) - net-telnet - sfl + net-ssh PLATFORMS ruby diff --git a/builder/test-integration/README.md b/builder/test-integration/README.md index 66b1f37..7a2bc02 100644 --- a/builder/test-integration/README.md +++ b/builder/test-integration/README.md @@ -1,24 +1,47 @@ # HypriotOS serverspec tests +To test the SD card image for the Raspberry Pi use this [Serverspec](http://serverspec.org) tests. See the [Serverspec Docs](http://serverspec.org/resource_types.html) for more details what you can test with it. + +## Preparation + +1. Flash the SD card image +2. Put the SD card into your Raspberry Pi +3. Power on the Raspberry Pi +4. Retrieve the host name or IP address to reach the Pi + ## Install Serverspec -You need `ruby` and `bundle` installed. Then you can install the dependencies locally with: +You need ruby and bundle installed. Then you can install the dependencies locally with + ```bash bundle install ``` -TODO: describe how to install rspec/rake +## Run tests +Set the `BOARD` environment variable to the host name or +IP address of your Pi. The user name for the test is `root`. -## Run tests +### Remove previous fingerpint -### Basic SD image tests +You normally have to remove the fingerprint of a previously tested Hypriot Pi. +Use the hostname or the IP address of your Raspberry Pi. + +```bash +ssh-keygen -R black-pearl.local +``` + +### Run basic SD image tests + +Now run the basic SD card image tests. This tests if docker is up and running and the image has everything as we expect it. ```bash BOARD=black-pearl.local bin/rspec spec/hypriotos-image ``` -### Full Docker tests +### Run full docker test + +Now run a full docker test. This does a full cycle with `docker pull` and `docker run` to see that everything works fine. ``` BOARD=black-pearl.local bin/rspec spec/hypriotos-docker diff --git a/builder/test-integration/spec/hypriotos-docker/docker-compose_spec.rb.off b/builder/test-integration/spec/hypriotos-docker/docker-compose_spec.rb.off new file mode 100644 index 0000000..23a3101 --- /dev/null +++ b/builder/test-integration/spec/hypriotos-docker/docker-compose_spec.rb.off @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe command('rm -rf rpi-node-haproxy-example && git clone https://github.com/hypriot/rpi-node-haproxy-example') do + its(:exit_status) { should eq 0 } +end + +describe command('cd rpi-node-haproxy-example && docker-compose up -d') do + its(:exit_status) { should eq 0 } +end + +describe command('cd rpi-node-haproxy-example && docker-compose ps') do + its(:stdout) { should match /rpinodehaproxyexample_haproxy_1 bash \/haproxy-start Up/ } + its(:stdout) { should match /rpinodehaproxyexample_weba_1 node index.js Up/ } + its(:stdout) { should match /rpinodehaproxyexample_webb_1 node index.js Up/ } + its(:stdout) { should match /rpinodehaproxyexample_webc_1 node index.js Up/ } + its(:exit_status) { should eq 0 } +end + +describe command('curl http://localhost') do + its(:stdout) { should match /Hello from Node.js container/ } + its(:exit_status) { should eq 0 } +end + +describe command('cd rpi-node-haproxy-example && docker-compose kill') do + its(:exit_status) { should eq 0 } +end + +describe command('cd rpi-node-haproxy-example && docker-compose ps') do + its(:stdout) { should match /rpinodehaproxyexample_haproxy_1 bash \/haproxy-start Exit 137/ } + its(:stdout) { should match /rpinodehaproxyexample_weba_1 node index.js Exit 137/ } + its(:stdout) { should match /rpinodehaproxyexample_webb_1 node index.js Exit 137/ } + its(:stdout) { should match /rpinodehaproxyexample_webc_1 node index.js Exit 137/ } + its(:exit_status) { should eq 0 } +end diff --git a/builder/test-integration/spec/hypriotos-docker/docker-node_spec.rb b/builder/test-integration/spec/hypriotos-docker/docker-node_spec.rb index 47842d2..8a4b2bf 100644 --- a/builder/test-integration/spec/hypriotos-docker/docker-node_spec.rb +++ b/builder/test-integration/spec/hypriotos-docker/docker-node_spec.rb @@ -6,6 +6,6 @@ describe command('docker run -t --rm hypriot/rpi-node:0.12.0 node --version') do its(:stdout) { should match /v0.12.0/ } - its(:stderr) { should match /^$/ } +# its(:stderr) { should match /^$/ } its(:exit_status) { should eq 0 } end diff --git a/builder/test-integration/spec/hypriotos-docker/docker-swarm_spec.rb b/builder/test-integration/spec/hypriotos-docker/docker-swarm_spec.rb deleted file mode 100644 index c8ceb79..0000000 --- a/builder/test-integration/spec/hypriotos-docker/docker-swarm_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe file('/var/hypriot/swarm.tar.gz') do - it { should_not be_file } -end - -describe command('docker run --rm -t hypriot/rpi-swarm --version') do - its(:stdout) { should match /swarm version 1.0.1 \(HEAD\)/ } - its(:exit_status) { should eq 0 } -end - -describe command('docker images hypriot/rpi-swarm') do - its(:stdout) { should match /hypriot\/rpi-swarm .*latest .*1cbff13985c5 / } - its(:exit_status) { should eq 0 } -end diff --git a/builder/test-integration/spec/hypriotos-image/base/bootfiles_spec.rb b/builder/test-integration/spec/hypriotos-image/base/bootfiles_spec.rb new file mode 100644 index 0000000..16150c3 --- /dev/null +++ b/builder/test-integration/spec/hypriotos-image/base/bootfiles_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe file('/boot/bl1.bin.hardkernel') do + it { should be_file } + it { should be_mode 755 } + it { should be_owned_by 'root' } +end + +describe file('/boot/boot.ini') do + it { should be_file } + it { should be_mode 755 } + it { should be_owned_by 'root' } +end + +describe file('/boot/meson64_odroidc2.dtb') do + it { should be_file } + it { should be_mode 755 } + it { should be_owned_by 'root' } +end + +describe file('/boot/u-boot.bin') do + it { should be_file } + it { should be_mode 755 } + it { should be_owned_by 'root' } +end diff --git a/builder/test-integration/spec/hypriotos-image/base/device_tree_spec.rb b/builder/test-integration/spec/hypriotos-image/base/device_tree_spec.rb index 9f5cf75..6e3a0ad 100644 --- a/builder/test-integration/spec/hypriotos-image/base/device_tree_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/base/device_tree_spec.rb @@ -2,6 +2,9 @@ # /proc/device-tree is only present if device-tree works describe file('/proc/device-tree') do + it { should be_symlink } + it { should be_linked_to '/sys/firmware/devicetree/base' } + it { should be_mode 777 } it { should be_owned_by 'root' } end @@ -9,5 +12,5 @@ it { should be_file } it { should be_mode 444 } it { should be_owned_by 'root' } - its(:content) { should match /AMLOGIC/ } + its(:content) { should match /ODROID-C2/ } end diff --git a/builder/test-integration/spec/hypriotos-image/base/firstboot_spec.rb b/builder/test-integration/spec/hypriotos-image/base/firstboot_spec.rb new file mode 100644 index 0000000..bc08d97 --- /dev/null +++ b/builder/test-integration/spec/hypriotos-image/base/firstboot_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe file('/etc/hypriot-firstboot_not_to_be_run') do + it { should be_file } +end diff --git a/builder/test-integration/spec/hypriotos-image/base/kernel_spec.rb b/builder/test-integration/spec/hypriotos-image/base/kernel_spec.rb index 54af96c..54a4d29 100644 --- a/builder/test-integration/spec/hypriotos-image/base/kernel_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/base/kernel_spec.rb @@ -1,6 +1,10 @@ require 'spec_helper' describe command('uname -r') do - its(:stdout) { should match /3.10.80-135/ } + its(:stdout) { should match /3.14.79(-v7)?+/ } its(:exit_status) { should eq 0 } end + +describe file('/lib/modules/3.14.79-105/kernel') do + it { should be_directory } +end diff --git a/builder/test-integration/spec/hypriotos-image/base/packages_spec.rb b/builder/test-integration/spec/hypriotos-image/base/packages_spec.rb index b3acf49..8443765 100644 --- a/builder/test-integration/spec/hypriotos-image/base/packages_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/base/packages_spec.rb @@ -1,67 +1,27 @@ -require 'spec_helper' - -# rootfs packages -describe package('apt-transport-https') do +describe package('curl') do it { should be_installed } end -describe package('avahi-daemon') do + +describe package('wget') do it { should be_installed } end + describe package('bash-completion') do it { should be_installed } end -describe package('binutils') do - it { should be_installed } -end -describe package('ca-certificates') do - it { should be_installed } -end -describe package('curl') do - it { should be_installed } -end -describe package('git-core') do - it { should be_installed } -end + describe package('htop') do it { should be_installed } end -describe package('locales') do - it { should be_installed } -end -describe package('net-tools') do - it { should be_installed } -end -describe package('openssh-server') do - it { should be_installed } -end -describe package('parted') do - it { should be_installed } -end -describe package('sudo') do - it { should be_installed } -end -describe package('usbutils') do - it { should be_installed } -end -# additional kernel packages -describe package('u-boot-tools') do - it { should be_installed } -end -describe package('initramfs-tools') do - it { should be_installed } -end -describe package('linux-image-c2') do - it { should be_installed } +describe package('occi') do + it { should_not be_installed } end -# additional application packages -describe package('docker-hypriot') do - it { should be_installed } -end -describe package('docker-compose') do +describe package('usbutils') do it { should be_installed } end -describe package('docker-machine') do + +describe package('fake-hwclock') do it { should be_installed } end diff --git a/builder/test-integration/spec/hypriotos-image/base/release_spec.rb b/builder/test-integration/spec/hypriotos-image/base/release_spec.rb index 39b2d39..b8ad6a9 100644 --- a/builder/test-integration/spec/hypriotos-image/base/release_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/base/release_spec.rb @@ -1,10 +1,23 @@ -require 'spec_helper' +describe file('/etc/hypriot_release') do + it { should_not be_file } +end describe file('/etc/os-release') do it { should be_file } it { should be_owned_by 'root' } - its(:content) { should match 'HYPRIOT_OS="HypriotOS/arm64"' } - its(:content) { should match 'HYPRIOT_OS_VERSION="v0.7.2"' } - its(:content) { should match 'HYPRIOT_DEVICE="ODROID C2"' } - its(:content) { should match 'HYPRIOT_IMAGE_VERSION=' } + its(:content) { should contain /ID=debian/ } + its(:content) { should match /HYPRIOT_OS="HypriotOS\/arm64"/ } + its(:content) { should match /HYPRIOT_OS_VERSION="v1.0.0"/ } + its(:content) { should match /HYPRIOT_DEVICE="ODROID C2"/ } + its(:content) { should match /HYPRIOT_IMAGE_VERSION=/ } +end + +describe file('/boot/os-release') do + it { should be_file } + it { should be_owned_by 'root' } + its(:content) { should contain /ID=debian/ } + its(:content) { should match /HYPRIOT_OS="HypriotOS\/arm64"/ } + its(:content) { should match /HYPRIOT_OS_VERSION="v1.0.0"/ } + its(:content) { should match /HYPRIOT_DEVICE="ODROID C2"/ } + its(:content) { should match /HYPRIOT_IMAGE_VERSION=/ } end diff --git a/builder/test-integration/spec/hypriotos-image/base/users_spec.rb b/builder/test-integration/spec/hypriotos-image/base/users_spec.rb index ab6b8a2..bad0c7f 100644 --- a/builder/test-integration/spec/hypriotos-image/base/users_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/base/users_spec.rb @@ -1,15 +1,13 @@ -require 'spec_helper' - -describe group('docker') do - it { should exist } -end - describe user('root') do it { should exist } it { should have_home_directory '/root' } it { should have_login_shell '/bin/bash' } end +describe group('docker') do + it { should exist } +end + describe user('pirate') do it { should exist } it { should have_home_directory '/home/pirate' } @@ -36,22 +34,6 @@ its(:content) { should match /pirate ALL=NOPASSWD: ALL/ } end -describe file('/etc/skel/.bashrc') do - it { should be_file } - it { should be_mode 644 } - it { should be_owned_by 'root' } -end -describe file('/etc/skel/.bash_prompt') do - it { should be_file } - it { should be_mode 644 } - it { should be_owned_by 'root' } -end -describe file('/etc/skel/.profile') do - it { should be_file } - it { should be_mode 644 } - it { should be_owned_by 'root' } -end - describe file('/root/.bashrc') do it { should be_file } it { should be_mode 644 } @@ -62,11 +44,6 @@ it { should be_mode 644 } it { should be_owned_by 'root' } end -describe file('/root/.profile') do - it { should be_file } - it { should be_mode 644 } - it { should be_owned_by 'root' } -end describe file('/home/pirate/.bashrc') do it { should be_file } @@ -78,8 +55,3 @@ it { should be_mode 644 } it { should be_owned_by 'pirate' } end -describe file('/home/pirate/.profile') do - it { should be_file } - it { should be_mode 644 } - it { should be_owned_by 'pirate' } -end diff --git a/builder/test-integration/spec/hypriotos-image/cmdline_kernel_spec.rb b/builder/test-integration/spec/hypriotos-image/cmdline_kernel_spec.rb new file mode 100644 index 0000000..d91fbeb --- /dev/null +++ b/builder/test-integration/spec/hypriotos-image/cmdline_kernel_spec.rb @@ -0,0 +1,13 @@ +describe file('/boot/boot.ini') do + it { should be_file } + it { should be_mode 755 } + it { should be_owned_by 'root' } + its(:content) { should match /root=\/dev\/mmcblk0p2/ } + its(:content) { should match /rootfstype=ext4/ } + its(:content) { should match /cgroup_enable=memory/ } + its(:content) { should match /cgroup_enable=cpuset/ } + its(:content) { should match /swapaccount=1/ } + its(:content) { should match /elevator=deadline/ } + its(:content) { should match /fsck.repair=yes/ } + its(:content) { should match /rootwait/ } +end diff --git a/builder/test-integration/spec/hypriotos-image/device-init_spec.rb b/builder/test-integration/spec/hypriotos-image/device-init_spec.rb new file mode 100644 index 0000000..5c42f0b --- /dev/null +++ b/builder/test-integration/spec/hypriotos-image/device-init_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +describe package('device-init') do + it { should be_installed } +end + +describe command('dpkg -l device-init') do + its(:stdout) { should match /ii device-init/ } + its(:stdout) { should match /0.1.8/ } + its(:exit_status) { should eq 0 } +end + +describe file('/boot/device-init.yaml') do + it { should be_file } + its(:content) { should match /hostname: / } +end + +describe file('/usr/local/bin/device-init') do + it { should be_file } + it { should be_mode 755 } + it { should be_owned_by 'root' } +end + +# describe command('device-init --version') do +# its(:stdout) { should match /0.0.14/m } +# # its(:stderr) { should match /^$/ } +# its(:exit_status) { should eq 0 } +# end diff --git a/builder/test-integration/spec/hypriotos-image/docker-compose_spec.rb b/builder/test-integration/spec/hypriotos-image/docker-compose_spec.rb index 5a4b648..25e5fe3 100644 --- a/builder/test-integration/spec/hypriotos-image/docker-compose_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/docker-compose_spec.rb @@ -6,7 +6,7 @@ describe command('dpkg -l docker-compose') do its(:stdout) { should match /ii docker-compose/ } - its(:stdout) { should match /1.5.2-80/ } + its(:stdout) { should match /1.9.0-23/ } its(:exit_status) { should eq 0 } end @@ -17,6 +17,6 @@ end describe command('docker-compose --version') do - its(:stdout) { should match /1.5.2/m } + its(:stdout) { should match /1.9.0/m } its(:exit_status) { should eq 0 } end diff --git a/builder/test-integration/spec/hypriotos-image/docker-machine_spec.rb b/builder/test-integration/spec/hypriotos-image/docker-machine_spec.rb index 3615a0f..8f22afa 100644 --- a/builder/test-integration/spec/hypriotos-image/docker-machine_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/docker-machine_spec.rb @@ -6,7 +6,7 @@ describe command('dpkg -l docker-machine') do its(:stdout) { should match /ii docker-machine/ } - its(:stdout) { should match /0.4.1-72/ } + its(:stdout) { should match /0.9.0-39/ } its(:exit_status) { should eq 0 } end @@ -17,17 +17,6 @@ end describe command('docker-machine --version') do - its(:stdout) { should match /0.4.1/m } - its(:stderr) { should match /^$/ } + its(:stdout) { should match /0.9.0/m } its(:exit_status) { should eq 0 } end - -describe command('docker-machine create --help') do - its(:stdout) { should match /Available drivers:.*hypriot/ } - its(:stdout) { should match /--hypriot-ip-address/ } - its(:stdout) { should match /--hypriot-ssh-key/ } - its(:stdout) { should match /--hypriot-ssh-port/ } - its(:stdout) { should match /--hypriot-ssh-user/ } - its(:stderr) { should match /^$/ } - its(:exit_status) { should eq 0 } -end \ No newline at end of file diff --git a/builder/test-integration/spec/hypriotos-image/docker_spec.rb b/builder/test-integration/spec/hypriotos-image/docker_spec.rb index 89a71b1..b567196 100644 --- a/builder/test-integration/spec/hypriotos-image/docker_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/docker_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' -describe package('docker-hypriot') do +describe package('docker-engine') do it { should be_installed } end -describe command('dpkg -l docker-hypriot') do - its(:stdout) { should match /ii docker-hypriot/ } - its(:stdout) { should match /1.9.1-1/ } +describe command('dpkg -l docker-engine') do + its(:stdout) { should match /ii docker-engine/ } + its(:stdout) { should match /1.13.1-0~debian-jessie/ } its(:exit_status) { should eq 0 } end @@ -16,24 +16,56 @@ it { should be_owned_by 'root' } end -describe file('/usr/lib/docker/dockerinit') do +describe file('/usr/bin/docker-containerd') do it { should be_file } it { should be_mode 755 } it { should be_owned_by 'root' } end -describe file('/etc/init.d/docker') do - it { should_not exist } +describe file('/usr/bin/docker-containerd-ctr') do + it { should be_file } + it { should be_mode 755 } + it { should be_owned_by 'root' } +end + +describe file('/usr/bin/docker-containerd-shim') do + it { should be_file } + it { should be_mode 755 } + it { should be_owned_by 'root' } +end + +describe file('/usr/bin/docker-runc') do + it { should be_file } + it { should be_mode 755 } + it { should be_owned_by 'root' } +end + +describe file('/lib/systemd/system/docker.socket') do + it { should be_file } + it { should be_mode 644 } + it { should be_owned_by 'root' } +end + +describe file('/var/run/docker.sock') do + it { should be_socket } + it { should be_mode 660 } + it { should be_owned_by 'root' } + it { should be_grouped_into 'docker' } end describe file('/etc/default/docker') do it { should be_file } it { should be_mode 644 } it { should be_owned_by 'root' } - its(:content) { should match /--storage-driver=aufs/ } end describe file('/var/lib/docker') do + it { should be_directory } + it { should be_mode 711 } + it { should be_owned_by 'root' } +end + +describe file('/var/lib/docker/overlay') do it { should be_directory } it { should be_mode 700 } it { should be_owned_by 'root' } @@ -41,24 +73,24 @@ describe file('/etc/bash_completion.d/docker') do it { should be_file } - it { should be_mode 755 } + it { should be_mode 644 } it { should be_owned_by 'root' } it { should be_file } end describe command('docker -v') do - its(:stdout) { should match /Docker version 1.9.1, build/ } + its(:stdout) { should match /Docker version 1.13.1, build/ } its(:exit_status) { should eq 0 } end describe command('docker version') do - its(:stdout) { should match /Client:. Version: 1.9.1. API version: 1.21/m } - its(:stdout) { should match /Server:. Version: 1.9.1. API version: 1.21/m } + its(:stdout) { should match /Client:. Version: 1.13.1. API version: 1.26/m } + its(:stdout) { should match /Server:. Version: 1.13.1. API version: 1.26/m } its(:exit_status) { should eq 0 } end describe command('docker info') do - its(:stdout) { should match /Storage Driver: aufs/ } + its(:stdout) { should match /Storage Driver: overlay/ } its(:exit_status) { should eq 0 } end diff --git a/builder/test-integration/spec/hypriotos-image/filesystems_spec.rb b/builder/test-integration/spec/hypriotos-image/filesystems_spec.rb index c51dc01..2d230f2 100644 --- a/builder/test-integration/spec/hypriotos-image/filesystems_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/filesystems_spec.rb @@ -1,6 +1,9 @@ -require 'spec_helper' - Specinfra::Runner.run_command('modprobe btrfs') describe kernel_module('btrfs') do it { should be_loaded } end + +Specinfra::Runner.run_command('modprobe overlay') +describe kernel_module('overlay') do + it { should be_loaded } +end diff --git a/builder/test-integration/spec/hypriotos-image/hypriot-list_spec.rb b/builder/test-integration/spec/hypriotos-image/hypriot-list_spec.rb index d71b944..87b7d99 100644 --- a/builder/test-integration/spec/hypriotos-image/hypriot-list_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/hypriot-list_spec.rb @@ -1,20 +1,12 @@ require 'spec_helper' -describe package('apt-transport-https') do - it { should be_installed } -end - describe file('/etc/apt/sources.list.d/hypriot.list') do it { should be_file } it { should be_mode 644 } it { should be_owned_by 'root' } - it { should contain 'deb https://packagecloud.io/Hypriot/Schatzkiste/debian/ wheezy main' } + it { should contain 'deb https://packagecloud.io/Hypriot/Schatzkiste/debian/ jessie main' } end -describe file('/etc/apt/sources.list.d/odroid.list') do - it { should be_file } - it { should be_mode 644 } - it { should be_owned_by 'root' } - it { should contain 'deb http://deb.odroid.in/c2/ trusty main' } - it { should contain 'deb http://deb.odroid.in/ trusty main' } +describe package('apt-transport-https') do + it { should be_installed } end diff --git a/builder/test-integration/spec/hypriotos-image/kernel_config_spec.rb b/builder/test-integration/spec/hypriotos-image/kernel_config_spec.rb deleted file mode 100644 index 6d4bc32..0000000 --- a/builder/test-integration/spec/hypriotos-image/kernel_config_spec.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'spec_helper' - -Specinfra::Runner.run_command('modprobe configs') - -describe command('zcat /proc/config.gz') do -# its(:stdout) { should match /CONFIG_KPROBES=y/ } -# its(:stdout) { should match /CONFIG_UPROBES=y/ } - its(:stdout) { should match /CONFIG_HAVE_KPROBES=y/ } -# its(:stdout) { should match /CONFIG_EVENT_TRACING=y/ } -# its(:stdout) { should match /CONFIG_KPROBE_EVENT=y/ } -# its(:stdout) { should match /CONFIG_UPROBE_EVENT=y/ } -# its(:stdout) { should match /CONFIG_PROBE_EVENTS=y/ } - its(:stdout) { should match /CONFIG_FTRACE=y/ } -# its(:stdout) { should match /CONFIG_FTRACE_SYSCALLS=y/ } -# its(:stdout) { should match /CONFIG_DYNAMIC_FTRACE=y/ } - its(:stdout) { should match /CONFIG_HAVE_DYNAMIC_FTRACE=y/ } - - # Docker specific kernel settings (see https://github.com/docker/docker/blob/master/contrib/check-config.sh) - ## Generally Necessary: - its(:stdout) { should match /CONFIG_NAMESPACES=y/ } - its(:stdout) { should match /CONFIG_NET_NS=y/ } - its(:stdout) { should match /CONFIG_PID_NS=y/ } - its(:stdout) { should match /CONFIG_IPC_NS=y/ } - its(:stdout) { should match /CONFIG_UTS_NS=y/ } - its(:stdout) { should match /CONFIG_DEVPTS_MULTIPLE_INSTANCES=y/ } - its(:stdout) { should match /CONFIG_CGROUPS=y/ } - its(:stdout) { should match /CONFIG_CGROUP_CPUACCT=y/ } - its(:stdout) { should match /CONFIG_CGROUP_DEVICE=y/ } - its(:stdout) { should match /CONFIG_CGROUP_FREEZER=y/ } - its(:stdout) { should match /CONFIG_CGROUP_SCHED=y/ } - its(:stdout) { should match /CONFIG_CPUSETS=y/ } - its(:stdout) { should match /CONFIG_MEMCG=y/ } - its(:stdout) { should match /CONFIG_MACVLAN=m/ } - its(:stdout) { should match /CONFIG_VETH=m/ } - its(:stdout) { should match /CONFIG_BRIDGE=y/ } - its(:stdout) { should match /CONFIG_BRIDGE_NETFILTER=y/ } - its(:stdout) { should match /CONFIG_NF_NAT_IPV4=m/ } - its(:stdout) { should match /CONFIG_IP_NF_FILTER=m/ } - its(:stdout) { should match /CONFIG_IP_NF_TARGET_MASQUERADE=m/ } - its(:stdout) { should match /CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=m/ } - its(:stdout) { should match /CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m/ } - its(:stdout) { should match /CONFIG_NF_NAT=m/ } - its(:stdout) { should match /CONFIG_NF_NAT_NEEDED=y/ } - its(:stdout) { should match /CONFIG_POSIX_MQUEUE=y/ } - - ## Optional Features: - its(:stdout) { should match /CONFIG_USER_NS=y/ } -# its(:stdout) { should match /CONFIG_SECCOMP=y/ } -# its(:stdout) { should match /CONFIG_MEMCG_KMEM=y/ } - its(:stdout) { should match /CONFIG_MEMCG_SWAP=y/ } - its(:stdout) { should match /CONFIG_MEMCG_SWAP_ENABLED=y/ } - its(:stdout) { should match /CONFIG_RESOURCE_COUNTERS=y/ } - its(:stdout) { should match /CONFIG_BLK_CGROUP=y/ } - its(:stdout) { should match /CONFIG_IOSCHED_CFQ=y/ } -# its(:stdout) { should match /CONFIG_BLK_DEV_THROTTLING=y/ } - its(:stdout) { should match /CONFIG_CGROUP_PERF=y/ } - #its(:stdout) { should match /CONFIG_CGROUP_HUGETLB=y/ } - its(:stdout) { should match /CONFIG_NET_CLS_CGROUP=m/ } -# its(:stdout) { should match /CONFIG_NETPRIO_CGROUP=y/ } - its(:stdout) { should match /CONFIG_CFS_BANDWIDTH=y/ } - its(:stdout) { should match /CONFIG_FAIR_GROUP_SCHED=y/ } - its(:stdout) { should match /CONFIG_RT_GROUP_SCHED=y/ } -# its(:stdout) { should match /CONFIG_EXT3_FS=y/ } -# its(:stdout) { should match /CONFIG_EXT3_FS_XATTR=y/ } -# its(:stdout) { should match /CONFIG_EXT3_FS_POSIX_ACL=y/ } -# its(:stdout) { should match /CONFIG_EXT3_FS_SECURITY=y/ } - its(:stdout) { should match /CONFIG_EXT4_FS=y/ } - its(:stdout) { should match /CONFIG_EXT4_FS_POSIX_ACL=y/ } - its(:stdout) { should match /CONFIG_EXT4_FS_SECURITY=y/ } - - ## Storage Drivers: - its(:stdout) { should match /CONFIG_AUFS_FS=y/ } - its(:stdout) { should match /CONFIG_BTRFS_FS=m/ } - its(:stdout) { should match /CONFIG_BLK_DEV_DM=y/ } - its(:stdout) { should match /CONFIG_DM_THIN_PROVISIONING=m/ } -# its(:stdout) { should match /CONFIG_OVERLAY_FS=m/ } - its(:exit_status) { should eq 0 } -end diff --git a/builder/test-integration/spec/hypriotos-image/kernel_modules_spec.rb b/builder/test-integration/spec/hypriotos-image/kernel_modules_spec.rb new file mode 100644 index 0000000..e69de29 diff --git a/builder/test-integration/spec/hypriotos-image/odroid-list_spec.rb b/builder/test-integration/spec/hypriotos-image/odroid-list_spec.rb new file mode 100644 index 0000000..dfcb83d --- /dev/null +++ b/builder/test-integration/spec/hypriotos-image/odroid-list_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +describe file('/etc/apt/sources.list.d/odroid.list') do + it { should be_file } + it { should be_mode 644 } + it { should be_owned_by 'root' } + it { should contain 'deb http://deb.odroid.in/c2/ xenial main' } +end diff --git a/builder/test/image_spec.rb b/builder/test/image_spec.rb index 48fca75..8112d74 100644 --- a/builder/test/image_spec.rb +++ b/builder/test/image_spec.rb @@ -9,13 +9,29 @@ context "Partition table" do let(:stdout) { run("list-filesystems").stdout } - it "has one partition" do + it "has two partitions" do partitions = stdout.split(/\r?\n/) - expect(partitions.size).to be 1 + expect(partitions.size).to be 2 + end + + it "has a boot-partition with a vfat filesystem" do + expect(stdout).to contain('sda1: vfat') end it "has a root-partition with a ext4 filesystem" do - expect(stdout).to contain('sda1: ext4') + expect(stdout).to contain('sda2: ext4') end end + + context "/etc/fstab" do + let(:stdout) { run_mounted("cat /etc/fstab").stdout } + + it "has a vfat boot entry" do + expect(stdout).to contain('/dev/mmcblk0p1 /boot vfat') + end + + it "has a ext4 root entry" do + expect(stdout).to contain('/dev/mmcblk0p2 / ext4') + end +end end diff --git a/builder/test/os-release_spec.rb b/builder/test/os-release_spec.rb index f5afeb4..811ac4f 100644 --- a/builder/test/os-release_spec.rb +++ b/builder/test/os-release_spec.rb @@ -36,8 +36,8 @@ expect(stdout).to contain('HYPRIOT_DEVICE="ODROID C2') end - it "uses os-rootfs version 'HYPRIOT_OS_VERSION=\"v0.7.2\"'" do - expect(stdout).to contain('^HYPRIOT_OS_VERSION="v0.7.2"$') + it "uses os-rootfs version 'HYPRIOT_OS_VERSION=\"v1.0.0\"'" do + expect(stdout).to contain('^HYPRIOT_OS_VERSION="v1.0.0"$') end if ENV.fetch('TRAVIS_TAG','') != '' diff --git a/builder/test/spec_helper.rb b/builder/test/spec_helper.rb index f9c7c9a..7f7179e 100644 --- a/builder/test/spec_helper.rb +++ b/builder/test/spec_helper.rb @@ -10,5 +10,5 @@ def run( cmd ) end def run_mounted( cmd ) - return run("mount /dev/sda1 / : #{cmd}") + return run("mount /dev/sda2 / : #{cmd}") end diff --git a/versions.config b/versions.config new file mode 100644 index 0000000..1380424 --- /dev/null +++ b/versions.config @@ -0,0 +1,18 @@ +# config vars for the root file system +HYPRIOT_OS_VERSION="v1.0.0" +ROOTFS_TAR_CHECKSUM="bc76226e56fb502d35dc22c182f5db8bf22222ded954a7961eed444afc4c26da" + +# name of the ready made raw image for Odroid +RAW_IMAGE="odroid-raw.img" +RAW_IMAGE_VERSION="v0.2.2" +RAW_IMAGE_CHECKSUM="fe9af7686960d5d2dd6c364197e196d751f6adedd7da515ed6521c31e9582f8a" + +# specific versions of kernel/firmware and docker tools +# export KERNEL_BUILD="20161218-142852" +# export KERNEL_VERSION="4.4.39" +# export DOCKER_VERSION="1.13.1" +export DOCKER_DEB_URL="https://github.com/DieterReuter/docker-armbuilds/releases/download/v1.13.1/docker-engine_1.13.1-0.debian-jessie_arm64.deb" +export DOCKER_DEB_CHECKSUM="dd7875ee1f62a9784c96cf22cd3dedbe61704ac5c2e054d6cfc914ac0e48de77" +export DOCKER_COMPOSE_VERSION="1.9.0-23" +export DOCKER_MACHINE_VERSION="0.9.0-39" +export DEVICE_INIT_VERSION="0.1.8" From 56d59b6641325d9aa13a9f67b0e268d939b1c503 Mon Sep 17 00:00:00 2001 From: Boris Pruessmann Date: Mon, 27 Feb 2017 23:45:14 +0100 Subject: [PATCH 2/2] Updated os-rootfs to v1.1.1 --- .gitignore | 1 + .../etc/systemd/system/docker.service.d/10-execstart.conf | 3 --- .../spec/hypriotos-image/base/kernel_spec.rb | 2 +- .../spec/hypriotos-image/base/release_spec.rb | 4 ++-- builder/test/os-release_spec.rb | 4 ++-- versions.config | 8 +++----- 6 files changed, 9 insertions(+), 13 deletions(-) delete mode 100644 builder/files/etc/systemd/system/docker.service.d/10-execstart.conf diff --git a/.gitignore b/.gitignore index 5ee9ad1..517406c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.img *.img.zip +*.img.zip.sha256 *.tar.gz *.xz .vagrant/ diff --git a/builder/files/etc/systemd/system/docker.service.d/10-execstart.conf b/builder/files/etc/systemd/system/docker.service.d/10-execstart.conf deleted file mode 100644 index 38ab466..0000000 --- a/builder/files/etc/systemd/system/docker.service.d/10-execstart.conf +++ /dev/null @@ -1,3 +0,0 @@ -[Service] -ExecStart= -ExecStart=/usr/bin/docker daemon -H fd:// --log-driver=journald --storage-driver=overlay --icc=false --iptables=true diff --git a/builder/test-integration/spec/hypriotos-image/base/kernel_spec.rb b/builder/test-integration/spec/hypriotos-image/base/kernel_spec.rb index 54a4d29..768dcc4 100644 --- a/builder/test-integration/spec/hypriotos-image/base/kernel_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/base/kernel_spec.rb @@ -5,6 +5,6 @@ its(:exit_status) { should eq 0 } end -describe file('/lib/modules/3.14.79-105/kernel') do +describe file('/lib/modules/3.14.79-107/kernel') do it { should be_directory } end diff --git a/builder/test-integration/spec/hypriotos-image/base/release_spec.rb b/builder/test-integration/spec/hypriotos-image/base/release_spec.rb index b8ad6a9..fb6fdf8 100644 --- a/builder/test-integration/spec/hypriotos-image/base/release_spec.rb +++ b/builder/test-integration/spec/hypriotos-image/base/release_spec.rb @@ -7,7 +7,7 @@ it { should be_owned_by 'root' } its(:content) { should contain /ID=debian/ } its(:content) { should match /HYPRIOT_OS="HypriotOS\/arm64"/ } - its(:content) { should match /HYPRIOT_OS_VERSION="v1.0.0"/ } + its(:content) { should match /HYPRIOT_OS_VERSION="v1.1.1"/ } its(:content) { should match /HYPRIOT_DEVICE="ODROID C2"/ } its(:content) { should match /HYPRIOT_IMAGE_VERSION=/ } end @@ -17,7 +17,7 @@ it { should be_owned_by 'root' } its(:content) { should contain /ID=debian/ } its(:content) { should match /HYPRIOT_OS="HypriotOS\/arm64"/ } - its(:content) { should match /HYPRIOT_OS_VERSION="v1.0.0"/ } + its(:content) { should match /HYPRIOT_OS_VERSION="v1.1.1"/ } its(:content) { should match /HYPRIOT_DEVICE="ODROID C2"/ } its(:content) { should match /HYPRIOT_IMAGE_VERSION=/ } end diff --git a/builder/test/os-release_spec.rb b/builder/test/os-release_spec.rb index 811ac4f..e1e3f07 100644 --- a/builder/test/os-release_spec.rb +++ b/builder/test/os-release_spec.rb @@ -36,8 +36,8 @@ expect(stdout).to contain('HYPRIOT_DEVICE="ODROID C2') end - it "uses os-rootfs version 'HYPRIOT_OS_VERSION=\"v1.0.0\"'" do - expect(stdout).to contain('^HYPRIOT_OS_VERSION="v1.0.0"$') + it "uses os-rootfs version 'HYPRIOT_OS_VERSION=\"v1.1.1\"'" do + expect(stdout).to contain('^HYPRIOT_OS_VERSION="v1.1.1"$') end if ENV.fetch('TRAVIS_TAG','') != '' diff --git a/versions.config b/versions.config index 1380424..0fad4c7 100644 --- a/versions.config +++ b/versions.config @@ -1,6 +1,6 @@ # config vars for the root file system -HYPRIOT_OS_VERSION="v1.0.0" -ROOTFS_TAR_CHECKSUM="bc76226e56fb502d35dc22c182f5db8bf22222ded954a7961eed444afc4c26da" +HYPRIOT_OS_VERSION="v1.1.1" +ROOTFS_TAR_CHECKSUM="5698b4f7363316d25ce735024836b499a4306802518b81d7231d457bbefd4f53" # name of the ready made raw image for Odroid RAW_IMAGE="odroid-raw.img" @@ -8,9 +8,7 @@ RAW_IMAGE_VERSION="v0.2.2" RAW_IMAGE_CHECKSUM="fe9af7686960d5d2dd6c364197e196d751f6adedd7da515ed6521c31e9582f8a" # specific versions of kernel/firmware and docker tools -# export KERNEL_BUILD="20161218-142852" -# export KERNEL_VERSION="4.4.39" -# export DOCKER_VERSION="1.13.1" +# export KERNEL_VERSION="107-1" export DOCKER_DEB_URL="https://github.com/DieterReuter/docker-armbuilds/releases/download/v1.13.1/docker-engine_1.13.1-0.debian-jessie_arm64.deb" export DOCKER_DEB_CHECKSUM="dd7875ee1f62a9784c96cf22cd3dedbe61704ac5c2e054d6cfc914ac0e48de77" export DOCKER_COMPOSE_VERSION="1.9.0-23"