xref: /OK3568_Linux_fs/yocto/poky/scripts/yocto-check-layer-wrapper (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/usr/bin/env bash
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun# Yocto Project layer check tool wrapper
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun# Creates a temporary build directory to run the yocto-check-layer
6*4882a593Smuzhiyun# script to avoid a contaminated environment.
7*4882a593Smuzhiyun#
8*4882a593Smuzhiyun# Copyright (C) 2017 Intel Corporation
9*4882a593Smuzhiyun#
10*4882a593Smuzhiyun# SPDX-License-Identifier: MIT
11*4882a593Smuzhiyun#
12*4882a593Smuzhiyun
13*4882a593Smuzhiyunif [ -z "$BUILDDIR" ]; then
14*4882a593Smuzhiyun	echo "Please source oe-init-build-env before run this script."
15*4882a593Smuzhiyun	exit 2
16*4882a593Smuzhiyunfi
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun# since we are using a temp directory, use the realpath for output
19*4882a593Smuzhiyun# log option
20*4882a593Smuzhiyunoutput_log=''
21*4882a593Smuzhiyunwhile getopts o: name
22*4882a593Smuzhiyundo
23*4882a593Smuzhiyun	case $name in
24*4882a593Smuzhiyun	o) output_log=$(realpath "$OPTARG")
25*4882a593Smuzhiyun	esac
26*4882a593Smuzhiyundone
27*4882a593Smuzhiyunshift $(($OPTIND - 1))
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun# generate a temp directory to run check layer script
30*4882a593Smuzhiyunbase_dir=$(realpath $BUILDDIR/../)
31*4882a593Smuzhiyuncd $base_dir
32*4882a593Smuzhiyun
33*4882a593Smuzhiyunbuild_dir=$(mktemp -p $base_dir -d -t build-XXXX)
34*4882a593Smuzhiyun
35*4882a593Smuzhiyunthis_dir=$(dirname $(readlink -f $0))
36*4882a593Smuzhiyun
37*4882a593Smuzhiyunsource $this_dir/../oe-init-build-env $build_dir
38*4882a593Smuzhiyunif [[ $output_log != '' ]]; then
39*4882a593Smuzhiyun	yocto-check-layer -o "$output_log" "$*"
40*4882a593Smuzhiyunelse
41*4882a593Smuzhiyun	yocto-check-layer "$@"
42*4882a593Smuzhiyunfi
43*4882a593Smuzhiyunretcode=$?
44*4882a593Smuzhiyun
45*4882a593Smuzhiyunrm -rf $build_dir
46*4882a593Smuzhiyun
47*4882a593Smuzhiyunexit $retcode
48