Skip to content

Commit

Permalink
[initrd] Support adding recovery tools to regular initrd. MER#1987
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaodan committed Jun 22, 2019
1 parent d688cdb commit bb8089b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion droid-hal-device-img-boot.inc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ sed -e 's/@embed_recovery@/%{?embed_recovery:1}%{!?embed_recovery:0}/g' initrd/j

# Create a hybris-boot.img image from the zImage
pushd %{_local_initrd_dir}
./mksfosinitrd.sh %{embed_recovery}
./mksfosinitrd.sh %{?embed_recovery:combined}
popd
%{mkbootimg_cmd} hybris-boot.img
%if 0%{!?embed_recovery:1}
Expand Down
31 changes: 20 additions & 11 deletions mksfosinitrd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,28 @@ chmod 0600 $FIX_FILE_PERMISSIONS

TOOL_LIST="$TOOL_LIST $(cat tools.files 2> /dev/null)"

OLD_DIR=$(pwd)
TMP_DIR=/tmp/sfosinitrd

if [ "$1" = "recovery" ]; then
TOOL_LIST="$TOOL_LIST $RECOVERY_FILES $(cat recovery.files 2> /dev/null)"
DEF_INIT="recovery-init"
DEF_INIT="recovery-init"
else
# The default init script
DEF_INIT="jolla-init"
# The default init script
DEF_INIT="jolla-init"
fi

if [ "$1" = "combined" ] || [ "$1" = "recovery" ] ; then
TOOL_LIST="$TOOL_LIST $RECOVERY_FILES $(cat recovery.files 2> /dev/null)"
fi

# Remove duplicates.
TOOL_LIST="$(echo $TOOL_LIST | sort | uniq)"

set -e

OLD_DIR=$(pwd)
TMP_DIR=/tmp/sfosinitrd
rm -rf "$TMP_DIR"
mkdir "$TMP_DIR"

# Remove duplicates.
TOOL_LIST="$(echo $TOOL_LIST | sort | uniq)"

check_files()
{
Expand All @@ -83,8 +90,10 @@ check_files()

check_files "$TOOL_LIST" || exit 1

rm -rf "$TMP_DIR"
mkdir "$TMP_DIR"
if [ "$1" = "combined" ] ; then
cp "$OLD_DIR"/recovery-init "$TMP_DIR"/.
fi

cd "$TMP_DIR"

# Copy local files to be added to initrd. If you add more, add also to TOOL_LIST.
Expand All @@ -94,7 +103,7 @@ mkdir -p etc
cp -a "$OLD_DIR"/etc/sysconfig etc

# Copy recovery files
if [ "$1" = "recovery" ]; then
if [ "$1" = "recovery" ] || [ "$1" = "combined" ]; then
cp -a "$OLD_DIR"/usr/ "$OLD_DIR"/etc/ -t ./
fi

Expand Down

0 comments on commit bb8089b

Please sign in to comment.