From 0f09ccea223720452cf9fe83a2296dc104cedeed Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 26 Oct 2011 17:16:46 -0400 Subject: [PATCH] parallel-debian: Add install and run scripts --- parallel-debian/gnomeos-install.sh | 45 +++++++++++++++++++++++++++ parallel-debian/gnomeos-make-image.sh | 13 +++++--- parallel-debian/gnomeos-run.sh | 34 ++++++++++++++++++++ 3 files changed, 88 insertions(+), 4 deletions(-) create mode 100755 parallel-debian/gnomeos-install.sh create mode 100755 parallel-debian/gnomeos-run.sh diff --git a/parallel-debian/gnomeos-install.sh b/parallel-debian/gnomeos-install.sh new file mode 100755 index 00000000..650d2508 --- /dev/null +++ b/parallel-debian/gnomeos-install.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# -*- indent-tabs-mode: nil; -*- +# Install built ostree image to current system +# +# Copyright (C) 2011 Colin Walters +# +# 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, 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 + +mkdir -p fs +umount fs || true +mount -o loop gnomeos-filesystem.img fs +cp -a fs/ostree / +umount fs +initrd=`readlink gnomeos-initrd.img` +cp ${initrd} /boot +grubby --title "GNOME OS" --add-kernel=$kernel --copy-default --initrd=/boot/${initrd} diff --git a/parallel-debian/gnomeos-make-image.sh b/parallel-debian/gnomeos-make-image.sh index a6e33f21..0d706546 100755 --- a/parallel-debian/gnomeos-make-image.sh +++ b/parallel-debian/gnomeos-make-image.sh @@ -24,7 +24,7 @@ set -x SRCDIR=`dirname $0` WORKDIR=`pwd` -DEPENDS="debootstrap qemu-img" +DEPENDS="debootstrap qemu-img grubby" for x in $DEPENDS; do if ! command -v $x; then @@ -133,9 +133,14 @@ fi cp ${SRCDIR}/ostree_switch_root ${WORKDIR} +kernel=`grubby --default-kernel` +kv=$(basename $kernel | sed -e s,vmlinuz-,,) + OBJ=gnomeos-initrd.img +VOBJ=gnomeos-initrd-${kv}.img if ! test -f ${OBJ}; then - rm -f ${OBJ}.tmp - $DRACUT -l -v --include `pwd`/ostree_switch_root /sbin/ostree_switch_root ${OBJ}.tmp - mv ${OBJ}.tmp ${OBJ} + rm -f ${OBJ}.tmp ${VOBJ}.tmp + $DRACUT -l -v --include `pwd`/ostree_switch_root /sbin/ostree_switch_root ${VOBJ}.tmp + mv ${VOBJ}.tmp ${VOBJ} + ln -sf ${VOBJ} gnomeos-initrd.img fi diff --git a/parallel-debian/gnomeos-run.sh b/parallel-debian/gnomeos-run.sh new file mode 100755 index 00000000..fe2f8204 --- /dev/null +++ b/parallel-debian/gnomeos-run.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# -*- indent-tabs-mode: nil; -*- +# Run built image in QEMU +# +# Copyright (C) 2011 Colin Walters +# +# 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, 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 + +umount fs || true +exec qemu-kvm -kernel `grubby --default-kernel` -initrd gnomeos-initrd.img -hda gnomeos-filesystem.img -append "root=/dev/sda ostree=current"