...
 
Commits (9)
  • Frédéric Dalleau's avatar
    u-boot: Add fdtdir option when generating uEnv.txt · 6a50ebc4
    Frédéric Dalleau authored
    u-boot config generator does not create fdtdir entry in uEnv.txt.
    Add fdtdir, as done in u-boot-distro.
    Signed-off-by: Frédéric Dalleau's avatarFrédéric Dalleau <frederic.dalleau@collabora.co.uk>
    
    Gbp-Pq: Name 0001-u-boot-Add-fdtdir-option-when-generating-uEnv.txt.patch
    6a50ebc4
  • Sjoerd Simons's avatar
    Add fdtdir bootconfig entry · 3fa38e4e
    Sjoerd Simons authored
    Gbp-Pq: Name Add-fdtdir-bootconfig-entry.patch
    3fa38e4e
  • Sjoerd Simons's avatar
    sysroot: Also deploy device-tree files · a1faf321
    Sjoerd Simons authored
    Most embedded system need a device-tree file to go along with the kernel
    and the initramfs. This file is a description of the non-introspectable
    parts of the hardware.
    
    Currently with ostree the only way to use it is to use the legacy "appended
    dtb" method, which is basically just slapping a specific boards dtb at
    the end of the kernel binary. Which is fine when creating deployments for a
    single board, but not very useful when targetting a bigger selection of
    boards.
    
    Add support to ostree sysroot deploy to apart from the kernel and
    initramfs also deploy the directory with dtbs directory.
    
    Gbp-Pq: Name sysroot-Also-deploy-device-tree-files.patch
    a1faf321
  • Sjoerd Simons's avatar
    tests: sysroot: Test deployment of dtb files · c7701a0b
    Sjoerd Simons authored
    There are two conventions for the layout of the dtb directory, one is to
    just have all the dtbs at the top-level (e.g. done on 32 bit arm) the
    other is to have them in subdirectories per vendor (e.g. done on 64 bit
    arm). Extend the test for dtb using both strategies and while there also
    check the initramfs is all happy.
    
    Gbp-Pq: Name tests-sysroot-Test-deployment-of-dtb-files.patch
    c7701a0b
  • Sjoerd Simons's avatar
    u-boot distro configuration loader · 039256b0
    Sjoerd Simons authored
    
    Gbp-Pq: Name u-boot-distro-configuration-loader.patch
    039256b0
  • Sjoerd Simons's avatar
    Add test for distro u-boot · d97c9abc
    Sjoerd Simons authored
    Gbp-Pq: Name Add-test-for-distro-u-boot.patch
    d97c9abc
  • Sjoerd Simons's avatar
    Add bootloader configuration for sd-boot · a13ca8c1
    Sjoerd Simons authored
    SD-boot bootloader support. Assumes the ESP is at /boot/efi and uses the
    existance of loader/entries on the ESP to detect of sd-boot is in use.
    Signed-off-by: 's avatarSjoerd Simons <sjoerd@luon.net>
    
    Gbp-Pq: Name 0001-Add-bootloader-configuration-for-sd-boot.patch
    a13ca8c1
  • Martyn Welch's avatar
    Add in rollback generation · 0ba0e7d4
    Martyn Welch authored
    We wish to provide a second config that can be used in the event that the
    latest upgrade fails to boot successfully (to be determined by system
    specific metrics). Cause OSTree to generate an alternative config that
    defaults to the alternative OSTree image that the bootloader can swtich to
    when a failure state is detected.
    Signed-off-by: Martyn Welch's avatarMartyn Welch <martyn.welch@collabora.co.uk>
    
    Gbp-Pq: Name Add-in-rollback-generation.patch
    0ba0e7d4
  • Martyn Welch's avatar
    Determine whether /boot resides on the / partition · 7c02210a
    Martyn Welch authored
    We need to know whether /boot resides on the boot partition or not when
    writing the U-Boot configuration. If /boot is on a separate partition then
    we do not need to include this directory in the locations of the boot
    components. If /boot is on the root partition then this needs to be
    specified or the boot components will not be found and boot will fail.
    Signed-off-by: Martyn Welch's avatarMartyn Welch <martyn.welch@collabora.co.uk>
    
    Gbp-Pq: Name Determine-whether-boot-resides-on-the-partition.patch
    7c02210a
......@@ -126,10 +126,14 @@ libostree_1_la_SOURCES = \
src/libostree/ostree-bootloader.c \
src/libostree/ostree-bootloader-grub2.h \
src/libostree/ostree-bootloader-grub2.c \
src/libostree/ostree-bootloader-sd-boot.h \
src/libostree/ostree-bootloader-sd-boot.c \
src/libostree/ostree-bootloader-syslinux.h \
src/libostree/ostree-bootloader-syslinux.c \
src/libostree/ostree-bootloader-uboot.h \
src/libostree/ostree-bootloader-uboot.c \
src/libostree/ostree-bootloader-uboot-distro.h \
src/libostree/ostree-bootloader-uboot-distro.c \
src/libostree/ostree-repo-static-delta-core.c \
src/libostree/ostree-repo-static-delta-processing.c \
src/libostree/ostree-repo-static-delta-compilation.c \
......
......@@ -101,6 +101,7 @@ _installed_or_uninstalled_test_scripts = \
tests/test-admin-deploy-switch.sh \
tests/test-admin-deploy-etcmerge-cornercases.sh \
tests/test-admin-deploy-uboot.sh \
tests/test-admin-deploy-uboot-distro.sh \
tests/test-admin-deploy-grub2.sh \
tests/test-admin-deploy-bootid-gc.sh \
tests/test-admin-instutil-set-kargs.sh \
......
This diff is collapsed.
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2013 Collabora Ltd
* Copyright (C) 2017 Sjoerd Simons <sjoerd@luon.net>
*
* This program 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 licence 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.
*
*/
#pragma once
#include "ostree-bootloader.h"
G_BEGIN_DECLS
#define OSTREE_TYPE_BOOTLOADER_SD_BOOT (_ostree_bootloader_sd_boot_get_type ())
#define OSTREE_BOOTLOADER_SD_BOOT(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTLOADER_SD_BOOT, OstreeBootloaderSdBoot))
#define OSTREE_IS_BOOTLOADER_SD_BOOT(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTLOADER_SD_BOOT))
typedef struct _OstreeBootloaderSdBoot OstreeBootloaderSdBoot;
GType _ostree_bootloader_sd_boot_get_type (void) G_GNUC_CONST;
OstreeBootloaderSdBoot * _ostree_bootloader_sd_boot_new (OstreeSysroot *sysroot);
G_END_DECLS
This diff is collapsed.
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
*
* This program 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 licence 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.
*/
#pragma once
#include "ostree-bootloader.h"
G_BEGIN_DECLS
#define OSTREE_TYPE_BOOTLOADER_UBOOT_DISTRO (_ostree_bootloader_uboot_distro_get_type ())
#define OSTREE_BOOTLOADER_UBOOT_DISTRO(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTLOADER_UBOOT_DISTRO, OstreeBootloaderUbootDistro))
#define OSTREE_IS_BOOTLOADER_UBOOT_DISTRO(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTLOADER_UBOOT_DISTRO))
typedef struct _OstreeBootloaderUbootDistro OstreeBootloaderUbootDistro;
GType _ostree_bootloader_uboot_distro_get_type (void) G_GNUC_CONST;
OstreeBootloaderUbootDistro * _ostree_bootloader_uboot_distro_new (OstreeSysroot *sysroot);
G_END_DECLS
......@@ -144,6 +144,10 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
if (val)
g_ptr_array_add (new_lines, g_strdup_printf ("fdt_file%s=%s", index_suffix, val));
val = ostree_bootconfig_parser_get (config, "fdtdir");
if (val)
g_ptr_array_add (new_lines, g_strdup_printf ("fdtdir%s=%s", index_suffix, val));
val = ostree_bootconfig_parser_get (config, "options");
if (val)
{
......
This diff is collapsed.
......@@ -34,6 +34,8 @@
#include "ostree-sysroot-private.h"
#include "ostree-deployment-private.h"
#include "ostree-bootloader-uboot.h"
#include "ostree-bootloader-sd-boot.h"
#include "ostree-bootloader-uboot-distro.h"
#include "ostree-bootloader-syslinux.h"
#include "ostree-bootloader-grub2.h"
......@@ -1188,6 +1190,22 @@ _ostree_sysroot_query_bootloader (OstreeSysroot *sysroot,
if (!_ostree_bootloader_query (ret_loader, &is_active, cancellable, error))
return FALSE;
}
if (!is_active)
{
g_object_unref (ret_loader);
ret_loader = (OstreeBootloader*)_ostree_bootloader_uboot_distro_new (sysroot);
if (!_ostree_bootloader_query (ret_loader, &is_active, cancellable, error))
return FALSE;
}
if (!is_active)
{
g_object_unref (ret_loader);
ret_loader = (OstreeBootloader*)_ostree_bootloader_sd_boot_new (sysroot);
if (!_ostree_bootloader_query (ret_loader, &is_active, cancellable, error))
return FALSE;
}
if (!is_active)
g_clear_object (&ret_loader);
......
......@@ -28,6 +28,8 @@ function validate_bootloader() {
bootloader=""
if test -f sysroot/boot/syslinux/syslinux.cfg; then
bootloader="syslinux"
elif test -f sysroot/boot/extlinux/extlinux.conf; then
bootloader="uboot-distro"
elif test -f sysroot/boot/grub2/grub.cfg; then
bootloader="grub2"
fi
......@@ -72,6 +74,9 @@ assert_has_file sysroot/boot/loader/entries/ostree-1-testos.conf
assert_file_has_content sysroot/boot/loader/entries/ostree-1-testos.conf 'options.* root=LABEL=MOO'
assert_file_has_content sysroot/boot/loader/entries/ostree-1-testos.conf 'options.* quiet'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/vmlinuz-3.6.0 'a kernel'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/initramfs-3.6.0.img 'an initramfs'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/dtbs-3.6.0/board.dtb 'a dtb'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/dtbs-3.6.0/vendor/board.dtb 'another dtb'
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
assert_file_has_content sysroot/ostree/boot.1/testos/${bootcsum}/0/etc/os-release 'NAME=TestOS'
assert_ostree_deployment_refs 1/1/0
......
......@@ -27,7 +27,11 @@ else:
bootloader = sys.argv[2]
loaderpath = sysroot + '/boot/loader/entries'
syslinuxpath = sysroot + '/boot/syslinux/syslinux.cfg'
if bootloader == "syslinux":
configpath = sysroot + '/boot/syslinux/syslinux.cfg'
elif bootloader == "uboot-distro":
configpath = sysroot + '/boot/extlinux/extlinux.conf'
if bootloader == "grub2":
sys.stdout.write('GRUB2 configuration validation not implemented.\n')
......@@ -48,7 +52,7 @@ def get_ostree_option(optionstring):
raise ValueError('ostree= not found')
entries = []
syslinux_entries = []
config_entries = []
# Parse loader configs
for fname in os.listdir(loaderpath):
......@@ -67,32 +71,37 @@ for fname in os.listdir(loaderpath):
entries.append(entry)
entries.sort(key=entry_get_version, reverse=True)
# Parse SYSLINUX config
with open(syslinuxpath) as f:
# Parse config
with open(configpath) as f:
in_ostree_config = False
syslinux_entry = None
syslinux_default = None
config_entry = None
config_default = None
for line in f:
line = line.strip()
if line.startswith('DEFAULT '):
if syslinux_entry is not None:
syslinux_default = line.split(' ', 1)[1]
elif line.startswith('LABEL '):
if syslinux_entry is not None:
syslinux_entries.append(syslinux_entry)
syslinux_entry = {}
syslinux_entry['title'] = line.split(' ', 1)[1]
elif line.startswith('KERNEL '):
syslinux_entry['linux'] = line.split(' ', 1)[1]
elif line.startswith('INITRD '):
syslinux_entry['initrd'] = line.split(' ', 1)[1]
elif line.startswith('APPEND '):
syslinux_entry['options'] = line.split(' ', 1)[1]
if syslinux_entry is not None:
syslinux_entries.append(syslinux_entry)
if len(entries) != len(syslinux_entries):
fatal("Found {0} loader entries, but {1} SYSLINUX entries\n".format(len(entries), len(syslinux_entries)))
if line == "":
continue
command, argument = line.split(' ', 1)
command = command.lower()
if command == "default":
config_default = argument
elif command == "label":
if config_entry is not None:
config_entries.append(config_entry)
config_entry = {}
config_entry['title'] = line.split(' ', 1)[1]
elif command == "kernel":
config_entry['linux'] = argument
elif command == "append":
config_entry['options'] = argument
elif config_entry is not None:
config_entry[command] = argument
if config_entry is not None:
config_entries.append(config_entry)
if len(entries) != len(config_entries):
fatal("Found {0} loader entries, but {1} config entries {2}\n".format(len(entries), len(config_entries), config_entries))
def assert_matches_key(a, b, key):
aval = a[key]
......@@ -100,13 +109,14 @@ def assert_matches_key(a, b, key):
if aval != bval:
fatal("Mismatch on {0}: {1} != {2}".format(key, aval, bval))
for i,(entry,syslinuxentry) in enumerate(zip(entries, syslinux_entries)):
assert_matches_key(entry, syslinuxentry, 'linux')
assert_matches_key(entry, syslinuxentry, 'initrd')
for i,(entry,configentry) in enumerate(zip(entries, config_entries)):
assert_matches_key(entry, configentry, 'linux')
config_ostree = get_ostree_option(configentry['options'])
assert_matches_key(entry, configentry, 'initrd')
entry_ostree = get_ostree_option(entry['options'])
syslinux_ostree = get_ostree_option(syslinuxentry['options'])
if entry_ostree != syslinux_ostree:
fatal("Mismatch on ostree option: {0} != {1}".format(entry_ostree, syslinux_ostree))
config_ostree = get_ostree_option(configentry['options'])
if entry_ostree != config_ostree:
fatal("Mismatch on ostree option: {0} != {1}".format(entry_ostree, config_ostree))
sys.stdout.write('SYSLINUX configuration validated\n')
sys.stdout.write('bootloader configuration validated\n')
sys.exit(0)
......@@ -332,6 +332,16 @@ setup_os_boot_syslinux() {
ln -s ../loader/syslinux.cfg sysroot/boot/syslinux/syslinux.cfg
}
setup_os_boot_uboot_distro() {
# Stub syslinux configuration
mkdir -p sysroot/boot/loader.0
ln -s loader.0 sysroot/boot/loader
touch sysroot/boot/loader/extlinux.conf
# And a compatibility symlink
mkdir -p sysroot/boot/extlinux
ln -s ../loader/extlinux.conf sysroot/boot/extlinux/extlinux.conf
}
setup_os_boot_uboot() {
# Stub U-Boot configuration
mkdir -p sysroot/boot/loader.0
......@@ -379,21 +389,27 @@ setup_os_repository () {
mkdir -p usr/bin ${bootdir} usr/lib/modules/${kver} usr/share usr/etc
kernel_path=${bootdir}/vmlinuz
initramfs_path=${bootdir}/initramfs.img
dtbs_path=${bootdir}/dtbs
# /usr/lib/modules just uses "vmlinuz", since the version is in the module
# directory name.
if [[ $bootdir != usr/lib/modules/* ]]; then
kernel_path=${kernel_path}-${kver}
initramfs_path=${bootdir}/initramfs-${kver}.img
dtbs_path=${bootdir}/dtbs-${kver}
fi
echo "a kernel" > ${kernel_path}
echo "an initramfs" > ${initramfs_path}
bootcsum=$(cat ${kernel_path} ${initramfs_path} | sha256sum | cut -f 1 -d ' ')
mkdir -p ${dtbs_path}/vendor
echo "a dtb" > ${dtbs_path}/board.dtb
echo "another dtb" > ${dtbs_path}/vendor/board.dtb
bootcsum=$(cat ${kernel_path} ${initramfs_path} ${dtbs_path}/board.dtb ${dtbs_path}/vendor/board.dtb | sha256sum | cut -f 1 -d ' ')
export bootcsum
# Add the checksum for legacy dirs (/boot, /usr/lib/ostree-boot), but not
# /usr/lib/modules.
if [[ $bootdir != usr/lib/modules/* ]]; then
mv ${kernel_path}{,-${bootcsum}}
mv ${initramfs_path}{,-${bootcsum}}
mv ${dtbs_path}{,-${bootcsum}}
fi
echo "an executable" > usr/bin/sh
......@@ -445,6 +461,9 @@ EOF
"uboot")
setup_os_boot_uboot
;;
"uboot-distro")
setup_os_boot_uboot_distro
;;
*grub2*)
setup_os_boot_grub2 "${bootmode}"
;;
......@@ -477,7 +496,7 @@ os_repository_new_commit ()
bootdir=boot
fi
fi
rm ${bootdir}/*
rm -r ${bootdir}/*
kernel_path=${bootdir}/vmlinuz
initramfs_path=${bootdir}/initramfs.img
if [[ $bootdir != usr/lib/modules/* ]]; then
......
#!/bin/bash
#
# Copyright (C) 2011,2014 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 -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "uboot-distro"
. $(dirname $0)/admin-test.sh