New feature

This commit is contained in:
Alexander Burmatov 2024-08-02 18:57:04 +03:00
parent 8bc333f3aa
commit 51f7abc311
3 changed files with 56 additions and 3 deletions

View File

@ -1,3 +1,4 @@
%define bin_name lib%name
Name: apt-pkg-native
Version: 0.3.2
Release: alt1
@ -12,6 +13,8 @@ Source: %name-%version.tar
BuildRequires(pre): rpm-build-rust
BuildRequires: /proc
BuildRequires: rust-cargo
BuildRequires: gcc-c++
BuildRequires: libapt-devel
%description
This crate provides bindings to libapt-pkg.
@ -20,10 +23,11 @@ This crate provides bindings to libapt-pkg.
%setup
%build
%rust_build
%rust_build --features alt-linux
# --features ye-olde-apt
%install
%rust_install
%rust_install %bin_name
%check
%rust_test

View File

@ -190,6 +190,21 @@ PCache *pkg_cache_create() {
return ret;
}
#else
PCache *pkg_cache_create(const bool WithLock, OpProgress &Progress) {
pkgCacheFile *cache_file = new pkgCacheFile(WithLock);
pkgCache *cache = cache_file->GetPkgCache(Progress);
pkgRecords *records = new pkgRecords(*cache);
PCache *ret = new PCache();
ret->cache_file = cache_file;
ret->cache = cache;
ret->records = records;
return ret;
}
#endif
void pkg_cache_release(PCache *cache) {
@ -227,6 +242,15 @@ PPkgIterator *pkg_cache_find_name_arch(PCache *cache, const char *name, const ch
return wrapper;
}
#else
PPkgIterator *pkg_cache_find_name_arch(PCache *cache, const char *name) {
PPkgIterator *wrapper = new PPkgIterator();
wrapper->iterator = cache->cache->FindPkg(name);
wrapper->cache = cache;
return wrapper;
}
#endif
void pkg_iter_release(PPkgIterator *wrapper) {
@ -263,6 +287,24 @@ const char *pkg_iter_candidate_version(PPkgIterator *wrapper) {
return it.VerStr();
}
#else
// const char *pkg_iter_arch(PPkgIterator *wrapper) {
// return wrapper->iterator.Arch();
// }
// const char *pkg_iter_current_version(PPkgIterator *wrapper) {
// return wrapper->iterator.CurVersion();
// }
const char *pkg_iter_candidate_version(PPkgIterator *wrapper, OpProgress &Progress) {
pkgCache::VerIterator it = wrapper->cache->cache_file->GetPolicy(Progress)->GetCandidateVer(wrapper->iterator);
if (it.end()) {
return nullptr;
}
return it.VerStr();
}
#endif
PVerIterator *pkg_iter_ver_iter(PPkgIterator *wrapper) {

View File

@ -8,7 +8,14 @@ fn main() {
let mut build = cc::Build::new();
build.file(SRC);
build.cpp(true);
build.flag("-std=gnu++11");
#[cfg(feature = "alt-linux")]
{
build.flag("-std=gnu++17");
}
#[cfg(not(feature = "alt-linux"))]
{
build.flag("-std=gnu++11");
}
#[cfg(feature = "ye-olde-apt")]
{