gnomeos: Move gnomeos/yocto into poky tree

Now lives here: https://github.com/cgwalters/poky
This commit is contained in:
Colin Walters 2012-03-13 11:57:14 -04:00
parent 8e3a3c5667
commit 03de1f8e20
24 changed files with 0 additions and 1263 deletions

View File

@ -1,149 +0,0 @@
From e9cb0f0c6ef13773c823610f27a562bd54b2acd3 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Mon, 24 Oct 2011 22:01:17 -0400
Subject: [PATCH] Support OSTree
See http://git.gnome.org/browse/ostree
---
modules.d/95rootfs-block/mount-root.sh | 12 ++++++------
modules.d/99base/init | 32 ++++++++++++++++++++++----------
2 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh
index 2c89431..4f411da 100755
--- a/modules.d/95rootfs-block/mount-root.sh
+++ b/modules.d/95rootfs-block/mount-root.sh
@@ -34,8 +34,8 @@ mount_root() {
READONLY=
fsckoptions=
- if [ -f "$NEWROOT"/etc/sysconfig/readonly-root ]; then
- . "$NEWROOT"/etc/sysconfig/readonly-root
+ if [ -f "$NEWROOT_PREFIX"/etc/sysconfig/readonly-root ]; then
+ . "$NEWROOT_PREFIX"/etc/sysconfig/readonly-root
fi
if getargbool 0 "readonlyroot=" -y readonlyroot; then
@@ -57,7 +57,7 @@ mount_root() {
if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then
fsckoptions="-f $fsckoptions"
elif [ -f "$NEWROOT"/.autofsck ]; then
- [ -f "$NEWROOT"/etc/sysconfig/autofsck ] && . "$NEWROOT"/etc/sysconfig/autofsck
+ [ -f "$NEWROOT_PREFIX"/etc/sysconfig/autofsck ] && . "$NEWROOT_PREFIX"/etc/sysconfig/autofsck
if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
AUTOFSCK_OPT="$AUTOFSCK_OPT -f"
fi
@@ -73,8 +73,8 @@ mount_root() {
rootopts=
if getargbool 1 rd.fstab -n rd_NO_FSTAB \
&& ! getarg rootflags \
- && [ -f "$NEWROOT/etc/fstab" ] \
- && ! [ -L "$NEWROOT/etc/fstab" ]; then
+ && [ -f "$NEWROOT_PREFIX/etc/fstab" ] \
+ && ! [ -L "$NEWROOT_PREFIX/etc/fstab" ]; then
# if $NEWROOT/etc/fstab contains special mount options for
# the root filesystem,
# remount it with the proper options
@@ -89,7 +89,7 @@ mount_root() {
rootopts=$opts
break
fi
- done < "$NEWROOT/etc/fstab"
+ done < "$NEWROOT_PREFIX/etc/fstab"
rootopts=$(filter_rootopts $rootopts)
fi
diff --git a/modules.d/99base/init b/modules.d/99base/init
index 36b2152..9636990 100755
--- a/modules.d/99base/init
+++ b/modules.d/99base/init
@@ -275,6 +275,13 @@ unset queuetriggered
unset main_loop
unset RDRETRY
+ostree=$(getarg ostree=)
+if test -n $ostree; then
+ NEWROOT_PREFIX=${NEWROOT}/ostree/$ostree
+else
+ NEWROOT_PREFIX=$NEWROOT
+fi
+
# pre-mount happens before we try to mount the root filesystem,
# and happens once.
getarg 'rd.break=pre-mount' 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
@@ -287,14 +294,15 @@ getarg 'rd.break=mount' 'rdbreak=mount' && emergency_shell -n mount "Break mount
i=0
while :; do
if ismounted "$NEWROOT"; then
- usable_root "$NEWROOT" && break;
+ echo "Checking usable $NEWROOT_PREFIX"
+ usable_root "$NEWROOT_PREFIX" && break;
umount "$NEWROOT"
fi
for f in $hookdir/mount/*.sh; do
[ -f "$f" ] && . "$f"
if ismounted "$NEWROOT"; then
- usable_root "$NEWROOT" && break;
- warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
+ usable_root "$NEWROOT_PREFIX" && break;
+ warn "$NEWROOT_PREFIX has no proper rootfs layout, ignoring and removing offending mount hook"
umount "$NEWROOT"
rm -f "$f"
fi
@@ -320,11 +328,11 @@ unset __usr_found
for i in "$(getarg real_init=)" "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do
[ -n "$i" ] || continue
- __p=$(readlink -m "$NEWROOT$i")
+ __p=$(readlink -m "$NEWROOT_PREFIX$i")
if [ -n "$__p" ] \
&& [ "x$__usr_found" = "x" ] \
&& [ ! -x "$__p" ] \
- && strstr "$__p" "$NEWROOT/usr" \
+ && strstr "$__p" "$NEWROOT_PREFIX/usr" \
; then
# we have to mount /usr
while read dev mp fs opts rest; do
@@ -333,14 +341,14 @@ for i in "$(getarg real_init=)" "$(getarg init=)" /sbin/init /etc/init /init /bi
__usr_found="1"
break
fi
- done < "$NEWROOT/etc/fstab" >> /etc/fstab
+ done < "$NEWROOT_PREFIX/etc/fstab" >> /etc/fstab
if [ "x$__usr_found" != "x" ]; then
info "Mounting /usr"
- mount "$NEWROOT/usr" 2>&1 | vinfo
+ mount "$NEWROOT_PREFIX/usr" 2>&1 | vinfo
fi
fi
- __p=$(readlink -f "$NEWROOT$i")
+ __p=$(readlink -f "$NEWROOT_PREFIX$i")
if [ -x "$__p" ]; then
INIT="$i"
break
@@ -445,7 +453,11 @@ info "Switching root"
unset PS4
CAPSH=$(command -v capsh)
-SWITCH_ROOT=$(command -v switch_root)
+if test -n "${ostree}"; then
+ SWITCH_ROOT=$(command -v ostree_switch_root)
+else
+ SWITCH_ROOT=$(command -v switch_root)
+fi
PATH=$OLDPATH
export PATH
@@ -463,7 +475,7 @@ if [ -f /etc/capsdrop ]; then
}
else
unset RD_DEBUG
- exec $SWITCH_ROOT "$NEWROOT" "$INIT" $initargs || {
+ exec $SWITCH_ROOT "$NEWROOT" $ostree "$INIT" $initargs || {
warn "Something went very badly wrong in the initramfs. Please "
warn "file a bug against dracut."
emergency_shell
--
1.7.6.4

View File

@ -1,60 +0,0 @@
#!/bin/sh
# This script sets up things we want to ship with the OS tree. It should
# NOT set up caches. For example, do NOT run ldconfig in here.
set -e
set -x
echo gnomeos >./etc/hostname
cat >./etc/default/locale <<EOF
LANG="en_US.UTF-8"
EOF
cp -p ./usr/share/sysvinit/inittab ./etc/inittab
cp -p ./usr/share/base-files/nsswitch.conf ./etc/nsswitch.conf
cat >./etc/pam.d/common-account <<EOF
account [success=1 new_authtok_reqd=done default=ignore] pam_unix.so
account requisite pam_deny.so
account required pam_permit.so
EOF
cat >./etc/pam.d/common-auth <<EOF
auth [success=1 default=ignore] pam_unix.so nullok_secure
auth requisite pam_deny.so
auth required pam_permit.so
EOF
cat >./etc/pam.d/common-password <<EOF
password [success=1 default=ignore] pam_unix.so obscure sha512
password requisite pam_deny.so
password required pam_permit.so
EOF
cat >./etc/pam.d/common-session <<EOF
session [default=1] pam_permit.so
session requisite pam_deny.so
session required pam_permit.so
session required pam_unix.so
EOF
# base-passwd
cp -p ./usr/share/base-passwd/passwd.master ./etc/passwd
cp -p ./usr/share/base-passwd/group.master ./etc/group
# Service rc.d defaults
setuprc () {
name=$1
shift
type=$1
shift
priority=$1
shift
for x in $@; do
ln -s ../init.d/$name ./etc/rc${x}.d/${type}${priority}${name}
done
}
setuprc rsyslog S 10 2 3 4 5
setuprc rsyslog S 30 0 6
setuprc rsyslog K 90 1
setuprc cron S 89 2 3 4 5

View File

@ -1,42 +0,0 @@
#!/bin/sh
# -*- indent-tabs-mode: nil; -*-
# Install built ostree image to current system
#
# 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`
OBJ=gnomeos-initrd.img
if ! test -f ${OBJ}; then
echo "Error: couldn't find '$OBJ'. Run gnomeos-make-image.sh"
exit 1
fi
if test -d /ostree; then
echo "/ostree already exists"
exit 1
fi
cp -a gnomeos-fs/ostree /
initrd=`readlink gnomeos-initrd.img`
cp ${initrd} /boot
grubby --title "GNOME OS" --add-kernel=$kernel --copy-default --initrd=/boot/${initrd}

View File

@ -1,205 +0,0 @@
#!/bin/sh
# -*- indent-tabs-mode: nil; -*-
# Generate a root filesystem image
#
# 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`
DEPENDS="debootstrap"
for x in $DEPENDS; do
if ! command -v $x; then
cat <<EOF
Couldn't find required dependency $x
EOF
exit 1
fi
done
if test $(id -u) == 0; then
echo "Should not run this script as root."
exit 1
fi
if test -z "${OSTREE}"; then
OSTREE=`command -v ostree || true`
fi
if test -z "${OSTREE}"; then
cat <<EOF
ERROR:
Couldn't find ostree; you can set the OSTREE environment variable to point to it
e.g.: OSTREE=~user/checkout/ostree/ostree $0
EOF
exit 1
fi
if test -z "$DRACUT"; then
if ! test -d dracut; then
cat <<EOF
Checking out and patching dracut...
EOF
git clone git://git.kernel.org/pub/scm/boot/dracut/dracut.git
(cd dracut; git am $SRCDIR/0001-Support-OSTree.patch)
(cd dracut; make)
fi
DRACUT=`pwd`/dracut/dracut
fi
case `uname -p` in
x86_64)
ARCH=amd64
;;
*)
echo "Unsupported architecture"
;;
esac;
DEBTARGET=wheezy
INITRD_MOVE_MOUNTS="dev proc sys"
TOPROOT_BIND_MOUNTS="boot home root tmp"
OSTREE_BIND_MOUNTS="var"
MOVE_MOUNTS="selinux mnt media"
READONLY_BIND_MOUNTS="bin etc lib lib32 lib64 sbin usr"
cd ${WORKDIR}
OBJ=debootstrap-$DEBTARGET
if ! test -d ${OBJ} ; then
echo "Creating $DEBTARGET.img"
mkdir -p ${OBJ}.tmp
debootstrap --download-only --arch $ARCH $DEBTARGET ${OBJ}.tmp
mv ${OBJ}.tmp ${OBJ}
fi
cd ${WORKDIR}
OBJ=$DEBTARGET-fs
if ! test -d ${OBJ}; then
rm -rf ${OBJ}.tmp
mkdir ${OBJ}.tmp
cd ${OBJ}.tmp;
mkdir -m 0755 $INITRD_MOVE_MOUNTS $TOPROOT_BIND_MOUNTS
chmod a=rwxt tmp
mkdir ostree
mkdir -p -m 0755 ostree/var/{log,run}
mkdir ostree/repo
$OSTREE --repo=ostree/repo init
BRANCHES=""
mkdir ostree/worktree
cd ostree/worktree
mkdir -m 0755 $INITRD_MOVE_MOUNTS $TOPROOT_BIND_MOUNTS $OSTREE_BIND_MOUNTS $READONLY_BIND_MOUNTS $MOVE_MOUNTS sysroot
chmod a=rwxt tmp
$OSTREE --repo=../repo commit -b gnomeos-filesystem -s "Base filesystem layout"
BRANCHES="$BRANCHES gnomeos-filesystem"
cd ..
rm -rf worktree
for d in ${WORKDIR}/debootstrap-$DEBTARGET/var/cache/apt/archives/*.deb; do
bn=$(basename $d)
debname=$(echo $bn | cut -f 1 -d _)
debversion=$(echo $bn | cut -f 2 -d _)
archivename="archive-${debname}"
rm -rf worktree; mkdir worktree;
cd worktree;
mkdir data;
ar x $d;
tar -x -z -C data -f data.tar.gz;
cd data;
$OSTREE --repo=../../repo commit -b "${archivename}" -s "Version ${debversion}"
BRANCHES="$BRANCHES $archivename"
cd ../..
done
rm -rf worktree
$OSTREE --repo=repo compose --out-metadata=./compose-meta worktree $BRANCHES
cd worktree
$OSTREE --repo=../repo commit --metadata-variant=../compose-meta -b gnomeos -s "Compose of Debian $DEBTARGET"
cd ..
rm -rf worktree
cd ${WORKDIR}
if test -d ${OBJ}; then
mv ${OBJ} ${OBJ}.old
fi
mv ${OBJ}.tmp ${OBJ}
rm -rf ${OBJ}.old
fi
# TODO download source for above
# TODO download build dependencies for above
cd ${WORKDIR}
OBJ=gnomeos-fs
if ! test -d ${OBJ}; then
rm -rf ${OBJ}.tmp
cp -al $DEBTARGET-fs ${OBJ}.tmp
cd ${OBJ}.tmp/ostree;
rm -rf worktree
$OSTREE --repo=repo checkout gnomeos worktree
cd worktree
${SRCDIR}/debian-setup.sh
$OSTREE --repo=../repo commit -b gnomeos -s "Run debian-setup.sh"
cd ..
rm -rf worktree
rev=$($OSTREE --repo=repo rev-parse gnomeos);
$OSTREE --repo=repo checkout ${rev} gnomeos-${rev}
$OSTREE --repo=repo run-triggers gnomeos-${rev}
ln -s gnomeos-${rev} current
cd ${WORKDIR}
if test -d ${OBJ}; then
mv ${OBJ} ${OBJ}.old
fi
mv ${OBJ}.tmp ${OBJ}
rm -rf ${OBJ}.old
fi
cd ${WORKDIR}
(cd ${SRCDIR}/..;
make ostree_switch_root;
cp ostree_switch_root ${WORKDIR})
kv=`uname -r`
kernel=/boot/vmlinuz-${kv}
if ! test -f "${kernel}"; then
cat <<EOF
Failed to find ${kernel}
EOF
fi
cd ${WORKDIR}
OBJ=gnomeos-initrd.img
VOBJ=gnomeos-initrd-${kv}.img
if ! test -f ${OBJ}; then
rm -f ${OBJ}.tmp ${VOBJ}.tmp
$DRACUT -l -v -o plymouth --include `pwd`/ostree_switch_root /sbin/ostree_switch_root ${VOBJ}.tmp
mv ${VOBJ}.tmp ${VOBJ}
ln -sf ${VOBJ} gnomeos-initrd.img
fi

View File

@ -1,49 +0,0 @@
#!/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 -d gnomeos-fs; then
echo "Error: couldn't find gnomeos-fs. Run gnomeos-make-image.sh"
exit 1
fi
OBJ=gnomeos-fs.img
if (! test -f ${OBJ}) || test gnomeos-fs -nt ${OBJ}; then
rm -f ${OBJ}.tmp
qemu-img create ${OBJ}.tmp 2G
mkfs.ext4 -q -F ${OBJ}.tmp
mkdir -p fs
umount fs || true
mount -o loop ${OBJ}.tmp fs
cp -a gnomeos-fs/* fs
umount fs
mv ${OBJ}.tmp ${OBJ}
fi
kv=`uname -r`
kernel=/boot/vmlinuz-${kv}
exec qemu-kvm -kernel ${kernel} -initrd gnomeos-initrd.img -hda gnomeos-fs.img -append "root=/dev/sda ostree=current $1"

View File

@ -1 +0,0 @@
ostree-init

View File

@ -1,309 +0,0 @@
/* -*- c-file-style: "linux" -*-
* ostree_switch_root.c - switch to new root directory and start init.
* Copyright 2011 Colin Walters <walters@verbum.org>
*
* Based of switch_root.c from util-linux.
* Copyright 2002-2009 Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Peter Jones <pjones@redhat.com>
* Jeremy Katz <katzj@redhat.com>
* Colin Walters <walters@verbum.org>
*/
#define _GNU_SOURCE
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <dirent.h>
static int
perrorv (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
static int
perrorv (const char *format, ...)
{
va_list args;
char buf[PATH_MAX];
char *p;
p = strerror_r (errno, buf, sizeof (buf));
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, ": %s\n", p);
fflush (stderr);
va_end (args);
sleep (3);
return 0;
}
/* remove all files/directories below dirName -- don't cross mountpoints */
static int recursiveRemove(int fd)
{
struct stat rb;
DIR *dir;
int rc = -1;
int dfd;
if (!(dir = fdopendir(fd))) {
perrorv("failed to open directory");
goto done;
}
/* fdopendir() precludes us from continuing to use the input fd */
dfd = dirfd(dir);
if (fstat(dfd, &rb)) {
perrorv("failed to stat directory");
goto done;
}
while(1) {
struct dirent *d;
errno = 0;
if (!(d = readdir(dir))) {
if (errno) {
perrorv("failed to read directory");
goto done;
}
break; /* end of directory */
}
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
continue;
if (d->d_type == DT_DIR) {
struct stat sb;
if (fstatat(dfd, d->d_name, &sb, AT_SYMLINK_NOFOLLOW)) {
perrorv("failed to stat %s", d->d_name);
continue;
}
/* remove subdirectories if device is same as dir */
if (sb.st_dev == rb.st_dev) {
int cfd;
cfd = openat(dfd, d->d_name, O_RDONLY);
if (cfd >= 0) {
recursiveRemove(cfd);
close(cfd);
}
} else
continue;
}
if (unlinkat(dfd, d->d_name,
d->d_type == DT_DIR ? AT_REMOVEDIR : 0))
perrorv("failed to unlink %s", d->d_name);
}
rc = 0; /* success */
done:
if (dir)
closedir(dir);
return rc;
}
static int make_readonly(const char *tree)
{
struct stat stbuf;
/* Ignore nonexistent directories for now;
* some installs won't have e.g. lib64
*/
if (stat (tree, &stbuf) < 0)
return 0;
if (mount(tree, tree, NULL, MS_BIND, NULL) < 0) {
perrorv("Failed to do initial RO bind mount %s", tree);
return -1;
}
if (mount(tree, tree, NULL, MS_BIND | MS_REMOUNT | MS_RDONLY, NULL) < 0) {
perrorv("Failed to remount RO bind mount %s", tree);
return -1;
}
return 0;
}
static int switchroot(const char *newroot, const char *subroot)
{
const char *initrd_move_mounts[] = { "/dev", "/proc", "/sys", NULL };
const char *toproot_bind_mounts[] = { "/boot", "/home", "/root", "/tmp", NULL };
const char *ostree_bind_mounts[] = { "/var", NULL };
const char *readonly_bind_mounts[] = { "/bin", "/etc", "/lib",
"/lib32", "/lib64", "/sbin",
"/usr",
NULL };
int i;
int orig_cfd;
int new_cfd;
int subroot_cfd;
pid_t pid;
char subroot_path[PATH_MAX];
char srcpath[PATH_MAX];
char destpath[PATH_MAX];
fprintf (stderr, "switching to root %s subroot: %s\n", newroot, subroot);
orig_cfd = open("/", O_RDONLY);
new_cfd = open(newroot, O_RDONLY);
/* For now just remount the rootfs r/w. Should definitely
* handle this better later... (famous last words)
*/
if (mount(newroot, newroot, NULL, MS_REMOUNT, NULL) < 0) {
perrorv("failed to remount %s read/write", newroot);
return -1;
}
snprintf(subroot_path, sizeof(subroot_path), "%s/ostree/%s", newroot, subroot);
subroot_cfd = open(subroot_path, O_RDONLY);
if (subroot_cfd < 0) {
perrorv("failed to open subroot %s", subroot_path);
return -1;
}
for (i = 0; initrd_move_mounts[i] != NULL; i++) {
snprintf(destpath, sizeof(destpath), "%s%s", subroot_path, initrd_move_mounts[i]);
if (mount(initrd_move_mounts[i], destpath, NULL, MS_MOVE, NULL) < 0) {
perrorv("failed to move initramfs mount %s to %s",
initrd_move_mounts[i], destpath);
umount2(initrd_move_mounts[i], MNT_FORCE);
}
}
for (i = 0; toproot_bind_mounts[i] != NULL; i++) {
snprintf(srcpath, sizeof(srcpath), "%s%s", newroot, toproot_bind_mounts[i]);
snprintf(destpath, sizeof(destpath), "%s/%s", subroot_path, toproot_bind_mounts[i]);
if (mount(srcpath, destpath, NULL, MS_BIND & ~MS_RDONLY, NULL) < 0) {
perrorv("failed to bind mount (class:toproot) %s to %s", srcpath, destpath);
return -1;
}
}
for (i = 0; ostree_bind_mounts[i] != NULL; i++) {
snprintf(srcpath, sizeof(srcpath), "%s/ostree%s", newroot, ostree_bind_mounts[i]);
snprintf(destpath, sizeof(destpath), "%s%s", subroot_path, ostree_bind_mounts[i]);
if (mount(srcpath, destpath, NULL, MS_BIND & ~MS_RDONLY, NULL) < 0) {
perrorv("failed to bind mount (class:bind) %s to %s", srcpath, destpath);
return -1;
}
}
snprintf(destpath, sizeof(destpath), "%s/sysroot", subroot_path);
if (mount(newroot, destpath, NULL, MS_BIND, NULL) < 0) {
perrorv("Failed bind mount sysroot");
return -1;
}
if (chdir(newroot)) {
perrorv("failed to change directory to %s", newroot);
return -1;
}
if (mount(newroot, "/", NULL, MS_MOVE, NULL) < 0) {
perrorv("failed to mount moving %s to /", newroot);
return -1;
}
if (fchdir (new_cfd) < 0) {
perrorv("failed to fchdir back to root");
return -1;
}
snprintf(destpath, sizeof(destpath), "ostree/%s", subroot);
if (chroot(destpath) < 0) {
perrorv("failed to change root to %s", destpath);
return -1;
}
if (chdir ("/") < 0) {
perrorv("failed to chdir to subroot");
return -1;
}
for (i = 0; readonly_bind_mounts[i] != NULL; i++) {
if (make_readonly(readonly_bind_mounts[i]) < 0) {
return -1;
}
}
if (orig_cfd >= 0) {
pid = fork();
if (pid <= 0) {
recursiveRemove(orig_cfd);
if (pid == 0)
exit(EXIT_SUCCESS);
}
close(orig_cfd);
}
close(new_cfd);
return 0;
}
static void usage(FILE *output)
{
fprintf(output, "usage: %s <newrootdir> <init> <args to init>\n",
program_invocation_short_name);
exit(output == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
int main(int argc, char *argv[])
{
char *newroot, *subroot, *init, **initargs;
fflush (stderr);
if (argc < 4)
usage(stderr);
if ((!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")))
usage(stdout);
newroot = argv[1];
subroot = argv[2];
init = argv[3];
initargs = &argv[3];
if (!*newroot || !*subroot || !*init)
usage(stderr);
if (switchroot(newroot, subroot))
exit(1);
if (access(init, X_OK))
perrorv("cannot access %s", init);
execv(init, initargs);
perrorv("Failed to exec init '%s'", init);
exit(1);
}

View File

@ -1,3 +0,0 @@
* Add ostree-init binary for the non-initramfs case
- Just need to do the chroot before running real init
* Modify init scripts to do read only bind mounts etc.

View File

@ -1,212 +0,0 @@
#
# 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}
IMAGE_INSTALL = "libuuid1 \
libblkid1 \
e2fsprogs-blkid \
e2fsprogs-fsck \
e2fsprogs-e2fsck \
e2fsprogs-mke2fs \
e2fsprogs-tune2fs \
libtiff3 \
libjpeg8 \
libltdl7 \
libstdc++6 \
libgnutls26 \
libogg0 \
eglibc-gconvs \
eglibc-binaries \
pam-plugin-cracklib \
pam-plugin-env \
pam-plugin-keyinit \
pam-plugin-limits \
pam-plugin-localuser \
pam-plugin-loginuid \
pam-plugin-unix \
pam-plugin-rootok \
pam-plugin-succeed-if \
pam-plugin-permit \
pam-plugin-nologin \
ncurses-terminfo-base \
module-init-tools \
cpio \
util-linux-mount \
"
RDEPENDS += "ostree-native \
eglibc-locale \
tiff \
libogg \
libvorbis \
speex \
cpio \
libatomics-ops \
"
RECIPE_PACKAGES = "task-core-boot \
coreutils \
ostree \
strace \
bash \
tar \
grep \
gawk \
gzip \
less \
curl \
tzdata \
libsndfile1 \
icu \
procps \
libpam \
ncurses \
libvorbis \
speex \
python-modules \
python-misc \
openssh \
"
PACKAGE_INSTALL = "${RECIPE_PACKAGES} ${IMAGE_INSTALL}"
RDEPENDS += "${RECIPE_PACKAGES}"
DEPENDS += "makedevs-native 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
def gnomeos_get_devtable_list(d):
return bb.which(d.getVar('BBPATH', 1), 'files/device_table-minimal.txt')
# 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
# Delete all of the init scripts; we have our own
rm -f ${IMAGE_ROOTFS}/etc/init.d/*
rm -f ${IMAGE_ROOTFS}/etc/rc*.d/*
# Clear out the default fstab; everything we need right now is mounted
# in the initramfs.
cat < /dev/null > ${IMAGE_ROOTFS}/etc/fstab
# Kill the Debian netbase stuff - we use NetworkManager
rm -rf ${IMAGE_ROOTFS}/etc/network
# We deploy kernels via an external mechanism; the modules
# directory is just a bind mount to /sysroot.
rm -rf ${IMAGE_ROOTFS}/lib/modules
mkdir -p ${IMAGE_ROOTFS}/lib/modules
# Blow away udev from poky in favor of our own
rm ${IMAGE_ROOTFS}/sbin/udevd
ln -s /usr/libexec/udevd ${IMAGE_ROOTFS}/sbin/udevd
rm ${IMAGE_ROOTFS}/sbin/udevadm
ln -s /usr/sbin/udevadm ${IMAGE_ROOTFS}/sbin/udevadm
# Random configuration changes here
sed -i -e 's,^DESTINATION=.*,DESTINATION=\"file\",' ${IMAGE_ROOTFS}/etc/syslog.conf
# Adjustments for /etc -> {/var,/run} here
ln -sf /run/resolv.conf ${IMAGE_ROOTFS}/etc/resolv.conf
rm -f ${IMAGE_ROOTFS}/etc/passwd
ln -s /var/passwd ${IMAGE_ROOTFS}/etc/passwd
rm -f ${IMAGE_ROOTFS}/etc/shadow ${IMAGE_ROOTFS}/etc/shadow-
ln -s /var/shadow ${IMAGE_ROOTFS}/etc/shadow
rm -f ${IMAGE_ROOTFS}/etc/group
ln -s /var/group ${IMAGE_ROOTFS}/etc/group
TOPROOT_BIND_MOUNTS="home root tmp"
OSTREE_BIND_MOUNTS="var"
OSDIRS="dev proc mnt media run 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"
set -x
if echo ${IMAGE_LINK_NAME} | grep -q -e -runtime; then
ostree_target=runtime
else
ostree_target=devel
fi
if test x${MACHINE_ARCH} = xqemux86; then
ostree_machine=i686
else
if test x${MACHINE_ARCH} = xqemux86_64; then
ostree_machine=x86_64
else
echo "error: unknown machine from ${MACHINE_ARCH}"; exit 1
fi
fi
buildroot=gnomeos-3.4-${ostree_machine}-${ostree_target}
base=bases/yocto/${buildroot}
repo=${DEPLOY_DIR_IMAGE}/repo
if ! test -d ${repo}; then
mkdir ${repo}
ostree --repo=${repo} init --archive
fi
ostree --repo=${repo} commit -s "${IMAGE_LINK_NAME}" --skip-if-unchanged "Build" -b ${base} --tree=tar=${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.tar.gz
ostree --repo=${repo} diff "${base}" || true
# Create the initial root if it doesn't exist
if ! ostree --repo=${repo} rev-parse "${buildroot}" 2>/dev/null; then
ostree --repo=${repo} compose -s "Initial compose" -b ${buildroot} ${base}:/
fi
}
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

View File

@ -1,46 +0,0 @@
#!/bin/bash
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
set -e
set -x
WORKDIR=`pwd`
cd `dirname $0`
SCRIPT_SRCDIR=`pwd`
cd -
if test $(id -u) = 0; then
cat <<EOF
This script should not be run as root.
EOF
exit 1
fi
usage () {
echo "$0 BRANCH"
exit 1
}
BRANCH=$1
test -n "$BRANCH" || usage
shift
YOCTO_ARCH=x86
MACHINE=i686
BUILDROOT="gnomeos-3.4-${MACHINE}-${BRANCH}"
BASE="bases/yocto/${BUILDROOT}"
OSTREE_VER=$(cd $SCRIPT_SRCDIR && git describe)
BUILDDIR=$WORKDIR/tmp-eglibc
OSTREE_REPO=$WORKDIR/repo
BUILD_TAR=$BUILDDIR/deploy/images/gnomeos-contents-$BRANCH-qemu${YOCTO_ARCH}.tar.gz
BUILD_TIME=$(date -r $BUILD_TAR)
ostree --repo=${OSTREE_REPO} commit --skip-if-unchanged -s "Build from OSTree ${OSTREE_VER}" -b "${BASE}" --tree=tar=${BUILD_TAR}
ostree --repo=${OSTREE_REPO} diff "${BASE}"^ "${BASE}" || true
ostree --repo=${OSTREE_REPO} compose -s "Initial compose" -b ${BUILDROOT} ${BASE}:/

View File

@ -1,50 +0,0 @@
DISTRO = "gnomeosdistro"
DISTRO_NAME = "GNOME OS (Poky 6.0+ostree)"
DISTRO_VERSION = "0+snapshot-${DATE}"
SDK_VENDOR = "-gnomesdk"
SDK_VERSION := "${@'${DISTRO_VERSION}'.replace('snapshot-${DATE}','snapshot')}"
MAINTAINER = "Colin Walters <walters@verbum.org>"
TARGET_VENDOR = "-gnomeos"
SYSVINIT_ENABLED_GETTYS = "1 2 3 4 5 6"
LOCALCONF_VERSION = "1"
DISTRO_FEATURES_append = " largefile opengl pam"
PREFERRED_VERSION_linux-yocto ?= "3.0.%"
PREFERRED_VERSION_linux-yocto_qemux86 ?= "3.0%"
PREFERRED_VERSION_linux-yocto_qemux86-64 ?= "3.0%"
SDK_NAME = "${DISTRO}-${TCLIBC}-${SDK_ARCH}-${TARGET_ARCH}"
SDKPATH = "/opt/${DISTRO}/${SDK_VERSION}"
DISTRO_EXTRA_RDEPENDS += "task-core-boot"
DISTRO_EXTRA_RRECOMMENDS += "kernel-module-af-packet"
QEMU_TARGETS ?= "i386 x86_64"
PREMIRRORS ?= "\
bzr://.*/.* http://autobuilder.yoctoproject.org/sources/ \n \
cvs://.*/.* http://autobuilder.yoctoproject.org/sources/ \n \
git://.*/.* http://autobuilder.yoctoproject.org/sources/ \n \
hg://.*/.* http://autobuilder.yoctoproject.org/sources/ \n \
osc://.*/.* http://autobuilder.yoctoproject.org/sources/ \n \
p4://.*/.* http://autobuilder.yoctoproject.org/sources/ \n \
svk://.*/.* http://autobuilder.yoctoproject.org/sources/ \n \
svn://.*/.* http://autobuilder.yoctoproject.org/sources/ \n"
MIRRORS =+ "\
ftp://.*/.* http://autobuilder.yoctoproject.org/sources/ \n \
http://.*/.* http://autobuilder.yoctoproject.org/sources/ \n \
https://.*/.* http://autobuilder.yoctoproject.org/sources/ \n"
# The CONNECTIVITY_CHECK_URI's are used to test whether we can succesfully
# fetch from the network (and warn you if not). To disable the test set
# the variable to be empty.
CONNECTIVITY_CHECK_URIS ?= "git://git.yoctoproject.org/yocto-firewall-test;protocol=git;rev=HEAD \
https://eula-downloads.yoctoproject.org/index.php \
http://bugzilla.yoctoproject.org/report.cgi"

View File

@ -1,7 +0,0 @@
BBPATH := "${BBPATH}:${LAYERDIR}"
BBFILES := "${BBFILES} ${LAYERDIR}/packages/*/*.bb ${LAYERDIR}/recipies-*/*/*.bb"
BBFILE_COLLECTIONS += "gnomeos"
BBFILE_PATTERN_gnomeos := "^${LAYERDIR}/"
BBFILE_PRIORITY_gnomeos = "6"

View File

@ -1,14 +0,0 @@
SUMMARY = "NetworkManager"
HOMEPAGE = "http://projects.gnome.org/NetworkManager/"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://COPYING;md5=cbbffd568227ada506640fe950a4823b"
DEPENDS = "gnutls wpa-supplicant libnl wireless-tools ppp glib-2.0 dbus-glib util-linux virtual/gettext"
SRC_URI = "http://ftp.acc.umu.se/pub/GNOME/sources/NetworkManager/0.9/NetworkManager-${PV}.tar.bz2 \
file://0001-configure-Allow-specifying-with-distro-generic.patch \
"
inherit autotools pkgconfig
EXTRA_OECONF = "--with-distro=generic --with-crypto=gnutls"

View File

@ -1,26 +0,0 @@
From 0c2a325a19dc80097bebd86fe77dfc0bfbcdaab6 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Mon, 28 Mar 2011 17:17:35 -0400
Subject: [PATCH] configure: Allow specifying --with-distro=generic
This option is useful if we simply don't need any legacy integration.
---
configure.ac | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 98e2b04..b940d50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,7 +128,7 @@ if test "z$with_distro" = "z"; then
exit 1
else
case $with_distro in
- redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus|linexa|exherbo) ;;
+ generic|redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus|linexa|exherbo) ;;
*)
echo "Your distribution (${with_distro}) is not yet supported! (patches welcome)"
exit 1
--
1.7.4

View File

@ -1,3 +0,0 @@
require NetworkManager.inc
SRC_URI[sha256sum] = "a178ed2f0b5a1045ec47b217ea531d0feba9208f6bcfe64b701174a5c1479816"

View File

@ -1,11 +0,0 @@
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"

View File

@ -1,51 +0,0 @@
#
# 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 gnomeos-contents
RECIPE_PACKAGES += "task-core-sdk \
python-dev \
bison flex \
git \
gdb \
zip \
libxml-parser-perl \
gettext-dev \
"
DEPENDS += "db"
IMAGE_INSTALL += "libc6-dev \
libgcc-s-dev \
linux-libc-headers-dev \
libz-dev \
libtool-dev \
libuuid-dev \
libblkid-dev \
libpam-dev \
libtiff-dev \
libjpeg-dev \
libltdl-dev \
libsndfile-dev \
libatomics-ops-dev \
libogg-dev \
speex-dev \
libvorbis-dev \
libstdc++-dev \
libcap-dev \
libcap-bin \
libgpg-error-dev \
libtasn1-dev \
libtasn1-bin \
libgcrypt-dev \
libgnutls-dev \
icu-dev \
curl-dev \
libcurl-dev \
ncurses-dev \
db-dev \
"

View File

@ -1,8 +0,0 @@
#
# 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 gnomeos-contents

View File

@ -1,17 +0,0 @@
SUMMARY = "GNOME OS management tool"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://COPYING;md5=97285cb818cf231e6a36f72c82592235"
SRC_URI = "git://git.gnome.org/ostree;tag=00ad0a2ea7965de5852e35395fcfd9c9df4ebc2a"
S = "${WORKDIR}/git"
DEPENDS += "libarchive glib-2.0"
inherit autotools
EXTRA_OECONF = "--without-soup-gnome --with-libarchive"
FILES_${PN} += "${libdir}/ostree/ ${libdir}/ostbuild"
BBCLASSEXTEND = "native"