Skip to content

Commit

Permalink
Merge pull request #503 from oliverkurth/stable-3.5
Browse files Browse the repository at this point in the history
stable 3.5
  • Loading branch information
oliverkurth authored Oct 15, 2024
2 parents fc845f1 + d5ed33c commit 0951d11
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-tdnf-rpms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
docker run --rm -v$(pwd)/rpms:/rpms ${DIST} /bin/sh -c 'tdnf -y --repofrompath=tdnf,/rpms install tdnf-pytests && pytest /usr/share/tdnf/pytests/'
- name: upload RPMs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: tdnf-rpms
path: rpms
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR)

project(tdnf VERSION 3.5.8 LANGUAGES C)
project(tdnf VERSION 3.5.9 LANGUAGES C)
set(VERSION ${PROJECT_VERSION})
set(PROJECT_YEAR 2024)

Expand Down
31 changes: 7 additions & 24 deletions client/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

uid_t gEuid;

static TDNF_ENV gEnv = {0};
static int gInitialized;

static tdnflock instance_lock;

Expand Down Expand Up @@ -56,44 +56,27 @@ static void IsTdnfAlreadyRunning(void)

uint32_t TDNFInit(void)
{
int nLocked = 0;
uint32_t dwError = 0;

pthread_mutex_lock(&gEnv.mutexInitialize);
nLocked = 1;
if(!gEnv.nInitialized)
if (!gInitialized)
{
dwError = rpmReadConfigFiles(NULL, NULL);
BAIL_ON_TDNF_ERROR(dwError);

gEnv.nInitialized = 1;
gInitialized = 1;
}

cleanup:
if(nLocked)
{
pthread_mutex_unlock(&gEnv.mutexInitialize);
}
return dwError;

error:
goto cleanup;
return dwError;
}

void
TDNFUninit(
void
)
void TDNFUninit(void)
{
pthread_mutex_lock (&gEnv.mutexInitialize);

if(gEnv.nInitialized)
if (gInitialized)
{
rpmFreeRpmrc();
gInitialized = 0;
}
gEnv.nInitialized = 0;

pthread_mutex_unlock(&gEnv.mutexInitialize);
}

//Check all available packages
Expand Down
1 change: 0 additions & 1 deletion client/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <sys/types.h>

#include <dirent.h>
#include <pthread.h>

#include "../solv/includes.h"

Expand Down
25 changes: 7 additions & 18 deletions client/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,30 +307,17 @@ TDNFRefreshSack(

if (nMetadataExpired)
{
if (gEuid)
{
if (!pTdnf->pArgs->nCacheOnly)
{
pr_err("\ntdnf repo cache needs to be refreshed\n"
"You can use one of the below methods to workaround this\n"
"1. Login as root & refresh cache\n"
"2. Use -c (--config) option & create repo cache where you have access\n"
"3. Use -C (--cacheonly) & use existing cache in the system\n\n");
}
goto cleanup;
}

dwError = TDNFRepoRemoveCache(pTdnf, pRepo);
if (dwError == ERROR_TDNF_FILE_NOT_FOUND)
{
dwError = 0;//Ignore non existent folders
dwError = 0; // ignore not existing folders
}
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFRemoveSolvCache(pTdnf, pRepo);
if (dwError == ERROR_TDNF_FILE_NOT_FOUND)
{
dwError = 0;//Ignore non existent folders
dwError = 0; // ignore not existing folders
}
BAIL_ON_TDNF_ERROR(dwError);
}
Expand All @@ -341,9 +328,11 @@ TDNFRefreshSack(
}
if (dwError && pRepo->nSkipIfUnavailable)
{
pRepo->nEnabled = 0;
pr_info("Disabling Repo: '%s'\n", pRepo->pszName);
dwError = 0;
if (dwError != (ERROR_TDNF_SYSTEM_BASE + EACCES)) {
pRepo->nEnabled = 0;
pr_info("Disabling Repo: '%s'\n", pRepo->pszName);
dwError = 0;
}
}
BAIL_ON_TDNF_ERROR(dwError);
}
Expand Down
2 changes: 1 addition & 1 deletion client/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ TDNFResolveBuildDependencies(
}

for (i = 0; i < qDeps.count; i++) {
pszDep = pool_id2str(pTdnf->pSack->pPool, qDeps.elements[i]);
pszDep = pool_dep2str(pTdnf->pSack->pPool, qDeps.elements[i]);
if (!pszDep) {
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
Expand Down
6 changes: 0 additions & 6 deletions client/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ typedef struct _TDNF_RPM_TS_
PTDNF_CACHED_RPM_LIST pCachedRpmsArray;
} TDNFRPMTS, *PTDNFRPMTS;

typedef struct _TDNF_ENV_
{
pthread_mutex_t mutexInitialize;
int nInitialized;
} TDNF_ENV, *PTDNF_ENV;

typedef struct _TDNF_REPO_METADATA
{
char *pszRepoCacheDir;
Expand Down
2 changes: 1 addition & 1 deletion client/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ TDNFTouchFile(
}

old_mask = umask(022);
fd = creat(pszFile, S_IRUSR | S_IRGRP | S_IROTH);
fd = creat(pszFile, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0)
{
if (errno == EEXIST)
Expand Down
2 changes: 1 addition & 1 deletion solv/tdnfpackage.c
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,7 @@ SolvGetDependenciesFromId(

for (i = 0; i < nNumDeps; i++)
{
pszDep = pool_id2str(pSack->pPool, queueDeps.elements[i]);
pszDep = pool_dep2str(pSack->pPool, queueDeps.elements[i]);
dwError = TDNFAllocateString(pszDep, &ppszDependencies[i]);
BAIL_ON_TDNF_ERROR(dwError);
}
Expand Down
14 changes: 13 additions & 1 deletion tools/cli/lib/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,19 @@ uint32_t
TDNFCliRefresh(
PTDNF_CLI_CONTEXT pContext)
{
return TDNFRefresh(pContext->hTdnf);
uint32_t dwError = 0;
dwError = TDNFRefresh(pContext->hTdnf);

if (dwError == ERROR_TDNF_SYSTEM_BASE + EACCES) {
if (geteuid()) {
pr_err("\ntdnf repo cache needs to be refreshed but you have insufficient permissions\n"
"You can use one of the below methods to workaround this\n"
"1. Login as root and refresh cache\n"
"2. Use -c (--config) with a configuration file that has 'cachedir' set to a directory where you have access\n"
"3. Use -C (--cacheonly) and use the existing cache in the system\n\n");
}
}
return dwError;
}

static
Expand Down
4 changes: 2 additions & 2 deletions tools/cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static TDNF_CLI_CMD_MAP arCmdMap[] =
{"check", TDNFCliCheckCommand, false},
{"check-local", TDNFCliCheckLocalCommand, false},
{"check-update", TDNFCliCheckUpdateCommand, false},
{"clean", TDNFCliCleanCommand, true},
{"clean", TDNFCliCleanCommand, false},
{"count", TDNFCliCountCommand, false},
{"distro-sync", TDNFCliDistroSyncCommand, true},
{"downgrade", TDNFCliDowngradeCommand, true},
Expand All @@ -38,7 +38,7 @@ static TDNF_CLI_CMD_MAP arCmdMap[] =
{"info", TDNFCliInfoCommand, false},
{"install", TDNFCliInstallCommand, true},
{"list", TDNFCliListCommand, false},
{"makecache", TDNFCliMakeCacheCommand, true},
{"makecache", TDNFCliMakeCacheCommand, false},
{"mark", TDNFCliMarkCommand, false},
{"provides", TDNFCliProvidesCommand, false},
{"whatprovides", TDNFCliProvidesCommand, false},
Expand Down

0 comments on commit 0951d11

Please sign in to comment.