1#!/bin/bash 2# Copyright (C) 2020 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16common_device="$1" 17gpu_common="$2" 18if ! [[ -f $common_device ]] || ! [[ -f $gpu_common ]]; then 19 echo "usage: $0 /path/to/common_device.policy /path/to/gpu_common.policy <input.policy >output.policy" 20 exit 1 21fi 22 23while IFS= read -r line 24do 25 if echo "$line" | egrep "@include[[:space:]]+/usr/share/policy/crosvm/common_device.policy" > /dev/null; then 26 cat $common_device 27 continue 28 elif echo "$line" | egrep "@include[[:space:]]+/usr/share/policy/crosvm/gpu_common.policy" > /dev/null; then 29 cat $gpu_common 30 continue 31 fi 32 echo $line 33done 34