klte-common: Add releasetools extension to install variant blobs

* General idea shamelessly kanged from m8
* Copy instead of symlink because we need the libril shim and doing
  that for each variant is non-scaleable
* Will only be used if explicitly called-for by dependent devices

Change-Id: I15b4b25d3e1b8856a9f8df2f2c6b72c0e55a6d66
This commit is contained in:
Kevin F. Haggerty 2017-03-05 10:02:05 -07:00
parent 020350a1f3
commit a27086acba
2 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# Copyright (C) 2017 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Custom OTA commands for klte devices """
import common
import re
import os
def FullOTA_InstallEnd(info):
info.script.Mount("/system")
info.script.AppendExtra('assert(run_program("/tmp/install/bin/variant_blobs.sh") == 0);')
info.script.Unmount("/system")

View File

@ -0,0 +1,58 @@
#!/sbin/sh
#
# Copyright (C) 2017 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e
better_copy()
{
cp -dp "$1" "$2"
# symlinks don't have a context
if [ ! -L "$1" ]; then
# it is assumed that every label starts with 'u:object_r' and has no white-spaces
local context=`ls -Z "$1" | grep -o 'u:object_r:[^ ]*' | head -1`
chcon -v "$context" "$2"
fi
}
# Detect variant and copy its specific-blobs
BOOTLOADER=`getprop ro.bootloader`
case $BOOTLOADER in
G900V*) VARIANT="vzw" ;;
*) VARIANT="gsm" ;;
esac
BLOBBASE=/system/blobs/$VARIANT
if [ -d $BLOBBASE ]; then
cd $BLOBBASE
for FILE in `find . -type f` ; do
mkdir -p `dirname /system/$FILE`
better_copy $FILE /system/$FILE
done
for FILE in bin/* ; do
chmod 755 /system/$FILE
done
else
echo "Expected source directory does not exist!"
exit 1
fi
exit 0