1
0
Fork 0

Compare commits

..

2 commits

Author SHA1 Message Date
76bdf6dab6
generate: container: Fix printf call in Environment.create
When creating the env-vars printf is called with arguments in single
quotes to prevent variable and sub-shell expansions. However, only one
single quote was passed as an argument to printf, but two format
specifiers are present in the escpaed string.

Fix this by adding another \"'\" to the variable cmd.

Signed-off-by: Enno Tensing <tenno@suij.in>
2025-07-26 21:34:36 +02:00
5237a70f3e
make: Add makefile to support install
Signed-off-by: Enno Tensing <tenno@suij.in>
2025-07-26 19:26:21 +02:00
3 changed files with 22 additions and 2 deletions

20
Makefile Normal file
View file

@ -0,0 +1,20 @@
DESTDIR ?= /usr
BINDIR ?= $(DESTDIR)/bin
VARDIR ?= /var/lib/containerctl
GENERATEDIR ?= $(VARDIR)/generate
CONFIGDIR ?= $(VARDIR)/configs
CONTAINERDIR ?= $(VARDIR)/containers
install:
mkdir -p \
$(PREFIX)/$(GENERATEDIR) \
$(PREFIX)/$(CONFIGDIR) \
$(PREFIX)/$(CONTAINERDIR) \
$(PREFIX)/$(BINDIR)
install -m755 containerctl $(PREFIX)/$(BINDIR)
cp -t $(PREFIX)/$(GENERATEDIR) \
generate/container.py \
generate/log.py \
generate/generate.py
.PHONY: install

View file

@ -1,6 +1,6 @@
version = 1
[[annotations]]
path = [".gitignore", "example.container", "ruff.toml"]
path = [".gitignore", "example.container", "ruff.toml", "Makefile"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2025 Enno Tensing <tenno+containerctl@suij.in>"
SPDX-License-Identifier = "CC0-1.0"

View file

@ -179,7 +179,7 @@ class Environment:
cmd = f"# Create env-file {self.file}\n"
for var in self.variables:
escaped_var = var.replace("'", "%b")
cmd += f"printf '{escaped_var}\\n' \"'\" >> '{self.file}'\n"
cmd += f"printf '{escaped_var}\\n' \"'\" \"'\">> '{self.file}'\n"
return cmd