[ostree] gnomeos: Starting to get something bootable with yocto
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] gnomeos: Starting to get something bootable with yocto
- Date: Tue, 15 Nov 2011 15:46:19 +0000 (UTC)
commit 5b70db8d6013a4ea2077f76eeadd30ec884d29ac
Author: Colin Walters <walters verbum org>
Date: Tue Nov 15 10:44:03 2011 -0500
gnomeos: Starting to get something bootable with yocto
gnomeos/yocto/commit-yocto-build.sh | 32 +++++++
gnomeos/yocto/gnomeos-run.sh | 88 ++++++++++++++++++++
gnomeos/yocto/make-gnomeos-fs.sh | 17 ++++
gnomeos/yocto/recipies-core/gtk-doc/gtk-doc.bb | 11 +++
.../recipies-core/images/gnomeos-image-contents.bb | 80 ++++++++++++++++++
.../yocto/recipies-core/images/gnomeos-image.bb | 19 ----
.../yocto/recipies-core/ostree-init/ostree-init.c | 45 +++++++++--
gnomeos/yocto/recipies-core/ostree/ostree.bb | 13 +++
8 files changed, 279 insertions(+), 26 deletions(-)
---
diff --git a/gnomeos/yocto/commit-yocto-build.sh b/gnomeos/yocto/commit-yocto-build.sh
new file mode 100755
index 0000000..d9ee3a5
--- /dev/null
+++ b/gnomeos/yocto/commit-yocto-build.sh
@@ -0,0 +1,32 @@
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+
+set -e
+set -x
+
+if test $(id -u) = 0; then
+ cat <<EOF
+This script should not be run as root.
+EOF
+ exit 1
+fi
+
+usage () {
+ echo "$0 OSTREE_REPO_PATH BINARY_TAR"
+ exit 1
+}
+
+OSTREE_REPO=$1
+test -n "$OSTREE_REPO" || usage
+shift
+BUILD_TAR=$1
+test -n "$BUILD_TAR" || usage
+shift
+
+tempdir=`mktemp -d tmp-commit-yocto-build.XXXXXXXXXX`
+cd $tempdir
+mkdir fs
+cd fs
+fakeroot -s ../fakeroot.db tar xf $BUILD_TAR
+fakeroot -i ../fakeroot.db ostree --repo=${OSTREE_REPO} commit -s "Build (need ostree git version here)" -b gnomeos-base
+rm -rf $tempdir
diff --git a/gnomeos/yocto/gnomeos-run.sh b/gnomeos/yocto/gnomeos-run.sh
new file mode 100755
index 0000000..b9b750e
--- /dev/null
+++ b/gnomeos/yocto/gnomeos-run.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+# -*- indent-tabs-mode: nil; -*-
+# Run built image in QEMU
+#
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+set -e
+set -x
+
+SRCDIR=`dirname $0`
+WORKDIR=`pwd`
+
+if test $(id -u) != 0; then
+ cat <<EOF
+This script should be run as root.
+EOF
+ exit 1
+fi
+
+usage () {
+ echo "$0 OSTREE_REPO_PATH"
+ exit 1
+}
+
+OSTREE_REPO=$1
+shift
+test -n "$OSTREE_REPO" || usage
+
+OBJ=gnomeos-fs.img
+if (! test -f ${OBJ}); then
+ rm -f ${OBJ}.tmp
+ qemu-img create ${OBJ}.tmp 2G
+ mkfs.ext3 -q -F ${OBJ}.tmp
+ mkdir -p fs
+ umount fs || true
+ mount -o loop ${OBJ}.tmp fs
+
+ cd fs
+
+ TOPROOT_BIND_MOUNTS="home root tmp"
+
+ for d in $TOPROOT_BIND_MOUNTS; do
+ mkdir -m 0755 $d
+ done
+ chmod a=rwxt tmp
+
+ mkdir ostree
+ mkdir -p -m 0755 ./ostree/var/{log,run,tmp,spool}
+ cd ostree
+ mkdir repo
+ rev=$(ostree --repo=${OSTREE_REPO} rev-parse gnomeos-base);
+ ostree --repo=${OSTREE_REPO} checkout ${rev} gnomeos-base-${rev}
+ ln -s gnomeos-base-${rev} current
+ cd ..
+
+ mkdir proc # needed for ostree-init
+ cp -a ./ostree/current/usr/sbin/ostree-init .
+
+ cd ${WORKDIR}
+
+ umount fs
+ mv ${OBJ}.tmp ${OBJ}
+fi
+
+ARGS="$@"
+if ! [ echo $ARGS | grep -q 'init=']; then
+ ARGS="init=/ostree-init $ARGS"
+fi
+if ! [ echo $ARGS | grep -q 'root=']; then
+ ARGS="root=/dev/hda $ARGS"
+fi
+
+exec qemu-kvm -kernel ./tmp/deploy/images/bzImage-qemux86.bin -hda gnomeos-fs.img -append "$ARGS"
diff --git a/gnomeos/yocto/make-gnomeos-fs.sh b/gnomeos/yocto/make-gnomeos-fs.sh
new file mode 100755
index 0000000..757189f
--- /dev/null
+++ b/gnomeos/yocto/make-gnomeos-fs.sh
@@ -0,0 +1,17 @@
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+
+set -e
+set -x
+
+if test $(id -u) = 0; then
+ cat <<EOF
+This script should not be run as root.
+EOF
+ exit 1
+fi
+
+
+mkdir gnomeos-fs
+cd gnomeos-fs
+
diff --git a/gnomeos/yocto/recipies-core/gtk-doc/gtk-doc.bb b/gnomeos/yocto/recipies-core/gtk-doc/gtk-doc.bb
new file mode 100644
index 0000000..c0180ce
--- /dev/null
+++ b/gnomeos/yocto/recipies-core/gtk-doc/gtk-doc.bb
@@ -0,0 +1,11 @@
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING-DOCS;md5=18ba770020b624031bc7c8a7b055d776"
+
+DEPENDS = "perl-native"
+
+SRC_URI = "git://git.gnome.org/gtk-doc;tag=GTK_DOC_1_18"
+S = "${WORKDIR}/git"
+
+inherit autotools gettext
+
+BBCLASSEXTEND = "native"
diff --git a/gnomeos/yocto/recipies-core/images/gnomeos-image-contents.bb b/gnomeos/yocto/recipies-core/images/gnomeos-image-contents.bb
new file mode 100644
index 0000000..fefda5a
--- /dev/null
+++ b/gnomeos/yocto/recipies-core/images/gnomeos-image-contents.bb
@@ -0,0 +1,80 @@
+#
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
+ file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+inherit rootfs_${IMAGE_PKGTYPE}
+
+PACKAGE_INSTALL = "task-core-boot task-base-extended \
+ ostree ostree-init"
+RDEPENDS += "${PACKAGE_INSTALL}"
+DEPENDS += "virtual/fakeroot-native"
+
+EXCLUDE_FROM_WORLD = "1"
+
+do_rootfs[nostamp] = "1"
+do_rootfs[dirs] = "${TOPDIR}"
+do_rootfs[lockfiles] += "${IMAGE_ROOTFS}.lock"
+do_build[nostamp] = "1"
+do_rootfs[umask] = 022
+
+# Must call real_do_rootfs() from inside here, rather than as a separate
+# task, so that we have a single fakeroot context for the whole process.
+fakeroot do_rootfs () {
+ set -x
+ rm -rf ${IMAGE_ROOTFS}
+ rm -rf ${MULTILIB_TEMP_ROOTFS}
+ mkdir -p ${IMAGE_ROOTFS}
+ mkdir -p ${DEPLOY_DIR_IMAGE}
+
+ rootfs_${IMAGE_PKGTYPE}_do_rootfs
+
+ echo "GNOME OS Unix login" > ${IMAGE_ROOTFS}/etc/issue
+
+ TOPROOT_BIND_MOUNTS="home root tmp"
+ OSTREE_BIND_MOUNTS="var"
+ OSDIRS="dev proc mnt media sys sysroot"
+ READONLY_BIND_MOUNTS="bin etc lib sbin usr"
+
+ rm -rf ${WORKDIR}/gnomeos-contents
+ mkdir ${WORKDIR}/gnomeos-contents
+ cd ${WORKDIR}/gnomeos-contents
+ for d in $TOPROOT_BIND_MOUNTS $OSTREE_BIND_MOUNTS $OSDIRS; do
+ mkdir $d
+ done
+ chmod a=rwxt tmp
+ for d in $READONLY_BIND_MOUNTS; do
+ mv ${IMAGE_ROOTFS}/$d .
+ done
+ rm -rf ${IMAGE_ROOTFS}
+ mv ${WORKDIR}/gnomeos-contents ${IMAGE_ROOTFS}
+
+ DEST=${IMAGE_NAME}.rootfs.tar.gz
+ (cd ${IMAGE_ROOTFS} && tar -zcv -f ${WORKDIR}/$DEST .)
+ echo "Created $DEST"
+ mv ${WORKDIR}/$DEST ${DEPLOY_DIR_IMAGE}/
+ cd ${DEPLOY_DIR_IMAGE}/
+ rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.tar.gz
+ ln -s ${IMAGE_NAME}.rootfs.tar.gz ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.tar.gz
+ echo "Created ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.tar.gz"
+}
+
+log_check() {
+ true
+}
+
+do_fetch[noexec] = "1"
+do_unpack[noexec] = "1"
+do_patch[noexec] = "1"
+do_configure[noexec] = "1"
+do_compile[noexec] = "1"
+do_install[noexec] = "1"
+do_populate_sysroot[noexec] = "1"
+do_package[noexec] = "1"
+do_package_write_ipk[noexec] = "1"
+do_package_write_deb[noexec] = "1"
+do_package_write_rpm[noexec] = "1"
+
+addtask rootfs before do_build
diff --git a/gnomeos/yocto/recipies-core/ostree-init/ostree-init.c b/gnomeos/yocto/recipies-core/ostree-init/ostree-init.c
index deeb330..d0368dc 100644
--- a/gnomeos/yocto/recipies-core/ostree-init/ostree-init.c
+++ b/gnomeos/yocto/recipies-core/ostree-init/ostree-init.c
@@ -62,7 +62,7 @@ perrorv (const char *format, ...)
int main(int argc, char *argv[])
{
FILE *cmdline_f = NULL;
- const char *ostree_root = NULL;
+ char *ostree_root = NULL;
const char *p = NULL;
size_t bytes_read;
size_t buf_size;
@@ -72,12 +72,23 @@ int main(int argc, char *argv[])
struct stat stbuf;
char **init_argv = NULL;
int i;
+ int mounted_proc = 0;
cmdline_f = fopen ("/proc/cmdline", "r");
if (!cmdline_f)
{
- perrorv ("Failed to open /proc/cmdline");
- return 1;
+ if (mount ("procs", "/proc", "proc", 0, NULL) < 0)
+ {
+ perrorv ("Failed to mount /proc");
+ return 1;
+ }
+ mounted_proc = 1;
+ cmdline_f = fopen ("/proc/cmdline", "r");
+ if (!cmdline_f)
+ {
+ perrorv ("Failed to open /proc/cmdline (after mounting)");
+ return 1;
+ }
}
buf_size = 8;
@@ -101,13 +112,22 @@ int main(int argc, char *argv[])
exit (1);
}
- for (p = buf; *p; p += strlen (p) + 1)
+ p = buf;
+ while (p != NULL)
{
- if (!strcmp (p, "ostree="))
+ if (!strncmp (p, "ostree=", strlen ("ostree=")))
{
- ostree_root = p + strlen ("ostree=");
+ const char *start = p + strlen ("ostree=");
+ const char *end = strchr (start, ' ');
+ if (end)
+ ostree_root = strndup (start, end - start);
+ else
+ ostree_root = strdup (start);
break;
}
+ p = strchr (p, ' ');
+ if (p)
+ p += 1;
}
if (ostree_root)
@@ -119,6 +139,13 @@ int main(int argc, char *argv[])
exit (1);
}
+ snprintf (destpath, sizeof(destpath), "/ostree/%s/var", ostree_root);
+ if (mount ("/ostree/var", destpath, NULL, MS_BIND, NULL) < 0)
+ {
+ perrorv ("Failed to bind mount /ostree/var to '%s'", destpath);
+ exit (1);
+ }
+
snprintf (destpath, sizeof(destpath), "/ostree/%s/sysroot", ostree_root);
if (mount ("/", destpath, NULL, MS_BIND, NULL) < 0)
{
@@ -138,7 +165,6 @@ int main(int argc, char *argv[])
perrorv ("failed to chdir to subroot");
exit (1);
}
-
}
else
{
@@ -146,12 +172,17 @@ int main(int argc, char *argv[])
exit (1);
}
+ if (mounted_proc)
+ (void)umount ("/proc");
+
init_argv = malloc (sizeof (char*)*(argc+1));
init_argv[0] = INIT_PATH;
for (i = 1; i < argc; i++)
init_argv[i] = argv[i];
init_argv[i] = NULL;
+ fprintf (stderr, "ostree-init: Running real init\n");
+ fflush (stderr);
execv (INIT_PATH, init_argv);
perrorv ("Failed to exec init '%s'", INIT_PATH);
exit (1);
diff --git a/gnomeos/yocto/recipies-core/ostree/ostree.bb b/gnomeos/yocto/recipies-core/ostree/ostree.bb
new file mode 100644
index 0000000..3871dac
--- /dev/null
+++ b/gnomeos/yocto/recipies-core/ostree/ostree.bb
@@ -0,0 +1,13 @@
+SUMMARY = "GNOME OS management tool"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=97285cb818cf231e6a36f72c82592235"
+
+SRC_URI = "git://git.gnome.org/ostree;tag=18f0b537a45f12852e4ec6b174440cbfe7702e4d"
+S = "${WORKDIR}/git"
+
+inherit autotools
+
+EXTRA_OECONF = "--without-soup-gnome"
+
+BBCLASSEXTEND = "native"
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]