git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] ci: libify logic for usage and checking CI_USER

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Mar 26, 2020, 07:35 UTC
Message-ID
<ca87bea4a379dac5d2e68bc18b0084201afe5fc4.1585203294.git.congdanhqx@gmail.com>
In-Reply-To
<cover.1585203294.git.congdanhqx@gmail.com>
This part of logic will be reused for alpine docker later.
Merge those logic into single chunk since they will be used together.

While we're at it, add a comment to tell people run with root inside podman container.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
This patch is viewed better with "git diff --color-moved"
 ci/lib-docker.sh        | 37 +++++++++++++++++++++++++++++++++++++
 ci/run-linux32-build.sh | 35 +----------------------------------
 2 files changed, 38 insertions(+), 34 deletions(-)
 create mode 100644 ci/lib-docker.sh
diff --git a/ci/lib-docker.sh b/ci/lib-docker.sh
new file mode 100644
index 0000000000..ac155ace54
--- /dev/null
+++ b/ci/lib-docker.sh
@@ -0,0 +1,37 @@
+# Library of functions shared by all CI scripts run inside docker
+
+if test $# -ne 1 || test -z "$1"
+then
+	echo >&2 "usage: $0 <host-user-id>"
+	exit 1
+fi
+
+# If this script runs inside a docker container, then all commands are
+# usually executed as root. Consequently, the host user might not be
+# able to access the test output files.
+# If a non 0 host user id is given, then create a user "ci" with that
+# user id to make everything accessible to the host user.
+HOST_UID=$1
+if test $HOST_UID -eq 0
+then
+	# Just in case someone does want to run the test suite as root.
+	# or podman is used in place of docker
+	CI_USER=root
+else
+	CI_USER=ci
+	if test "$(id -u $CI_USER 2>/dev/null)" = $HOST_UID
+	then
+		echo "user '$CI_USER' already exists with the requested ID $HOST_UID"
+	else
+		useradd -u $HOST_UID $CI_USER
+	fi
+
+	# Due to a bug the test suite was run as root in the past, so
+	# a prove state file created back then is only accessible by
+	# root.  Now that bug is fixed, the test suite is run as a
+	# regular user, but the prove state file coming from Travis
+	# CI's cache might still be owned by root.
+	# Make sure that this user has rights to any cached files,
+	# including an existing prove state file.
+	test -n "$cache_dir" && chown -R $HOST_UID:$HOST_UID "$cache_dir"
+fi
diff --git a/ci/run-linux32-build.sh b/ci/run-linux32-build.sh
index e3a193adbc..81296cdd19 100755
--- a/ci/run-linux32-build.sh
+++ b/ci/run-linux32-build.sh
@@ -8,11 +8,7 @@
 
 set -ex
 
-if test $# -ne 1 || test -z "$1"
-then
-	echo >&2 "usage: run-linux32-build.sh <host-user-id>"
-	exit 1
-fi
+. "${0%/*}/lib-docker.sh"
 
 # Update packages to the latest available versions
 linux32 --32bit i386 sh -c '
@@ -21,35 +17,6 @@ linux32 --32bit i386 sh -c '
 	libexpat-dev gettext python >/dev/null
 '
 
-# If this script runs inside a docker container, then all commands are
-# usually executed as root. Consequently, the host user might not be
-# able to access the test output files.
-# If a non 0 host user id is given, then create a user "ci" with that
-# user id to make everything accessible to the host user.
-HOST_UID=$1
-if test $HOST_UID -eq 0
-then
-	# Just in case someone does want to run the test suite as root.
-	CI_USER=root
-else
-	CI_USER=ci
-	if test "$(id -u $CI_USER 2>/dev/null)" = $HOST_UID
-	then
-		echo "user '$CI_USER' already exists with the requested ID $HOST_UID"
-	else
-		useradd -u $HOST_UID $CI_USER
-	fi
-
-	# Due to a bug the test suite was run as root in the past, so
-	# a prove state file created back then is only accessible by
-	# root.  Now that bug is fixed, the test suite is run as a
-	# regular user, but the prove state file coming from Travis
-	# CI's cache might still be owned by root.
-	# Make sure that this user has rights to any cached files,
-	# including an existing prove state file.
-	test -n "$cache_dir" && chown -R $HOST_UID:$HOST_UID "$cache_dir"
-fi
-
 # Build and test
 linux32 --32bit i386 su -m -l $CI_USER -c '
 	set -ex
-- 
2.26.0.rc2.357.g1e1ba0441d
Previous: Đoàn Trần Công DanhNext: Đoàn Trần Công Danh
Message 2 of 42 in “add travis job for linux with musl libc”
  1. 0/3 add travis job for linux with musl libcĐoàn Trần Công Danh, Mar 26, 2020
  2. 1/3 ci: libify logic for usage and checking CI_USERĐoàn Trần Công Danh, Mar 26, 2020
  3. 2/3 ci: refactor docker runner scriptĐoàn Trần Công Danh, Mar 26, 2020
  4. Eric SunshineMar 26, 2020
  5. SZEDER GáborMar 28, 2020
  6. Danh DoanMar 29, 2020
  7. 3/3 travis: build and test on Linux with musl libc and busyboxĐoàn Trần Công Danh, Mar 26, 2020
  8. Junio C HamanoMar 29, 2020
  9. 0/4 Travis + Azure jobs for linux with musl libcĐoàn Trần Công Danh, Mar 29, 2020
  10. 1/4 ci: libify logic for usage and checking CI_USERĐoàn Trần Công Danh, Mar 29, 2020
  11. 2/4 ci: refactor docker runner scriptĐoàn Trần Công Danh, Mar 29, 2020
  12. SZEDER GáborApr 1, 2020
  13. 3/4 travis: build and test on Linux with musl libc and busyboxĐoàn Trần Công Danh, Mar 29, 2020
  14. SZEDER GáborApr 1, 2020
  15. Danh DoanApr 2, 2020
  16. Johannes SchindelinApr 7, 2020
  17. Junio C HamanoApr 7, 2020
  18. Johannes SchindelinApr 10, 2020
  19. 4/4 t3402: use POSIX compliant regex(7)Đoàn Trần Công Danh, Mar 29, 2020
  20. Junio C HamanoMar 29, 2020
  21. 0/6 Travis + Azure jobs for linux with musl libcĐoàn Trần Công Danh, Apr 2, 2020
  22. 1/6 ci: make MAKEFLAGS available inside the Docker container in the Linux32 jobĐoàn Trần Công Danh, Apr 2, 2020
  23. 2/6 ci/lib-docker: preserve required environment variablesĐoàn Trần Công Danh, Apr 2, 2020
  24. SZEDER GáborApr 3, 2020
  25. Danh DoanApr 3, 2020
  26. SZEDER GáborApr 3, 2020
  27. 3/6 ci/linux32: parameterise command to switch archĐoàn Trần Công Danh, Apr 2, 2020
  28. 4/6 ci: refactor docker runner scriptĐoàn Trần Công Danh, Apr 2, 2020
  29. 5/6 ci/linux32: libify install-dependencies stepĐoàn Trần Công Danh, Apr 2, 2020
  30. 6/6 travis: build and test on Linux with musl libc and busyboxĐoàn Trần Công Danh, Apr 2, 2020
  31. Junio C HamanoApr 2, 2020
  32. Danh DoanApr 3, 2020
  33. 0/6 Travis jobs for linux with musl libcĐoàn Trần Công Danh, Apr 4, 2020
  34. 1/6 ci: make MAKEFLAGS available inside the Docker container in the Linux32 jobĐoàn Trần Công Danh, Apr 4, 2020
  35. 2/6 ci/lib-docker: preserve required environment variablesĐoàn Trần Công Danh, Apr 4, 2020
  36. 3/6 ci/linux32: parameterise command to switch archĐoàn Trần Công Danh, Apr 4, 2020
  37. 4/6 ci: refactor docker runner scriptĐoàn Trần Công Danh, Apr 4, 2020
  38. 5/6 ci/linux32: libify install-dependencies stepĐoàn Trần Công Danh, Apr 4, 2020
  39. 6/6 travis: build and test on Linux with musl libc and busyboxĐoàn Trần Công Danh, Apr 4, 2020
  40. Junio C HamanoApr 5, 2020
  41. Johannes SchindelinApr 7, 2020
  42. Junio C HamanoApr 7, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.