Skip to content

Instantly share code, notes, and snippets.

@jperkin
Created December 9, 2020 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jperkin/b8b98d0dd701270b4c6967280696bacd to your computer and use it in GitHub Desktop.
Save jperkin/b8b98d0dd701270b4c6967280696bacd to your computer and use it in GitHub Desktop.
diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c
index e78e6190ac5a..c5239d14a329 100644
--- a/pkgtools/pkg_install/files/add/perform.c
+++ b/pkgtools/pkg_install/files/add/perform.c
@@ -151,6 +151,13 @@ compatible_platform(const char *opsys, const char *host, const char *package)
{
int i = 0;
+ /*
+ * If the user has set the CHECK_OS_VERSION variable to "no" then skip any
+ * version checks and assume they know what they're doing.
+ */
+ if (strcasecmp(check_os_version, "no") == 0)
+ return 1;
+
/* returns 1 if host and package operating system match */
if (strcmp(host, package) == 0)
return 1;
diff --git a/pkgtools/pkg_install/files/lib/lib.h b/pkgtools/pkg_install/files/lib/lib.h
index c79e6a6e1cda..f46a25233c46 100644
--- a/pkgtools/pkg_install/files/lib/lib.h
+++ b/pkgtools/pkg_install/files/lib/lib.h
@@ -447,6 +447,7 @@ extern const char *cert_chain_file;
extern const char *certs_packages;
extern const char *certs_pkg_vulnerabilities;
extern const char *check_eol;
+extern const char *check_os_version;
extern const char *check_vulnerabilities;
extern const char *config_file;
extern const char *config_pkg_dbdir;
diff --git a/pkgtools/pkg_install/files/lib/parse-config.c b/pkgtools/pkg_install/files/lib/parse-config.c
index 10bac8202a7a..af92f3d08a81 100644
--- a/pkgtools/pkg_install/files/lib/parse-config.c
+++ b/pkgtools/pkg_install/files/lib/parse-config.c
@@ -66,6 +66,7 @@ const char *cert_chain_file;
const char *certs_packages;
const char *certs_pkg_vulnerabilities;
const char *check_eol = "yes";
+const char *check_os_version = "yes";
const char *check_vulnerabilities;
static const char *config_cache_connections;
static const char *config_cache_connections_host;
@@ -100,6 +101,7 @@ static struct config_variable {
{ "CERTIFICATE_CHAIN", &cert_chain_file },
{ "CHECK_LICENSE", &do_license_check },
{ "CHECK_END_OF_LIFE", &check_eol },
+ { "CHECK_OS_VERSION", &check_os_version },
{ "CHECK_VULNERABILITIES", &check_vulnerabilities },
{ "DEFAULT_ACCEPTABLE_LICENSES", &default_acceptable_licenses },
{ "GPG", &gpg_cmd },
diff --git a/pkgtools/pkg_install/files/lib/pkg_install.conf.5.in b/pkgtools/pkg_install/files/lib/pkg_install.conf.5.in
index d5ad8b449485..0c83dbd70eff 100644
--- a/pkgtools/pkg_install/files/lib/pkg_install.conf.5.in
+++ b/pkgtools/pkg_install/files/lib/pkg_install.conf.5.in
@@ -93,6 +93,10 @@ Missing license conditions are considered an error.
During vulnerability checks, consider packages that have reached end-of-life
as vulnerable.
This option is enabled by default.
+.It Dv CHECK_OS_VERSION
+If "no", pkg_add will not warn if the host OS version does not match the OS
+version the package was built on.
+The default is "yes".
.It Dv CHECK_OSABI
If "no", osabi package does not check OS version.
The default is "yes".
diff --git a/pkgtools/pkg_install/files/lib/pkg_install.conf.cat.in b/pkgtools/pkg_install/files/lib/pkg_install.conf.cat.in
index 01b891f3c711..bf14902706ea 100644
--- a/pkgtools/pkg_install/files/lib/pkg_install.conf.cat.in
+++ b/pkgtools/pkg_install/files/lib/pkg_install.conf.cat.in
@@ -60,6 +60,11 @@ DDEESSCCRRIIPPTTIIOONN
During vulnerability checks, consider packages that have reached
end-of-life as vulnerable. This option is enabled by default.
+ CHECK_OS_VERSION
+ If "no", pkg_add will not warn if the host OS version does not
+ match the OS version the package was built on. The default is
+ "yes".
+
CHECK_OSABI
If "no", osabi package does not check OS version. The default is
"yes".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment