Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix module test failure on Debian 12 #818

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/common/commonutils/PackageUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ static bool g_tdnfIsPresent = false;
static bool g_dnfIsPresent = false;
static bool g_yumIsPresent = false;
static bool g_zypperIsPresent = false;
static bool g_aptGetUpdateExecuted = false;

int IsPresent(const char* what, void* log)
{
Expand Down Expand Up @@ -178,6 +179,27 @@ int CheckPackageNotInstalled(const char* packageName, char** reason, void* log)
return result;
}

void AptGetUpdateOnce(void* log)
{
const char* command = "apt-get update";
int status = 0;
if (g_aptGetUpdateExecuted)
{
return;
}

if (0 == (status = ExecuteCommand(NULL, command, false, false, 0, 0, NULL, NULL, log)))
{
OsConfigLogInfo(log, "AptGetUpdateOnce: apt-get update was successful");
g_aptGetUpdateExecuted = true;
}
else
{
OsConfigLogError(log, "AptGetUpdateOnce: apt-get update failed with %d", status);
}

}

int InstallOrUpdatePackage(const char* packageName, void* log)
{
const char* commandTemplate = "%s install -y %s";
Expand All @@ -187,6 +209,7 @@ int InstallOrUpdatePackage(const char* packageName, void* log)

if (g_aptGetIsPresent)
{
AptGetUpdateOnce(log);
status = CheckOrInstallPackage(commandTemplate, g_aptGet, packageName, log);
}
else if (g_tdnfIsPresent)
Expand Down
Loading