icecc-create-env: Allow logging to a file

Modifies the icecc-create-env script so that it can log output to a log
file. In addition, a --debug flag is added that allows verbose logging.
Finally, the silent flag was removed since it was never used in
icecc.bbclass

(From OE-Core rev: 3d0bd786fd79967cf8754d022044df311dd8ad3e)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Watt
2018-04-10 21:21:54 -05:00
committed by Richard Purdie
parent f91523b22f
commit 57ca83dac1

View File

@@ -7,6 +7,24 @@
target_paths= target_paths=
target_aliases= target_aliases=
# Always prints, optionally to a log file
print_output ()
{
if test -n "$log_path"; then
echo "$@" | tee -a "$log_path"
else
echo "$@"
fi
}
# Only prints if the debug flag is specified
print_debug ()
{
if test -n "$debug"; then
print_output "$@"
fi
}
is_dynamic_elf () is_dynamic_elf ()
{ {
# Is the file an dynamically linked ELF executable? # Is the file an dynamically linked ELF executable?
@@ -54,6 +72,7 @@ add_alias ()
*" $alias "*) *" $alias "*)
;; ;;
*) *)
print_debug "Adding alias '$2' -> '$1'"
target_aliases="$target_aliases $alias" target_aliases="$target_aliases $alias"
;; ;;
esac esac
@@ -123,17 +142,23 @@ add_file ()
fi fi
} }
# backward compat while test -n "$1"; do
if test "$1" = "--respect-path"; then case "$1" in
--respect-path)
# Ignore for backward compatability
;;
--debug)
debug=1
;;
--log)
do_log=1
;;
*)
break
;;
esac
shift shift
fi done
#add a --silent switch to avoid "broken pipe" errors when calling this scipt from within OE
if test "$1" = "--silent"; then
silent=1
shift
fi
added_gcc=$1 added_gcc=$1
shift shift
@@ -143,6 +168,11 @@ added_as=$1
shift shift
archive_name=$1 archive_name=$1
if test -n "$do_log"; then
log_path="$archive_name.log"
rm -f "$log_path"
fi
if test -z "$PATCHELF"; then if test -z "$PATCHELF"; then
PATCHELF=`which patchelf 2> /dev/null` PATCHELF=`which patchelf 2> /dev/null`
fi fi
@@ -150,22 +180,22 @@ if test -z "$PATCHELF"; then
PATCHELF=`which patchelf-uninative 2> /dev/null` PATCHELF=`which patchelf-uninative 2> /dev/null`
fi fi
if test -z "$PATCHELF"; then if test -z "$PATCHELF"; then
echo "patchelf is required" print_output "patchelf is required"
exit 1 exit 1
fi fi
if test -z "$added_gcc" || test -z "$added_gxx" ; then if test -z "$added_gcc" || test -z "$added_gxx" ; then
echo "usage: $0 <gcc_path> <g++_path>" print_output "usage: $0 <gcc_path> <g++_path>"
exit 1 exit 1
fi fi
if ! test -x "$added_gcc" ; then if ! test -x "$added_gcc" ; then
echo "'$added_gcc' is no executable." print_output "'$added_gcc' is not executable."
exit 1 exit 1
fi fi
if ! test -x "$added_gxx" ; then if ! test -x "$added_gxx" ; then
echo "'$added_gcc' is no executable." print_output "'$added_gcc' is not executable."
exit 1 exit 1
fi fi
@@ -178,7 +208,7 @@ if test -z "$added_as" ; then
add_file /usr/bin/as /usr/bin/as add_file /usr/bin/as /usr/bin/as
else else
if ! test -x "$added_as" ; then if ! test -x "$added_as" ; then
echo "'$added_as' is no executable." print_output "'$added_as' is not executable."
exit 1 exit 1
fi fi
@@ -206,7 +236,7 @@ if test -x /bin/true; then
elif test -x /usr/bin/true; then elif test -x /usr/bin/true; then
add_file /usr/bin/true /bin/true add_file /usr/bin/true /bin/true
else else
echo "'true' not found" print_output "'true' not found"
exit 1 exit 1
fi fi
@@ -266,9 +296,7 @@ if test -z "$archive_name"; then
#calculate md5 and use it as the archive name #calculate md5 and use it as the archive name
archive_name=`for i in $target_files; do test -f $tempdir/$i && $md5sum $tempdir/$i; done | sed -e 's/ .*$//' | $md5sum | sed -e 's/ .*$//'`.tar.gz || { archive_name=`for i in $target_files; do test -f $tempdir/$i && $md5sum $tempdir/$i; done | sed -e 's/ .*$//' | $md5sum | sed -e 's/ .*$//'`.tar.gz || {
if test -z "$silent"; then print_output "Couldn't compute MD5 sum."
echo "Couldn't compute MD5 sum."
fi
exit 2 exit 2
} }
mydir=`pwd` mydir=`pwd`
@@ -283,9 +311,7 @@ else
fi fi
fi fi
if test -z "$silent"; then print_output "creating $archive_name"
echo "creating $archive_name"
fi
cd $tempdir cd $tempdir
# Add everything in the temp directory. Tar doesn't like to be given files with # Add everything in the temp directory. Tar doesn't like to be given files with
@@ -293,9 +319,7 @@ cd $tempdir
# the path prefix past the offending "..". This makes the archive generate # the path prefix past the offending "..". This makes the archive generate
# incorrectly # incorrectly
tar -czf "$mydir/$archive_name" . || { tar -czf "$mydir/$archive_name" . || {
if test -z "$silent"; then print_output "Couldn't create archive"
echo "Couldn't create archive"
fi
exit 3 exit 3
} }
cd .. cd ..