From 1d93adc925fa7b0b8c6fd3ecb794cedd82b9060a Mon Sep 17 00:00:00 2001 From: Colin Walters <walters@verbum.org> Date: Thu, 2 Feb 2012 07:46:52 -0500 Subject: [PATCH] gnomeos: start writing an install script --- gnomeos/yocto/15_ostree | 73 ++++++++++++++++++++++++++++++++ gnomeos/yocto/gnomeos-install.sh | 64 ++++++++++++++++++++++++++++ gnomeos/yocto/ostree-setup.sh | 67 +++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+) create mode 100755 gnomeos/yocto/15_ostree create mode 100755 gnomeos/yocto/gnomeos-install.sh create mode 100755 gnomeos/yocto/ostree-setup.sh diff --git a/gnomeos/yocto/15_ostree b/gnomeos/yocto/15_ostree new file mode 100755 index 00000000..d67cf444 --- /dev/null +++ b/gnomeos/yocto/15_ostree @@ -0,0 +1,73 @@ +#!/bin/sh + +set -e + +. /usr/lib/grub/grub-mkconfig_lib + +CLASS="--class gnu-linux --class gnu --class os" + +if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ + || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + || uses_abstraction "${GRUB_DEVICE}" lvm; then + LINUX_ROOT_DEVICE=${GRUB_DEVICE} +else + LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} +fi + +ostree_linux_entry () +{ + os="$1" + version="$2" + args="$3" + + printf "menuentry '${os}; Linux ${version}' ${CLASS} {\n" + + cat << EOF + insmod gzio +EOF + + cat <<EOF + echo '"Loading ${os} ${version}"' + linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro init=/ostree/ostree-init ${args} +EOF + if test -n "${initrd}" ; then + message="$(gettext_printf "Loading initial ramdisk ...")" + cat << EOF + echo '$message' + initrd ${rel_dirname}/${initrd} +EOF + fi + cat << EOF +} +EOF +} + +machine=$(uname -m) +kernels=$(echo /boot/vmlinuz-*.${machine}) +while [ "x${kernels}" != x ]; do + linux=`version_find_latest $kernels` >&2 + basename=`basename $linux` + dirname=`dirname $linux` + rel_dirname=`make_system_path_relative_to_its_root $dirname` + version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` + alt_version=`echo $version | sed -e "s,\.old$,,g"` + linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" + + initrd= + for i in "initrd.img-${version}" "initrd-${version}.img" \ + "initrd-${version}" "initramfs-${version}.img" \ + "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ + "initrd-${alt_version}" "initramfs-${alt_version}.img" \ + "initramfs-genkernel-${version}" \ + "initramfs-genkernel-${alt_version}"; do + if test -e "${dirname}/${i}" ; then + initrd="$i" + break + fi + done + + ostree_linux_entry "GNOMEOS 3.4" "${version}" \ + "${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_LINUX_DEFAULT}" + + kernels=`echo $kernels | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '` +done diff --git a/gnomeos/yocto/gnomeos-install.sh b/gnomeos/yocto/gnomeos-install.sh new file mode 100755 index 00000000..8d906e3c --- /dev/null +++ b/gnomeos/yocto/gnomeos-install.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# -*- indent-tabs-mode: nil; -*- +# Install OSTree to system +# +# 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_URL" + exit 1 +} + +ARCH=i686 +BRANCH_PREFIX="gnomeos-3.4-${ARCH}-" + +if ! test -d /ostree; then + mkdir /ostree + + $SRCDIR/ostree-setup.sh /ostree +fi + +cd /ostree +for branch in runtime devel; do + rev=$(ostree --repo=$(pwd)/repo rev-parse ${BRANCH_PREFIX}${branch}); + if ! test -d ${BRANCH_PREFIX}${branch}-${rev}; then + ostree --repo=repo checkout ${rev} ${BRANCH_PREFIX}${branch}-${rev} + ostbuild chroot-run-triggers ${BRANCH_PREFIX}${branch}-${rev} + fi + rm -f ${BRANCH_PREFIX}${branch}-current + ln -s ${BRANCH_PREFIX}${branch}-${rev} ${BRANCH_PREFIX}${branch}-current +done +rm -f current +ln -s ${BRANCH_PREFIX}runtime-current current + +cp -a ./${BRANCH_PREFIX}${branch}-current/usr/sbin/ostree-init . + +cp $SRCDIR/15_ostree /etc/grub.d/ diff --git a/gnomeos/yocto/ostree-setup.sh b/gnomeos/yocto/ostree-setup.sh new file mode 100755 index 00000000..584c3a92 --- /dev/null +++ b/gnomeos/yocto/ostree-setup.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# -*- indent-tabs-mode: nil; -*- +# Set up ostree directory +# +# 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_DIR_PATH" + exit 1 +} + +OSTREE_DIR_PATH=$1 +shift +test -n "$OSTREE_DIR_PATH" || usage + +cd "$OSTREE_DIR_PATH" +mkdir -p -m 0755 ./var/{log,run,tmp,spool} +mkdir -p ./var/lib/dbus +dbus-uuidgen > ./var/lib/dbus/machine-id + +mkdir ./var/lib/gdm +chown 2:2 ./var/lib/gdm + +touch ./var/shadow +chmod 0600 ./var/shadow + +mkdir repo +ostree --repo=repo init + +cat >./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 >./var/group << EOF +root:*:0:root +dbus:*:1: +gdm:*:2: +EOF