diff mbox series

[meta-arago,oe-layersetup] oe-layertool-setup: fix dldir logic for templates

Message ID 20240521212045.105324-2-rs@ti.com
State Accepted
Delegated to: Ryan Eatmon
Headers show
Series [meta-arago,oe-layersetup] oe-layertool-setup: fix dldir logic for templates | expand

Commit Message

Randolph Sapp May 21, 2024, 9:20 p.m. UTC
From: Randolph Sapp <rs@ti.com>

Previously templates were always being overridden with this internal
value that just so happened to be functionally equivalent to the
template DL_DIR.

Template:
	DL_DIR = "${OEBASE}/downloads"

Internal override:
	DL_DIR = "$oebase/downloads"

Functionally equivalent, but the internal override would be expanded to
include the full path of "$oebase" before being written to the file. In
the end it was unnecessarily bound to the context in which oe-layersetup
was executed.

This change lets us keep the local.conf sample/template value unless a
value is specified over cmdline or a backup value is found. It also
explicitly warns the user when a backup value is used.

Signed-off-by: Randolph Sapp <rs@ti.com>
---
 oe-layertool-setup.sh | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh
index 2bee538..eb412ff 100755
--- a/oe-layertool-setup.sh
+++ b/oe-layertool-setup.sh
@@ -808,21 +808,21 @@  EOM
     # First copy the template file
     cp -f "$OECORELOCALCONFPATH" "$confdir/local.conf"
 
-    # Find if old DL_DIR was set
-    if [ -e "$confdir/local.conf.bak" ]
-    then
-        old_dldir=$(grep -e "^DL_DIR =" "$confdir/local.conf.bak" | sed 's|DL_DIR = ||' | sed 's/"//g')
-    else
-        old_dldir="$oebase/downloads"
-    fi
-
     # If command line option was not set use the old dldir
     if [ -z "$dldir" ]
     then
-        dldir=$old_dldir
+        if [ -e "$confdir/local.conf.bak" ]
+        then
+            dldir=$(grep -e "^DL_DIR =" "$confdir/local.conf.bak" | sed 's|DL_DIR = ||' | sed 's/"//g')
+            printf '%s\n' "WARNING: Loading old DL_DIR from $confdir/local.conf" \
+                          "DL_DIR = $dldir";
+        fi
     fi
 
-    sed -i "s|^DL_DIR.*|DL_DIR = \"${dldir}\"|" "$confdir/local.conf"
+    if [ -n "$dldir" ]
+    then
+        sed -i "s|^DL_DIR.*|DL_DIR = \"${dldir}\"|" "$confdir/local.conf"
+    fi
 
     if [ -e "$oebase/tmp_append_local.conf" ]
     then