Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[initrd] Pass device-specific environment variables to initrd. JB#54875
The problem is unable to set device-specific environment variable
in both normal and recovery initrd environment
without edit droid-hal-device-img-boot.inc. To resolve
this issue we can use droid-hal-$DEVICE-img-boot.spec and define macro "initrd_env_vars"
for example

%define initrd_env_vars \
FOO=bar\
XYZ=123\
%{nil}

and then handle it in initrd spec to forward variables to /etc/sysconfig/init
Also we need to add /etc/sysconfig/init to allexport section of recovery-init
so that variables appeared in recovery environment.
Also we need to add allexport section to root-mount script for appear
variables in boot initrd environment.
  • Loading branch information
AndreevDmitry authored and sledges committed Jul 9, 2021
1 parent 17cf892 commit dc15604
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
18 changes: 16 additions & 2 deletions droid-hal-device-img-boot.inc
Expand Up @@ -18,6 +18,13 @@
# battery_capacity_threshold: Battery threshold for factory reset [0, 100].
# Default 0 (no threshold).
#
# initrd_env_vars: Pass the list of variables to /etc/sysconfig/init
# Define as follows (deduplicate percentage sign):
# %%define initrd_env_vars \
# FOO=bar\
# XYZ=123\
# %%{nil}
#
# Adding device specific files to initrd folder:
#
# Create a folder named initrd-%{device} and copy the overriding files there.
Expand Down Expand Up @@ -162,8 +169,8 @@ fi
%if 0%{!?lvm_root_size:1}
%define lvm_root_size 2500
%endif
sed --in-place 's|@LVM_ROOT_PART_SIZE@|%{lvm_root_size}|' %{_local_initrd_dir}/etc/sysconfig/init
INIT_FILE=%{_local_initrd_dir}/etc/sysconfig/init
sed --in-place 's|@LVM_ROOT_PART_SIZE@|%{lvm_root_size}|' $INIT_FILE
sed --in-place 's|@PHYSDEV_PART_LABEL@|%{root_part_label}|' %{_local_initrd_dir}/etc/sysconfig/partitions
sed --in-place 's|@FIMAGE_PART_LABEL@|%{factory_part_label}|' %{_local_initrd_dir}/etc/sysconfig/partitions
Expand Down Expand Up @@ -194,6 +201,13 @@ sed --in-place 's|@BATTERY_CAPACITY_THRESHOLD@|%{battery_capacity_threshold}|' %
sed --in-place 's|@LIB_DIR@|%{_libdir}|' %{_local_initrd_dir}/usr/bin/recovery-menu-devicelock
# Add device-specific environment variables from droid-hal-$DEVICE-img-boot.spec to /etc/sysconfig/init
%if 0%{?initrd_env_vars:1}
cat <<EOF >> $INIT_FILE
%{?initrd_env_vars}
EOF
%endif
# Create a hybris-boot.img image from the zImage
%if 0%{?_obs_build_project:1}
%ifarch %{ix86}
Expand Down
2 changes: 2 additions & 0 deletions recovery-init
Expand Up @@ -5,6 +5,7 @@
# This file is part of Jolla recovery console
#
# Copyright (C) 2013-2015 Jolla Ltd.
# Copyright (c) 2021 Open Mobile Platform LLC.
# Originally written by Andrea Bernabei
# Contact: Igor Zhbanov <igor.zhbanov@jolla.com>
#
Expand Down Expand Up @@ -97,6 +98,7 @@ usb_info() {
}

set -o allexport
. /etc/sysconfig/init
. /etc/sysconfig/display
. /usr/bin/recovery-functions.sh
set +o allexport
Expand Down
3 changes: 3 additions & 0 deletions sbin/root-mount
Expand Up @@ -3,6 +3,7 @@
# Jolla btrfs root mounting script, adapted for ext4
#
# Copyright (C) 2014 Jolla Ltd.
# Copyright (c) 2021 Open Mobile Platform LLC.
# Contact: Kalle Jokiniemi <kalle.jokiniemi@jolla.com>
#
# This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -32,9 +33,11 @@ if [ -z $1 ] || [ ! -e $1 ]; then
exit 1
fi

set -o allexport
. /etc/sysconfig/init
. /etc/sysconfig/partitions
. /etc/sysconfig/display
set +o allexport

PHYSDEV_SEARCHLIST="$PHYSDEV_PART_LABEL sailfishos"
FS_RESIZED=".fs-resized"
Expand Down

0 comments on commit dc15604

Please sign in to comment.