From patchwork Wed Jun 7 20:04:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25251 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51E4DC87FF2 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by mx.groups.io with SMTP id smtpd.web11.8432.1686168314883161808 for ; Wed, 07 Jun 2023 13:05:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=qfP5HdAD; spf=pass (domain: ti.com, ip: 198.47.19.141, mailfrom: rs@ti.com) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5BPh002214; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=Usdb5ij611CHGdBUuVcRARLMsuqWtAmYHy1M7SnH0wE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=qfP5HdADKpXaCsuRawrDw7PRXuLUfgBlzMiMRHblTWH1mpAr7lbnlPXELri7abwKN itCKpIkehqCogcpwuLVjpj/D9XpQ6lGYAZFYa0G0Z0qOTjisXjbl7SI82bz05k/FMs 45ImZr+wHFW2iZNsbyTtmi/n1qo00ENT3azwVpwo= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5AbI030610 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:10 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:10 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:10 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AKv125548; Wed, 7 Jun 2023 15:05:10 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 01/15] oe-layertool-setup: prefer use of $() notation Date: Wed, 7 Jun 2023 15:04:50 -0500 Message-ID: <20230607200504.3810426-2-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14534 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Shellcheck: Use $(...) notation instead of legacy backticked `...`. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 80 +++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index ef25ca0..cd4e242 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -45,8 +45,8 @@ interactive="n" # flag for interactive mode. Default is n resethead="n" # flag for reset head mode. Default is n layers="" # variable holding the layers to add to bblayers.conf output="" # variable holding the output to write to outputfile -scriptdir=`pwd` # directory of this calling script -oebase=`pwd` # variable to hold base directory +scriptdir=$(pwd) # directory of this calling script +oebase=$(pwd) # variable to hold base directory sourcedir="" # directory where repos will be cloned builddir="" # directory for builds confdir="" # directory for build configuration files @@ -154,27 +154,27 @@ check_input() { # Input is a line of the form OECORE.*=value parse_oecore_line() { - var=`echo $1 | cut -d= -f1` - val=`echo $1 | cut -d= -f2` + var=$(echo $1 | cut -d= -f1) + val=$(echo $1 | cut -d= -f2) eval $var=$val } # Input is a line of the form BITBAKE.*=value parse_bitbake_line() { - var=`echo $1 | cut -d= -f1` - val=`echo $1 | cut -d= -f2` + var=$(echo $1 | cut -d= -f1) + val=$(echo $1 | cut -d= -f2) eval $var=$val } # Input is a line of the form LOCALCONF:.*=value parse_localconf_line() { - localconf=`echo "$1" | cut -d: -f2-100` + localconf=$(echo "$1" | cut -d: -f2-100) echo "$localconf" >> $oebase/tmp_append_local.conf } # Input is a line of the form MOTD: parse_motd_line() { - motd=`echo "$1" | cut -d: -f2-100` + motd=$(echo "$1" | cut -d: -f2-100) echo "$motd" >> $oebase/tmp_motd echo "$motd" } @@ -197,11 +197,11 @@ parse_repo_line() { # split the line on the comma separators # use the prefix if it was set. - eval $prefix"name"=`echo $1 | cut -d, -f1` - eval $prefix"uri"=`echo $1 | cut -d, -f2` - eval $prefix"branch"=`echo $1 | cut -d, -f3` - eval $prefix"commit"=`echo $1 | cut -d, -f4` - parsed_layers=`echo $1 | cut -d, -f5-` + eval $prefix"name"=$(echo $1 | cut -d, -f1) + eval $prefix"uri"=$(echo $1 | cut -d, -f2) + eval $prefix"branch"=$(echo $1 | cut -d, -f3) + eval $prefix"commit"=$(echo $1 | cut -d, -f4) + parsed_layers=$(echo $1 | cut -d, -f5-) # If no layers= was used, then don't add any layers temp_layers="none" @@ -210,9 +210,9 @@ parse_repo_line() { if [ "x$parsed_layers" != "x" ] then temp_layers="" - temp=`echo $parsed_layers | cut -d= -f2` + temp=$(echo $parsed_layers | cut -d= -f2) # temporarily reset the IFS value to : to split the layers - for x in `IFS=":";echo $temp` + for x in $(IFS=":";echo $temp) do # Add the $name value to each layer so that we have consistency # with how the layers are represented between the saved value @@ -319,7 +319,7 @@ parse_input_file() { # Create the repository line corresponding to the selections given. # In the case that no layers= option was passed then this will # create the layers= option corresponding to all layers being selected. - repo_line=`build_repo_line` + repo_line=$(build_repo_line) # Save the line in the output variable for if we create an output file output="$output""$repo_line\n" @@ -338,7 +338,7 @@ configure_repo() { # Check if the repo with $name was already seen. Use the , at the end # of the grep to avoid matching similar named repos. - temp=`printf '%s\n' $output | grep -e "^$name,"` + temp=$(printf '%s\n' $output | grep -e "^$name,") if [ "x$temp" != "x" ] then @@ -417,12 +417,12 @@ get_repo_branch() { # Get a unique list of branches for the user to chose from # Also delete the origin/HEAD line that the -r option returns - t_branches=`git branch -r | sed '/origin\/HEAD/d'` + t_branches=$(git branch -r | sed '/origin\/HEAD/d') for b in $t_branches do - branches="$branches"`echo $b | sed 's:.*origin/::g'`"\n" + branches="$branches"$(echo $b | sed 's:.*origin/::g')"\n" done - branches=`printf "$branches\n" | sort | uniq` + branches=$(printf "$branches\n" | sort | uniq) cat << EOM @@ -500,7 +500,7 @@ cat << EOM The $name repository has the following tags available: EOM - tags=`git tag` + tags=$(git tag) if [ "x$tags" = "x" ] then printf "\tNo tags found\n" @@ -566,7 +566,7 @@ select_layers() { cd $sourcedir # Get a count of how many layers there are - count=`find $name -name "layer.conf" | grep -c layer.conf` + count=$(find $name -name "layer.conf" | grep -c layer.conf) case $count in 0 ) @@ -581,7 +581,7 @@ select_layers() { ;; esac - t_layers=`find $name -name "layer.conf" | sed 's:\/conf\/layer.conf::'` + t_layers=$(find $name -name "layer.conf" | sed 's:\/conf\/layer.conf::') if [ "x$arg1" != "xall" ] then @@ -597,7 +597,7 @@ EOM for l in $t_layers do - printf "\t"`echo $l | sed "s:${name}\/::"`"\n" + printf "\t"$(echo $l | sed "s:${name}\/::")"\n" done cat << EOM @@ -656,7 +656,7 @@ get_oecorelayerconf() { fi cd $sourcedir - confs=`find . -name "bblayers.conf.sample"` + confs=$(find . -name "bblayers.conf.sample") done="n" @@ -711,7 +711,7 @@ get_oecorelocalconf() { fi cd $sourcedir - confs=`find . -name "local.conf.sample"` + confs=$(find . -name "local.conf.sample") done="n" @@ -813,7 +813,7 @@ EOM # Find if old DL_DIR was set if [ -e $confdir/local.conf.bak ] then - old_dldir=`cat $confdir/local.conf.bak | grep -e "^DL_DIR =" | sed 's|DL_DIR = ||' | sed 's/"//g'` + old_dldir=$(cat $confdir/local.conf.bak | grep -e "^DL_DIR =" | sed 's|DL_DIR = ||' | sed 's/"//g') else old_dldir="$oebase/downloads" fi @@ -854,7 +854,7 @@ print_motd() { print_image_names() { SOURCES="${1}" - FOLDERS=`find "${SOURCES}" -type d -a -iname images|grep recipes-core|sed -e "s/.*sources\///g"|cut -d '/' -f1|sort -u -r` + FOLDERS=$(find "${SOURCES}" -type d -a -iname images|grep recipes-core|sed -e "s/.*sources\///g"|cut -d '/' -f1|sort -u -r) IMAGES="" for FOLDER in ${FOLDERS} do @@ -863,15 +863,15 @@ print_image_names() { RECO="[recommended]" fi echo "From ${FOLDER}${RECO}:" - F_IMAGE_FOLDERS=`find "${SOURCES}/${FOLDER}" -type d -a -iname images|grep recipes-core` + F_IMAGE_FOLDERS=$(find "${SOURCES}/${FOLDER}" -type d -a -iname images|grep recipes-core) for IMG_FOLDER in ${F_IMAGE_FOLDERS} do - F_IMAGES=`find "${IMG_FOLDER}" -iname *.bb` + F_IMAGES=$(find "${IMG_FOLDER}" -iname *.bb) if [ -n "${F_IMAGES}" ]; then for img in ${F_IMAGES} do - name=`basename "${img}"|sed 's/\.bb$//g'` - summary=`grep SUMMARY "${img}"|cut -d '=' -f2| sed 's/["/]//g'|xargs echo` + name=$(basename "${img}"|sed 's/\.bb$//g') + summary=$(grep SUMMARY "${img}"|cut -d '=' -f2| sed 's/["/]//g'|xargs echo) if [ -z "${summary}" ]; then summary="No Summary available" fi @@ -911,7 +911,7 @@ cat > $confdir/setenv << EOM export OEBASE=${oebase} # try to find out bitbake directory -BITBAKEDIR=\`find \${OEBASE}/sources -name "*bitbake*"\` +BITBAKEDIR=\$(find \${OEBASE}/sources -name "*bitbake*") for f in \${BITBAKEDIR} do if [ -d \${f}/bin ] @@ -922,7 +922,7 @@ done # check for any scripts directories in the top-level of the repos and add those # to the PATH -SCRIPTS=\`find \${OEBASE}/sources -maxdepth 2 -name "scripts" -type d\` +SCRIPTS=\$(find \${OEBASE}/sources -maxdepth 2 -name "scripts" -type d) for s in \${SCRIPTS} do PATH="\${s}:\$PATH" @@ -945,13 +945,13 @@ EOM build_repo_line() { # clean up the layers to remove the repository name and add : divider temp_layers="" - for l in `echo $repo_layers | sed "s:${name}::" | sed -e 's:^\/::'` + for l in $(echo $repo_layers | sed "s:${name}::" | sed -e 's:^\/::') do - temp_layers="$temp_layers""`echo $l | sed "s:${name}\/::"`:" + temp_layers="$temp_layers""$(echo $l | sed "s:${name}\/::"):" done # Lastly clean off any trailing : - temp_layers=`echo $temp_layers | sed 's/:$//'` + temp_layers=$(echo $temp_layers | sed 's/:$//') echo "$name,$uri,$branch,$commit,layers=$temp_layers" } @@ -980,7 +980,7 @@ mkdir -p $oebase # retrive the absolute path to the oebase directory incase # a relative path is passed in cd $oebase -oebase=`pwd` +oebase=$(pwd) cd - # Populate the following variables depending on the value of oebase @@ -1019,7 +1019,7 @@ then # Create the repository line corresponding to the selections given. # In the case that no layers= option was passed then this will # create the layers= option corresponding to all layers being selected. - repo_line=`build_repo_line` + repo_line=$(build_repo_line) # Save the line in the output variable for if we create an output file output="$output""$repo_line\n" @@ -1043,7 +1043,7 @@ if [ "x$outputfile" != "x" ] then # make sure that the directory for the output file exists cd $oebase - dir=`dirname $outputfile` + dir=$(dirname $outputfile) if [ ! -d $dir ] then mkdir -p $dir From patchwork Wed Jun 7 20:04:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25244 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26FA6C87FDC for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by mx.groups.io with SMTP id smtpd.web11.8429.1686168314766396577 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=RV3hR+Ia; spf=pass (domain: ti.com, ip: 198.47.23.248, mailfrom: rs@ti.com) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5B2O106640; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=OjMcsPdbQJyPmbKctV05wCFYGNyqoaFBHYnDGL/9m1g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=RV3hR+Ia+K+bwgi7brYy2XIEV07isn+hgcLpbRdLXm07EI3Zj521k7WASFKFUVWYX 8HY4v/f0/QOTjHzGtDY7n2NLxQqg3keBsLsktS1DmaOkYw6YvZz7wVMLVFwVDXCW+J +aft4tf9qlJkhQrPsP5W3LL1bmwnVza4kT+NQ1js= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5BKA036862 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:10 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:10 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AKw125548; Wed, 7 Jun 2023 15:05:10 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 02/15] oe-layertool-setup: replace all x comparisons with -n/-z Date: Wed, 7 Jun 2023 15:04:51 -0500 Message-ID: <20230607200504.3810426-3-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14531 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Replace all the stray x$var comparisons with the proper -n/-z equivalent. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index cd4e242..3faf00c 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -126,7 +126,7 @@ exit 1 check_input() { # Check that at least -i or -f was used - if [ "$interactive" = "n" ] && [ "x$inputfile" = "x" ] + if [ "$interactive" = "n" ] && [ -z "$inputfile" ] then echo "ERROR: You must either use this script with the -i or -f options" usage @@ -207,7 +207,7 @@ parse_repo_line() { temp_layers="none" # If layers= was used then set the layers variable, empty list would add all found layers - if [ "x$parsed_layers" != "x" ] + if [ -n "$parsed_layers" ] then temp_layers="" temp=$(echo $parsed_layers | cut -d= -f2) @@ -223,10 +223,10 @@ parse_repo_line() { # Assign the layers. If the temp_layers is empty then set the layers # to all and we will fill in the actual layers in the later steps. - if [ "x$temp_layers" = "x" ] + if [ -z "$temp_layers" ] then eval $prefix"repo_layers"="all" - elif [ "x$temp_layers" = "xnone" ] + elif [ "$temp_layers" = "none" ] then eval $prefix"repo_layers"="none" else @@ -256,7 +256,7 @@ parse_input_file() { repo_layers="" # Skip empty lines - if [ "x$line" = "x" ] + if [ -z "$line" ] then continue fi @@ -331,7 +331,7 @@ parse_input_file() { configure_repo() { - if [ "x$name" = "x" ] + if [ -z "$name" ] then get_repo_name fi @@ -340,7 +340,7 @@ configure_repo() { # of the grep to avoid matching similar named repos. temp=$(printf '%s\n' $output | grep -e "^$name,") - if [ "x$temp" != "x" ] + if [ -n "$temp" ] then echo "This repository ($name) has already been configured with the following values:" printf '\t%s\n' $temp @@ -348,7 +348,7 @@ configure_repo() { return 1 fi - if [ "x$uri" = "x" ] + if [ -z "$uri" ] then get_repo_uri fi @@ -360,28 +360,28 @@ configure_repo() { clone_repo - if [ "x$branch" = "x" ] + if [ -z "$branch" ] then get_repo_branch fi checkout_branch - if [ "x$commit" = "x" ] + if [ -z "$commit" ] then get_repo_commit fi checkout_commit - if [ "x$repo_layers" = "xall" ] + if [ "$repo_layers" = "all" ] then # Call select layers with the all option to select all layers select_layers "all" - elif [ "x$repo_layers" = "x" ] + elif [ -z "$repo_layers" ] then select_layers - elif [ "x$repo_layers" = "xnone" ] + elif [ "$repo_layers" = "none" ] then # Call select layers with the none option to not select any layers select_layers "none" @@ -473,7 +473,7 @@ checkout_branch() { # any. In the case of a clean checkout this should be already up to date, # but for an existing checkout this should be the changes that were # fetched earlier. - if [ "x$resethead" = "xy" ] + if [ "$resethead" = "y" ] then # Instead of merging, reset to remote branch to avoid conflicts due to rebase git reset --hard origin/$branch @@ -484,7 +484,7 @@ checkout_branch() { checkout_commit() { cd $sourcedir/$name - if [ "x$commit" != "xHEAD" ] + if [ "$commit" != "HEAD" ] then git checkout $commit fi @@ -501,7 +501,7 @@ The $name repository has the following tags available: EOM tags=$(git tag) - if [ "x$tags" = "x" ] + if [ -z "$tags" ] then printf "\tNo tags found\n" else @@ -519,7 +519,7 @@ EOM read input - if [ "x$input" = "x" ] + if [ -z "$input" ] then commit="HEAD" fi @@ -558,7 +558,7 @@ select_layers() { #If so prompt for which layers to configure #If there is only one then just configure that layer and don't prompt - if [ "x$arg1" = "xnone" ] + if [ "$arg1" = "none" ] then repo_layers="" return @@ -583,7 +583,7 @@ select_layers() { t_layers=$(find $name -name "layer.conf" | sed 's:\/conf\/layer.conf::') - if [ "x$arg1" != "xall" ] + if [ "$arg1" != "all" ] then echo "arg1 = $arg1" # Prompt for which layers to configure @@ -609,7 +609,7 @@ EOM read input fi - if [ "x$input" = "x" ] + if [ -z "$input" ] then repo_layers=$t_layers else @@ -643,7 +643,7 @@ EOM get_oecorelayerconf() { # Check if the variable is already set. - if [ "x$OECORELAYERCONF" != "x" ] + if [ -n "$OECORELAYERCONF" ] then OECORELAYERCONFPATH=$scriptdir/$OECORELAYERCONF @@ -697,7 +697,7 @@ EOM get_oecorelocalconf() { # Check if the variable is already set. - if [ "x$OECORELOCALCONF" != "x" ] + if [ -n "$OECORELOCALCONF" ] then OECORELOCALCONFPATH=$scriptdir/$OECORELOCALCONF @@ -819,7 +819,7 @@ EOM fi # If command line option was not set use the old dldir - if [ "x$dldir" = "x" ] + if [ -z "$dldir" ] then dldir=$old_dldir fi @@ -990,17 +990,17 @@ confdir="$builddir/conf" check_input -if [ "x$inputfile" != "x" ] +if [ -n "$inputfile" ] then parse_input_file print_motd fi -if [ "x$interactive" = "xy" ] +if [ "$interactive" = "y" ] then cont="y" - while [ "x$cont" = "xy" ] || [ "x$cont" = "xY" ] + while [ "$cont" = "y" ] || [ "$cont" = "Y" ] do # clean up the variables for each repo name="" @@ -1039,7 +1039,7 @@ config_oecorelayerconf get_oecorelocalconf config_oecorelocalconf -if [ "x$outputfile" != "x" ] +if [ -n "$outputfile" ] then # make sure that the directory for the output file exists cd $oebase From patchwork Wed Jun 7 20:04:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25238 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13DF1C7EE43 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by mx.groups.io with SMTP id smtpd.web10.8314.1686168314604781058 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=PN5XzeV5; spf=pass (domain: ti.com, ip: 198.47.23.249, mailfrom: rs@ti.com) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5BhS023389; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=JJ2EEgLLKfiPCvsfXef5bAYXhpwKDFS7+dzpgJ/APSE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=PN5XzeV5sW5bGz8vGjjetXntt/r6E0hdlDlj6rdnXMRONKmoH/UqdKUj6DoapPA+v MDnZa42HZfa7UnSn+7tXJGKxl2V8VByqEKC400oDrw8uXDRDxtR3hvinGAyr4juqwf MUvPR7WftC9sjnxKD0UxBbnjmXSDwkrXcFVmSrII= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5BGx030614 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:10 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:10 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AKx125548; Wed, 7 Jun 2023 15:05:10 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 03/15] oe-layertool-setup: fix all the printf calls Date: Wed, 7 Jun 2023 15:04:52 -0500 Message-ID: <20230607200504.3810426-4-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14526 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> You aren't supposed to use a variable in the printf format definition. It kinda defeats the purpose of using printf. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index 3faf00c..3e6ac4e 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -338,12 +338,12 @@ configure_repo() { # Check if the repo with $name was already seen. Use the , at the end # of the grep to avoid matching similar named repos. - temp=$(printf '%s\n' $output | grep -e "^$name,") + temp=$(printf '%s\n' "$output" | grep -e "^$name,") if [ -n "$temp" ] then echo "This repository ($name) has already been configured with the following values:" - printf '\t%s\n' $temp + printf '\t%s\n' "$temp" echo "Skipping configuring duplicate repository" return 1 fi @@ -422,7 +422,7 @@ get_repo_branch() { do branches="$branches"$(echo $b | sed 's:.*origin/::g')"\n" done - branches=$(printf "$branches\n" | sort | uniq) + branches=$(printf '%s\n' "$branches" | sort | uniq) cat << EOM @@ -503,12 +503,12 @@ EOM tags=$(git tag) if [ -z "$tags" ] then - printf "\tNo tags found\n" + printf '\t%s\n' "No tags found" else # Format the tags nicely for t in $tags do - printf "\t* $t\n" + printf '\t%s\n' "* $t" done fi cat << EOM @@ -597,7 +597,7 @@ EOM for l in $t_layers do - printf "\t"$(echo $l | sed "s:${name}\/::")"\n" + printf '\t%s\n' "$(echo $l | sed "s:${name}\/::")" done cat << EOM @@ -673,7 +673,7 @@ EOM for f in $confs do - printf "\t$f\n" + printf '\t%s\n' "$f" done cat << EOM @@ -728,7 +728,7 @@ EOM for f in $confs do - printf "\t$f\n" + printf '\t%s\n' "$f" done cat << EOM @@ -777,7 +777,7 @@ BBLAYERS += " \\ EOM for l in $layers do - printf "\t$l \\%b" "\n" >> $confdir/bblayers.conf + printf '\t%s \\\n' "$l" >> $confdir/bblayers.conf done echo "\"" >> $confdir/bblayers.conf } @@ -1048,7 +1048,7 @@ then then mkdir -p $dir fi - printf '%s\n' $output > $outputfile + printf '%s\n' "$output" > $outputfile echo "Output file is $outputfile" fi From patchwork Wed Jun 7 20:04:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25242 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15462C8300C for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by mx.groups.io with SMTP id smtpd.web10.8311.1686168314400722297 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=J0fWl6Jd; spf=pass (domain: ti.com, ip: 198.47.19.141, mailfrom: rs@ti.com) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5BKL002219; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=CgiqDIJx8qPrpzoKWMmehNc3E985EwjbWkCqVXC5kOY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=J0fWl6JdVtNx1xGreDCzMB8iu0NI5ezcdjzPLYeI+wEjah2bOzWUTCtwuhQGfrCvb Zlex87ZtEzoIp6OcDlt3T153VSCEPNJ7GDGdWGI4UnDotN+XaVos6uaqMd0zsQpI56 fxM9a3LSSeIiNC/xWjCU+uvQBJzDT1/idU7h3W+U= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5BPJ070105 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL0125548; Wed, 7 Jun 2023 15:05:10 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 04/15] oe-layertool-setup: fix all quoting, switch eval to export Date: Wed, 7 Jun 2023 15:04:53 -0500 Message-ID: <20230607200504.3810426-5-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14525 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Quote everything to prevent unexpected splitting and globbing. Also switch out eval for export where we can. Export is capable of much less runtime shenanigans than eval is. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 222 +++++++++++++++++++++--------------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index 3e6ac4e..abe3f12 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -133,7 +133,7 @@ check_input() { fi # If an input file was given make sure it exists - if [ ! -f $inputfile ] + if [ ! -f "$inputfile" ] then echo "ERROR: the file \"$inputfile\" given for inputfile does not exist" usage @@ -142,10 +142,10 @@ check_input() { # If directories do not exist then create them for f in sourcedir builddir confdir do - eval t="$"$f - if [ ! -d $t ] + eval t="\$${f}" + if [ ! -d "$t" ] then - mkdir -p $t + mkdir -p "$t" fi done @@ -154,28 +154,28 @@ check_input() { # Input is a line of the form OECORE.*=value parse_oecore_line() { - var=$(echo $1 | cut -d= -f1) - val=$(echo $1 | cut -d= -f2) - eval $var=$val + var=$(echo "$1" | cut -d= -f1) + val=$(echo "$1" | cut -d= -f2) + export "$var"="$val" } # Input is a line of the form BITBAKE.*=value parse_bitbake_line() { - var=$(echo $1 | cut -d= -f1) - val=$(echo $1 | cut -d= -f2) - eval $var=$val + var=$(echo "$1" | cut -d= -f1) + val=$(echo "$1" | cut -d= -f2) + export "$var"="$val" } # Input is a line of the form LOCALCONF:.*=value parse_localconf_line() { localconf=$(echo "$1" | cut -d: -f2-100) - echo "$localconf" >> $oebase/tmp_append_local.conf + echo "$localconf" >> "$oebase/tmp_append_local.conf" } # Input is a line of the form MOTD: parse_motd_line() { motd=$(echo "$1" | cut -d: -f2-100) - echo "$motd" >> $oebase/tmp_motd + echo "$motd" >> "$oebase/tmp_motd" echo "$motd" } @@ -197,11 +197,11 @@ parse_repo_line() { # split the line on the comma separators # use the prefix if it was set. - eval $prefix"name"=$(echo $1 | cut -d, -f1) - eval $prefix"uri"=$(echo $1 | cut -d, -f2) - eval $prefix"branch"=$(echo $1 | cut -d, -f3) - eval $prefix"commit"=$(echo $1 | cut -d, -f4) - parsed_layers=$(echo $1 | cut -d, -f5-) + export "${prefix}name"="$(echo "$1" | cut -d, -f1)" + export "${prefix}uri"="$(echo "$1" | cut -d, -f2)" + export "${prefix}branch"="$(echo "$1" | cut -d, -f3)" + export "${prefix}commit"="$(echo "$1" | cut -d, -f4)" + parsed_layers=$(echo "$1" | cut -d, -f5-) # If no layers= was used, then don't add any layers temp_layers="none" @@ -210,14 +210,14 @@ parse_repo_line() { if [ -n "$parsed_layers" ] then temp_layers="" - temp=$(echo $parsed_layers | cut -d= -f2) + temp=$(echo "$parsed_layers" | cut -d= -f2) # temporarily reset the IFS value to : to split the layers - for x in $(IFS=":";echo $temp) + for x in $(IFS=":"; echo "$temp") do # Add the $name value to each layer so that we have consistency # with how the layers are represented between the saved value # and the dynamically parsed values - temp_layers="$temp_layers""$name/$x " + temp_layers="${temp_layers}${name}/${x} " done fi @@ -225,25 +225,25 @@ parse_repo_line() { # to all and we will fill in the actual layers in the later steps. if [ -z "$temp_layers" ] then - eval $prefix"repo_layers"="all" + export "${prefix}repo_layers"="all" elif [ "$temp_layers" = "none" ] then - eval $prefix"repo_layers"="none" + export "${prefix}repo_layers"="none" else - eval $prefix"repo_layers"='$temp_layers' + export "${prefix}repo_layers"="$temp_layers" fi } parse_input_file() { - if [ -e $oebase/tmp_append_local.conf ] + if [ -e "$oebase/tmp_append_local.conf" ] then - rm $oebase/tmp_append_local.conf + rm "$oebase/tmp_append_local.conf" fi - if [ -e $oebase/tmp_motd ] + if [ -e "$oebase/tmp_motd" ] then - rm $oebase/tmp_motd + rm "$oebase/tmp_motd" fi while read line @@ -262,41 +262,41 @@ parse_input_file() { fi # Skip comment lines - echo $line | grep -e "^#" > /dev/null + echo "$line" | grep -e "^#" > /dev/null if [ "$?" = "0" ] then continue fi # If the line starts with OECORE then parse the OECORE setting - echo $line | grep -e "^OECORE.*=" > /dev/null + echo "$line" | grep -e "^OECORE.*=" > /dev/null if [ "$?" = "0" ] then - parse_oecore_line $line - output="$output""$line\n" + parse_oecore_line "$line" + output="${output}${line}\n" continue fi # If the line starts with BITBAKE then parse the BITBAKE setting - echo $line | grep -e "^BITBAKE.*=" > /dev/null + echo "$line" | grep -e "^BITBAKE.*=" > /dev/null if [ "$?" = "0" ] then - parse_bitbake_line $line - output="$output""$line\n" + parse_bitbake_line "$line" + output="${output}${line}\n" continue fi # If the line starts with LOCALCONF: then parse the LOCALCONF: setting - echo $line | grep -e "^LOCALCONF:.*" > /dev/null + echo "$line" | grep -e "^LOCALCONF:.*" > /dev/null if [ "$?" = "0" ] then parse_localconf_line "$line" - output="$output""$line\n" + output="${output}${line}\n" continue fi # If the line starts with MOTD: then parse the MOTD: setting - echo $line | grep -e "^MOTD:.*" > /dev/null + echo "$line" | grep -e "^MOTD:.*" > /dev/null if [ "$?" = "0" ] then parse_motd_line "$line" @@ -305,7 +305,7 @@ parse_input_file() { # Since the line is not a comment or an OECORE setting let's assume # it is a repository information line and parse it - parse_repo_line $line + parse_repo_line "$line" configure_repo @@ -322,11 +322,11 @@ parse_input_file() { repo_line=$(build_repo_line) # Save the line in the output variable for if we create an output file - output="$output""$repo_line\n" + output="${output}${repo_line}\n" save_layers - done < $inputfile + done < "$inputfile" } @@ -393,12 +393,12 @@ configure_repo() { clone_repo() { # check if the repo already exists. if so then fetch the latest updates, # else clone it - if [ -d $sourcedir/$name ] + if [ -d "$sourcedir/$name" ] then - cd $sourcedir/$name - $scriptdir/git_retry.sh fetch --all + cd "$sourcedir/$name" + "$scriptdir/git_retry.sh" fetch --all else - $scriptdir/git_retry.sh clone $uri $sourcedir/$name + "$scriptdir/git_retry.sh" clone "$uri" "$sourcedir/$name" if [ "$?" != "0" ] then echo "ERROR: Could not clone repository at $uri" @@ -413,14 +413,14 @@ get_repo_branch() { while [ "$found" = "0" ] do - cd $sourcedir/$name + cd "$sourcedir/$name" # Get a unique list of branches for the user to chose from # Also delete the origin/HEAD line that the -r option returns t_branches=$(git branch -r | sed '/origin\/HEAD/d') for b in $t_branches do - branches="$branches"$(echo $b | sed 's:.*origin/::g')"\n" + branches="${branches}$(echo "$b" | sed 's:.*origin/::g')\n" done branches=$(printf '%s\n' "$branches" | sort | uniq) @@ -456,17 +456,17 @@ EOM } checkout_branch() { - cd $sourcedir/$name + cd "$sourcedir/$name" # Check if a local branch already exists to track the remote branch. # If not then create a tracking branch and checkout the branch # else just checkout the existing branch - git branch | grep $branch > /dev/null + git branch | grep "$branch" > /dev/null if [ "$?" != "0" ] then - git checkout origin/$branch -b $branch --track + git checkout "origin/$branch" -b "$branch" --track else - git checkout $branch + git checkout "$branch" fi # Now that we are on the proper branch pull the remote branch changes if @@ -476,14 +476,14 @@ checkout_branch() { if [ "$resethead" = "y" ] then # Instead of merging, reset to remote branch to avoid conflicts due to rebase - git reset --hard origin/$branch + git reset --hard "origin/$branch" else - git merge origin/$branch + git merge "origin/$branch" fi } checkout_commit() { - cd $sourcedir/$name + cd "$sourcedir/$name" if [ "$commit" != "HEAD" ] then git checkout $commit @@ -492,7 +492,7 @@ checkout_commit() { get_repo_commit() { # prompt for what commit to use with HEAD as default - cd $sourcedir/$name + cd "$sourcedir/$name" cat << EOM @@ -526,10 +526,10 @@ EOM } verify_layers() { - cd $sourcedir + cd "$sourcedir" for l in $repo_layers do - if [ ! -f $sourcedir/$l/conf/layer.conf ] + if [ ! -f "$sourcedir/$l/conf/layer.conf" ] then echo "ERROR: the $l layer in the $name repository could not be" echo " found. Bailing out." @@ -543,7 +543,7 @@ save_layers() { # Add the repo layers to the layers list for l in $repo_layers do - layers="$layers""$sourcedir/$l " + layers="${layers}${sourcedir}/$l " done } @@ -564,9 +564,9 @@ select_layers() { return fi - cd $sourcedir + cd "$sourcedir" # Get a count of how many layers there are - count=$(find $name -name "layer.conf" | grep -c layer.conf) + count=$(find "$name" -name "layer.conf" | grep -c layer.conf) case $count in 0 ) @@ -581,7 +581,7 @@ select_layers() { ;; esac - t_layers=$(find $name -name "layer.conf" | sed 's:\/conf\/layer.conf::') + t_layers=$(find "$name" -name "layer.conf" | sed 's:\/conf\/layer.conf::') if [ "$arg1" != "all" ] then @@ -597,7 +597,7 @@ EOM for l in $t_layers do - printf '\t%s\n' "$(echo $l | sed "s:${name}\/::")" + printf '\t%s\n' "$(echo "$l" | sed "s:${name}\/::")" done cat << EOM @@ -647,7 +647,7 @@ get_oecorelayerconf() { then OECORELAYERCONFPATH=$scriptdir/$OECORELAYERCONF - if [ ! -e $OECORELAYERCONFPATH ] + if [ ! -e "$OECORELAYERCONFPATH" ] then echo "ERROR: Could not find the specified layer conf file $OECORELAYERCONFPATH" fi @@ -655,7 +655,7 @@ get_oecorelayerconf() { return fi - cd $sourcedir + cd "$sourcedir" confs=$(find . -name "bblayers.conf.sample") done="n" @@ -683,7 +683,7 @@ EOM read input - if [ -e $input ] + if [ -e "$input" ] then done="y" OECORELAYERCONF=$input @@ -701,7 +701,7 @@ get_oecorelocalconf() { then OECORELOCALCONFPATH=$scriptdir/$OECORELOCALCONF - if [ ! -e $OECORELOCALCONFPATH ] + if [ ! -e "$OECORELOCALCONFPATH" ] then echo "ERROR: Could not find the specified local conf file $OECORELOCALCONFPATH" exit 1 @@ -710,7 +710,7 @@ get_oecorelocalconf() { return fi - cd $sourcedir + cd "$sourcedir" confs=$(find . -name "local.conf.sample") done="n" @@ -738,7 +738,7 @@ EOM read input - if [ -e $input ] + if [ -e "$input" ] then done="y" OECORELOCALCONF=$input @@ -767,19 +767,19 @@ NOTE: Any additional entries to this file will be lost if the $0 EOM # First copy the template file - cp -f $OECORELAYERCONFPATH $confdir/bblayers.conf + cp -f "$OECORELAYERCONFPATH" "$confdir/bblayers.conf" # Now add the layers we have configured to the BBLAYERS variable -cat >> $confdir/bblayers.conf << EOM +cat >> "$confdir/bblayers.conf" << EOM # Layers configured by oe-core-setup script BBLAYERS += " \\ EOM for l in $layers do - printf '\t%s \\\n' "$l" >> $confdir/bblayers.conf + printf '\t%s \\\n' "$l" >> "$confdir/bblayers.conf" done - echo "\"" >> $confdir/bblayers.conf + echo "\"" >> "$confdir/bblayers.conf" } @@ -800,20 +800,20 @@ NOTE: You will probably want to change the default MACHINE setting in the EOM - if [ -e $confdir/local.conf ] + if [ -e "$confdir/local.conf" ] then echo "WARNING: Found existing $confdir/local.conf" echo "Saving a backup to $confdir/local.conf.bak" - cp -f $confdir/local.conf $confdir/local.conf.bak + cp -f "$confdir/local.conf" "$confdir/local.conf.bak" fi # First copy the template file - cp -f $OECORELOCALCONFPATH $confdir/local.conf + cp -f "$OECORELOCALCONFPATH" "$confdir/local.conf" # Find if old DL_DIR was set - if [ -e $confdir/local.conf.bak ] + if [ -e "$confdir/local.conf.bak" ] then - old_dldir=$(cat $confdir/local.conf.bak | grep -e "^DL_DIR =" | sed 's|DL_DIR = ||' | sed 's/"//g') + old_dldir=$(cat "$confdir/local.conf.bak" | grep -e "^DL_DIR =" | sed 's|DL_DIR = ||' | sed 's/"//g') else old_dldir="$oebase/downloads" fi @@ -824,30 +824,30 @@ EOM dldir=$old_dldir fi - sed -i "s|^DL_DIR.*|DL_DIR = \"${dldir}\"|" $confdir/local.conf + sed -i "s|^DL_DIR.*|DL_DIR = \"${dldir}\"|" "$confdir/local.conf" - if [ -e $oebase/tmp_append_local.conf ] + if [ -e "$oebase/tmp_append_local.conf" ] then - echo "" >> $confdir/local.conf - echo "#====================================================================" >> $confdir/local.conf - echo "# LOCALCONF: settings from config file:" >> $confdir/local.conf - echo "# $inputfile" >> $confdir/local.conf - echo "#" >> $confdir/local.conf - echo "# Do not remove." >> $confdir/local.conf - echo "#--------------------------------------------------------------------" >> $confdir/local.conf - cat $oebase/tmp_append_local.conf >> $confdir/local.conf - echo "#====================================================================" >> $confdir/local.conf - echo "" >> $confdir/local.conf - rm $oebase/tmp_append_local.conf + echo "" >> "$confdir/local.conf" + echo "#====================================================================" >> "$confdir/local.conf" + echo "# LOCALCONF: settings from config file:" >> "$confdir/local.conf" + echo "# $inputfile" >> "$confdir/local.conf" + echo "#" >> "$confdir/local.conf" + echo "# Do not remove." >> "$confdir/local.conf" + echo "#--------------------------------------------------------------------" >> "$confdir/local.conf" + cat "$oebase/tmp_append_local.conf" >> "$confdir/local.conf" + echo "#====================================================================" >> "$confdir/local.conf" + echo "" >> "$confdir/local.conf" + rm "$oebase/tmp_append_local.conf" fi } print_motd() { - if [ -e $oebase/tmp_motd ] + if [ -e "$oebase/tmp_motd" ] then echo "" - cat $oebase/tmp_motd + cat "$oebase/tmp_motd" echo "" fi } @@ -866,7 +866,7 @@ print_image_names() { F_IMAGE_FOLDERS=$(find "${SOURCES}/${FOLDER}" -type d -a -iname images|grep recipes-core) for IMG_FOLDER in ${F_IMAGE_FOLDERS} do - F_IMAGES=$(find "${IMG_FOLDER}" -iname *.bb) + F_IMAGES=$(find "${IMG_FOLDER}" -iname '*.bb') if [ -n "${F_IMAGES}" ]; then for img in ${F_IMAGES} do @@ -901,17 +901,17 @@ For example: Common targets are: EOM -print_image_names ${sourcedir} +print_image_names "${sourcedir}" # Write the setenv file -cat > $confdir/setenv << EOM +cat > "$confdir/setenv" << EOM # Set OEBASE to where the build and source directories reside # NOTE: Do NOT place a trailing / on the end of OEBASE. -export OEBASE=${oebase} +export OEBASE="${oebase}" # try to find out bitbake directory -BITBAKEDIR=\$(find \${OEBASE}/sources -name "*bitbake*") +BITBAKEDIR=\$(find "\${OEBASE}/sources" -name "*bitbake*") for f in \${BITBAKEDIR} do if [ -d \${f}/bin ] @@ -922,7 +922,7 @@ done # check for any scripts directories in the top-level of the repos and add those # to the PATH -SCRIPTS=\$(find \${OEBASE}/sources -maxdepth 2 -name "scripts" -type d) +SCRIPTS=\$(find "\${OEBASE}/sources" -maxdepth 2 -name "scripts" -type d) for s in \${SCRIPTS} do PATH="\${s}:\$PATH" @@ -931,13 +931,13 @@ done unset BITBAKEDIR unset SCRIPTS export PATH -export BUILDDIR=${builddir} +export BUILDDIR="${builddir}" EOM if [ "$BITBAKE_INCLUSIVE_VARS" = "no" ]; then - echo "export BB_ENV_EXTRAWHITE=\"MACHINE DISTRO TCMODE TCLIBC http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS PARALLEL_MAKE GIT_PROXY_COMMAND GIT_PROXY_IGNORE SOCKS5_PASSWD SOCKS5_USER OEBASE META_SDK_PATH TOOLCHAIN_TYPE TOOLCHAIN_BRAND TOOLCHAIN_BASE TOOLCHAIN_PATH TOOLCHAIN_PATH_ARMV5 TOOLCHAIN_PATH_ARMV7 TOOLCHAIN_PATH_ARMV8 EXTRA_TISDK_FILES TISDK_VERSION ARAGO_BRAND ARAGO_RT_ENABLE ARAGO_SYSTEST_ENABLE ARAGO_KERNEL_SUFFIX TI_SECURE_DEV_PKG_CAT TI_SECURE_DEV_PKG_AUTO TI_SECURE_DEV_PKG_K3 ARAGO_SYSVINIT SYSFW_FILE ARAGO_JAILHOUSE_ENABLE\"" >> $confdir/setenv + echo "export BB_ENV_EXTRAWHITE=\"MACHINE DISTRO TCMODE TCLIBC http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS PARALLEL_MAKE GIT_PROXY_COMMAND GIT_PROXY_IGNORE SOCKS5_PASSWD SOCKS5_USER OEBASE META_SDK_PATH TOOLCHAIN_TYPE TOOLCHAIN_BRAND TOOLCHAIN_BASE TOOLCHAIN_PATH TOOLCHAIN_PATH_ARMV5 TOOLCHAIN_PATH_ARMV7 TOOLCHAIN_PATH_ARMV8 EXTRA_TISDK_FILES TISDK_VERSION ARAGO_BRAND ARAGO_RT_ENABLE ARAGO_SYSTEST_ENABLE ARAGO_KERNEL_SUFFIX TI_SECURE_DEV_PKG_CAT TI_SECURE_DEV_PKG_AUTO TI_SECURE_DEV_PKG_K3 ARAGO_SYSVINIT SYSFW_FILE ARAGO_JAILHOUSE_ENABLE\"" >> "$confdir/setenv" else - echo "export BB_ENV_PASSTHROUGH_ADDITIONS=\"MACHINE DISTRO TCMODE TCLIBC http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS PARALLEL_MAKE GIT_PROXY_COMMAND GIT_PROXY_IGNORE SOCKS5_PASSWD SOCKS5_USER OEBASE META_SDK_PATH TOOLCHAIN_TYPE TOOLCHAIN_BRAND TOOLCHAIN_BASE TOOLCHAIN_PATH TOOLCHAIN_PATH_ARMV5 TOOLCHAIN_PATH_ARMV7 TOOLCHAIN_PATH_ARMV8 EXTRA_TISDK_FILES TISDK_VERSION ARAGO_BRAND ARAGO_RT_ENABLE ARAGO_SYSTEST_ENABLE ARAGO_KERNEL_SUFFIX TI_SECURE_DEV_PKG_CAT TI_SECURE_DEV_PKG_AUTO TI_SECURE_DEV_PKG_K3 ARAGO_SYSVINIT SYSFW_FILE ARAGO_JAILHOUSE_ENABLE\"" >> $confdir/setenv + echo "export BB_ENV_PASSTHROUGH_ADDITIONS=\"MACHINE DISTRO TCMODE TCLIBC http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS PARALLEL_MAKE GIT_PROXY_COMMAND GIT_PROXY_IGNORE SOCKS5_PASSWD SOCKS5_USER OEBASE META_SDK_PATH TOOLCHAIN_TYPE TOOLCHAIN_BRAND TOOLCHAIN_BASE TOOLCHAIN_PATH TOOLCHAIN_PATH_ARMV5 TOOLCHAIN_PATH_ARMV7 TOOLCHAIN_PATH_ARMV8 EXTRA_TISDK_FILES TISDK_VERSION ARAGO_BRAND ARAGO_RT_ENABLE ARAGO_SYSTEST_ENABLE ARAGO_KERNEL_SUFFIX TI_SECURE_DEV_PKG_CAT TI_SECURE_DEV_PKG_AUTO TI_SECURE_DEV_PKG_K3 ARAGO_SYSVINIT SYSFW_FILE ARAGO_JAILHOUSE_ENABLE\"" >> "$confdir/setenv" fi } @@ -945,13 +945,13 @@ EOM build_repo_line() { # clean up the layers to remove the repository name and add : divider temp_layers="" - for l in $(echo $repo_layers | sed "s:${name}::" | sed -e 's:^\/::') + for l in $(echo "$repo_layers" | sed "s:${name}::" | sed -e 's:^\/::') do - temp_layers="$temp_layers""$(echo $l | sed "s:${name}\/::"):" + temp_layers="${temp_layers}$(echo "$l" | sed "s:${name}\/::"):" done # Lastly clean off any trailing : - temp_layers=$(echo $temp_layers | sed 's/:$//') + temp_layers=$(echo "$temp_layers" | sed 's/:$//') echo "$name,$uri,$branch,$commit,layers=$temp_layers" } @@ -975,11 +975,11 @@ do done # create passed in directory if it doesn't exist -mkdir -p $oebase +mkdir -p "$oebase" # retrive the absolute path to the oebase directory incase # a relative path is passed in -cd $oebase +cd "$oebase" oebase=$(pwd) cd - @@ -1022,7 +1022,7 @@ then repo_line=$(build_repo_line) # Save the line in the output variable for if we create an output file - output="$output""$repo_line\n" + output="${output}${repo_line}\n" save_layers @@ -1042,13 +1042,13 @@ config_oecorelocalconf if [ -n "$outputfile" ] then # make sure that the directory for the output file exists - cd $oebase - dir=$(dirname $outputfile) - if [ ! -d $dir ] + cd "$oebase" + dir=$(dirname "$outputfile") + if [ ! -d "$dir" ] then - mkdir -p $dir + mkdir -p "$dir" fi - printf '%s\n' "$output" > $outputfile + printf '%s\n' "$output" > "$outputfile" echo "Output file is $outputfile" fi From patchwork Wed Jun 7 20:04:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25250 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CC77C88C84 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by mx.groups.io with SMTP id smtpd.web10.8317.1686168315235046767 for ; Wed, 07 Jun 2023 13:05:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=wIp5w+MK; spf=pass (domain: ti.com, ip: 198.47.23.248, mailfrom: rs@ti.com) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5BqE106644; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=I6pAJYQmseZ7331O/poX4YJPaC18ET5DxkDKPu05gKk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=wIp5w+MK1Kgo448b5MgbgYEqzn2k/w0e+zgC5Avm28rwCH2/e6KeGjcExbD2Ag4MA opoi3+NG45XCqPxBM9Ofo/yPqQCkZxtOwCSBlcM8mmEbgJCol+oRk1QErLi9WkkW0v LZ5YD2ir9NXiStlpd1QwDf0z9LIKMzIRCsGDYowA= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5BAN030617 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL1125548; Wed, 7 Jun 2023 15:05:10 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 05/15] oe-layertool-setup: only invoke read with -r Date: Wed, 7 Jun 2023 15:04:54 -0500 Message-ID: <20230607200504.3810426-6-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14536 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Shellcheck: read without -r will mangle backslashes. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index abe3f12..ee93ec9 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -246,7 +246,7 @@ parse_input_file() { rm "$oebase/tmp_motd" fi - while read line + while read -r line do # clean the parsing variables for each run name="" @@ -434,7 +434,7 @@ $branches What branch would you like to checkout for the $name repository? EOM - read input + read -r input # check that the branch is in the list of branches # NOTE: using a for loop here because I want exact matches. @@ -517,7 +517,7 @@ You can either select one of these tags or specify your own commit SHA sum, or press ENTER to use the HEAD of the current branch. EOM - read input + read -r input if [ -z "$input" ] then @@ -606,7 +606,7 @@ Please provide the list of layers you wish to use as a space separated list, or press enter to use all of the layers. EOM - read input + read -r input fi if [ -z "$input" ] @@ -625,7 +625,7 @@ cat << EOM What is the name of the repository you want to configure? EOM - read name + read -r name } @@ -637,7 +637,7 @@ cat << EOM What is the git clone uri of the $name repository? EOM - read uri + read -r uri } @@ -681,7 +681,7 @@ Please select one of the above sample files to use as a template for configuring your build environment. EOM - read input + read -r input if [ -e "$input" ] then @@ -736,7 +736,7 @@ Please select one of the above sample files to use as a template for configuring your build environment. EOM - read input + read -r input if [ -e "$input" ] then @@ -1029,7 +1029,7 @@ then echo "" echo "" echo "Would you like to configure another repository? [y/n] " - read cont + read -r cont done fi From patchwork Wed Jun 7 20:04:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25246 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39239C87FE2 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by mx.groups.io with SMTP id smtpd.web10.8313.1686168314515104534 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=eXRLKBSo; spf=pass (domain: ti.com, ip: 198.47.19.141, mailfrom: rs@ti.com) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5Bv0002227; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=+iWhz9Bx6mBdtqwulw4Ef52fduATUucrofXi5IH6R9Y=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=eXRLKBSoeCG5vQbfZa4ssajuD8h8kDyRYR9XVLEbbz+Je+R5nwIoULHqzCX1uVHSO /fcdr/f+O0mTYz07rJlqnqnlHTbel4K5wWXq1uDD4nDqyUnUGiDIUGCokNnFeuyqtu fo9Nl1ruig+OI60iB+Lo2RWKZuZWRUDd+1EG+5fM= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5B4Q070112 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:10 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL2125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 06/15] oe-layertool-setup: check exit code directly Date: Wed, 7 Jun 2023 15:04:55 -0500 Message-ID: <20230607200504.3810426-7-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14529 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Shellcheck: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index ee93ec9..a87a423 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -262,15 +262,13 @@ parse_input_file() { fi # Skip comment lines - echo "$line" | grep -e "^#" > /dev/null - if [ "$?" = "0" ] + if echo "$line" | grep -q -e "^#" then continue fi # If the line starts with OECORE then parse the OECORE setting - echo "$line" | grep -e "^OECORE.*=" > /dev/null - if [ "$?" = "0" ] + if echo "$line" | grep -q -e "^OECORE.*=" then parse_oecore_line "$line" output="${output}${line}\n" @@ -278,8 +276,7 @@ parse_input_file() { fi # If the line starts with BITBAKE then parse the BITBAKE setting - echo "$line" | grep -e "^BITBAKE.*=" > /dev/null - if [ "$?" = "0" ] + if echo "$line" | grep -q -e "^BITBAKE.*=" then parse_bitbake_line "$line" output="${output}${line}\n" @@ -287,8 +284,7 @@ parse_input_file() { fi # If the line starts with LOCALCONF: then parse the LOCALCONF: setting - echo "$line" | grep -e "^LOCALCONF:.*" > /dev/null - if [ "$?" = "0" ] + if echo "$line" | grep -q -e "^LOCALCONF:.*" then parse_localconf_line "$line" output="${output}${line}\n" @@ -296,8 +292,7 @@ parse_input_file() { fi # If the line starts with MOTD: then parse the MOTD: setting - echo "$line" | grep -e "^MOTD:.*" > /dev/null - if [ "$?" = "0" ] + if echo "$line" | grep -q -e "^MOTD:.*" then parse_motd_line "$line" continue @@ -307,11 +302,9 @@ parse_input_file() { # it is a repository information line and parse it parse_repo_line "$line" - configure_repo - # if the return from configure repo was non-zero then do not save # the output - if [ "$?" != "0" ] + if ! configure_repo then continue fi @@ -398,8 +391,7 @@ clone_repo() { cd "$sourcedir/$name" "$scriptdir/git_retry.sh" fetch --all else - "$scriptdir/git_retry.sh" clone "$uri" "$sourcedir/$name" - if [ "$?" != "0" ] + if ! "$scriptdir/git_retry.sh" clone "$uri" "$sourcedir/$name" then echo "ERROR: Could not clone repository at $uri" exit 1 @@ -461,8 +453,7 @@ checkout_branch() { # Check if a local branch already exists to track the remote branch. # If not then create a tracking branch and checkout the branch # else just checkout the existing branch - git branch | grep "$branch" > /dev/null - if [ "$?" != "0" ] + if git branch | grep -q "$branch" then git checkout "origin/$branch" -b "$branch" --track else @@ -1009,9 +1000,7 @@ then commit="" repo_layers="" - configure_repo - - if [ "$?" != "0" ] + if ! configure_repo then continue fi From patchwork Wed Jun 7 20:04:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25248 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 592E5C88C83 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by mx.groups.io with SMTP id smtpd.web10.8310.1686168314396010938 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=DDd24qrt; spf=pass (domain: ti.com, ip: 198.47.19.141, mailfrom: rs@ti.com) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5Bku002229; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=BGhjst7LgE50k8ENymCmeVpum2BANcJA6XVVTtfUkPA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DDd24qrtZhHzucDaA/ie8EuG/eclfoZ18fT/X+2+j7bpbTs0SGKhGIS1kBUVgiDBc e6DrfGdPCz1qVtpMNPnVqK8UtRBgQfS7sm1NB7d1UQ16Y3gT9YRRkhjJqj/58ccWJx zBL2d1lKJwdGOJSwoq2hMIot1F5/iIYbihc9Oafs= Received: from DFLE101.ent.ti.com (dfle101.ent.ti.com [10.64.6.22]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5Bsb036869 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL3125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 07/15] oe-layertool-setup: guard all cd calls Date: Wed, 7 Jun 2023 15:04:56 -0500 Message-ID: <20230607200504.3810426-8-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14523 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Make the scrip exit early if any cd calls fail in the main process. Return 1 in the case a function fails to cd. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index a87a423..6908fe2 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -386,9 +386,8 @@ configure_repo() { clone_repo() { # check if the repo already exists. if so then fetch the latest updates, # else clone it - if [ -d "$sourcedir/$name" ] + if cd "$sourcedir/$name" 2> /dev/null then - cd "$sourcedir/$name" "$scriptdir/git_retry.sh" fetch --all else if ! "$scriptdir/git_retry.sh" clone "$uri" "$sourcedir/$name" @@ -405,7 +404,7 @@ get_repo_branch() { while [ "$found" = "0" ] do - cd "$sourcedir/$name" + cd "$sourcedir/$name" || return 1 # Get a unique list of branches for the user to chose from # Also delete the origin/HEAD line that the -r option returns @@ -448,7 +447,7 @@ EOM } checkout_branch() { - cd "$sourcedir/$name" + cd "$sourcedir/$name" || return 1 # Check if a local branch already exists to track the remote branch. # If not then create a tracking branch and checkout the branch @@ -474,7 +473,7 @@ checkout_branch() { } checkout_commit() { - cd "$sourcedir/$name" + cd "$sourcedir/$name" || return 1 if [ "$commit" != "HEAD" ] then git checkout $commit @@ -483,7 +482,7 @@ checkout_commit() { get_repo_commit() { # prompt for what commit to use with HEAD as default - cd "$sourcedir/$name" + cd "$sourcedir/$name" || return 1 cat << EOM @@ -517,7 +516,7 @@ EOM } verify_layers() { - cd "$sourcedir" + cd "$sourcedir" || return 1 for l in $repo_layers do if [ ! -f "$sourcedir/$l/conf/layer.conf" ] @@ -555,7 +554,7 @@ select_layers() { return fi - cd "$sourcedir" + cd "$sourcedir" || return 1 # Get a count of how many layers there are count=$(find "$name" -name "layer.conf" | grep -c layer.conf) @@ -646,7 +645,7 @@ get_oecorelayerconf() { return fi - cd "$sourcedir" + cd "$sourcedir" || return 1 confs=$(find . -name "bblayers.conf.sample") done="n" @@ -701,7 +700,7 @@ get_oecorelocalconf() { return fi - cd "$sourcedir" + cd "$sourcedir" || return 1 confs=$(find . -name "local.conf.sample") done="n" @@ -970,9 +969,9 @@ mkdir -p "$oebase" # retrive the absolute path to the oebase directory incase # a relative path is passed in -cd "$oebase" +cd "$oebase" || exit 1 oebase=$(pwd) -cd - +cd - || exit 1 # Populate the following variables depending on the value of oebase sourcedir="$oebase/sources" @@ -1031,7 +1030,7 @@ config_oecorelocalconf if [ -n "$outputfile" ] then # make sure that the directory for the output file exists - cd "$oebase" + cd "$oebase" || exit 1 dir=$(dirname "$outputfile") if [ ! -d "$dir" ] then From patchwork Wed Jun 7 20:04:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25239 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24F13C87FDD for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by mx.groups.io with SMTP id smtpd.web10.8309.1686168314311029003 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=CxwYu2kT; spf=pass (domain: ti.com, ip: 198.47.19.142, mailfrom: rs@ti.com) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5BQu106440; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=pjcwyDHrtzS5gPhKXDnp8oCWcegMcf1yVdbcW9Htjug=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CxwYu2kT6LwblrHtpctFQr51HH+yEz7/1y1uwjjCXiKY+Mh0/0ItSxYAlOJW5nnAo EM5eXZE62uI3q6APIttM1C8nXd9r7xZg4kMGOGb4bU3NILhvT7AqnCEOFPB9r/6lft 1+glGcU1Y1kLu2bs3ncl8hGvZ+5xDmzplEYFfyIw= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5Bd9070117 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL4125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 08/15] oe-layertool-setup: eliminate useless cat Date: Wed, 7 Jun 2023 15:04:57 -0500 Message-ID: <20230607200504.3810426-9-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14527 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Eliminate useless cat into grep. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index 6908fe2..b824114 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -803,7 +803,7 @@ EOM # Find if old DL_DIR was set if [ -e "$confdir/local.conf.bak" ] then - old_dldir=$(cat "$confdir/local.conf.bak" | grep -e "^DL_DIR =" | sed 's|DL_DIR = ||' | sed 's/"//g') + old_dldir=$(grep -e "^DL_DIR =" "$confdir/local.conf.bak" | sed 's|DL_DIR = ||' | sed 's/"//g') else old_dldir="$oebase/downloads" fi From patchwork Wed Jun 7 20:04:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25243 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 377CCC87FDE for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by mx.groups.io with SMTP id smtpd.web10.8315.1686168314698164428 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=L3HpdHZh; spf=pass (domain: ti.com, ip: 198.47.19.142, mailfrom: rs@ti.com) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5Btb106444; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=j8VLxptmubibkr1GBAVKuOPOQ4zj9U34XvkAM/m2FM8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=L3HpdHZhPd92C4o5Ro9UkI/naqXBLCik6AshWHYx7oYDMKXacV8YXN4F6hRvQoMaH dpmn97TE05fmMSiKMbI26iryvmogjUZnhHOFb5lDR/RMP3eqq/GNDQbuIzQ5FKbZQ+ Ygmb0gWtQXkzrGgqF9RHsjykd4q96iuLhutOlqes= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5B79036872 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL5125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 09/15] oe-layertool-setup: use subshell execution with redirect Date: Wed, 7 Jun 2023 15:04:58 -0500 Message-ID: <20230607200504.3810426-10-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14530 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Shellcheck: Consider using { cmd1; cmd2; } >> file instead of individual redirects. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index b824114..8e29f9a 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -818,16 +818,18 @@ EOM if [ -e "$oebase/tmp_append_local.conf" ] then - echo "" >> "$confdir/local.conf" - echo "#====================================================================" >> "$confdir/local.conf" - echo "# LOCALCONF: settings from config file:" >> "$confdir/local.conf" - echo "# $inputfile" >> "$confdir/local.conf" - echo "#" >> "$confdir/local.conf" - echo "# Do not remove." >> "$confdir/local.conf" - echo "#--------------------------------------------------------------------" >> "$confdir/local.conf" - cat "$oebase/tmp_append_local.conf" >> "$confdir/local.conf" - echo "#====================================================================" >> "$confdir/local.conf" - echo "" >> "$confdir/local.conf" + { + echo ""; + echo "#===================================================================="; + echo "# LOCALCONF: settings from config file:"; + echo "# $inputfile"; + echo "#"; + echo "# Do not remove."; + echo "#--------------------------------------------------------------------"; + cat "$oebase/tmp_append_local.conf"; + echo "#===================================================================="; + echo ""; + } >> "$confdir/local.conf" rm "$oebase/tmp_append_local.conf" fi } From patchwork Wed Jun 7 20:04:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25240 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22C17C83005 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by mx.groups.io with SMTP id smtpd.web11.8428.1686168314657855489 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=hu47eVe7; spf=pass (domain: ti.com, ip: 198.47.19.142, mailfrom: rs@ti.com) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5BiI106448; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168311; bh=fPYmfGAV2EMv73ZWNG/A3TqZohTgTjO/3FxZtXkA/u4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hu47eVe7LSvstdSm0n2HoMyrqZPx8kiSUhQdyhQBNbq/i/S6AnDbQt1b/kazQYiA5 teKjczL/Prfpogep6H99FKmldb64krVMdEgwEHLJL0wNPWgJi2M2luK90Z1Cw2a5gS 8DezcWtgZAlRC1TxnZg1OsUPoJIudaPTjHVPChC0= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5BKU087593 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL6125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 10/15] oe-layertool-setup: guard against invalid expression in case Date: Wed, 7 Jun 2023 15:04:59 -0500 Message-ID: <20230607200504.3810426-11-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14528 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Guard against and invalid expression in the main option case statement. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index 8e29f9a..e427393 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -962,7 +962,7 @@ do o ) outputfile="$OPTARG";; d ) dldir="$OPTARG";; b ) oebase="$OPTARG";; - h ) usage;; + * ) usage;; esac done From patchwork Wed Jun 7 20:05:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25241 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00FEBC7EE23 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by mx.groups.io with SMTP id smtpd.web11.8433.1686168315016232430 for ; Wed, 07 Jun 2023 13:05:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=EVzGRLrg; spf=pass (domain: ti.com, ip: 198.47.23.248, mailfrom: rs@ti.com) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5C1q106652; Wed, 7 Jun 2023 15:05:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168312; bh=BfGwYclz08x/oVM61bB6Zro3g6BeApcHgzGzIGUC9kg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=EVzGRLrgZTrJ/Q3WSojqncr6HA/h5S74jaK7sIjtDopwekFvVQp5GzpOXybzwOWiQ RXT/bFKr216JGfK6rwb9c3Wf10wh63O+k08zPQcj6Yxwi8Q6dABvokg2KlT8n5nmLw DrQtVE3KH+bDQ+ahGbNXNPFT5e0L0TKV1LcKP/e4= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5BEM036878 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:12 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL7125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 11/15] oe-layertool-setup: replace all calls to echo with printf Date: Wed, 7 Jun 2023 15:05:00 -0500 Message-ID: <20230607200504.3810426-12-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:16 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14535 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Replace all echo calls with `printf '%s\n'` since that handles arbitrary string input much more reliably. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 137 +++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 68 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index e427393..e0cfe4e 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -128,14 +128,14 @@ check_input() { # Check that at least -i or -f was used if [ "$interactive" = "n" ] && [ -z "$inputfile" ] then - echo "ERROR: You must either use this script with the -i or -f options" + printf '%s\n' "ERROR: You must either use this script with the -i or -f options" usage fi # If an input file was given make sure it exists if [ ! -f "$inputfile" ] then - echo "ERROR: the file \"$inputfile\" given for inputfile does not exist" + printf '%s\n' "ERROR: the file \"$inputfile\" given for inputfile does not exist" usage fi @@ -154,29 +154,29 @@ check_input() { # Input is a line of the form OECORE.*=value parse_oecore_line() { - var=$(echo "$1" | cut -d= -f1) - val=$(echo "$1" | cut -d= -f2) + var=$(printf '%s\n' "$1" | cut -d= -f1) + val=$(printf '%s\n' "$1" | cut -d= -f2) export "$var"="$val" } # Input is a line of the form BITBAKE.*=value parse_bitbake_line() { - var=$(echo "$1" | cut -d= -f1) - val=$(echo "$1" | cut -d= -f2) + var=$(printf '%s\n' "$1" | cut -d= -f1) + val=$(printf '%s\n' "$1" | cut -d= -f2) export "$var"="$val" } # Input is a line of the form LOCALCONF:.*=value parse_localconf_line() { - localconf=$(echo "$1" | cut -d: -f2-100) - echo "$localconf" >> "$oebase/tmp_append_local.conf" + localconf=$(printf '%s\n' "$1" | cut -d: -f2-100) + printf '%s\n' "$localconf" >> "$oebase/tmp_append_local.conf" } # Input is a line of the form MOTD: parse_motd_line() { - motd=$(echo "$1" | cut -d: -f2-100) - echo "$motd" >> "$oebase/tmp_motd" - echo "$motd" + motd=$(printf '%s\n' "$1" | cut -d: -f2-100) + printf '%s\n' "$motd" >> "$oebase/tmp_motd" + printf '%s\n' "$motd" } @@ -197,11 +197,11 @@ parse_repo_line() { # split the line on the comma separators # use the prefix if it was set. - export "${prefix}name"="$(echo "$1" | cut -d, -f1)" - export "${prefix}uri"="$(echo "$1" | cut -d, -f2)" - export "${prefix}branch"="$(echo "$1" | cut -d, -f3)" - export "${prefix}commit"="$(echo "$1" | cut -d, -f4)" - parsed_layers=$(echo "$1" | cut -d, -f5-) + export "${prefix}name"="$(printf '%s\n' "$1" | cut -d, -f1)" + export "${prefix}uri"="$(printf '%s\n' "$1" | cut -d, -f2)" + export "${prefix}branch"="$(printf '%s\n' "$1" | cut -d, -f3)" + export "${prefix}commit"="$(printf '%s\n' "$1" | cut -d, -f4)" + parsed_layers=$(printf '%s\n' "$1" | cut -d, -f5-) # If no layers= was used, then don't add any layers temp_layers="none" @@ -210,9 +210,10 @@ parse_repo_line() { if [ -n "$parsed_layers" ] then temp_layers="" - temp=$(echo "$parsed_layers" | cut -d= -f2) - # temporarily reset the IFS value to : to split the layers - for x in $(IFS=":"; echo "$temp") + temp=$(printf '%s\n' "$parsed_layers" | cut -d= -f2) + # use tr to split the layers since we assume layer names don't have + # whitespace characters later anyway + for x in $(printf '%s\n' "$temp" | tr ':' ' ') do # Add the $name value to each layer so that we have consistency # with how the layers are represented between the saved value @@ -262,13 +263,13 @@ parse_input_file() { fi # Skip comment lines - if echo "$line" | grep -q -e "^#" + if printf '%s\n' "$line" | grep -q -e "^#" then continue fi # If the line starts with OECORE then parse the OECORE setting - if echo "$line" | grep -q -e "^OECORE.*=" + if printf '%s\n' "$line" | grep -q -e "^OECORE.*=" then parse_oecore_line "$line" output="${output}${line}\n" @@ -276,7 +277,7 @@ parse_input_file() { fi # If the line starts with BITBAKE then parse the BITBAKE setting - if echo "$line" | grep -q -e "^BITBAKE.*=" + if printf '%s\n' "$line" | grep -q -e "^BITBAKE.*=" then parse_bitbake_line "$line" output="${output}${line}\n" @@ -284,7 +285,7 @@ parse_input_file() { fi # If the line starts with LOCALCONF: then parse the LOCALCONF: setting - if echo "$line" | grep -q -e "^LOCALCONF:.*" + if printf '%s\n' "$line" | grep -q -e "^LOCALCONF:.*" then parse_localconf_line "$line" output="${output}${line}\n" @@ -292,7 +293,7 @@ parse_input_file() { fi # If the line starts with MOTD: then parse the MOTD: setting - if echo "$line" | grep -q -e "^MOTD:.*" + if printf '%s\n' "$line" | grep -q -e "^MOTD:.*" then parse_motd_line "$line" continue @@ -335,9 +336,9 @@ configure_repo() { if [ -n "$temp" ] then - echo "This repository ($name) has already been configured with the following values:" + printf '%s\n' "This repository ($name) has already been configured with the following values:" printf '\t%s\n' "$temp" - echo "Skipping configuring duplicate repository" + printf '%s\n' "Skipping configuring duplicate repository" return 1 fi @@ -346,10 +347,10 @@ configure_repo() { get_repo_uri fi - echo "" - echo "" - echo "cloning repo $name" - echo "" + printf '%s\n' "" + printf '%s\n' "" + printf '%s\n' "cloning repo $name" + printf '%s\n' "" clone_repo @@ -392,7 +393,7 @@ clone_repo() { else if ! "$scriptdir/git_retry.sh" clone "$uri" "$sourcedir/$name" then - echo "ERROR: Could not clone repository at $uri" + printf '%s\n' "ERROR: Could not clone repository at $uri" exit 1 fi fi @@ -411,7 +412,7 @@ get_repo_branch() { t_branches=$(git branch -r | sed '/origin\/HEAD/d') for b in $t_branches do - branches="${branches}$(echo "$b" | sed 's:.*origin/::g')\n" + branches="${branches}$(printf '%s\n' "$b" | sed 's:.*origin/::g')\n" done branches=$(printf '%s\n' "$branches" | sort | uniq) @@ -440,7 +441,7 @@ EOM if [ "$found" != "1" ] then - echo "Invalid branch ($input) selected. Please try again" + printf '%s\n' "Invalid branch ($input) selected. Please try again" fi done branch=$input @@ -521,8 +522,8 @@ verify_layers() { do if [ ! -f "$sourcedir/$l/conf/layer.conf" ] then - echo "ERROR: the $l layer in the $name repository could not be" - echo " found. Bailing out." + printf '%s\n' "ERROR: the $l layer in the $name repository could not be" + printf '%s\n' " found. Bailing out." exit 1 fi done @@ -575,7 +576,7 @@ select_layers() { if [ "$arg1" != "all" ] then - echo "arg1 = $arg1" + printf '%s\n' "arg1 = $arg1" # Prompt for which layers to configure cat << EOM @@ -587,7 +588,7 @@ EOM for l in $t_layers do - printf '\t%s\n' "$(echo "$l" | sed "s:${name}\/::")" + printf '\t%s\n' "$(printf '%s\n' "$l" | sed "s:${name}\/::")" done cat << EOM @@ -639,7 +640,7 @@ get_oecorelayerconf() { if [ ! -e "$OECORELAYERCONFPATH" ] then - echo "ERROR: Could not find the specified layer conf file $OECORELAYERCONFPATH" + printf '%s\n' "ERROR: Could not find the specified layer conf file $OECORELAYERCONFPATH" fi return @@ -679,7 +680,7 @@ EOM OECORELAYERCONF=$input OECORELAYERCONFPATH=$sourcedir/$OECORELAYERCONF else - echo "ERROR: Could not find the specified layer conf file $input" + printf '%s\n' "ERROR: Could not find the specified layer conf file $input" fi done } @@ -693,7 +694,7 @@ get_oecorelocalconf() { if [ ! -e "$OECORELOCALCONFPATH" ] then - echo "ERROR: Could not find the specified local conf file $OECORELOCALCONFPATH" + printf '%s\n' "ERROR: Could not find the specified local conf file $OECORELOCALCONFPATH" exit 1 fi @@ -734,7 +735,7 @@ EOM OECORELOCALCONF=$input OECORELOCALCONFPATH=$sourcedir/$OECORELOCALCONF else - echo "ERROR: Could not find the inputted sample file: $input" + printf '%s\n' "ERROR: Could not find the inputted sample file: $input" exit 1 fi done @@ -769,7 +770,7 @@ EOM do printf '\t%s \\\n' "$l" >> "$confdir/bblayers.conf" done - echo "\"" >> "$confdir/bblayers.conf" + printf '%s\n' "\"" >> "$confdir/bblayers.conf" } @@ -792,8 +793,8 @@ EOM if [ -e "$confdir/local.conf" ] then - echo "WARNING: Found existing $confdir/local.conf" - echo "Saving a backup to $confdir/local.conf.bak" + printf '%s\n' "WARNING: Found existing $confdir/local.conf" + printf '%s\n' "Saving a backup to $confdir/local.conf.bak" cp -f "$confdir/local.conf" "$confdir/local.conf.bak" fi @@ -819,16 +820,16 @@ EOM if [ -e "$oebase/tmp_append_local.conf" ] then { - echo ""; - echo "#===================================================================="; - echo "# LOCALCONF: settings from config file:"; - echo "# $inputfile"; - echo "#"; - echo "# Do not remove."; - echo "#--------------------------------------------------------------------"; + printf '%s\n' ""; + printf '%s\n' "#===================================================================="; + printf '%s\n' "# LOCALCONF: settings from config file:"; + printf '%s\n' "# $inputfile"; + printf '%s\n' "#"; + printf '%s\n' "# Do not remove."; + printf '%s\n' "#--------------------------------------------------------------------"; cat "$oebase/tmp_append_local.conf"; - echo "#===================================================================="; - echo ""; + printf '%s\n' "#===================================================================="; + printf '%s\n' ""; } >> "$confdir/local.conf" rm "$oebase/tmp_append_local.conf" fi @@ -838,9 +839,9 @@ print_motd() { if [ -e "$oebase/tmp_motd" ] then - echo "" + printf '%s\n' "" cat "$oebase/tmp_motd" - echo "" + printf '%s\n' "" fi } @@ -854,7 +855,7 @@ print_image_names() { if [ "${FOLDER}" = "meta-arago" ]; then RECO="[recommended]" fi - echo "From ${FOLDER}${RECO}:" + printf '%s\n' "From ${FOLDER}${RECO}:" F_IMAGE_FOLDERS=$(find "${SOURCES}/${FOLDER}" -type d -a -iname images|grep recipes-core) for IMG_FOLDER in ${F_IMAGE_FOLDERS} do @@ -863,11 +864,11 @@ print_image_names() { for img in ${F_IMAGES} do name=$(basename "${img}"|sed 's/\.bb$//g') - summary=$(grep SUMMARY "${img}"|cut -d '=' -f2| sed 's/["/]//g'|xargs echo) + summary=$(grep SUMMARY "${img}"|cut -d '=' -f2| sed 's/["/]//g') if [ -z "${summary}" ]; then summary="No Summary available" fi - echo " ${name}: ${summary}" + printf '%s\n' " ${name}: ${summary}" done fi done @@ -927,9 +928,9 @@ export BUILDDIR="${builddir}" EOM if [ "$BITBAKE_INCLUSIVE_VARS" = "no" ]; then - echo "export BB_ENV_EXTRAWHITE=\"MACHINE DISTRO TCMODE TCLIBC http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS PARALLEL_MAKE GIT_PROXY_COMMAND GIT_PROXY_IGNORE SOCKS5_PASSWD SOCKS5_USER OEBASE META_SDK_PATH TOOLCHAIN_TYPE TOOLCHAIN_BRAND TOOLCHAIN_BASE TOOLCHAIN_PATH TOOLCHAIN_PATH_ARMV5 TOOLCHAIN_PATH_ARMV7 TOOLCHAIN_PATH_ARMV8 EXTRA_TISDK_FILES TISDK_VERSION ARAGO_BRAND ARAGO_RT_ENABLE ARAGO_SYSTEST_ENABLE ARAGO_KERNEL_SUFFIX TI_SECURE_DEV_PKG_CAT TI_SECURE_DEV_PKG_AUTO TI_SECURE_DEV_PKG_K3 ARAGO_SYSVINIT SYSFW_FILE ARAGO_JAILHOUSE_ENABLE\"" >> "$confdir/setenv" + printf 'export %s="%s"\n' 'BB_ENV_EXTRAWHITE' 'MACHINE DISTRO TCMODE TCLIBC http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS PARALLEL_MAKE GIT_PROXY_COMMAND GIT_PROXY_IGNORE SOCKS5_PASSWD SOCKS5_USER OEBASE META_SDK_PATH TOOLCHAIN_TYPE TOOLCHAIN_BRAND TOOLCHAIN_BASE TOOLCHAIN_PATH TOOLCHAIN_PATH_ARMV5 TOOLCHAIN_PATH_ARMV7 TOOLCHAIN_PATH_ARMV8 EXTRA_TISDK_FILES TISDK_VERSION ARAGO_BRAND ARAGO_RT_ENABLE ARAGO_SYSTEST_ENABLE ARAGO_KERNEL_SUFFIX TI_SECURE_DEV_PKG_CAT TI_SECURE_DEV_PKG_AUTO TI_SECURE_DEV_PKG_K3 ARAGO_SYSVINIT SYSFW_FILE ARAGO_JAILHOUSE_ENABLE' >> "$confdir/setenv" else - echo "export BB_ENV_PASSTHROUGH_ADDITIONS=\"MACHINE DISTRO TCMODE TCLIBC http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS PARALLEL_MAKE GIT_PROXY_COMMAND GIT_PROXY_IGNORE SOCKS5_PASSWD SOCKS5_USER OEBASE META_SDK_PATH TOOLCHAIN_TYPE TOOLCHAIN_BRAND TOOLCHAIN_BASE TOOLCHAIN_PATH TOOLCHAIN_PATH_ARMV5 TOOLCHAIN_PATH_ARMV7 TOOLCHAIN_PATH_ARMV8 EXTRA_TISDK_FILES TISDK_VERSION ARAGO_BRAND ARAGO_RT_ENABLE ARAGO_SYSTEST_ENABLE ARAGO_KERNEL_SUFFIX TI_SECURE_DEV_PKG_CAT TI_SECURE_DEV_PKG_AUTO TI_SECURE_DEV_PKG_K3 ARAGO_SYSVINIT SYSFW_FILE ARAGO_JAILHOUSE_ENABLE\"" >> "$confdir/setenv" + printf 'export %s="%s"\n' 'BB_ENV_PASSTHROUGH_ADDITIONS' 'MACHINE DISTRO TCMODE TCLIBC http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS PARALLEL_MAKE GIT_PROXY_COMMAND GIT_PROXY_IGNORE SOCKS5_PASSWD SOCKS5_USER OEBASE META_SDK_PATH TOOLCHAIN_TYPE TOOLCHAIN_BRAND TOOLCHAIN_BASE TOOLCHAIN_PATH TOOLCHAIN_PATH_ARMV5 TOOLCHAIN_PATH_ARMV7 TOOLCHAIN_PATH_ARMV8 EXTRA_TISDK_FILES TISDK_VERSION ARAGO_BRAND ARAGO_RT_ENABLE ARAGO_SYSTEST_ENABLE ARAGO_KERNEL_SUFFIX TI_SECURE_DEV_PKG_CAT TI_SECURE_DEV_PKG_AUTO TI_SECURE_DEV_PKG_K3 ARAGO_SYSVINIT SYSFW_FILE ARAGO_JAILHOUSE_ENABLE' >> "$confdir/setenv" fi } @@ -937,15 +938,15 @@ EOM build_repo_line() { # clean up the layers to remove the repository name and add : divider temp_layers="" - for l in $(echo "$repo_layers" | sed "s:${name}::" | sed -e 's:^\/::') + for l in $(printf '%s\n' "$repo_layers" | sed "s:${name}::" | sed -e 's:^\/::') do - temp_layers="${temp_layers}$(echo "$l" | sed "s:${name}\/::"):" + temp_layers="${temp_layers}$(printf '%s\n' "$l" | sed "s:${name}\/::"):" done # Lastly clean off any trailing : - temp_layers=$(echo "$temp_layers" | sed 's/:$//') + temp_layers=$(printf '%s\n' "$temp_layers" | sed 's/:$//') - echo "$name,$uri,$branch,$commit,layers=$temp_layers" + printf '%s\n' "$name,$uri,$branch,$commit,layers=$temp_layers" } ############### @@ -1016,9 +1017,9 @@ then save_layers - echo "" - echo "" - echo "Would you like to configure another repository? [y/n] " + printf '%s\n' "" + printf '%s\n' "" + printf '%s\n' "Would you like to configure another repository? [y/n] " read -r cont done fi @@ -1039,7 +1040,7 @@ then mkdir -p "$dir" fi printf '%s\n' "$output" > "$outputfile" - echo "Output file is $outputfile" + printf '%s\n' "Output file is $outputfile" fi create_setenv_file From patchwork Wed Jun 7 20:05:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25237 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07858C77B7A for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by mx.groups.io with SMTP id smtpd.web10.8312.1686168314429321124 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=RZOLm9PB; spf=pass (domain: ti.com, ip: 198.47.19.141, mailfrom: rs@ti.com) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5B0K002235; Wed, 7 Jun 2023 15:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168312; bh=ENLIikhf5uZljkotKEZhWNS9mL0rFeykxOEld7q/Pgg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=RZOLm9PBWGKUu9i1Xhc84uK8ZdkhR1aC9RtJaJrsdpJ0sncEf3Zv4WvLLQGeIHtQ2 A4mZ1Q2d49+iMvS6m5X77rk+k/2Sr49p42p4Tz4mmMZ8xv7hIgP0bR1FBMF1SMEd9T FUFgmidLojGneAe/9otvlFKb4kvh/QkNFpCLkBhU= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5BWv030621 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:11 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL8125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 12/15] oe-layertool-setup: drop unused variable Date: Wed, 7 Jun 2023 15:05:01 -0500 Message-ID: <20230607200504.3810426-13-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14524 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Drop the unused IMAGES variable. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index e0cfe4e..0928959 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -848,7 +848,6 @@ print_motd() { print_image_names() { SOURCES="${1}" FOLDERS=$(find "${SOURCES}" -type d -a -iname images|grep recipes-core|sed -e "s/.*sources\///g"|cut -d '/' -f1|sort -u -r) - IMAGES="" for FOLDER in ${FOLDERS} do RECO="" From patchwork Wed Jun 7 20:05:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25249 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FB6AC87FE7 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by mx.groups.io with SMTP id smtpd.web10.8316.1686168314874622052 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=lLy9xqH0; spf=pass (domain: ti.com, ip: 198.47.23.249, mailfrom: rs@ti.com) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5C0S023512; Wed, 7 Jun 2023 15:05:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168312; bh=WiBvpzc1CcoFVFonuGnJQMzzM4qxiYl4fLHFjUeX8Uw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=lLy9xqH0PErRayoAc1nSynWeEnHIIf6waDZUR1Vox4pu2Xo3dLuI8FDKV1bqJ78SP hsLRGQoaQp05BbnqylozU/T3G1K5Oq56Uk7Epe/C+VLElsOmvNYsno77gEuLu24+ab NWDvHxb/BEod5aQJKjad9ZqlCoSnOQ6RfYyKCr1U= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5CYS087599 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:12 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5AL9125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 13/15] oe-layertool-setup: add a path sanity check for oebase Date: Wed, 7 Jun 2023 15:05:02 -0500 Message-ID: <20230607200504.3810426-14-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14533 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> OEBase can not have a space in it's name due to parsing limitations of POSIX shell. Make sure to check this before doing anything. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index 0928959..8694abd 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -966,6 +966,14 @@ do esac done +# add early sanity check +if printf '%s\n' "$oebase" | grep -q '\s' +then + printf '%s\n' "OE-Base path has whitespace characters in it's path!" \ + "This is currently unsupported." ; + exit 1 +fi + # create passed in directory if it doesn't exist mkdir -p "$oebase" From patchwork Wed Jun 7 20:05:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25247 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B528C87FE4 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by mx.groups.io with SMTP id smtpd.web11.8431.1686168314799506483 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=A6bVqHkX; spf=pass (domain: ti.com, ip: 198.47.19.141, mailfrom: rs@ti.com) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5CPg002239; Wed, 7 Jun 2023 15:05:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168312; bh=mDjzrDaOnFEXIHOFUl1bxuyMGIsXQI/ii/jyk8exmrU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=A6bVqHkX63xyVqr5rVFPhiCrNUccDukmprv/fixMcTxoOnccCjjFzFXNsThkRFH+/ gkhhhn3tRmEROp77qwQoGgswlYwUwegKiRPo2+DC3UQTy/NQxPmnPfjPWAgGLL2XGp Ytr2yuK31pxJtQ4bYATkmjNrx7WJTdb5I1VtKIoE= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5Cba070124 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:12 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5ALA125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 14/15] oe-layertool-setup: fix multi-line printfs Date: Wed, 7 Jun 2023 15:05:03 -0500 Message-ID: <20230607200504.3810426-15-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14532 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Replace multiple printf calls with one call and a good format. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index 8694abd..2b05550 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -347,10 +347,10 @@ configure_repo() { get_repo_uri fi - printf '%s\n' "" - printf '%s\n' "" - printf '%s\n' "cloning repo $name" - printf '%s\n' "" + printf '%s\n' "" \ + "" \ + "cloning repo $name" \ + "" ; clone_repo @@ -522,8 +522,8 @@ verify_layers() { do if [ ! -f "$sourcedir/$l/conf/layer.conf" ] then - printf '%s\n' "ERROR: the $l layer in the $name repository could not be" - printf '%s\n' " found. Bailing out." + printf '%s\n' "ERROR: the $l layer in the $name repository could not be" \ + " found. Bailing out." ; exit 1 fi done @@ -793,8 +793,8 @@ EOM if [ -e "$confdir/local.conf" ] then - printf '%s\n' "WARNING: Found existing $confdir/local.conf" - printf '%s\n' "Saving a backup to $confdir/local.conf.bak" + printf '%s\n' "WARNING: Found existing $confdir/local.conf" \ + "Saving a backup to $confdir/local.conf.bak"; cp -f "$confdir/local.conf" "$confdir/local.conf.bak" fi @@ -820,16 +820,16 @@ EOM if [ -e "$oebase/tmp_append_local.conf" ] then { - printf '%s\n' ""; - printf '%s\n' "#===================================================================="; - printf '%s\n' "# LOCALCONF: settings from config file:"; - printf '%s\n' "# $inputfile"; - printf '%s\n' "#"; - printf '%s\n' "# Do not remove."; - printf '%s\n' "#--------------------------------------------------------------------"; + printf '%s\n' "" \ + "#====================================================================" \ + "# LOCALCONF: settings from config file:" \ + "# $inputfile" \ + "#" \ + "# Do not remove." \ + "#--------------------------------------------------------------------" ; cat "$oebase/tmp_append_local.conf"; - printf '%s\n' "#===================================================================="; - printf '%s\n' ""; + printf '%s\n' "#====================================================================" \ + "" ; } >> "$confdir/local.conf" rm "$oebase/tmp_append_local.conf" fi @@ -1024,9 +1024,9 @@ then save_layers - printf '%s\n' "" - printf '%s\n' "" - printf '%s\n' "Would you like to configure another repository? [y/n] " + printf '%s\n' "" \ + "" ; + printf '%s' "Would you like to configure another repository? [y/n] " read -r cont done fi From patchwork Wed Jun 7 20:05:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randolph Sapp X-Patchwork-Id: 25245 X-Patchwork-Delegate: reatmon@ti.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E180C87FE1 for ; Wed, 7 Jun 2023 20:05:17 +0000 (UTC) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by mx.groups.io with SMTP id smtpd.web11.8427.1686168314466445607 for ; Wed, 07 Jun 2023 13:05:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ti.com header.s=ti-com-17q1 header.b=SboAByil; spf=pass (domain: ti.com, ip: 198.47.19.142, mailfrom: rs@ti.com) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 357K5C40106453; Wed, 7 Jun 2023 15:05:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686168312; bh=J/rmZgREshmbK0jtUJ527YK5NsRjK78jlX1nIaMUFNc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SboAByilY4dgT/zn2Afnda/IK+RPN2OklH73XW2+7bFEuYv+e29t1vXai31IWDU9S NdlvvO1HpGdHRX5ZINhlz40NufaLFVK0AeBETWSA+duOaIhUKS+zRG0bl61wRlAY3k LJwa0xVFwMN78IAni4OdE/nSdXHdfWeuXjDzkKfc= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 357K5CGC070129 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Jun 2023 15:05:12 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Jun 2023 15:05:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 15:05:11 -0500 Received: from rs-desk.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 357K5ALB125548; Wed, 7 Jun 2023 15:05:11 -0500 From: To: , , , CC: , StaticRocket <35777938+StaticRocket@users.noreply.github.com> Subject: [oe-layersetup][PATCH 15/15] oe-layertool-setup: add sanity check for layer names Date: Wed, 7 Jun 2023 15:05:04 -0500 Message-ID: <20230607200504.3810426-16-rs@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607200504.3810426-1-rs@ti.com> References: <20230607200504.3810426-1-rs@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 07 Jun 2023 20:05:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arago/message/14522 From: StaticRocket <35777938+StaticRocket@users.noreply.github.com> Due to POSIX shell string parsing limitations we currently can't parse layer names with spaces. Display an error message and bail out when detected. Signed-off-by: StaticRocket <35777938+StaticRocket@users.noreply.github.com> --- oe-layertool-setup.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index 2b05550..16b7844 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -211,6 +211,13 @@ parse_repo_line() { then temp_layers="" temp=$(printf '%s\n' "$parsed_layers" | cut -d= -f2) + # sanity check for whitespace in layer names string + if printf '%s\n' "$temp" | grep -q '\s' + then + printf '%s\n' "Whitespace character detected in layer names string!" \ + "This is currently unsupported." ; + exit 1 + fi # use tr to split the layers since we assume layer names don't have # whitespace characters later anyway for x in $(printf '%s\n' "$temp" | tr ':' ' ')