[Piuparts-devel] [Git][debian/piuparts][develop] 4 commits: Pass all environment variables to docker run
Nicolas Dandrimont (@olasd)
gitlab at salsa.debian.org
Sat Jan 13 13:07:06 GMT 2024
Nicolas Dandrimont pushed to branch develop at Debian / piuparts
Commits:
cd856e65 by Nicolas Dandrimont at 2024-01-13T12:59:47+01:00
Pass all environment variables to docker run
This aligns the docker environment to how the (s)chroot-based environments
are called.
Thanks to Richard Davis <crashvb at gmail.com> for the initial suggestion
and merge request.
- - - - -
1e5fcbca by Nicolas Dandrimont at 2024-01-13T13:25:24+01:00
Move VERSION variable below imports
- - - - -
025d84ae by Nicolas Dandrimont at 2024-01-13T14:04:29+01:00
gitlab-ci: enable the SCRIPT_SECTIONS feature flag
This feature flag should ensure multi-line commands are available in the
job logs.
- - - - -
e043bbc8 by Nicolas Dandrimont at 2024-01-13T14:05:25+01:00
Makefile: Don't change VERSION for UNRELEASED builds in salsaci
The VERSION variable changing according to the current date makes
salsaci fail reproducibility tests, so skip that altogether.
- - - - -
3 changed files:
- .gitlab-ci.yml
- Makefile
- piuparts.py
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -1,4 +1,7 @@
---
+variables:
+ FF_SCRIPT_SECTIONS: "true"
+
include:
- https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml
- https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml
=====================================
Makefile
=====================================
@@ -11,12 +11,12 @@ htdocsdir = $(sharedir)/piuparts/htdocs
etcdir = $(prefix)/etc
distribution=${shell dpkg-parsechangelog -SDistribution}
+version = ${shell dpkg-parsechangelog -SVersion}
ifeq ($(distribution),UNRELEASED)
-version := ${shell echo "`dpkg-parsechangelog -SVersion`~`date +%Y%m%d%H%M`~`git describe --dirty`"}
-else
-version := ${shell dpkg-parsechangelog -SVersion}
+ifeq (,$(findstring salsaci,$(version)))
+version = ${shell echo "`dpkg-parsechangelog -SVersion`~`date +%Y%m%d%H%M`~`git describe --dirty`"}
+endif
endif
-
# generate several scripts, conffiles, ... from templates (*.in, *.py)
# by substituting placeholders
=====================================
piuparts.py
=====================================
@@ -32,9 +32,6 @@ Lars Wirzenius <liw at iki.fi>
"""
from __future__ import print_function
-VERSION = "__PIUPARTS_VERSION__"
-
-
import errno
import logging
import optparse
@@ -53,6 +50,7 @@ import traceback
import uuid
from collections import namedtuple
from signal import SIGALRM, SIGKILL, SIGTERM, alarm, signal
+from typing import Dict
import apt_pkg
import distro_info
@@ -60,6 +58,8 @@ import distro_info
import piupartslib.conf
from debian import deb822
+VERSION = "__PIUPARTS_VERSION__"
+
apt_pkg.init_system()
DISTRO_CONFIG_FILE = "/etc/piuparts/distros.conf"
@@ -511,6 +511,32 @@ def alarm_handler(signum, frame):
raise Alarm
+FILTERED_ENVVARS = {
+ "LANG",
+ "LANGUAGE",
+ "LC_CTYPE",
+ "LC_NUMERIC",
+ "LC_TIME",
+ "LC_COLLATE",
+ "LC_MONETARY",
+ "LC_MESSAGES",
+ "LC_PAPER",
+ "LC_NAME",
+ "LC_ADDRESS",
+ "LC_TELEPHONE",
+ "LC_MEASUREMENT",
+ "LC_IDENTIFICATION",
+ "LC_ALL",
+}
+
+
+def get_clean_environment() -> Dict[str, str]:
+ """Get a cleaned up environment"""
+ env = {k: v for k, v in os.environ.items() if k not in FILTERED_ENVVARS}
+ env["PIUPARTS_OBJECTS"] = " ".join(str(vobject) for vobject in settings.testobjects)
+ return env
+
+
def run(command, ignore_errors=False, timeout=0):
"""Run an external command and die with error message if it fails."""
@@ -528,27 +554,7 @@ def run(command, ignore_errors=False, timeout=0):
assert isinstance(command, type([]))
logging.debug("Starting command: %s" % command)
- env = os.environ.copy()
- for var in [
- "LANG",
- "LANGUAGE",
- "LC_CTYPE",
- "LC_NUMERIC",
- "LC_TIME",
- "LC_COLLATE",
- "LC_MONETARY",
- "LC_MESSAGES",
- "LC_PAPER",
- "LC_NAME",
- "LC_ADDRESS",
- "LC_TELEPHONE",
- "LC_MEASUREMENT",
- "LC_IDENTIFICATION",
- "LC_ALL",
- ]:
- if var in env:
- del env[var]
- env["PIUPARTS_OBJECTS"] = " ".join(str(vobject) for vobject in settings.testobjects)
+ env = get_clean_environment()
devnull = open("/dev/null", "r")
p = subprocess.Popen(
command,
@@ -1007,14 +1013,12 @@ class Chroot:
timeout=settings.max_command_runtime,
)
elif settings.docker_image:
+ docker_cli = ["docker", "exec"]
+ # Pass all environment variables as arguments to docker exec
+ for k, v in get_clean_environment().items():
+ docker_cli.extend(("--env", f"{k}={v}"))
return run(
- [
- "docker",
- "exec",
- self.docker_container,
- ]
- + prefix
- + command,
+ docker_cli + [self.docker_container] + prefix + command,
ignore_errors=ignore_errors,
timeout=settings.max_command_runtime,
)
View it on GitLab: https://salsa.debian.org/debian/piuparts/-/compare/6980c39586865a01267ec49758efd4ddb85514d9...e043bbc88ff9a0f693b662c71b58b3c03ae1a39a
--
View it on GitLab: https://salsa.debian.org/debian/piuparts/-/compare/6980c39586865a01267ec49758efd4ddb85514d9...e043bbc88ff9a0f693b662c71b58b3c03ae1a39a
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/piuparts-devel/attachments/20240113/acca742b/attachment-0001.htm>
More information about the Piuparts-devel
mailing list