installer: Rename run.sh to clone-qemu.sh

The idea here is that we expect people to run installed (i.e. with
host kernel), but we now have an option to boot via qemu too.
This commit is contained in:
Colin Walters 2012-02-09 12:38:21 -05:00
parent 883896a1b2
commit ee712b8419
2 changed files with 99 additions and 148 deletions

View File

@ -0,0 +1,99 @@
#!/bin/sh
# -*- indent-tabs-mode: nil; -*-
# Run built image in QEMU
#
# Copyright (C) 2011,2012 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
}
ARCH=i686
BRANCH_PREFIX="gnomeos-3.4-${ARCH}-"
OBJ=gnomeos-fs.img
if ! test -f ${OBJ}; then
cat <<EOF
Create gnomeos-fs.img like this:
$ qemu-img create gnomeos-fs.img 6G
$ mkfs.ext4 -q -F gnomeos-fs.img
EOF
exit 1
fi
if ! test -d ${WORKDIR}/repo/objects; then
cat <<EOF
No ./repo/objects found
EOF
exit 1
fi
mkdir -p fs
umount fs || true
sleep 1 # Avoid Linux kernel bug, pretty sure it's the new RCU pathname lookup
mount -o loop gnomeos-fs.img fs
cd fs
TOPROOT_BIND_MOUNTS="home root tmp"
for d in $TOPROOT_BIND_MOUNTS; do
if ! test -d $d; then
mkdir -m 0755 $d
fi
done
chmod a=rwxt tmp
if ! test -d ostree; then
mkdir -p ostree
$SRCDIR/ostree-setup.sh $(pwd)/ostree
fi
rsync -a -H -v ${WORKDIR}/repo ${WORKDIR}/gnomeos-3.4-* ./ostree
current_uname=$(uname -r)
cd ${WORKDIR}
sync
umount fs
rmdir fs
if ! echo $ARGS | grep -q 'ostree='; then
ARGS="ostree=${BRANCH_PREFIX}runtime-current $ARGS"
fi
ARGS="rd.plymouth=0 root=/dev/sda $ARGS"
KERNEL=/boot/vmlinuz-${current_uname}
INITRD_ARG="-initrd /boot/initramfs-ostree-${current_uname}.img"
exec qemu-kvm -kernel ${KERNEL} ${INITRD_ARG} -hda gnomeos-fs.img -net user -net nic,model=virtio -m 512M -append "$ARGS" -monitor stdio

View File

@ -1,148 +0,0 @@
#!/bin/sh
# -*- indent-tabs-mode: nil; -*-
# Run built image in QEMU
#
# Copyright (C) 2011,2012 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
TYPE=$1
shift
ARCH=i686
BRANCH_PREFIX="gnomeos-3.4-${ARCH}-"
OBJ=gnomeos-fs.img
if (! test -f ${OBJ}); then
rm -f ${OBJ}.tmp
qemu-img create ${OBJ}.tmp 6G
mkfs.ext3 -q -F ${OBJ}.tmp
mv ${OBJ}.tmp ${OBJ}
fi
mkdir -p fs
umount fs || true
sleep 1 # Avoid Linux kernel bug, pretty sure it's the new RCU pathname lookup
mount -o loop gnomeos-fs.img fs
cd fs
TOPROOT_BIND_MOUNTS="home root tmp"
for d in $TOPROOT_BIND_MOUNTS; do
if ! test -d $d; then
mkdir -m 0755 $d
fi
done
chmod a=rwxt tmp
if ! test -d ostree; then
mkdir ostree
mkdir -p -m 0755 ./ostree/var/{log,run,tmp,spool}
mkdir -p ./ostree/var/lib/dbus
dbus-uuidgen > ./ostree/var/lib/dbus/machine-id
mkdir ./ostree/var/lib/gdm
chown 2:2 ./ostree/var/lib/gdm
touch ./ostree/var/shadow
chmod 0600 ./ostree/var/shadow
mkdir ostree/repo
ostree --repo=ostree/repo init
cat >ostree/var/passwd << EOF
root::0:0:root:/:/bin/sh
dbus:*:1:1:dbus:/:/bin/false
gdm:*:2:2:gdm:/var/lib/gdm:/bin/false
EOF
cat >ostree/var/group << EOF
root:*:0:root
dbus:*:1:
gdm:*:2:
EOF
fi
if test x${TYPE} = xcurrent; then
current_uname=$(uname -r)
fi
cd ostree
ostree --repo=${OSTREE_REPO} local-clone repo ${BRANCH_PREFIX}runtime ${BRANCH_PREFIX}devel
for branch in runtime devel; do
rev=$(ostree --repo=repo rev-parse ${BRANCH_PREFIX}${branch});
if ! test -d ${BRANCH_PREFIX}${branch}-${rev}; then
ostree --repo=repo checkout ${rev} ${BRANCH_PREFIX}${branch}-${rev}.tmp
ostbuild chroot-run-triggers ${BRANCH_PREFIX}${branch}-${rev}.tmp
if test x$TYPE = xcurrent; then
cp -ar /lib/modules/${current_uname} ${BRANCH_PREFIX}${branch}-${rev}.tmp/lib/modules
fi
mv ${BRANCH_PREFIX}${branch}-${rev}{.tmp,}
fi
rm -f ${BRANCH_PREFIX}${branch}-current
ln -s ${BRANCH_PREFIX}${branch}-${rev} ${BRANCH_PREFIX}${branch}-current
done
cd ..
test -d proc || mkdir proc # needed for ostree-init
cp -a ./ostree/${BRANCH_PREFIX}${branch}-current/usr/sbin/ostree-init .
cd ${WORKDIR}
sync
umount fs
rmdir fs
ARGS="rd.plymouth=0 $@"
if ! echo $ARGS | grep -q 'init='; then
ARGS="init=/ostree-init $ARGS"
fi
if ! echo $ARGS | grep -q 'ostree='; then
ARGS="ostree=${BRANCH_PREFIX}runtime-current $ARGS"
fi
if test x$TYPE = xqemu; then
ARGS="root=/dev/hda $ARGS"
KERNEL=./tmp-eglibc/deploy/images/bzImage-qemux86.bin
else
if test x$TYPE = xcurrent; then
ARGS="root=/dev/sda $ARGS"
KERNEL=/boot/vmlinuz-${current_uname}
INITRD_ARG="-initrd /boot/initramfs-ostree-${current_uname}.img"
fi
fi
exec qemu-kvm -kernel ${KERNEL} ${INITRD_ARG} -hda gnomeos-fs.img -net user -net nic,model=virtio -m 512M -append "$ARGS" -monitor stdio