Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content

Build error with docker and vXX-aXX branch naming: DEVICE_LIST_… invalid variable name

The problem

Building with docker on vXX-aXX fails:

/root/build.sh: line 46: DEVICE_LIST_V3.0.1-A14: invalid variable name
/root/build.sh: line 85: DEVICE_LIST_V3.0.1-A14: invalid variable name

As explained here: https://community.e.foundation/t/build-error-with-docker-and-new-axx-branch-naming-device-list-invalid-variable-name/70824

From the build-e documentation, Step 6. Start build, using BRANCH_NAME=v3.0.1-a14 results in the errors above. The build stops immediately.

Steps to reproduce

sudo docker pull registry.gitlab.e.foundation:5000/e/os/docker-lineage-cicd:community
sudo docker run --rm -v "/srv/e/src:/srv/src" -v "/srv/e/zips:/srv/zips" -v "/srv/e/logs:/srv/logs" -v "/srv/e/ccache:/srv/ccache" -e "BRANCH_NAME=v3.0.4-a14" -e "DEVICE_LIST=not_relevant" -e "REPO=https://gitlab.e.foundation/e/os/releases.git" -e "INCLUDE_PROPRIETARY=false" registry.gitlab.e.foundation:5000/e/os/docker-lineage-cicd:community

Technical details

build-community.sh#L44 · master · e / os / docker-lineage-cicd · GitLab doesn't support numbers in the branch name of the tag. sed fails silently, same line 83.

Note that with "REPO=https://gitlab.e.foundation/e/os/android.git", BRANCH_NAME=a15 works, but not BRANCH_NAME=v3.1-a15.

Fix

Patch from https://community.e.foundation/t/build-error-with-docker-and-new-axx-branch-naming-device-list-invalid-variable-name/70824/6

diff build-commun
diff --git a/build-community.sh b/build-community2.sh
index 5d3c5e6..bf7d217 100644
--- a/build-community.sh
+++ b/build-community2.sh
@@ -41,7 +41,7 @@ fi
 # Treat DEVICE_LIST as DEVICE_LIST_<first_branch>
 first_branch=$(cut -d ',' -f 1 <<<"$BRANCH_NAME")
 if [ -n "$DEVICE_LIST" ]; then
-  device_list_first_branch="DEVICE_LIST_$(sed 's/.*-\([a-zA-Z]*\)$/\1/' <<<$first_branch)"
+  device_list_first_branch="DEVICE_LIST_$(sed 's/.*-\([a-zA-Z0-9]*\)$/\1/' <<<$first_branch)"
   device_list_first_branch=${device_list_first_branch^^}
   read $device_list_first_branch <<<"$DEVICE_LIST,${!device_list_first_branch}"
 fi
@@ -80,7 +80,7 @@ if [ "$LOCAL_MIRROR" = true ]; then
 fi
 
 for branch in ${BRANCH_NAME//,/ }; do
-  branch_dir=$(sed 's/.*-\([a-zA-Z]*\)$/\1/' <<<$branch)
+  branch_dir=$(sed 's/.*-\([a-zA-Z0-9]*\)$/\1/' <<<$branch)
   branch_dir=${branch_dir^^}
   device_list_cur_branch="DEVICE_LIST_$branch_dir"
   devices=${!device_list_cur_branch}