From f655d5f14b2716262c99a0396c01f46619ae893e Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Mon, 20 Jan 2020 15:09:26 +0100 Subject: [PATCH] Add docker-image in order to launch a base system capable of running docker daemon --- buildconf/bananapi-m3/conf-notes.txt | 1 + buildconf/bananapi-m3/local.conf.sample | 2 +- .../beaglebone-yocto/bblayers.conf.sample | 5 +- buildconf/beaglebone-yocto/conf-notes.txt | 2 + buildconf/beaglebone-yocto/local.conf.sample | 2 +- buildconf/raspberrypi3-64/conf-notes.txt | 1 + buildconf/raspberrypi3-64/local.conf.sample | 2 +- conf/distro/roro.conf | 18 +++ conf/distro/tkl.conf | 15 -- .../docker/docker-ce_git.bbappend | 7 + recipes-containers/docker/files/docker.init | 131 ++++++++++++++++++ recipes-core/images/docker-image.bb | 10 ++ recipes-core/images/tiny-image-base.inc | 48 +++++++ recipes-core/images/tiny-image.bb | 8 ++ recipes-core/images/users.inc | 8 ++ .../files/beaglebone-yocto/enable_cgroups.cfg | 4 + recipes-kernel/linux/linux-yocto_5.2.bbappend | 1 + 17 files changed, 246 insertions(+), 19 deletions(-) create mode 100644 conf/distro/roro.conf delete mode 100644 conf/distro/tkl.conf create mode 100644 recipes-containers/docker/docker-ce_git.bbappend create mode 100644 recipes-containers/docker/files/docker.init create mode 100644 recipes-core/images/docker-image.bb create mode 100644 recipes-core/images/tiny-image-base.inc create mode 100644 recipes-core/images/tiny-image.bb create mode 100644 recipes-core/images/users.inc create mode 100644 recipes-kernel/linux/files/beaglebone-yocto/enable_cgroups.cfg diff --git a/buildconf/bananapi-m3/conf-notes.txt b/buildconf/bananapi-m3/conf-notes.txt index 5759f0d..df80596 100644 --- a/buildconf/bananapi-m3/conf-notes.txt +++ b/buildconf/bananapi-m3/conf-notes.txt @@ -1,6 +1,7 @@ Common targets are: console-image console-dev-image + tiny-image core-image-minimal core-image-sato meta-toolchain diff --git a/buildconf/bananapi-m3/local.conf.sample b/buildconf/bananapi-m3/local.conf.sample index f73d44b..ce418bd 100644 --- a/buildconf/bananapi-m3/local.conf.sample +++ b/buildconf/bananapi-m3/local.conf.sample @@ -4,7 +4,7 @@ MACHINE ?= "bananapi-m3" #SSTATE_DIR ?= "${TOPDIR}/../../sstate-cache" #TMPDIR = "${TOPDIR}/tmp" -DISTRO ?= "poky" +DISTRO ?= "roro" PACKAGE_CLASSES ?= "package_ipk" #SDKMACHINE ?= "i686" diff --git a/buildconf/beaglebone-yocto/bblayers.conf.sample b/buildconf/beaglebone-yocto/bblayers.conf.sample index 2604ba7..5574c58 100644 --- a/buildconf/beaglebone-yocto/bblayers.conf.sample +++ b/buildconf/beaglebone-yocto/bblayers.conf.sample @@ -1,6 +1,6 @@ # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf # changes incompatibly -POKY_BBLAYERS_CONF_VERSION = "2" +POKY_BBLAYERS_CONF_VERSION = "3" BBPATH = "${TOPDIR}" BBFILES ?= "" @@ -9,8 +9,11 @@ BBLAYERS ?= " \ ${TOPDIR}/../layers/poky/meta \ ${TOPDIR}/../layers/poky/meta-poky \ ${TOPDIR}/../layers/poky/meta-yocto-bsp \ + ${TOPDIR}/../layers/meta-openembedded/meta-filesystems \ ${TOPDIR}/../layers/meta-openembedded/meta-oe \ ${TOPDIR}/../layers/meta-openembedded/meta-networking \ ${TOPDIR}/../layers/meta-openembedded/meta-python \ + ${TOPDIR}/../layers/meta-virtualization \ ${TOPDIR}/../layers/meta-blackfinn \ " + diff --git a/buildconf/beaglebone-yocto/conf-notes.txt b/buildconf/beaglebone-yocto/conf-notes.txt index 5759f0d..c24917c 100644 --- a/buildconf/beaglebone-yocto/conf-notes.txt +++ b/buildconf/beaglebone-yocto/conf-notes.txt @@ -1,6 +1,8 @@ Common targets are: console-image console-dev-image + docker-image + tiny-image core-image-minimal core-image-sato meta-toolchain diff --git a/buildconf/beaglebone-yocto/local.conf.sample b/buildconf/beaglebone-yocto/local.conf.sample index b7fd35e..229fe51 100644 --- a/buildconf/beaglebone-yocto/local.conf.sample +++ b/buildconf/beaglebone-yocto/local.conf.sample @@ -4,7 +4,7 @@ MACHINE ?= "beaglebone-yocto" #SSTATE_DIR ?= "${TOPDIR}/../../sstate-cache" #TMPDIR = "${TOPDIR}/tmp" -DISTRO ?= "poky" +DISTRO ?= "roro" PACKAGE_CLASSES ?= "package_ipk" #SDKMACHINE ?= "i686" diff --git a/buildconf/raspberrypi3-64/conf-notes.txt b/buildconf/raspberrypi3-64/conf-notes.txt index 5759f0d..df80596 100644 --- a/buildconf/raspberrypi3-64/conf-notes.txt +++ b/buildconf/raspberrypi3-64/conf-notes.txt @@ -1,6 +1,7 @@ Common targets are: console-image console-dev-image + tiny-image core-image-minimal core-image-sato meta-toolchain diff --git a/buildconf/raspberrypi3-64/local.conf.sample b/buildconf/raspberrypi3-64/local.conf.sample index e3407a1..f0e4959 100644 --- a/buildconf/raspberrypi3-64/local.conf.sample +++ b/buildconf/raspberrypi3-64/local.conf.sample @@ -1,6 +1,6 @@ MACHINE ?= "raspberrypi3-64" -DISTRO ?= "poky" +DISTRO ?= "roro" PACKAGE_CLASSES ?= "package_ipk" #SDKMACHINE ?= "i686" diff --git a/conf/distro/roro.conf b/conf/distro/roro.conf new file mode 100644 index 0000000..da50503 --- /dev/null +++ b/conf/distro/roro.conf @@ -0,0 +1,18 @@ +require conf/distro/poky.conf +# distro name +DISTRO = "roro" +DISTRO_NAME = "roro distribution" +DISTRO_VERSION = "1.0" +DISTRO_CODENAME = "roro" +#DISTRO_FEATURES_append = " alsa usbhost usbgadget keyboard bluetooth" + +POKY_DEFAULT_DISTRO_FEATURES = "largefile" +POKY_DEFAULT_EXTRA_RDEPENDS = "packagegroup-core-boot" +POKY_DEFAULT_EXTRA_RRECOMMENDS = "kernel-module-af-packet" +DISTRO_FEATURES_DEFAULT = "ipv4 ipv6 largefile usbhost wifi zeroconf virtualization" + +SDK_VENDOR = "-rorodistsdk" +SDK_VERSION := "${@'${DISTRO_VERSION}'.replace('snapshot-${DATE}','snapshot')}" +MAINTAINER = "rorodist " +INHERIT += "buildhistory" +BUILDHISTORY_COMMIT = "1" diff --git a/conf/distro/tkl.conf b/conf/distro/tkl.conf deleted file mode 100644 index 960e2df..0000000 --- a/conf/distro/tkl.conf +++ /dev/null @@ -1,15 +0,0 @@ -require conf/distro/poky.conf -# distro name -DISTRO = "tkl" -DISTRO_NAME = "tkl distribution" -DISTRO_VERSION = "1.0" -DISTRO_CODENAME = "tkl" -#DISTRO_FEATURES_append = " alsa usbhost usbgadget keyboard bluetooth" - -PREFERRED_VERSION_mypy = "0.4.2" - -SDK_VENDOR = "-tkldistsdk" -SDK_VERSION := "${@'${DISTRO_VERSION}'.replace('snapshot-${DATE}','snapshot')}" -MAINTAINER = "tkldist " -INHERIT += "buildhistory" -BUILDHISTORY_COMMIT = "1" diff --git a/recipes-containers/docker/docker-ce_git.bbappend b/recipes-containers/docker/docker-ce_git.bbappend new file mode 100644 index 0000000..89cf576 --- /dev/null +++ b/recipes-containers/docker/docker-ce_git.bbappend @@ -0,0 +1,7 @@ +LICENSE = "GPLv2" +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += " \ + file://docker.init \ +" + diff --git a/recipes-containers/docker/files/docker.init b/recipes-containers/docker/files/docker.init new file mode 100644 index 0000000..d4b6a88 --- /dev/null +++ b/recipes-containers/docker/files/docker.init @@ -0,0 +1,131 @@ +#!/bin/sh +# +# /etc/rc.d/init.d/docker +# +# Daemon for docker.com +# +# chkconfig: 2345 95 95 +# description: Daemon for docker.com + +### BEGIN INIT INFO +# Provides: docker +# Required-Start: $network cgconfig +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: start and stop docker +# Description: Daemon for docker.com +### END INIT INFO + +# Source function library. +. /etc/init.d/functions + +prog="dockerd" +unshare=/usr/bin/unshare +exec="/usr/bin/$prog" +pidfile="/var/run/$prog.pid" +lockfile="/var/lock/subsys/$prog" +logfile="/var/log/$prog" +other_args="--pidfile $pidfile --registry-mirror=http://localhost:5000 --insecure-registry=http://localhost:5000 --raw-logs" + +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +start() { + [ -x $exec ] || exit 5 + + check_for_cleanup + + if ! [ -f $pidfile ]; then + printf "Starting $prog:\t" + echo -e "\n$(date)\n" >> $logfile + "$unshare" -m -- $exec $other_args & >> $logfile & + pid=$! + touch $lockfile + # wait up to 10 seconds for the pidfile to exist. see + # https://github.com/docker/docker/issues/5359 + tries=0 + while [ ! -f $pidfile -a $tries -lt 10 ]; do + sleep 1 + tries=$((tries + 1)) + done + success + echo + else + failure + echo + printf "$pidfile still exists...\n" + exit 7 + fi +} + +stop() { + echo -n $"Stopping $prog: " + killproc $prog + retval=$? + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + stop + start +} + +reload() { + restart +} + +force_reload() { + restart +} + +rh_status() { + status $prog +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + + +check_for_cleanup() { + if [ -f ${pidfile} ]; then + /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile} + fi +} + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 +esac + +exit $? diff --git a/recipes-core/images/docker-image.bb b/recipes-core/images/docker-image.bb new file mode 100644 index 0000000..5386270 --- /dev/null +++ b/recipes-core/images/docker-image.bb @@ -0,0 +1,10 @@ +SUMMARY = "A tiny image" +HOMEPAGE = "https://blackfinn.de" +LICENSE = "MIT" + +require tiny-image-base.inc + +IMAGE_INSTALL_append = " docker" + +export IMAGE_BASENAME = "tiny-image" + diff --git a/recipes-core/images/tiny-image-base.inc b/recipes-core/images/tiny-image-base.inc new file mode 100644 index 0000000..16786b0 --- /dev/null +++ b/recipes-core/images/tiny-image-base.inc @@ -0,0 +1,48 @@ +inherit core-image + +require users.inc + +IMAGE_FEATURES += "package-management" + +CORE_OS = " \ + openssh \ + openssh-keygen \ + openssh-sftp-server \ + psplash \ + tzdata \ +" + +KERNEL_EXTRA_INSTALL = " \ + kernel-modules \ +" + +WIFI_SUPPORT = " \ + wpa-supplicant \ +" + +EXTRA_TOOLS_INSTALL = " \ +" + +IMAGE_INSTALL += " \ + ${CORE_OS} \ + ${EXTRA_TOOLS_INSTALL} \ + ${KERNEL_EXTRA_INSTALL} \ + ${WIFI_SUPPORT} \ +" + +IMAGE_INSTALL_append_beaglebone-yocto = " linux-firmware-rtl8192cu" +IMAGE_INSTALL_append_bananapi-m3 += " linux-firmware-bcm43430" + +set_local_timezone() { + ln -sf /usr/share/zoneinfo/Europe/Berlin ${IMAGE_ROOTFS}/etc/localtime +} + +disable_bootlogd() { + echo BOOTLOGD_ENABLE=no > ${IMAGE_ROOTFS}/etc/default/bootlogd +} + +ROOTFS_POSTPROCESS_COMMAND += " \ + set_local_timezone ; \ + disable_bootlogd ; \ + " + diff --git a/recipes-core/images/tiny-image.bb b/recipes-core/images/tiny-image.bb new file mode 100644 index 0000000..364e5eb --- /dev/null +++ b/recipes-core/images/tiny-image.bb @@ -0,0 +1,8 @@ +SUMMARY = "A tiny image" +HOMEPAGE = "https://blackfinn.de" +LICENSE = "MIT" + +require tiny-image-base.inc + +export IMAGE_BASENAME = "tiny-image" + diff --git a/recipes-core/images/users.inc b/recipes-core/images/users.inc new file mode 100644 index 0000000..0894f1b --- /dev/null +++ b/recipes-core/images/users.inc @@ -0,0 +1,8 @@ +inherit extrausers + +# Encrypt the password with: echo "" | openssl passwd -1 -stdin +EXTRA_USERS_PARAMS = " \ + usermod -p '\$1\$4h5Qdc3i\$Vke4J2Ci5z.D3TtFDmV9r/' root; \ + useradd -p '\$1\$4h5Qdc3i\$Vke4J2Ci5z.D3TtFDmV9r/' tkl; \ +" + diff --git a/recipes-kernel/linux/files/beaglebone-yocto/enable_cgroups.cfg b/recipes-kernel/linux/files/beaglebone-yocto/enable_cgroups.cfg new file mode 100644 index 0000000..663ab12 --- /dev/null +++ b/recipes-kernel/linux/files/beaglebone-yocto/enable_cgroups.cfg @@ -0,0 +1,4 @@ +CONFIG_DEBUG_BLK_CGROUP=y +CONFIG_CFS_BANDWIDTH=y +CONFIG_CGROUP_RDMA=y + diff --git a/recipes-kernel/linux/linux-yocto_5.2.bbappend b/recipes-kernel/linux/linux-yocto_5.2.bbappend index 1af34f6..dae764d 100644 --- a/recipes-kernel/linux/linux-yocto_5.2.bbappend +++ b/recipes-kernel/linux/linux-yocto_5.2.bbappend @@ -14,5 +14,6 @@ KERNEL_CONFIG_FRAGMENTS_append_ti33x = " \ ${WORKDIR}/rtl8192cu.cfg \ ${WORKDIR}/enable_onboard_leds.cfg \ ${WORKDIR}/enable_hostap_wext.cfg \ + ${WORKDIR}/enable_cgroups.cfg \ "