Skip to content

Commit

Permalink
Merge pull request #375 from oliverkurth/stable-3.4
Browse files Browse the repository at this point in the history
Changes for release 3.4.4
  • Loading branch information
oliverkurth authored Dec 9, 2022
2 parents 7547615 + b8f0032 commit aa26146
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 79 deletions.
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.4.3 LANGUAGES C)
project(tdnf VERSION 3.4.4 LANGUAGES C)
set(VERSION ${PROJECT_VERSION})
set(PROJECT_YEAR 2022)

Expand Down
3 changes: 1 addition & 2 deletions client/plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,8 @@ _TDNFLoadPluginLibs(
}
dwError = TDNFAllocateStringPrintf(
&pszPlugin,
"%s/%s/lib%s.so",
"%s/lib%s.so",
pszLibPath,
pPlugin->pszName,
pPlugin->pszName);
BAIL_ON_TDNF_ERROR(dwError);

Expand Down
6 changes: 0 additions & 6 deletions client/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,6 @@ TDNFFreeHistoryInfoItems(
int nCount
);

uint32_t
TDNFCheckRepoMDFileHashFromMetalink(
const char *pszFile,
TDNF_ML_CTX *ml_ctx
);

//remoterepo.c
uint32_t
TDNFDownloadFileFromRepo(
Expand Down
34 changes: 0 additions & 34 deletions client/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,40 +81,6 @@ typedef struct _TDNF_EVENT_DATA_
struct _TDNF_EVENT_DATA_ *pNext;
} TDNF_EVENT_DATA, *PTDNF_EVENT_DATA;

//Metalink Structures.
typedef struct _TDNF_ML_LIST_
{
struct _TDNF_ML_LIST_ *next;
void* data;
} TDNF_ML_LIST, TDNF_ML_URL_LIST, TDNF_ML_HASH_LIST;

//Metalink hash info per hash type.
typedef struct _TDNF_ML_HASH_INFO_
{
char *type;
char *value;
} TDNF_ML_HASH_INFO;

//Metalink url info per hash type.
typedef struct _TDNF_ML_URL_INFO_
{
char *protocol;
char *type;
char *location;
char *url;
int preference;
} TDNF_ML_URL_INFO;

//Metalink global parsed info.
typedef struct _TDNF_ML_CTX_
{
char *filename;
signed long timestamp;
signed long size;
TDNF_ML_LIST *hashes;
TDNF_ML_LIST *urls;
} TDNF_ML_CTX;

typedef struct progress_cb_data {
time_t cur_time;
time_t prev_time;
Expand Down
2 changes: 1 addition & 1 deletion plugins/metalink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ target_link_libraries(${PROJECT_NAME}
)

set_target_properties(${PROJECT_NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/lib/${PROJECT_NAME})
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/lib)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/tdnf-plugins)
6 changes: 6 additions & 0 deletions plugins/metalink/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ TDNFParseUrlTag(
xmlNode *node
);

uint32_t
TDNFCheckRepoMDFileHashFromMetalink(
const char *pszFile,
TDNF_ML_CTX *ml_ctx
);

// api.c

const char *
Expand Down
34 changes: 34 additions & 0 deletions plugins/metalink/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,40 @@

#pragma once

//Metalink Structures.
typedef struct _TDNF_ML_LIST_
{
struct _TDNF_ML_LIST_ *next;
void* data;
} TDNF_ML_LIST, TDNF_ML_URL_LIST, TDNF_ML_HASH_LIST;

//Metalink hash info per hash type.
typedef struct _TDNF_ML_HASH_INFO_
{
char *type;
char *value;
} TDNF_ML_HASH_INFO;

//Metalink url info per hash type.
typedef struct _TDNF_ML_URL_INFO_
{
char *protocol;
char *type;
char *location;
char *url;
int preference;
} TDNF_ML_URL_INFO;

//Metalink global parsed info.
typedef struct _TDNF_ML_CTX_
{
char *filename;
signed long timestamp;
signed long size;
TDNF_ML_LIST *hashes;
TDNF_ML_LIST *urls;
} TDNF_ML_CTX;

/* per repo */
typedef struct _TDNF_METALINK_DATA_
{
Expand Down
50 changes: 33 additions & 17 deletions plugins/metalink/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ TDNFCheckRepoMDFileHashFromMetalink(
{
uint32_t dwError = 0;
TDNF_ML_HASH_LIST *hashList = NULL;
TDNF_ML_HASH_INFO *hashInfo = NULL;
unsigned char digest[EVP_MAX_MD_SIZE] = {0};
int hash_Type = -1;
TDNF_ML_HASH_INFO *currHashInfo = NULL;
Expand All @@ -383,6 +382,7 @@ TDNFCheckRepoMDFileHashFromMetalink(
BAIL_ON_TDNF_ERROR(dwError);
}

/* find best (highest) available hash type */
for(hashList = ml_ctx->hashes; hashList; hashList = hashList->next)
{
int currHashType = TDNF_HASH_SENTINEL;
Expand All @@ -397,28 +397,42 @@ TDNFCheckRepoMDFileHashFromMetalink(
dwError = TDNFGetResourceType(currHashInfo->type, &currHashType);
BAIL_ON_TDNF_ERROR(dwError);

if ((hash_Type > currHashType)||
(!TDNFCheckHexDigest(currHashInfo->value, hash_ops[currHashType].length)))
{
continue;
}
hash_Type = currHashType;
hashInfo = currHashInfo;
if (hash_Type < currHashType)
hash_Type = currHashType;
}

if (hashInfo != NULL)
{
dwError = TDNFChecksumFromHexDigest(hashInfo->value, digest);
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFCheckHash(pszFile, digest, hash_Type);
if (hash_Type < 0) {
/* no hash type was found */
dwError = ERROR_TDNF_INVALID_REPO_FILE;
BAIL_ON_TDNF_ERROR(dwError);
}
else
/* otherwise hash_Type is the best one */

/* now check for all best hash types. Test until one succeeds
or until we run out */
for(hashList = ml_ctx->hashes; hashList; hashList = hashList->next)
{
dwError = ERROR_TDNF_INVALID_REPO_FILE;
int currHashType = TDNF_HASH_SENTINEL;
currHashInfo = hashList->data;

dwError = TDNFGetResourceType(currHashInfo->type, &currHashType);
BAIL_ON_TDNF_ERROR(dwError);

/* filter for our best type and also check that the value is valid */
if (hash_Type == currHashType &&
TDNFCheckHexDigest(currHashInfo->value, hash_ops[currHashType].length)) {
dwError = TDNFChecksumFromHexDigest(currHashInfo->value, digest);
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFCheckHash(pszFile, digest, hash_Type);
if (dwError != 0 && dwError != ERROR_TDNF_CHECKSUM_VALIDATION_FAILED) {
BAIL_ON_TDNF_ERROR(dwError);
}
if (dwError == 0)
break;
}
}

cleanup:
return dwError;
error:
Expand Down Expand Up @@ -766,7 +780,9 @@ TDNFXmlParseData(
BAIL_ON_TDNF_ERROR(dwError);
}
}
TDNFXmlParseData(ml_ctx, node->children, filename);
if (node->children) {
TDNFXmlParseData(ml_ctx, node->children, filename);
}
node = node->next;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/repogpgcheck/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ target_link_libraries(${PROJECT_NAME}
)

set_target_properties(${PROJECT_NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/lib/${PROJECT_NAME})
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/lib)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/tdnf-plugins)
23 changes: 9 additions & 14 deletions tdnf.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ mkdir build && cd build
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
-DCMAKE_INSTALL_LIBDIR=%{_libdir} \
-DSYSTEMD_DIR=%{_unitdir} \
..

Expand All @@ -130,15 +130,10 @@ cd build && make %{?_smp_mflags} check
%install
cd build && make DESTDIR=%{buildroot} install %{?_smp_mflags}
find %{buildroot} -name '*.a' -delete
mkdir -p %{buildroot}/var/cache/tdnf %{buildroot}%{_unitdir}
ln -sf %{_bindir}/tdnf %{buildroot}%{_bindir}/tyum
ln -sf %{_bindir}/tdnf %{buildroot}%{_bindir}/yum
ln -sf %{_bindir}/tdnf %{buildroot}%{_bindir}/tdnfj
mv %{buildroot}%{_libdir}/pkgconfig/tdnfcli.pc %{buildroot}%{_libdir}/pkgconfig/tdnf-cli-libs.pc
mkdir -p %{buildroot}%{_tdnfpluginsdir}/tdnfmetalink
mkdir -p %{buildroot}%{_tdnfpluginsdir}/tdnfrepogpgcheck
mv %{buildroot}%{_tdnfpluginsdir}/libtdnfmetalink.so %{buildroot}%{_tdnfpluginsdir}/tdnfmetalink/
mv %{buildroot}%{_tdnfpluginsdir}/libtdnfrepogpgcheck.so %{buildroot}%{_tdnfpluginsdir}/tdnfrepogpgcheck/
mkdir -p %{buildroot}/var/cache/%{name} %{buildroot}%{_unitdir}
ln -sfv %{name} %{buildroot}%{_bindir}/tyum
ln -sfv %{name} %{buildroot}%{_bindir}/yum
ln -sfv %{name} %{buildroot}%{_bindir}/tdnfj

pushd python
python3 setup.py install --skip-build --prefix=%{_prefix} --root=%{buildroot}
Expand Down Expand Up @@ -235,13 +230,13 @@ systemctl try-restart tdnf-cache-updateinfo.timer >/dev/null 2>&1 || :
%defattr(-,root,root)
%dir %{_sysconfdir}/tdnf/pluginconf.d
%config(noreplace) %{_sysconfdir}/tdnf/pluginconf.d/tdnfmetalink.conf
%{_tdnfpluginsdir}/tdnfmetalink/libtdnfmetalink.so
%{_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}/%{name}/pluginconf.d
%config(noreplace) %{_sysconfdir}/%{name}/pluginconf.d/tdnfrepogpgcheck.conf
%{_tdnfpluginsdir}/libtdnfrepogpgcheck.so

%files python
%defattr(-,root,root)
Expand Down
6 changes: 3 additions & 3 deletions tools/cli/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

# configure pkgconfig file
configure_file(
tdnfcli.pc.in
tdnfcli.pc @ONLY
tdnf-cli-libs.pc.in
tdnf-cli-libs.pc @ONLY
)

add_library(${LIB_TDNF_CLI} SHARED
Expand Down Expand Up @@ -38,5 +38,5 @@ set_target_properties(${LIB_TDNF_CLI} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LIB_TDNF_CLI}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tdnf-cli-libs.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(TARGETS ${LIB_TDNF_CLI} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library)
File renamed without changes.

0 comments on commit aa26146

Please sign in to comment.