Upgrade tdnf package to version 3.5.2 (#5297)

Co-authored-by: Jon Slobodzian <joslobo@microsoft.com>
Co-authored-by: Pawel Winogrodzki <pawelwi@microsoft.com>
Co-authored-by: Andrew Phelps <anphel@microsoft.com>
Co-authored-by: Andrew Phelps <anphel31@users.noreply.github.com>
This commit is contained in:
Sam Meluch 2023-06-13 11:09:00 -05:00 коммит произвёл GitHub
Родитель 6d03ae88f7
Коммит af30cc0ec2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
22 изменённых файлов: 315 добавлений и 1134 удалений

Просмотреть файл

@ -1,6 +1,6 @@
{
"Signatures": {
"cmake-3.21.4.tar.gz": "d9570a95c215f4c9886dd0f0564ca4ef8d18c30750f157238ea12669c2985978",
"macros.cmake": "efb1ac073027f0e542b830c14a036c324b2340b8f8bc3f3110710f8c8843659a"
"macros.cmake": "1b5f1916a2118b932b217c4c5c4d52e723b1cf4c9587fe7f8fa45b41abfa7c60"
}
}
}

Просмотреть файл

@ -2,7 +2,7 @@
Summary: Cmake
Name: cmake
Version: 3.21.4
Release: 6%{?dist}
Release: 7%{?dist}
License: BSD AND LGPLv2+
Vendor: Microsoft Corporation
Distribution: Mariner
@ -81,6 +81,9 @@ bin/ctest --force-new-ctest-process --rerun-failed --output-on-failure
%{_prefix}/doc/%{name}-*/*
%changelog
* Thu Jun 08 2023 Sam Meluch <sammeluch@microsoft.com> - 3.21.4-7
- Add source directory for when not building in source
* Thu Jun 08 2023 Sumedh Sharma <sumsharma@microsoft.com> - 3.21.4-6
- Patch vendored curl for CVE-2023-28322

Просмотреть файл

@ -27,7 +27,8 @@
%{?_cmake_lib_suffix64} \\\
%endif \
-DBUILD_SHARED_LIBS:BOOL=ON \\\
-B "%{__cmake_builddir}"
%{!?__cmake_in_source_build:-S "%{_vpath_srcdir}"} \\\
-B "%{__cmake_builddir}"
%cmake_build \
%__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose

Просмотреть файл

@ -25,7 +25,7 @@
Summary: Access and modify virtual machine disk images
Name: libguestfs
Version: 1.44.0
Release: 11%{?dist}
Release: 12%{?dist}
License: LGPLv2+
Vendor: Microsoft Corporation
Distribution: Mariner
@ -755,9 +755,9 @@ cp %{SOURCE9} %{_sysconfdir}/yum.repos.d/allrepos.repo
# Must keep in sync with BRs under "Build requirements for the appliance"
# Download to
mkdir -pv %{_var}/cache/tdnf
tdnf download -y --disablerepo=* \
tdnf install --downloadonly -y --disablerepo=* \
--enablerepo=local-repo --enablerepo=upstream-cache-repo \
--alldeps --destdir %{_var}/cache/tdnf \
--alldeps --downloaddir %{_var}/cache/tdnf \
acl \
attr \
augeas-libs \
@ -1234,6 +1234,9 @@ rm ocaml/html/.gitignore
%endif
%changelog
* Wed Apr 12 2023 Sam Meluch <sammeluch@microsoft.com> - 1.44.0-12
- Update tdnf download to tdnf install --downloadonly
* Fri Dec 16 2022 Daniel McIlvaney <damcilva@microsoft.com> - 1.44.0-11
- Bump release to rebuild with go 1.18.8 with patch for CVE-2022-41717

Просмотреть файл

@ -0,0 +1,42 @@
From 17d73f1f7adb72b587b3710a7338996397abc63a Mon Sep 17 00:00:00 2001
From: Oliver Kurth <okurth@gmail.com>
Date: Fri, 9 Jun 2023 14:23:52 -0700
Subject: [PATCH] Fix error when a repo was disabled because it's unavailable.
Fixes #431
---
client/repo.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/client/repo.c b/client/repo.c
index 2c9cb9ca..ee0224f8 100644
--- a/client/repo.c
+++ b/client/repo.c
@@ -57,6 +57,14 @@ TDNFInitRepo(
NULL);
BAIL_ON_TDNF_ERROR(dwError);
+ if (pRepoData->nHasMetaData) {
+ dwError = TDNFGetRepoMD(pTdnf,
+ pRepoData,
+ pszRepoDataDir,
+ &pRepoMD);
+ BAIL_ON_TDNF_ERROR(dwError);
+ }
+
dwError = TDNFAllocateMemory(
1,
sizeof(SOLV_REPO_INFO_INTERNAL),
@@ -74,12 +82,6 @@ TDNFInitRepo(
pRepo->appdata = pSolvRepoInfo;
if (pRepoData->nHasMetaData) {
- dwError = TDNFGetRepoMD(pTdnf,
- pRepoData,
- pszRepoDataDir,
- &pRepoMD);
- BAIL_ON_TDNF_ERROR(dwError);
-
dwError = SolvCalculateCookieForFile(pRepoMD->pszRepoMD, pSolvRepoInfo->cookie);
BAIL_ON_TDNF_ERROR(dwError);
pSolvRepoInfo->nCookieSet = 1;

Просмотреть файл

@ -1,963 +0,0 @@
From d8f0bf57ed1024fe6c6970530f8480b651e2cdcc Mon Sep 17 00:00:00 2001
From: Joe Schmitt <joschmit@microsoft.com>
Date: Thu, 14 Nov 2019 21:54:04 +0000
Subject: [PATCH] Merged PR 221: Add download option to TDNF
Add a `download` command to TDNF that will download RPMs to a directory.
Usage:
- `tdnf download <package1, package2, ...> --destdir /path/to/download/folder>`
- To download a package and all of its dependencies even if the system already has them installed, add the `--alldeps` option.
Behavior:
- `tdnf download` will create the destination directory if it does not exist.
- `tdnf download` will respond to other tdnf options, such as silent, no gpg check, etc.
- `tdnf download` will skip RPMs if the correct version already exists in the destination directory.
- `tdnf download` will check GPG signatures unless otherwise specified.
From: Joe Schmitt <joschmit@microsoft.com>
Date: Tue, 28 Jul 2020 15:49:55 -0700
Subject: [PATCH] Add download-nodeps command
From: Mateusz Malisz <mamalisz@microsoft.com>
Date: Thu, 20 Jan 2022 21:54:04+0000
Subject: [PATCH] Update download commands to work with tdnf-3.2.2.
Updated code to work with tdnf 3.2.2.
diff --git a/client/api.c b/client/api.c
index ef25d09..561461b 100644
--- a/client/api.c
+++ b/client/api.c
@@ -629,10 +629,10 @@ TDNFOpenHandle(
{
uint32_t dwError = 0;
PTDNF pTdnf = NULL;
- PSolvSack pSack = NULL;
char *pszCacheDir = NULL;
char *pszRepoDir = NULL;
int nHasOptReposdir = 0;
+ const int nSkipInstalledRpms = 0;
if(!pArgs || !ppTdnf)
{
@@ -704,25 +704,7 @@ TDNFOpenHandle(
dwError = TDNFLoadPlugins(pTdnf);
BAIL_ON_TDNF_ERROR(dwError);
- dwError = SolvInitSack(
- &pSack,
- pTdnf->pConf->pszCacheDir,
- pTdnf->pArgs->pszInstallRoot);
- BAIL_ON_TDNF_ERROR(dwError);
-
- dwError = TDNFLoadRepoData(
- pTdnf,
- REPOLISTFILTER_ALL,
- &pTdnf->pRepos);
- BAIL_ON_TDNF_ERROR(dwError);
-
- dwError = TDNFRepoListFinalize(pTdnf);
- BAIL_ON_TDNF_ERROR(dwError);
-
- dwError = TDNFInitCmdLineRepo(pTdnf, pSack);
- BAIL_ON_TDNF_ERROR(dwError);
-
- pTdnf->pSack = pSack;
+ dwError = TDNFResetSack(pTdnf, nSkipInstalledRpms);
*ppTdnf = pTdnf;
cleanup:
@@ -739,10 +721,6 @@ error:
{
*ppTdnf = NULL;
}
- if(pSack)
- {
- SolvFreeSack(pSack);
- }
goto cleanup;
}
@@ -1463,7 +1441,7 @@ TDNFRepoQuery(
BAIL_ON_TDNF_ERROR(dwError);
}
- /* get results in list */
+ /* get results in list */
dwError = SolvGetQueryResult(pQuery, &pPkgList);
BAIL_ON_TDNF_ERROR(dwError);
@@ -1939,3 +1917,183 @@ TDNFGetPackageName(
{
return PACKAGE_NAME;
}
+
+uint32_t
+TDNFResetSack(
+ PTDNF pTdnf,
+ int nSkipInstalledRpms
+ )
+{
+ uint32_t dwError = 0;
+ PSolvSack pSack = NULL;
+
+ if(!pTdnf)
+ {
+ dwError = ERROR_TDNF_INVALID_PARAMETER;
+ BAIL_ON_TDNF_ERROR(dwError);
+ }
+ dwError = SolvInitSack(
+ &pSack,
+ pTdnf->pConf->pszCacheDir,
+ pTdnf->pArgs->pszInstallRoot,
+ nSkipInstalledRpms);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = TDNFLoadRepoData(
+ pTdnf,
+ REPOLISTFILTER_ALL,
+ &pTdnf->pRepos);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = TDNFRepoListFinalize(pTdnf);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = TDNFInitCmdLineRepo(pTdnf, pSack);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ if(!pTdnf->pSack)
+ {
+ SolvFreeSack(pTdnf->pSack);
+ }
+ pTdnf->pSack = pSack;
+
+cleanup:
+ return dwError;
+
+error:
+ if(pSack)
+ {
+ SolvFreeSack(pSack);
+ }
+ goto cleanup;
+}
+
+//Downloads all requested packages without any of their dependencies.
+uint32_t
+TDNFDownloadNoDepsCommand(
+ PTDNF pTdnf,
+ TDNF_SCOPE nScope,
+ char** ppszPackageNameSpecs,
+ PTDNF_PKG_INFO* ppPkgInfo,
+ uint32_t* pdwCount
+ )
+{
+ const int nSkipInstalledRpms = 1;
+ const int nUpgrade = 0;
+
+ uint32_t dwError = 0;
+ uint32_t dwCount = 0;
+ uint32_t dwIndex = 0;
+
+ PSolvQuery pQuery = NULL;
+ PTDNF_PKG_INFO pPkgInfo = NULL;
+ PTDNF_PKG_INFO pPkg = NULL;
+ PSolvPackageList pPkgList = NULL;
+
+ TDNFRPMTS ts = {0};
+
+ if(!pTdnf || !pTdnf->pSack ||!pdwCount || !ppPkgInfo ||
+ !ppszPackageNameSpecs || IsNullOrEmptyString(pTdnf->pArgs->pszDestDir))
+ {
+ dwError = ERROR_TDNF_INVALID_PARAMETER;
+ BAIL_ON_TDNF_ERROR(dwError);
+ }
+
+ dwError = TDNFResetSack(pTdnf, nSkipInstalledRpms);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = SolvCreateQuery(pTdnf->pSack, &pQuery);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = TDNFApplyScopeFilter(pQuery, nScope);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = SolvApplyPackageFilter(pQuery, ppszPackageNameSpecs);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = SolvApplyListQuery(pQuery);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = SolvGetQueryResult(pQuery, &pPkgList);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = TDNFPopulatePkgInfoArray(
+ pTdnf->pSack,
+ pPkgList,
+ DETAIL_INFO,
+ &pPkgInfo,
+ &dwCount);
+ BAIL_ON_TDNF_ERROR(dwError);
+
+ if(dwError == ERROR_TDNF_NO_MATCH && !*ppszPackageNameSpecs)
+ {
+ dwError = 0;
+ }
+
+ *ppPkgInfo = pPkgInfo;
+ *pdwCount = dwCount;
+
+ ts.nQuiet = pTdnf->pArgs->nQuiet;
+
+ ts.pTS = rpmtsCreate();
+ if(!ts.pTS)
+ {
+ dwError = ERROR_TDNF_RPMTS_CREATE_FAILED;
+ BAIL_ON_TDNF_ERROR(dwError);
+ }
+
+ ts.nTransFlags = rpmtsSetFlags (ts.pTS, RPMTRANS_FLAG_NONE);
+
+ if(rpmtsSetNotifyCallback(ts.pTS, TDNFRpmCB, (void*)&ts))
+ {
+ dwError = ERROR_TDNF_RPMTS_SET_CB_FAILED;
+ BAIL_ON_TDNF_ERROR(dwError);
+ }
+
+ for(dwIndex = 0; dwIndex < dwCount; ++dwIndex)
+ {
+ pPkg = &pPkgInfo[dwIndex];
+
+ dwError = TDNFTransAddInstallPkg(
+ &ts,
+ pTdnf,
+ pPkg->pszLocation,
+ pPkg->pszName,
+ pPkg->pszRepoName,
+ nUpgrade);
+ BAIL_ON_TDNF_ERROR(dwError);
+ rpmtsEmpty(ts.pTS);
+ }
+
+cleanup:
+ if(pQuery)
+ {
+ SolvFreeQuery(pQuery);
+ }
+ if(pPkgList)
+ {
+ SolvFreePackageList(pPkgList);
+ }
+ if(ts.pTS)
+ {
+ rpmtsCloseDB(ts.pTS);
+ rpmtsFree(ts.pTS);
+ }
+
+ return dwError;
+
+error:
+ if(ppPkgInfo)
+ {
+ *ppPkgInfo = NULL;
+ }
+ if(pdwCount)
+ {
+ *pdwCount = 0;
+ }
+ if(pPkgInfo)
+ {
+ TDNFFreePackageInfoArray(pPkgInfo, dwCount);
+ }
+ goto cleanup;
+}
diff --git a/client/goal.c b/client/goal.c
index 916388c..3700df5 100644
--- a/client/goal.c
+++ b/client/goal.c
@@ -514,6 +514,7 @@ TDNFAddGoal(
break;
case ALTER_REINSTALL:
case ALTER_INSTALL:
+ case ALTER_INSTALL_ONLY_DOWNLOAD:
case ALTER_UPGRADE:
dwError = SolvAddPkgInstallJob(pQueueJobs, dwId);
BAIL_ON_TDNF_ERROR(dwError);
diff --git a/client/init.c b/client/init.c
index 871dae7..a8ccb6a 100644
--- a/client/init.c
+++ b/client/init.c
@@ -37,6 +37,7 @@ TDNFCloneCmdArgs(
(void**)&pCmdArgs);
BAIL_ON_TDNF_ERROR(dwError);
+ pCmdArgs->nAllDeps = pCmdArgsIn->nAllDeps;
pCmdArgs->nAllowErasing = pCmdArgsIn->nAllowErasing;
pCmdArgs->nAssumeNo = pCmdArgsIn->nAssumeNo;
pCmdArgs->nAssumeYes = pCmdArgsIn->nAssumeYes;
@@ -116,6 +117,15 @@ TDNFCloneCmdArgs(
BAIL_ON_TDNF_ERROR(dwError);
}
+ if(!IsNullOrEmptyString(pCmdArgsIn->pszDestDir))
+ {
+ dwError = TDNFAllocateString(
+ pCmdArgsIn->pszDestDir,
+ &pCmdArgs->pszDestDir);
+ pCmdArgs->nDownloadOnly=1;
+ BAIL_ON_TDNF_ERROR(dwError);
+ }
+
pCmdArgs->nCmdCount = pCmdArgsIn->nCmdCount;
dwError = TDNFAllocateMemory(
pCmdArgs->nCmdCount,
diff --git a/client/packageutils.c b/client/packageutils.c
index e130d66..510c337 100644
--- a/client/packageutils.c
+++ b/client/packageutils.c
@@ -186,6 +186,13 @@ TDNFPopulatePkgInfoArray(
dwPkgId,
&pPkgInfo->pszDescription);
BAIL_ON_TDNF_ERROR(dwError);
+
+ dwError = SolvGetPkgLocationFromId(
+ pSack,
+ dwPkgId,
+ &pPkgInfo->pszLocation);
+ BAIL_ON_TDNF_ERROR(dwError);
+
}
else if (nDetail == DETAIL_CHANGELOG)
{
@@ -1211,4 +1218,3 @@ cleanup:
error:
goto cleanup;
}
-
diff --git a/client/resolve.c b/client/resolve.c
index b9164e8..125d4b2 100644
--- a/client/resolve.c
+++ b/client/resolve.c
@@ -378,7 +378,8 @@ TDNFPrepareSinglePkg(
pszPkgName);
BAIL_ON_TDNF_ERROR(dwError);
}
- else if (nAlterType == ALTER_INSTALL)
+ else if (nAlterType == ALTER_INSTALL ||
+ nAlterType == ALTER_INSTALL_ONLY_DOWNLOAD)
{
dwError = TDNFAddPackagesForInstall(
pSack,
diff --git a/client/rpmtrans.c b/client/rpmtrans.c
index 8fa055a..46a6f3d 100644
--- a/client/rpmtrans.c
+++ b/client/rpmtrans.c
@@ -41,7 +41,9 @@ TDNFRpmExecTransaction(
ts.nQuiet = pTdnf->pArgs->nQuiet;
nKeepCachedRpms = pTdnf->pConf->nKeepCache;
- nDownloadOnly = pTdnf->pArgs->nDownloadOnly;
+ nDownloadOnly = pTdnf->pArgs->nDownloadOnly ||
+ nAlterType == ALTER_INSTALL_ONLY_DOWNLOAD;
+
dwError = TDNFAllocateMemory(
1,
@@ -509,6 +511,12 @@ TDNFTransAddInstallPkg(
Header rpmHeader = NULL;
PTDNF_CACHED_RPM_ENTRY pRpmCache = NULL;
+ if (!pTdnf || !pTdnf->pConf)
+ {
+ dwError = ERROR_TDNF_INVALID_PARAMETER;
+ BAIL_ON_TDNF_ERROR(dwError);
+ }
+
if (pszPackageLocation[0] == '/')
{
dwError = TDNFAllocateString(
@@ -519,7 +527,9 @@ TDNFTransAddInstallPkg(
}
else
{
- if (!pTdnf->pArgs->nDownloadOnly || pTdnf->pArgs->pszDownloadDir == NULL)
+ if ((!pTdnf->pArgs->nDownloadOnly ||
+ IsNullOrEmptyString(pTdnf->pArgs->pszDownloadDir)) &&
+ IsNullOrEmptyString(pTdnf->pArgs->pszDestDir))
{
dwError = TDNFDownloadPackageToCache(
pTdnf,
@@ -531,14 +541,29 @@ TDNFTransAddInstallPkg(
}
else
{
- dwError = TDNFDownloadPackageToDirectory(
- pTdnf,
- pszPackageLocation,
- pszPkgName,
- pszRepoName,
- pTdnf->pArgs->pszDownloadDir,
- &pszFilePath
- );
+ if(!IsNullOrEmptyString(pTdnf->pArgs->pszDestDir)) {
+ dwError = TDNFDownloadPackageToDirectory(
+ pTdnf,
+ pszPackageLocation,
+ pszPkgName,
+ pszRepoName,
+ pTdnf->pArgs->pszDestDir,
+ &pszFilePath
+ );
+ }
+ else if(!IsNullOrEmptyString(pTdnf->pArgs->pszDownloadDir)) {
+ dwError = TDNFDownloadPackageToDirectory(
+ pTdnf,
+ pszPackageLocation,
+ pszPkgName,
+ pszRepoName,
+ pTdnf->pArgs->pszDownloadDir,
+ &pszFilePath
+ );
+ }
+ else {
+ dwError = ERROR_TDNF_INVALID_PARAMETER;
+ }
}
BAIL_ON_TDNF_ERROR(dwError);
diff --git a/include/tdnf.h b/include/tdnf.h
index d15ea62..e35a65b 100644
--- a/include/tdnf.h
+++ b/include/tdnf.h
@@ -173,6 +173,13 @@ TDNFSearchCommand(
uint32_t* pdwCount
);
+//reset solv goal dependency resolution
+uint32_t
+TDNFResetSack(
+ PTDNF pTdnf,
+ int nSkipInstalledRpms
+ );
+
//invoke solv goal dependency resolution
//return solved pkg info which has descriptive
//info about steps to reach current goal.
@@ -277,6 +284,15 @@ TDNFUninit(
void
);
+//Downloads all requested packages without any of their dependencies.
+uint32_t
+TDNFDownloadNoDepsCommand(
+ PTDNF pTdnf,
+ TDNF_SCOPE nScope,
+ char** ppszPackageNameSpecs,
+ PTDNF_PKG_INFO* ppPkgInfo,
+ uint32_t* pdwCount
+ );
#ifdef __cplusplus
}
diff --git a/include/tdnfcli.h b/include/tdnfcli.h
index 4644cd0..f33f9d4 100644
--- a/include/tdnfcli.h
+++ b/include/tdnfcli.h
@@ -169,6 +169,18 @@ TDNFCliInfoCommand(
PTDNF_CMD_ARGS pCmdArgs
);
+uint32_t
+TDNFCliDownloadCommand(
+ PTDNF_CLI_CONTEXT pContext,
+ PTDNF_CMD_ARGS pCmdArgs
+ );
+
+uint32_t
+TDNFCliDownloadNoDepsCommand(
+ PTDNF_CLI_CONTEXT pContext,
+ PTDNF_CMD_ARGS pCmdArgs
+ );
+
uint32_t
TDNFCliSearchCommand(
PTDNF_CLI_CONTEXT pContext,
diff --git a/include/tdnfclitypes.h b/include/tdnfclitypes.h
index b7b33d1..3a6178e 100644
--- a/include/tdnfclitypes.h
+++ b/include/tdnfclitypes.h
@@ -121,6 +121,11 @@ typedef uint32_t
uint32_t *
);
+typedef uint32_t
+(*PFN_TDNF_RESET_SACK)(
+ PTDNF_CLI_CONTEXT,
+ int);
+
typedef uint32_t
(*PFN_TDNF_RESOLVE)(
PTDNF_CLI_CONTEXT,
@@ -147,6 +152,15 @@ typedef uint32_t
PTDNF_UPDATEINFO_ARGS,
PTDNF_UPDATEINFO_SUMMARY *);
+typedef uint32_t
+(*PFN_TDNF_DOWNLOAD_NO_DEPS)(
+ PTDNF_CLI_CONTEXT,
+ PTDNF_LIST_ARGS,
+ PTDNF_PKG_INFO *,
+ uint32_t *
+ );
+
+
typedef struct _TDNF_CLI_CONTEXT_
{
HTDNF hTdnf;
@@ -162,12 +176,14 @@ typedef struct _TDNF_CLI_CONTEXT_
PFN_TDNF_LIST pFnList;
PFN_TDNF_PROVIDES pFnProvides;
PFN_TDNF_REPOLIST pFnRepoList;
+ PFN_TDNF_RESET_SACK pFnResetSack;
PFN_TDNF_REPOSYNC pFnRepoSync;
PFN_TDNF_REPOQUERY pFnRepoQuery;
PFN_TDNF_RESOLVE pFnResolve;
PFN_TDNF_SEARCH pFnSearch;
PFN_TDNF_UPDATEINFO pFnUpdateInfo;
PFN_TDNF_UPDATEINFO_SUMMARY pFnUpdateInfoSummary;
+ PFN_TDNF_DOWNLOAD_NO_DEPS pFnDownloadNoDeps;
}TDNF_CLI_CONTEXT, *PTDNF_CLI_CONTEXT;
#ifdef __cplusplus
diff --git a/include/tdnftypes.h b/include/tdnftypes.h
index a547b8a..a50cfec 100644
--- a/include/tdnftypes.h
+++ b/include/tdnftypes.h
@@ -54,7 +54,8 @@ typedef enum
ALTER_UPGRADE,
ALTER_UPGRADEALL,
ALTER_DISTRO_SYNC,
- ALTER_OBSOLETED
+ ALTER_OBSOLETED,
+ ALTER_INSTALL_ONLY_DOWNLOAD
}TDNF_ALTERTYPE;
typedef enum
@@ -231,6 +232,7 @@ typedef struct _TDNF_CMD_ARGS
//Represent options in the dnf cmd line.
//All options are one to one maps to dnf command line
//options (incomplete)
+ int nAllDeps; //add all package dependencies when resolving
int nAllowErasing; //allow erasures when solving
int nAssumeNo; //assume no for all questions
int nAssumeYes; //assume yes for all questions
@@ -251,6 +253,7 @@ typedef struct _TDNF_CMD_ARGS
int nDisableExcludes; //disable excludes from tdnf.conf
int nDownloadOnly; //download packages only, no install
char* pszDownloadDir; //directory for download, if nDownloadOnly is set
+ char* pszDestDir; //directory for download, if install command is called
char* pszInstallRoot; //set install root
char* pszConfFile; //set conf file location
char* pszReleaseVer; //Release version
diff --git a/solv/prototypes.h b/solv/prototypes.h
index 04e877e..c71b19f 100644
--- a/solv/prototypes.h
+++ b/solv/prototypes.h
@@ -315,7 +315,8 @@ uint32_t
SolvInitSack(
PSolvSack *ppSack,
const char* pszCacheDir,
- const char* pszRootDir
+ const char* pszRootDir,
+ int nSkipInstalledRpms
);
@@ -504,8 +505,16 @@ SolvCountPackages(
uint32_t
SolvReadInstalledRpms(
Pool* pPool,
- Repo** ppRepo,
+ Repo** pRepo,
const char* pszCacheFileName
+);
+
+uint32_t
+SolvInitializeSystemRepo(
+ Pool* pPool,
+ Repo** ppRepo,
+ const char* pszCacheFileName,
+ int nSkipInstalledRpms
);
uint32_t
diff --git a/solv/tdnfpool.c b/solv/tdnfpool.c
index b22de1d..6cc7731 100644
--- a/solv/tdnfpool.c
+++ b/solv/tdnfpool.c
@@ -61,7 +61,8 @@ uint32_t
SolvInitSack(
PSolvSack *ppSack,
const char* pszCacheDir,
- const char* pszRootDir
+ const char* pszRootDir,
+ int nSkipInstalledRpms
)
{
uint32_t dwError = 0;
@@ -109,9 +110,16 @@ SolvInitSack(
pool_setarch(pPool, systemInfo.machine);
pool_set_flag(pPool, POOL_FLAG_ADDFILEPROVIDESFILTERED, 1);
- dwError = SolvReadInstalledRpms(pPool, &pRepo, pszCacheDir);
- BAIL_ON_TDNF_LIBSOLV_ERROR(dwError);
-
+ if(nSkipInstalledRpms){
+ pRepo = repo_create(pPool, SYSTEM_REPO_NAME);
+ if(pRepo == NULL) {
+ dwError = ERROR_TDNF_INVALID_PARAMETER;
+ BAIL_ON_TDNF_LIBSOLV_ERROR(dwError);
+ }
+ } else {
+ dwError = SolvReadInstalledRpms(pPool, &pRepo, pszCacheDir);
+ BAIL_ON_TDNF_LIBSOLV_ERROR(dwError);
+ }
pool_set_installed(pPool, pRepo);
pool_createwhatprovides(pPool);
diff --git a/solv/tdnfrepo.c b/solv/tdnfrepo.c
index d98d9c7..bcab90b 100644
--- a/solv/tdnfrepo.c
+++ b/solv/tdnfrepo.c
@@ -1,4 +1,3 @@
-
/*
* Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved.
*
@@ -275,7 +274,7 @@ SolvReadInstalledRpms(
)
{
uint32_t dwError = 0;
- Repo *pRepo = NULL;
+ Repo* pRepo = NULL;
FILE *pCacheFile = NULL;
int dwFlags = 0;
if(!pPool || !ppRepo)
@@ -325,6 +324,49 @@ error:
goto cleanup;
}
+uint32_t
+SolvInitializeSystemRepo(
+ Pool* pPool,
+ Repo** ppRepo,
+ const char* pszCacheFileName,
+ int nSkipInstalledRpms
+ )
+{
+ uint32_t dwError = 0;
+ Repo* pRepo = NULL;
+
+ if(!pPool)
+ {
+ dwError = ERROR_TDNF_INVALID_PARAMETER;
+ BAIL_ON_TDNF_LIBSOLV_ERROR(dwError);
+ }
+
+ if(!nSkipInstalledRpms)
+ {
+ dwError = SolvReadInstalledRpms(pPool, pRepo, pszCacheFileName);
+ BAIL_ON_TDNF_SYSTEM_ERROR(dwError);
+
+
+ if (dwError)
+ {
+ dwError = ERROR_TDNF_SOLV_IO;
+ BAIL_ON_TDNF_LIBSOLV_ERROR(dwError);
+ }
+ *ppRepo = pRepo;
+ }
+
+cleanup:
+ return dwError;
+
+error:
+ if(pRepo)
+ {
+ repo_free(pRepo, 1);
+ }
+ goto cleanup;
+}
+
+
uint32_t
SolvCalculateCookieForFile(
char *pszFilePath,
diff --git a/tools/cli/lib/api.c b/tools/cli/lib/api.c
index f277b7c..539b908 100644
--- a/tools/cli/lib/api.c
+++ b/tools/cli/lib/api.c
@@ -718,3 +718,123 @@ TDNFCliRefresh(
return TDNFRefresh(pContext->hTdnf);
}
+uint32_t
+TDNFCliDownloadCommand(
+ PTDNF_CLI_CONTEXT pContext,
+ PTDNF_CMD_ARGS pCmdArgs
+ )
+ {
+ uint32_t dwError = 0;
+ char** ppszPackageArgs = NULL;
+ int nPackageCount = 0;
+ PTDNF_SOLVED_PKG_INFO pSolvedPkgInfo = NULL;
+ int nSilent = 0;
+ const int nSkipInstalledRpms = 1;
+ const TDNF_ALTERTYPE nAlterType = ALTER_INSTALL_ONLY_DOWNLOAD;
+
+ if(!pContext ||
+ !pContext->hTdnf ||
+ !pCmdArgs ||
+ IsNullOrEmptyString(pCmdArgs->pszDestDir))
+ {
+ dwError = ERROR_TDNF_INVALID_PARAMETER;
+ BAIL_ON_CLI_ERROR(dwError);
+ }
+
+ nSilent = pCmdArgs->nNoOutput;
+
+ dwError = TDNFCliParsePackageArgs(
+ pCmdArgs,
+ &ppszPackageArgs,
+ &nPackageCount);
+ BAIL_ON_CLI_ERROR(dwError);
+
+ if (pCmdArgs->nAllDeps)
+ {
+ // On startup, tdnf initializes a libsolv pool and stores the
+ // initialized instance in a SolvSack. This pool contains all RPMs
+ // installed on the system. This data is taken into account during
+ // dependency resolution.
+ //
+ // Since initialization happens so early in the startup process,
+ // there is no clean way of altering it for *only* download commands.
+ //
+ // Instead, reset the SolvSack to generate a new libsolv pool that omits
+ // the system's RPMs. This will force all dependencies of the target
+ // download RPM to be obtained.
+ dwError = pContext->pFnResetSack(pContext, nSkipInstalledRpms);
+ BAIL_ON_CLI_ERROR(dwError);
+ }
+
+ dwError = pContext->pFnResolve(
+ pContext,
+ nAlterType,
+ &pSolvedPkgInfo);
+ BAIL_ON_CLI_ERROR(dwError);
+
+ if(!nSilent && pSolvedPkgInfo->ppszPkgsNotResolved)
+ {
+ dwError = PrintNotAvailable(pSolvedPkgInfo->ppszPkgsNotResolved);
+ BAIL_ON_CLI_ERROR(dwError);
+ }
+
+ dwError = TDNFAlterCommand(
+ pContext->hTdnf,
+ nAlterType,
+ pSolvedPkgInfo);
+ BAIL_ON_CLI_ERROR(dwError);
+
+cleanup:
+ TDNF_CLI_SAFE_FREE_STRINGARRAY(ppszPackageArgs);
+ TDNFCliFreeSolvedPackageInfo(pSolvedPkgInfo);
+ return dwError;
+
+error:
+ goto cleanup;
+}
+
+uint32_t
+TDNFCliDownloadNoDepsCommand(
+ PTDNF_CLI_CONTEXT pContext,
+ PTDNF_CMD_ARGS pCmdArgs
+ )
+{
+ uint32_t dwError = 0;
+
+ PTDNF_PKG_INFO pPkgInfo = NULL;
+ PTDNF_LIST_ARGS pInfoArgs = NULL;
+
+ uint32_t dwCount = 0;
+
+ if(!pContext ||
+ !pContext->hTdnf ||
+ !pContext->pFnDownloadNoDeps ||
+ !pCmdArgs ||
+ IsNullOrEmptyString(pCmdArgs->pszDestDir))
+ {
+ dwError = ERROR_TDNF_INVALID_PARAMETER;
+ BAIL_ON_CLI_ERROR(dwError);
+ }
+
+ dwError = TDNFCliParseInfoArgs(pCmdArgs, &pInfoArgs);
+ BAIL_ON_CLI_ERROR(dwError);
+
+ dwError = pContext->pFnDownloadNoDeps(pContext, pInfoArgs, &pPkgInfo, &dwCount);
+ BAIL_ON_CLI_ERROR(dwError);
+
+ printf("Download %d packages\n", dwCount);
+
+cleanup:
+ if(pInfoArgs)
+ {
+ TDNFCliFreeListArgs(pInfoArgs);
+ }
+ if(pPkgInfo)
+ {
+ TDNFFreePackageInfoArray(pPkgInfo, dwCount);
+ }
+ return dwError;
+
+error:
+ goto cleanup;
+}
diff --git a/tools/cli/lib/help.c b/tools/cli/lib/help.c
index 369e4e2..8b48c3c 100644
--- a/tools/cli/lib/help.c
+++ b/tools/cli/lib/help.c
@@ -39,6 +39,7 @@ TDNFCliShowHelp(
pr_crit("\n");
pr_crit("options [-c [config file]]\n");
+ pr_crit(" [--alldeps]\n");
pr_crit(" [--debugsolver]\n");
pr_crit(" [--disablerepo=<repoid>]\n");
pr_crit(" [--enablerepo=<repoid>]\n");
@@ -108,6 +109,8 @@ TDNFCliShowHelp(
pr_crit("check-update Check for available package upgrades\n");
pr_crit("clean Remove cached data\n");
pr_crit("distro-sync Synchronize installed packages to the latest available versions\n");
+ pr_crit("download download a package\n");
+ pr_crit("download-nodeps download a package without dependencies\n");
pr_crit("downgrade downgrade a package\n");
pr_crit("erase Remove a package or packages from your system\n");
pr_crit("help Display a helpful usage message\n");
diff --git a/tools/cli/lib/parseargs.c b/tools/cli/lib/parseargs.c
index a022e13..15329ce 100644
--- a/tools/cli/lib/parseargs.c
+++ b/tools/cli/lib/parseargs.c
@@ -74,6 +74,7 @@ static TDNF_CMD_ARGS _opt = {0};
//options - incomplete
static struct option pstOptions[] =
{
+ {"alldeps", no_argument, &_opt.nAllDeps, 1}, //--alldeps
{"allowerasing", no_argument, &_opt.nAllowErasing, 1},//--allowerasing
{"assumeno", no_argument, &_opt.nAssumeNo, 1}, //--assumeno
{"assumeyes", no_argument, 0, 'y'}, //--assumeyes
@@ -112,6 +113,7 @@ static struct option pstOptions[] =
{"noplugins", no_argument, 0, 0}, //--noplugins
{"disableplugin", required_argument, 0, 0}, //--disableplugin
{"enableplugin", required_argument, 0, 0}, //--enableplugin
+ {"destdir", required_argument, 0, 0}, //--destdir
{"disableexcludes", no_argument, &_opt.nDisableExcludes, 1}, //--disableexcludes
{"downloadonly", no_argument, &_opt.nDownloadOnly, 1}, //--downloadonly
{"downloaddir", required_argument, 0, 0}, //--downloaddir
@@ -326,6 +328,7 @@ TDNFCopyOptions(
BAIL_ON_CLI_ERROR(dwError);
}
+ pArgs->nAllDeps = pOptionArgs->nAllDeps;
pArgs->nAllowErasing = pOptionArgs->nAllowErasing;
pArgs->nAssumeNo = pOptionArgs->nAssumeNo;
pArgs->nAssumeYes = pOptionArgs->nAssumeYes;
@@ -383,6 +386,10 @@ ParseOption(
{
dwError = TDNFAllocateString(optarg, &pCmdArgs->pszInstallRoot);
}
+ else if (!strcasecmp(pszName, "destdir"))
+ {
+ dwError = TDNFAllocateString(optarg, &pCmdArgs->pszDestDir);
+ }
else if (!strcasecmp(pszName, "downloaddir"))
{
dwError = TDNFAllocateString(optarg, &pCmdArgs->pszDownloadDir);
diff --git a/tools/cli/main.c b/tools/cli/main.c
index 203f50a..eeeabdb 100644
--- a/tools/cli/main.c
+++ b/tools/cli/main.c
@@ -43,6 +43,8 @@ int main(int argc, char* argv[])
{"clean", TDNFCliCleanCommand},
{"count", TDNFCliCountCommand},
{"distro-sync", TDNFCliDistroSyncCommand},
+ {"download", TDNFCliDownloadCommand},
+ {"download-nodeps", TDNFCliDownloadNoDepsCommand},
{"downgrade", TDNFCliDowngradeCommand},
{"erase", TDNFCliEraseCommand},
{"help", TDNFCliHelpCommand},
@@ -109,13 +111,15 @@ int main(int argc, char* argv[])
/*
* Alter and resolve will address commands like
- * install, upgrade, erase, downgrade, distrosync
+ * install, upgrade, erase, download, downgrade, distrosync
*/
_context.pFnAlter = TDNFCliInvokeAlter;
+ _context.pFnResetSack = TDNFCliInvokeResetSack;
_context.pFnResolve = TDNFCliInvokeResolve;
_context.pFnSearch = TDNFCliInvokeSearch;
_context.pFnUpdateInfo = TDNFCliInvokeUpdateInfo;
_context.pFnUpdateInfoSummary = TDNFCliInvokeUpdateInfoSummary;
+ _context.pFnDownloadNoDeps = TDNFCliInvokeDownloadNoDeps;
dwError = TDNFCliParseArgs(argc, argv, &pCmdArgs);
BAIL_ON_CLI_ERROR(dwError);
@@ -527,3 +531,26 @@ TDNFCliInvokeUpdateInfoSummary(
ppSummary);
}
+uint32_t
+TDNFCliInvokeResetSack(
+ PTDNF_CLI_CONTEXT pContext,
+ int nSkipInstalledRpms
+ )
+{
+ return TDNFResetSack(pContext->hTdnf, nSkipInstalledRpms);
+}
+
+uint32_t
+TDNFCliInvokeDownloadNoDeps(
+ PTDNF_CLI_CONTEXT pContext,
+ PTDNF_LIST_ARGS pInfoArgs,
+ PTDNF_PKG_INFO *ppPkgInfo,
+ uint32_t *pdwCount
+ )
+{
+ return TDNFDownloadNoDepsCommand(pContext->hTdnf,
+ pInfoArgs->nScope,
+ pInfoArgs->ppszPackageNameSpecs,
+ ppPkgInfo,
+ pdwCount);
+}
diff --git a/tools/cli/prototypes.h b/tools/cli/prototypes.h
index 0afba59..daff8be 100644
--- a/tools/cli/prototypes.h
+++ b/tools/cli/prototypes.h
@@ -369,3 +369,17 @@ void
TDNFFreeListArgs(
PTDNF_LIST_ARGS pListArgs
);
+
+uint32_t
+TDNFCliInvokeResetSack(
+ PTDNF_CLI_CONTEXT pContext,
+ int nSkipInstalledRpms
+ );
+
+uint32_t
+TDNFCliInvokeDownloadNoDeps(
+ PTDNF_CLI_CONTEXT pContext,
+ PTDNF_LIST_ARGS pInfoArgs,
+ PTDNF_PKG_INFO *ppPkgInfo,
+ uint32_t *pdwCount
+ );

Просмотреть файл

@ -1,6 +1,6 @@
From: Andrew Phelps <anphel@microsoft.com>
Date: Mon, 25 Nov 2019 04:16:16 +0000
Subject: [PATCH] Merged PR 253: fix default distroverpkg
From: Sam Meluch <sammeluch@microsoft.com>
Date: Tue, 11 Apr 2023 17:44:54 +0000
Subject: [PATCH] Fix the default distroverpkg
fix default distroverpkg to prevent error:
Error(1022) : distroverpkg config entry is set to a package that is not installed. Check /etc/tdnf/tdnf.conf
@ -13,12 +13,29 @@ mariner-release.noarch 1.0-1.cm1 @System
Workaround: add the following to /etc/tdnf/tdnf.conf
distroverpkg=mariner-release
---
client/defines.h | 2 +-
common/config.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/defines.h b/client/defines.h
index 7cb16b8..5131040 100644
index 602b249..59b058e 100644
--- a/client/defines.h
+++ b/client/defines.h
@@ -121,7 +121,7 @@ typedef enum
@@ -137,7 +137,7 @@ typedef enum
and configurable with "persistdir" at run time */
#define TDNF_DEFAULT_DB_LOCATION HISTORY_DB_DIR
-#define TDNF_DEFAULT_DISTROVERPKG "system-release"
+#define TDNF_DEFAULT_DISTROVERPKG "mariner-release"
#define TDNF_DEFAULT_DISTROARCHPKG "x86_64"
#define TDNF_RPM_CACHE_DIR_NAME "rpms"
#define TDNF_REPODATA_DIR_NAME "repodata"
diff --git a/common/config.h b/common/config.h
index 222a448..b01e2ea 100644
--- a/common/config.h
+++ b/common/config.h
@@ -83,7 +83,7 @@
// repo defaults
#define TDNF_DEFAULT_REPO_LOCATION "/etc/yum.repos.d"
#define TDNF_DEFAULT_CACHE_LOCATION "/var/cache/tdnf"
@ -27,3 +44,6 @@ index 7cb16b8..5131040 100644
#define TDNF_DEFAULT_DISTROARCHPKG "x86_64"
#define TDNF_RPM_CACHE_DIR_NAME "rpms"
#define TDNF_REPODATA_DIR_NAME "repodata"
--
2.33.6

Просмотреть файл

@ -1,9 +1,20 @@
From: Sam Meluch <sammeluch@microsoft.com>
Date: Mon, 10 Apr 2023 23:07:00 +0000
Subject: [PATCH] enable plugins by default
---
etc/tdnf/tdnf.conf | 1 +
1 file changed, 1 insertion(+)
diff --git a/etc/tdnf/tdnf.conf b/etc/tdnf/tdnf.conf
index f8cbc96..a7897ed 100644
index a10bcbe..67c4d51 100644
--- a/etc/tdnf/tdnf.conf
+++ b/etc/tdnf/tdnf.conf
@@ -4,3 +4,4 @@ installonly_limit=3
clean_requirements_on_remove=true
clean_requirements_on_remove=0
repodir=/etc/yum.repos.d
cachedir=/var/cache/tdnf
+plugins=1
--
2.33.6

Просмотреть файл

@ -1,26 +1,33 @@
From: Pawel <pawelwi@microsoft.com>
Date: Mon, 28 Dec 2020 14:18:43 -0800
From: Sam Meluch <sammeluch@microsoft.com>
Date: Mon, 10 Apr 2023 22:24:58 +0000
Subject: [PATCH] Mandatory space in list output
---
tools/cli/lib/api.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/cli/lib/api.c b/tools/cli/lib/api.c
index f277b7c..7b7602c 100644
index c58c890..f55974b 100644
--- a/tools/cli/lib/api.c
+++ b/tools/cli/lib/api.c
@@ -172,7 +172,7 @@ TDNFCliListCommand(
if(snprintf(
szNameAndArch,
MAX_COL_LEN,
- "%s.%s",
+ "%s.%s ",
pPkg->pszName,
pPkg->pszArch) < 0)
{
@@ -184,7 +184,7 @@ TDNFCliListCommand(
if(snprintf(
szVersionAndRelease,
MAX_COL_LEN,
- "%s-%s",
+ "%s-%s ",
pPkg->pszVersion,
pPkg->pszRelease) < 0)
{
@@ -174,7 +174,7 @@ TDNFCliListPackagesPrint(
if(snprintf(
szNameAndArch,
MAX_COL_LEN,
- "%s.%s",
+ "%s.%s ",
pPkg->pszName,
pPkg->pszArch) < 0)
{
@@ -186,7 +186,7 @@ TDNFCliListPackagesPrint(
if(snprintf(
szVersionAndRelease,
MAX_COL_LEN,
- "%s-%s",
+ "%s-%s ",
pPkg->pszVersion,
pPkg->pszRelease) < 0)
{
--
2.33.6

Просмотреть файл

@ -0,0 +1,22 @@
From d62d7097c009ee867bee992840334dbc12f4f0f3 Mon Sep 17 00:00:00 2001
From: Oliver Kurth <okurth@gmail.com>
Date: Fri, 7 Apr 2023 11:53:56 -0700
Subject: [PATCH] fix printf usage
---
tools/config/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/config/main.c b/tools/config/main.c
index 2f07e460..e78e767d 100644
--- a/tools/config/main.c
+++ b/tools/config/main.c
@@ -462,7 +462,7 @@ int main(int argc, char *argv[])
struct json_dump *jd = cnftree2json(cn_repo);
unlink_node(cn_repo); /* do not dump siblings */
if (jd) {
- printf(jd->buf);
+ printf("%s", jd->buf);
jd_destroy(jd);
} else
fail(ERR_JSON, "failed to generate json\n");

Просмотреть файл

@ -0,0 +1,35 @@
From 5311b5ed0867a40ceb71b89358d70290bc2d0c51 Mon Sep 17 00:00:00 2001
From: Oliver Kurth <okurth@gmail.com>
Date: Wed, 16 Nov 2022 11:01:28 -0800
Subject: [PATCH] add sqlite libs to build with
---
history/CMakeLists.txt | 5 +++++
tools/cli/CMakeLists.txt | 1 +
2 files changed, 6 insertions(+)
diff --git a/history/CMakeLists.txt b/history/CMakeLists.txt
index c7df53ae..d2dbc876 100644
--- a/history/CMakeLists.txt
+++ b/history/CMakeLists.txt
@@ -28,3 +28,8 @@ target_link_libraries(${TDNF_HISTORY_UTIL_BIN}
${SQLITE3_LIBRARIES}
${LIB_TDNF_HISTORY}
)
+
+target_link_libraries(${LIB_TDNF_HISTORY}
+ ${RPM_LIBRARIES}
+ ${SQLITE3_LIBRARIES}
+)
diff --git a/tools/cli/CMakeLists.txt b/tools/cli/CMakeLists.txt
index 9487db2b..0e2a2e30 100644
--- a/tools/cli/CMakeLists.txt
+++ b/tools/cli/CMakeLists.txt
@@ -13,6 +13,7 @@ add_executable(${TDNF_BIN}
)
target_link_libraries(${TDNF_BIN}
+ ${SQLITE3_LIBRARIES}
${LIB_TDNF_CLI}
${LIB_TDNF}
)

Просмотреть файл

@ -3,7 +3,7 @@
"cache-updateinfo": "3e2157658b163a4b0558faaaf08e9fbca3d3e031fd294136de4ad39d61d232c3",
"cache-updateinfo.service": "2a033533bbb280c61c4f850701f6df1f6e9fde1c7d8132acf03279844cc3bbba",
"cache-updateinfo.timer": "7339fd7be53c57b9bbc000b27026d507e3d2d70958a2db7d1799f5960e3904ee",
"tdnf-3.2.2.tar.gz": "bf3117dc1c8c537dd664ef120e09710e715ae39f00e0e33c223dcfb752b87b6a",
"tdnf-3.5.2.tar.gz": "cc9a2a12ee44159362314d687110afaefe0e0cec7d227a65a78a28cfea272b94",
"tdnfrepogpgcheck.conf": "84c1c0c956a492cadbfd2cec581ef678c190e3e245f0d61665eb0f66b8b34fd6"
}
}

Просмотреть файл

@ -1,7 +1,11 @@
%undefine __cmake_in_source_build
%define _tdnfpluginsdir %{_libdir}/tdnf-plugins
%define _tdnf_history_db_dir %{_libdir}/sysimage/tdnf
Summary: dnf/yum equivalent using C libs
Name: tdnf
Version: 3.2.2
Release: 4%{?dist}
Version: 3.5.2
Release: 1%{?dist}
License: LGPLv2.1 AND GPLv2
Vendor: Microsoft Corporation
Distribution: Mariner
@ -16,7 +20,15 @@ Source4: tdnfrepogpgcheck.conf
Patch0: tdnf-mandatory-space-list-output.patch
Patch1: tdnf-default-mariner-release.patch
Patch2: tdnf-enable-plugins-by-default.patch
Patch3: tdnf-add-download-command.patch
# Patch to be removed once we upgrade to a version of tdnf which contains the upstream fix
# https://github.com/vmware/tdnf/commit/d62d7097c009ee867bee992840334dbc12f4f0f3
Patch3: tdnf-printf-fix.patch
# Patch to be removed once we upgrade to a version of tdnf which contains the upstream fix
# https://github.com/vmware/tdnf/commit/5311b5ed0867a40ceb71b89358d70290bc2d0c51
Patch4: tdnf-sqlite-library.patch
# Patch to be removed once we upgrade to a version of tdnf which contains the upstream fix
# https://github.com/vmware/tdnf/pull/432
Patch5: tdnf-GetRepoMD-fix.patch
#Cmake requires binutils
BuildRequires: binutils
BuildRequires: cmake
@ -26,19 +38,22 @@ BuildRequires: gcc
BuildRequires: glibc-devel
#plugin repogpgcheck
BuildRequires: gpgme-devel
BuildRequires: libmetalink-devel
BuildRequires: libsolv-devel
BuildRequires: libxml2-devel
BuildRequires: make
BuildRequires: openssl-devel
BuildRequires: popt-devel
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: rpm-devel
Requires: curl
Requires: libmetalink
BuildRequires: sqlite-devel
BuildRequires: zlib-devel
Requires: curl-libs
Requires: libsolv
Requires: openssl-libs
Requires: rpm-libs
Requires: tdnf-cli-libs = %{version}-%{release}
Requires: zlib
Obsoletes: yum
Provides: yum
%if %{with_check}
@ -47,20 +62,17 @@ BuildRequires: glib
BuildRequires: libxml2
BuildRequires: python3-pip
BuildRequires: python3-requests
BuildRequires: python3-setuptools
BuildRequires: python3-xml
%endif
%description
tdnf is a yum/dnf equivalent which uses libsolv and libcurl
%define _tdnfpluginsdir %{_libdir}/tdnf-plugins
%package devel
Summary: A Library providing C API for tdnf
Group: Development/Libraries
Requires: libsolv-devel
Requires: tdnf = %{version}-%{release}
Requires: %{name} = %{version}-%{release}
%description devel
Development files for tdnf
@ -72,9 +84,19 @@ Group: Development/Libraries
%description cli-libs
Library providing cli libs for tdnf like clients.
%package plugin-metalink
Summary: tdnf plugin providing metalink functionality for repo configurations
Group: Applications/RPM
Requires: %{name} = %{version}-%{release}
Requires: libxml2
%description plugin-metalink
tdnf plugin providing metalink functionality for repo configurations
%package plugin-repogpgcheck
Summary: tdnf plugin providing gpg verification for repository metadata
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: gpgme
%description plugin-repogpgcheck
@ -90,6 +112,7 @@ python bindings for tdnf
%package autoupdate
Summary: systemd services for periodic automatic update
Group: Applications/RPM
Requires: %{name} = %{version}-%{release}
%description autoupdate
@ -99,85 +122,112 @@ systemd services for periodic automatic update
%autosetup -p1
%build
mkdir build && cd build
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
..
make %{?_smp_mflags} && make python
%cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \
-DHISTORY_DB_DIR=%{_tdnf_history_db_dir}
%cmake_build
cd %{__cmake_builddir}
%make_build python
%check
pip3 install pytest requests pyOpenSSL
cd build && make %{?_smp_mflags} check
%install
cd build && %make_install
%cmake_install
find %{buildroot} -name '*.a' -delete -print
mkdir -p %{buildroot}%{_var}/cache/tdnf
mkdir -p %{buildroot}%{_tdnf_history_db_dir}
ln -sf %{_bindir}/tdnf %{buildroot}%{_bindir}/tyum
ln -sf %{_bindir}/tdnf %{buildroot}%{_bindir}/yum
ln -sf %{_bindir}/tdnf %{buildroot}%{_bindir}/tdnfj
install -v -D -m 0755 %{SOURCE1} %{buildroot}%{_bindir}/tdnf-cache-updateinfo
install -v -D -m 0644 %{SOURCE2} %{buildroot}%{_libdir}/systemd/system/tdnf-cache-updateinfo.service
install -v -D -m 0644 %{SOURCE3} %{buildroot}%{_libdir}/systemd/system/tdnf-cache-updateinfo.timer
install -v -D -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/tdnf/pluginconf.d/tdnfrepogpgcheck.conf
mv %{buildroot}%{_libdir}/pkgconfig/tdnfcli.pc %{buildroot}%{_libdir}/pkgconfig/tdnf-cli-libs.pc
mkdir -p %{buildroot}/%{_tdnfpluginsdir}/tdnfrepogpgcheck
mv %{buildroot}/%{_tdnfpluginsdir}/libtdnfrepogpgcheck.so %{buildroot}/%{_tdnfpluginsdir}/tdnfrepogpgcheck/libtdnfrepogpgcheck.so
rm -f %{buildroot}%{_bindir}/jsondumptest
rm -rf %{buildroot}%{_datadir}/tdnf
pushd python
python3 setup.py install --skip-build --prefix=%{_prefix} --root=%{buildroot}
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/protected.d
pushd %{__cmake_builddir}/python
%py3_install
popd
find %{buildroot} -name '*.pyc' -delete
%ldconfig_scriptlets
%post
/sbin/ldconfig
# Required step to ensure new history util from version 3.4.1 does not fail
if [[ ! -f %{_tdnf_history_db_dir}/history.db ]]; then
%{_libdir}/tdnf/tdnf-history-util init
fi
%postun
/sbin/ldconfig
%files
%license COPYING
%defattr(-,root,root,0755)
%config(noreplace) %{_sysconfdir}/tdnf/tdnf.conf
%dir %{_tdnf_history_db_dir}
%dir %{_var}/cache/tdnf
%{_bindir}/tdnf
%{_bindir}/tdnf-cache-updateinfo
%{_bindir}/tdnf-config
%{_bindir}/tdnfj
%{_bindir}/tyum
%{_bindir}/yum
%{_bindir}/tdnf-cache-updateinfo
%{_datadir}/bash-completion/completions/tdnf
%{_libdir}/libtdnf.so.3
%{_libdir}/libtdnf.so.3.*
%config(noreplace) %{_sysconfdir}/tdnf/tdnf.conf
%dir %{_var}/cache/tdnf
%{_datadir}/bash-completion/completions/tdnf
%{_libdir}/tdnf/tdnf-history-util
%files devel
%defattr(-,root,root)
%exclude %{_libdir}/debug
%{_includedir}/tdnf/*.h
%{_libdir}/libtdnf.so
%{_libdir}/libtdnfcli.so
%exclude %{_libdir}/debug
%{_libdir}/pkgconfig/tdnf.pc
%{_libdir}/pkgconfig/tdnf-cli-libs.pc
%{_libdir}/pkgconfig/tdnf.pc
%files cli-libs
%defattr(-,root,root)
%{_libdir}/libtdnfcli.so.3
%{_libdir}/libtdnfcli.so.3.*
%files plugin-metalink
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/tdnf/pluginconf.d/tdnfmetalink.conf
%dir %{_sysconfdir}/tdnf/pluginconf.d
%{_tdnfpluginsdir}/libtdnfmetalink.so
%files plugin-repogpgcheck
%defattr(-,root,root)
%dir %{_sysconfdir}/tdnf/pluginconf.d
%config(noreplace) %{_sysconfdir}/tdnf/pluginconf.d/tdnfrepogpgcheck.conf
%{_tdnfpluginsdir}/tdnfrepogpgcheck/libtdnfrepogpgcheck.so
%dir %{_sysconfdir}/tdnf/pluginconf.d
%{_tdnfpluginsdir}/libtdnfrepogpgcheck.so
%files python
%defattr(-,root,root)
%{python3_sitelib}/*
%files autoupdate
%{_bindir}/tdnf-automatic
%{_libdir}/systemd/system/tdnf-cache-updateinfo*
%{_sysconfdir}/motdgen.d/02-tdnf-updateinfo.sh
%{_sysconfdir}/tdnf/automatic.conf
/%{_lib}/systemd/system/tdnf*
%{_libdir}/systemd/system/tdnf-cache-updateinfo*
%{_bindir}/tdnf-automatic
%changelog
* Wed Apr 12 2023 Sam Meluch <sammeluch@microsoft.com> - 3.5.2-1
- Update tdnf to version 3.5.2
- Remove tdnf download patch in favor of upstream --downloadonly functionality
* Tue May 03 2022 Pawel Winogrodzki <pawelwi@microsoft.com> - 3.2.2-4
- Reverting usage of "rpm" in RPM scripts since "/var/lib/rpm/.rpm.lock" is always taken.

Просмотреть файл

@ -28257,8 +28257,8 @@
"type": "other",
"other": {
"name": "tdnf",
"version": "3.2.2",
"downloadUrl": "https://github.com/vmware/tdnf/archive/v3.2.2.tar.gz"
"version": "3.5.2",
"downloadUrl": "https://github.com/vmware/tdnf/archive/v3.5.2.tar.gz"
}
}
},

Просмотреть файл

@ -193,10 +193,6 @@ nghttp2-1.46.0-2.cm2.aarch64.rpm
curl-8.0.1-2.cm2.aarch64.rpm
curl-devel-8.0.1-2.cm2.aarch64.rpm
curl-libs-8.0.1-2.cm2.aarch64.rpm
tdnf-3.2.2-4.cm2.aarch64.rpm
tdnf-cli-libs-3.2.2-4.cm2.aarch64.rpm
tdnf-devel-3.2.2-4.cm2.aarch64.rpm
tdnf-plugin-repogpgcheck-3.2.2-4.cm2.aarch64.rpm
createrepo_c-0.17.5-1.cm2.aarch64.rpm
libxml2-2.10.3-1.cm2.aarch64.rpm
libxml2-devel-2.10.3-1.cm2.aarch64.rpm
@ -210,6 +206,10 @@ lua-5.4.4-1.cm2.aarch64.rpm
lua-libs-5.4.4-1.cm2.aarch64.rpm
mariner-rpm-macros-2.0-21.cm2.noarch.rpm
mariner-check-macros-2.0-21.cm2.noarch.rpm
tdnf-3.5.2-1.cm2.aarch64.rpm
tdnf-cli-libs-3.5.2-1.cm2.aarch64.rpm
tdnf-devel-3.5.2-1.cm2.aarch64.rpm
tdnf-plugin-repogpgcheck-3.5.2-1.cm2.aarch64.rpm
libassuan-2.5.5-2.cm2.aarch64.rpm
libassuan-devel-2.5.5-2.cm2.aarch64.rpm
libgpg-error-1.46-1.cm2.aarch64.rpm

Просмотреть файл

@ -193,10 +193,6 @@ nghttp2-1.46.0-2.cm2.x86_64.rpm
curl-8.0.1-2.cm2.x86_64.rpm
curl-devel-8.0.1-2.cm2.x86_64.rpm
curl-libs-8.0.1-2.cm2.x86_64.rpm
tdnf-3.2.2-4.cm2.x86_64.rpm
tdnf-cli-libs-3.2.2-4.cm2.x86_64.rpm
tdnf-devel-3.2.2-4.cm2.x86_64.rpm
tdnf-plugin-repogpgcheck-3.2.2-4.cm2.x86_64.rpm
createrepo_c-0.17.5-1.cm2.x86_64.rpm
libxml2-2.10.3-1.cm2.x86_64.rpm
libxml2-devel-2.10.3-1.cm2.x86_64.rpm
@ -210,6 +206,10 @@ lua-5.4.4-1.cm2.x86_64.rpm
lua-libs-5.4.4-1.cm2.x86_64.rpm
mariner-rpm-macros-2.0-21.cm2.noarch.rpm
mariner-check-macros-2.0-21.cm2.noarch.rpm
tdnf-3.5.2-1.cm2.x86_64.rpm
tdnf-cli-libs-3.5.2-1.cm2.x86_64.rpm
tdnf-devel-3.5.2-1.cm2.x86_64.rpm
tdnf-plugin-repogpgcheck-3.5.2-1.cm2.x86_64.rpm
libassuan-2.5.5-2.cm2.x86_64.rpm
libassuan-devel-2.5.5-2.cm2.x86_64.rpm
libgpg-error-1.46-1.cm2.x86_64.rpm

Просмотреть файл

@ -30,8 +30,8 @@ check-debuginfo-0.15.2-1.cm2.aarch64.rpm
chkconfig-1.20-3.cm2.aarch64.rpm
chkconfig-debuginfo-1.20-3.cm2.aarch64.rpm
chkconfig-lang-1.20-3.cm2.aarch64.rpm
cmake-3.21.4-6.cm2.aarch64.rpm
cmake-debuginfo-3.21.4-6.cm2.aarch64.rpm
cmake-3.21.4-7.cm2.aarch64.rpm
cmake-debuginfo-3.21.4-7.cm2.aarch64.rpm
coreutils-8.32-6.cm2.aarch64.rpm
coreutils-debuginfo-8.32-6.cm2.aarch64.rpm
coreutils-lang-8.32-6.cm2.aarch64.rpm
@ -557,13 +557,14 @@ systemd-bootstrap-devel-250.3-12.cm2.aarch64.rpm
systemd-bootstrap-rpm-macros-250.3-12.cm2.noarch.rpm
tar-1.34-1.cm2.aarch64.rpm
tar-debuginfo-1.34-1.cm2.aarch64.rpm
tdnf-3.2.2-4.cm2.aarch64.rpm
tdnf-autoupdate-3.2.2-4.cm2.aarch64.rpm
tdnf-cli-libs-3.2.2-4.cm2.aarch64.rpm
tdnf-debuginfo-3.2.2-4.cm2.aarch64.rpm
tdnf-devel-3.2.2-4.cm2.aarch64.rpm
tdnf-plugin-repogpgcheck-3.2.2-4.cm2.aarch64.rpm
tdnf-python-3.2.2-4.cm2.aarch64.rpm
tdnf-3.5.2-1.cm2.aarch64.rpm
tdnf-autoupdate-3.5.2-1.cm2.aarch64.rpm
tdnf-cli-libs-3.5.2-1.cm2.aarch64.rpm
tdnf-debuginfo-3.5.2-1.cm2.aarch64.rpm
tdnf-devel-3.5.2-1.cm2.aarch64.rpm
tdnf-plugin-metalink-3.5.2-1.cm2.aarch64.rpm
tdnf-plugin-repogpgcheck-3.5.2-1.cm2.aarch64.rpm
tdnf-python-3.5.2-1.cm2.aarch64.rpm
texinfo-6.8-1.cm2.aarch64.rpm
texinfo-debuginfo-6.8-1.cm2.aarch64.rpm
unzip-6.0-20.cm2.aarch64.rpm

Просмотреть файл

@ -30,8 +30,8 @@ check-debuginfo-0.15.2-1.cm2.x86_64.rpm
chkconfig-1.20-3.cm2.x86_64.rpm
chkconfig-debuginfo-1.20-3.cm2.x86_64.rpm
chkconfig-lang-1.20-3.cm2.x86_64.rpm
cmake-3.21.4-6.cm2.x86_64.rpm
cmake-debuginfo-3.21.4-6.cm2.x86_64.rpm
cmake-3.21.4-7.cm2.x86_64.rpm
cmake-debuginfo-3.21.4-7.cm2.x86_64.rpm
coreutils-8.32-6.cm2.x86_64.rpm
coreutils-debuginfo-8.32-6.cm2.x86_64.rpm
coreutils-lang-8.32-6.cm2.x86_64.rpm
@ -557,13 +557,14 @@ systemd-bootstrap-devel-250.3-12.cm2.x86_64.rpm
systemd-bootstrap-rpm-macros-250.3-12.cm2.noarch.rpm
tar-1.34-1.cm2.x86_64.rpm
tar-debuginfo-1.34-1.cm2.x86_64.rpm
tdnf-3.2.2-4.cm2.x86_64.rpm
tdnf-autoupdate-3.2.2-4.cm2.x86_64.rpm
tdnf-cli-libs-3.2.2-4.cm2.x86_64.rpm
tdnf-debuginfo-3.2.2-4.cm2.x86_64.rpm
tdnf-devel-3.2.2-4.cm2.x86_64.rpm
tdnf-plugin-repogpgcheck-3.2.2-4.cm2.x86_64.rpm
tdnf-python-3.2.2-4.cm2.x86_64.rpm
tdnf-3.5.2-1.cm2.x86_64.rpm
tdnf-autoupdate-3.5.2-1.cm2.x86_64.rpm
tdnf-cli-libs-3.5.2-1.cm2.x86_64.rpm
tdnf-debuginfo-3.5.2-1.cm2.x86_64.rpm
tdnf-devel-3.5.2-1.cm2.x86_64.rpm
tdnf-plugin-metalink-3.5.2-1.cm2.x86_64.rpm
tdnf-plugin-repogpgcheck-3.5.2-1.cm2.x86_64.rpm
tdnf-python-3.5.2-1.cm2.x86_64.rpm
texinfo-6.8-1.cm2.x86_64.rpm
texinfo-debuginfo-6.8-1.cm2.x86_64.rpm
unzip-6.0-20.cm2.x86_64.rpm

Просмотреть файл

@ -416,7 +416,7 @@ chroot_and_install_rpms lua lua
build_rpm_in_chroot_no_install lua-rpm-macros
chroot_and_install_rpms lua-rpm-macros
# Build tdnf-3.2.2
# Build tdnf-3.5.2
build_rpm_in_chroot_no_install kmod
build_rpm_in_chroot_no_install perl-XML-Parser
build_rpm_in_chroot_no_install libssh2

Просмотреть файл

@ -543,7 +543,6 @@ func initializeRpmDatabase(installRoot string, diffDiskBuild bool) (err error) {
return err
}
}
err = initializeTdnfConfiguration(installRoot)
return
}
@ -610,63 +609,6 @@ func TdnfInstallWithProgress(packageName, installRoot string, currentPackagesIns
return
}
// initializeTdnfConfiguration installs the 'mariner-release' package
// into the clean RPM root. The package is used by tdnf to properly set
// the default values for its variables and internal configuration.
func initializeTdnfConfiguration(installRoot string) (err error) {
const (
squashErrors = false
releasePackage = "mariner-release"
)
var (
releaseverCliArg string
)
logger.Log.Debugf("Downloading '%s' package to a clean RPM root under '%s'.", releasePackage, installRoot)
releaseverCliArg, err = tdnf.GetReleaseverCliArg()
if err != nil {
return
}
err = shell.ExecuteLive(squashErrors, "tdnf", "download", releaseverCliArg, "--alldeps", "--destdir", installRoot, releasePackage)
if err != nil {
logger.Log.Errorf("Failed to prepare the RPM database on downloading the 'mariner-release' package: %v", err)
return
}
rpmSearch := filepath.Join(installRoot, "*.rpm")
rpmFiles, err := filepath.Glob(rpmSearch)
if err != nil {
logger.Log.Errorf("Failed to prepare the RPM database while searching for RPM files: %v", err)
return
}
defer func() {
logger.Log.Tracef("Cleaning up leftover RPM files after installing 'mariner-release' package under '%s'.", installRoot)
for _, file := range rpmFiles {
err = os.Remove(file)
if err != nil {
logger.Log.Errorf("Failed to prepare the RPM database on removing leftover file (%s): %v", file, err)
return
}
}
}()
logger.Log.Debugf("Installing 'mariner-release' package to a clean RPM root under '%s'.", installRoot)
rpmArgs := []string{"-i", "--root", installRoot}
rpmArgs = append(rpmArgs, rpmFiles...)
err = shell.ExecuteLive(squashErrors, "rpm", rpmArgs...)
if err != nil {
logger.Log.Errorf("Failed to prepare the RPM database on installing the 'mariner-release' package: %v", err)
return
}
return
}
func configureSystemFiles(installChroot *safechroot.Chroot, hostname string, config configuration.SystemConfig, installMap, mountPointToFsTypeMap, mountPointToMountArgsMap, partIDToDevPathMap, partIDToFsTypeMap map[string]string, encryptedRoot diskutils.EncryptedRootDevice, hidepidEnabled bool) (err error) {
// Update hosts file
err = updateHosts(installChroot.RootDir(), hostname)

Просмотреть файл

@ -110,16 +110,17 @@ func buildSystemConfig(systemConfig configuration.SystemConfig, disks []configur
defer timestamp.StopEvent(nil)
const (
assetsMountPoint = "/installer"
localRepoMountPoint = "/mnt/cdrom/RPMS"
repoFileMountPoint = "/etc/yum.repos.d"
setupRoot = "/setuproot"
installRoot = "/installroot"
rootID = "rootfs"
defaultDiskIndex = 0
defaultTempDiskName = "disk.raw"
existingChrootDir = false
leaveChrootOnDisk = false
assetsMountPoint = "/installer"
localRepoMountPoint = "/mnt/cdrom/RPMS"
repoFileMountPoint = "/etc/yum.repos.d"
setupRoot = "/setuproot"
installRoot = "/installroot"
rootID = "rootfs"
defaultDiskIndex = 0
defaultTempDiskName = "disk.raw"
existingChrootDir = false
leaveChrootOnDisk = false
marinerReleasePackage = "mariner-release"
)
var (
@ -144,6 +145,11 @@ func buildSystemConfig(systemConfig configuration.SystemConfig, disks []configur
return
}
// Mariner images don't work appropriately when mariner-release is not installed.
// As a stopgap to this, mariner-release will now be added to all images regardless
// of presence in the CONFIG_FILE
packagesToInstall = append([]string{marinerReleasePackage}, packagesToInstall...)
isRootFS = len(systemConfig.PartitionSettings) == 0
if isRootFS {
logger.Log.Infof("Creating rootfs")

Просмотреть файл

@ -361,15 +361,15 @@ func (r *RpmRepoCloner) Clone(cloneDeps bool, packagesToClone ...*pkgjson.Packag
logger.Log.Debugf("Cloning: %s", pkgName)
args := []string{
"--destdir",
"--downloaddir",
downloadDir,
pkgName,
}
if cloneDeps {
args = append([]string{"download", "--alldeps"}, args...)
args = append([]string{"install", "-y", "--downloadonly", "--alldeps"}, args...)
} else {
args = append([]string{"download-nodeps"}, args...)
args = append([]string{"install", "-y", "--downloadonly", "--nodeps"}, args...)
}
err = r.chroot.Run(func() (err error) {