diff options
3 files changed, 282 insertions, 0 deletions
diff --git a/recipes-core/runx/runx/0001-make-initrd-cross-install-tweaks.patch b/recipes-core/runx/runx/0001-make-initrd-cross-install-tweaks.patch new file mode 100644 index 00000000..c9fdc5d6 --- /dev/null +++ b/recipes-core/runx/runx/0001-make-initrd-cross-install-tweaks.patch | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | From d8bd5749e6fc6e0c86a8720044ec78167bab3569 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Bruce Ashfield <bruce.ashfield@xilinx.com> | ||
| 3 | Date: Mon, 16 Dec 2019 22:03:14 -0800 | ||
| 4 | Subject: [PATCH] make-initrd: cross install tweaks | ||
| 5 | |||
| 6 | Signed-off-by: Bruce Ashfield <bruce.ashfield@xilinx.com> | ||
| 7 | --- | ||
| 8 | kernel/make-initrd | 18 ++++++++++++++++-- | ||
| 9 | 1 file changed, 16 insertions(+), 2 deletions(-) | ||
| 10 | |||
| 11 | diff --git a/kernel/make-initrd b/kernel/make-initrd | ||
| 12 | index 4c299dc..9ef386f 100755 | ||
| 13 | --- a/kernel/make-initrd | ||
| 14 | +++ b/kernel/make-initrd | ||
| 15 | @@ -16,8 +16,22 @@ mkdir -p $tmpdir/sys | ||
| 16 | mkdir -p $tmpdir/lib | ||
| 17 | mkdir -p $tmpdir/var | ||
| 18 | mkdir -p $tmpdir/mnt | ||
| 19 | -cp `which busybox` $tmpdir/bin | ||
| 20 | -$tmpdir/bin/busybox --install $tmpdir/bin | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +if [ -z "$BUSYBOX" ]; then | ||
| 24 | + BUSYBOX=`which busybox` | ||
| 25 | +fi | ||
| 26 | +cp $BUSYBOX $tmpdir/bin | ||
| 27 | +if [ -n "$CROSS_COMPILE" ]; then | ||
| 28 | + echo "cross compiling, busybox --install emulation" | ||
| 29 | + if [ -n "$QEMU_USER" ]; then | ||
| 30 | + $QEMU_USER $tmpdir/bin/busybox --install $tmpdir/bin | ||
| 31 | + else | ||
| 32 | + echo "QEMU_USER is not defined, no binary symlinks will be available" | ||
| 33 | + fi | ||
| 34 | +else | ||
| 35 | + $tmpdir/bin/busybox --install $tmpdir/bin | ||
| 36 | +fi | ||
| 37 | |||
| 38 | cp $init $tmpdir/init | ||
| 39 | chmod +x $tmpdir/init | ||
| 40 | -- | ||
| 41 | 2.17.1 | ||
| 42 | |||
diff --git a/recipes-core/runx/runx/0001-make-kernel-cross-compilation-tweaks.patch b/recipes-core/runx/runx/0001-make-kernel-cross-compilation-tweaks.patch new file mode 100644 index 00000000..7d66f421 --- /dev/null +++ b/recipes-core/runx/runx/0001-make-kernel-cross-compilation-tweaks.patch | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | From 7e3498ab7c375bd545de501920acffa77eb24120 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Bruce Ashfield <bruce.ashfield@xilinx.com> | ||
| 3 | Date: Mon, 16 Dec 2019 20:42:04 -0800 | ||
| 4 | Subject: [PATCH] make-kernel: cross-compilation tweaks | ||
| 5 | |||
| 6 | Signed-off-by: Bruce Ashfield <bruce.ashfield@xilinx.com> | ||
| 7 | --- | ||
| 8 | kernel/make-kernel | 41 +++++++++++++++++++++++++++++++++-------- | ||
| 9 | 1 file changed, 33 insertions(+), 8 deletions(-) | ||
| 10 | |||
| 11 | diff --git a/kernel/make-kernel b/kernel/make-kernel | ||
| 12 | index 33b7150..c684669 100755 | ||
| 13 | --- a/kernel/make-kernel | ||
| 14 | +++ b/kernel/make-kernel | ||
| 15 | @@ -13,6 +13,7 @@ fi | ||
| 16 | |||
| 17 | kernel_stuffdir=`readlink -f kernel` | ||
| 18 | kernel_outpath=$kernel_stuffdir/out | ||
| 19 | +kernel_srcdir=$kernel_stuffdir/src | ||
| 20 | kernel_builddir=$kernel_stuffdir/build | ||
| 21 | kernel_out=$kernel_outpath/kernel | ||
| 22 | |||
| 23 | @@ -22,28 +23,52 @@ kernel_tarball="$kernel_name".tar.xz | ||
| 24 | kernel_url=https://www.kernel.org/pub/linux/kernel/v4.x/"$kernel_tarball" | ||
| 25 | kernel_src_config="$kernel_stuffdir"/cutdown-config.$ARCH | ||
| 26 | kernel_patchesdir="$kernel_stuffdir"/patches | ||
| 27 | -kernel_image="$kernel_builddir"/"$kernel_name"/arch/"$ARCH"/boot/"$image" | ||
| 28 | +kernel_image="$kernel_builddir"/arch/"$ARCH"/boot/"$image" | ||
| 29 | |||
| 30 | +echo "#########################" | ||
| 31 | +echo "kernel build summary:" | ||
| 32 | +echo " version: $kernel_version" | ||
| 33 | +echo " url: $kernel_url" | ||
| 34 | +echo " src dir: $kernel_srcdir" | ||
| 35 | +echo " out dir: $kernel_builddir" | ||
| 36 | +echo " artifacts: $kernel_out" | ||
| 37 | +echo " image: $image" | ||
| 38 | +echo " build vars: $build_vars" | ||
| 39 | +echo "#########################" | ||
| 40 | |||
| 41 | -rm -rf $kernel_outpath | ||
| 42 | +if [ ! -e "$kernel_builddir/.config" ]; | ||
| 43 | +then | ||
| 44 | + rm -rf $kernel_buildir | ||
| 45 | +fi | ||
| 46 | mkdir -p $kernel_outpath | ||
| 47 | mkdir -p $kernel_builddir | ||
| 48 | +mkdir -p $kernel_srcdir | ||
| 49 | |||
| 50 | if [[ ! -f $kernel_builddir/$kernel_tarball ]] | ||
| 51 | then | ||
| 52 | + echo "fetching the kernel .." | ||
| 53 | wget -O $kernel_builddir/$kernel_tarball --tries=20 $kernel_url | ||
| 54 | fi | ||
| 55 | -if [[ ! -d $kernel_builddir/$kernel_name ]] | ||
| 56 | + | ||
| 57 | +if [[ ! -d $kernel_srcdir/$kernel_name ]] | ||
| 58 | then | ||
| 59 | - tar --extract --xz --touch --file="$kernel_builddir/$kernel_tarball" --directory="$kernel_builddir" | ||
| 60 | - cd $kernel_builddir/$kernel_name | ||
| 61 | + echo "extracting the kernel ..." | ||
| 62 | + echo " tar --extract --xz --touch --file=\"$kernel_builddir/$kernel_tarball\" --directory=\"$kernel_srcdir\"" | ||
| 63 | + tar --extract --xz --touch --file="$kernel_builddir/$kernel_tarball" --directory="$kernel_srcdir" | ||
| 64 | + cd $kernel_srcdir/$kernel_name | ||
| 65 | for i in $kernel_patchesdir/* | ||
| 66 | do | ||
| 67 | patch -p1 < $i | ||
| 68 | done | ||
| 69 | - cp $kernel_src_config .config | ||
| 70 | fi | ||
| 71 | -cd $kernel_builddir/$kernel_name | ||
| 72 | -make -j4 $image | ||
| 73 | +if [[ ! -f $kernel_builddir/.config ]] | ||
| 74 | +then | ||
| 75 | + cp $kernel_src_config $kernel_builddir/.config | ||
| 76 | +fi | ||
| 77 | +cd $kernel_srcdir/$kernel_name | ||
| 78 | + | ||
| 79 | +echo "building the kernel ..." | ||
| 80 | +eval make O=$kernel_builddir $build_vars oldconfig | ||
| 81 | +eval make -j4 O=$kernel_builddir $build_vars $image | ||
| 82 | |||
| 83 | cp $kernel_image $kernel_out | ||
| 84 | -- | ||
| 85 | 2.17.1 | ||
| 86 | |||
diff --git a/recipes-core/runx/runx_git.bb b/recipes-core/runx/runx_git.bb new file mode 100644 index 00000000..36fede67 --- /dev/null +++ b/recipes-core/runx/runx_git.bb | |||
| @@ -0,0 +1,154 @@ | |||
| 1 | HOMEPAGE = "https://github.com/lf-edge/runx" | ||
| 2 | SUMMARY = "runx stuff" | ||
| 3 | DESCRIPTION = "Xen Runtime for OCI" | ||
| 4 | |||
| 5 | SRCREV_runx = "a6fe5ca3081f44e9085972d424c74707d4f0fc71" | ||
| 6 | SRC_URI = "\ | ||
| 7 | git://github.com/lf-edge/runx;nobranch=1;name=runx \ | ||
| 8 | https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.15.tar.xz;destsuffix=git/kernel/build \ | ||
| 9 | file://0001-make-kernel-cross-compilation-tweaks.patch \ | ||
| 10 | file://0001-make-initrd-cross-install-tweaks.patch \ | ||
| 11 | " | ||
| 12 | SRC_URI[md5sum] = "0d701ac1e2a67d47ce7127432df2c32b" | ||
| 13 | SRC_URI[sha256sum] = "5a26478906d5005f4f809402e981518d2b8844949199f60c4b6e1f986ca2a769" | ||
| 14 | |||
| 15 | LICENSE = "Apache-2.0" | ||
| 16 | LIC_FILES_CHKSUM = "file://LICENSE;md5=945fc9aa694796a6337395cc291ddd8c" | ||
| 17 | |||
| 18 | S = "${WORKDIR}/git" | ||
| 19 | PV = "0.1-git${SRCREV_runx}" | ||
| 20 | |||
| 21 | inherit distro_features_check | ||
| 22 | REQUIRED_DISTRO_FEATURES = "vmsep" | ||
| 23 | |||
| 24 | |||
| 25 | # TODO: for if we need a go shim | ||
| 26 | # GO_IMPORT = "import" | ||
| 27 | # inherit go | ||
| 28 | # inherit goarch | ||
| 29 | inherit pkgconfig | ||
| 30 | |||
| 31 | # for the kernel build | ||
| 32 | inherit kernel-arch | ||
| 33 | |||
| 34 | # we have a busybox bbappend that makes /bin available to the | ||
| 35 | # sysroot, and hence gets us the target binary that we need | ||
| 36 | DEPENDS = "busybox" | ||
| 37 | |||
| 38 | # for the kernel build phase | ||
| 39 | DEPENDS += "openssl-native coreutils-native util-linux-native xz-native bc-native" | ||
| 40 | DEPENDS += "qemu-native" | ||
| 41 | |||
| 42 | RDEPENDS_${PN} += " jq bash" | ||
| 43 | RDEPENDS_${PN} += " xen-xl" | ||
| 44 | |||
| 45 | do_compile() { | ||
| 46 | # we'll need this for the initrd later, so lets error if it isn't what | ||
| 47 | # we expect (statically linked) | ||
| 48 | file ${STAGING_DIR_HOST}/bin/busybox.nosuid | ||
| 49 | |||
| 50 | # prep steps to short circuit some of make-kernel's fetching and | ||
| 51 | # building. | ||
| 52 | mkdir -p ${S}/kernel/build | ||
| 53 | mkdir -p ${S}/kernel/src | ||
| 54 | cp ${DL_DIR}/linux-4.15.tar.xz ${S}/kernel/build/ | ||
| 55 | |||
| 56 | # In the future, we might want to link the extracted kernel source (if | ||
| 57 | # we move patches to recipe space, but for now, we need make-kernel to | ||
| 58 | # extract a copy and possibly patch it. | ||
| 59 | # ln -sf ${WORKDIR}/linux-4.15 ${S}/kernel/src/ | ||
| 60 | |||
| 61 | # build the kernel | ||
| 62 | echo "[INFO]: runx: building the kernel" | ||
| 63 | |||
| 64 | export KERNEL_CC="${KERNEL_CC}" | ||
| 65 | export KERNEL_LD="${KERNEL_LD}" | ||
| 66 | export ARCH="${ARCH}" | ||
| 67 | export HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" | ||
| 68 | export HOSTCPP="${BUILD_CPP}" | ||
| 69 | export CROSS_COMPILE="${CROSS_COMPILE}" | ||
| 70 | export build_vars="HOSTCC='$HOSTCC' STRIP='$STRIP' OBJCOPY='$OBJCOPY' ARCH=$ARCH CC='$KERNEL_CC' LD='$KERNEL_LD'" | ||
| 71 | |||
| 72 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE | ||
| 73 | |||
| 74 | # We want make-kernel, to have the following build lines: | ||
| 75 | # make O=$kernel_builddir HOSTCC="${HOSTCC}" ARCH=$ARCH oldconfig | ||
| 76 | # make -j4 O=$kernel_builddir HOSTCC="${HOSTCC}" STRIP="$STRIP" OBJCOPY="$OBJCOPY" ARCH=$ARCH CC="$KERNEL_CC" LD="$KERNEL_LD" $image | ||
| 77 | ${S}/kernel/make-kernel | ||
| 78 | |||
| 79 | # construct the initrd | ||
| 80 | echo "[INFO]: runx: constructing the initrd" | ||
| 81 | |||
| 82 | cp ${STAGING_DIR_HOST}/bin/busybox.nosuid ${WORKDIR}/busybox | ||
| 83 | export QEMU_USER=`which qemu-${HOST_ARCH}` | ||
| 84 | export BUSYBOX="${WORKDIR}/busybox" | ||
| 85 | export CROSS_COMPILE="t" | ||
| 86 | ${S}/kernel/make-initrd | ||
| 87 | } | ||
| 88 | |||
| 89 | do_build_go_shim() { | ||
| 90 | |||
| 91 | # placeholder for any go shim code we may need, i.e. console | ||
| 92 | |||
| 93 | # export GOARCH="${TARGET_GOARCH}" | ||
| 94 | # export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" | ||
| 95 | # export GOPATH="${S}/src/import:${S}/src/import/vendor" | ||
| 96 | |||
| 97 | # # Pass the needed cflags/ldflags so that cgo | ||
| 98 | # # can find the needed headers files and libraries | ||
| 99 | # export CGO_ENABLED="1" | ||
| 100 | # export CFLAGS="" | ||
| 101 | # export LDFLAGS="" | ||
| 102 | # export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
| 103 | # export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
| 104 | |||
| 105 | # # link fixups for compilation | ||
| 106 | # rm -f ${S}/src/import/vendor/src | ||
| 107 | # ln -sf ./ ${S}/src/import/vendor/src | ||
| 108 | |||
| 109 | # mkdir -p ${S}/src/import/vendor/github.com/hyperhq/runv | ||
| 110 | |||
| 111 | # ln -sf src/import/cli | ||
| 112 | # ln -sf ../../../../api ${S}/src/import/vendor/github.com/hyperhq/runv/api | ||
| 113 | # ln -sf ../../../../cli ${S}/src/import/vendor/github.com/hyperhq/runv/cli | ||
| 114 | # ln -sf ../../../../lib ${S}/src/import/vendor/github.com/hyperhq/runv/lib | ||
| 115 | # ln -sf ../../../../driverloader ${S}/src/import/vendor/github.com/hyperhq/runv/driverloader | ||
| 116 | # ln -sf ../../../../factory ${S}/src/import/vendor/github.com/hyperhq/runv/factory | ||
| 117 | # ln -sf ../../../../hyperstart ${S}/src/import/vendor/github.com/hyperhq/runv/hyperstart | ||
| 118 | # ln -sf ../../../../hypervisor ${S}/src/import/vendor/github.com/hyperhq/runv/hypervisor | ||
| 119 | # ln -sf ../../../../template ${S}/src/import/vendor/github.com/hyperhq/runv/template | ||
| 120 | |||
| 121 | # export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go" | ||
| 122 | # export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go" | ||
| 123 | |||
| 124 | # # Pass the needed cflags/ldflags so that cgo | ||
| 125 | # # can find the needed headers files and libraries | ||
| 126 | # export CGO_ENABLED="1" | ||
| 127 | # export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
| 128 | # export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
| 129 | |||
| 130 | # oe_runmake build-shim | ||
| 131 | |||
| 132 | true | ||
| 133 | } | ||
| 134 | |||
| 135 | do_install() { | ||
| 136 | install -d ${D}${bindir} | ||
| 137 | install -m 755 ${S}/runX ${D}${bindir} | ||
| 138 | |||
| 139 | install -d ${D}${datadir}/runX | ||
| 140 | install -m 755 ${S}/kernel/out/kernel ${D}/${datadir}/runX | ||
| 141 | install -m 755 ${S}/kernel/out/initrd ${D}/${datadir}/runX | ||
| 142 | install -m 755 ${S}/files/start ${D}/${datadir}/runX | ||
| 143 | install -m 755 ${S}/files/state ${D}/${datadir}/runX | ||
| 144 | install -m 755 ${S}/files/delete ${D}/${datadir}/runX | ||
| 145 | |||
| 146 | |||
| 147 | } | ||
| 148 | |||
| 149 | deltask compile_ptest_base | ||
| 150 | |||
| 151 | FILES_${PN} += "${bindir}/* ${datadir}/runX/*" | ||
| 152 | |||
| 153 | INHIBIT_PACKAGE_STRIP = "1" | ||
| 154 | INSANE_SKIP_${PN} += "ldflags already-stripped" | ||
