Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
compression: make the defaut level a config option
Baptiste Daroussin committed 5 years ago
commit f98616385f963b29afe597dbfa416118a5e4ebf8
parent 31000cb
4 files changed +17 -2
modified docs/pkg.conf.5
@@ -15,7 +15,7 @@
.\"     @(#)pkg.1
.\" $FreeBSD$
.\"
-
.Dd November 5, 2020
+
.Dd March 13, 2021
.Dt PKG.CONF 5
.Os
.Sh NAME
@@ -113,6 +113,12 @@ Default: NO.
Location where the libraries are backed up.
Default:
.Pa /usr/local/lib/compat/pkg .
+
.It Cm COMPRESSION_LEVEL: integer
+
Set the default compression level, special values are:
+
.Bl -tag
+
.It 0 default value per libarchive developers
+
.It -1 default value per pkg developers (default)
+
.El
.It Cm CONSERVATIVE_UPGRADE: boolean
Ensure in multi repository mode that the priority is given as much as possible
to the repository where a package was first installed from.
modified libpkg/pkg_config.c
@@ -75,6 +75,7 @@ struct pkg_ctx ctx = {
	.osversion = 0,
	.backup_libraries = false,
	.triggers = true,
+
	.compression_level = -1,
};

struct config_entry {
@@ -471,6 +472,12 @@ static struct config_entry c[] = {
		"NULL",
		"List of regex to ignore while autiditing for vulnerabilities",
	},
+
	{
+
		PKG_INT,
+
		"COMPRESSION_LEVEL",
+
		"-1",
+
		"Set the default compression level",
+
	},
};

static bool parsed = false;
@@ -1293,6 +1300,7 @@ pkg_ini(const char *path, const char *reposdir, pkg_init_flags flags)
	ctx.backup_library_path = pkg_object_string(pkg_config_get("BACKUP_LIBRARY_PATH"));
	ctx.triggers = pkg_object_bool(pkg_config_get("PKG_TRIGGERS_ENABLE"));
	ctx.triggers_path = pkg_object_string(pkg_config_get("PKG_TRIGGERS_DIR"));
+
	ctx.compression_level = pkg_object_int(pkg_config_get("COMPRESSION_LEVEL"));

	it = NULL;
	object = ucl_object_find_key(config, "PKG_ENV");
modified libpkg/pkg_create.c
@@ -241,7 +241,7 @@ pkg_create_new(void)

	pc = xcalloc(1, sizeof(*pc));
	pc->format = DEFAULT_COMPRESSION;
-
	pc->compression_level = -1;
+
	pc->compression_level = ctx.compression_level;
	pc->timestamp = (time_t) -1;
	pc->overwrite = true;
	pc->expand_manifest = false;
modified libpkg/private/pkg.h
@@ -254,6 +254,7 @@ struct pkg_ctx {
	const char *pkg_rootdir;
	const char *dbdir;
	const char *cachedir;
+
	int compression_level;
	int rootfd;
	int cachedirfd;
	int dbdirfd;