Add ALT Linux support

This commit is contained in:
Alexander Burmatov 2024-07-11 02:46:07 +03:00
parent af18754224
commit 8bc333f3aa
6 changed files with 70 additions and 0 deletions

37
.gear/apt-pkg-native.spec Normal file
View File

@ -0,0 +1,37 @@
Name: apt-pkg-native
Version: 0.3.2
Release: alt1
Summary: Rust bindings for libapt-pkg
License: MIT
Group: Development/Tools
Url: https://github.com/FauxFaux/apt-pkg-native-rs
Source: %name-%version.tar
BuildRequires(pre): rpm-build-rust
BuildRequires: /proc
BuildRequires: rust-cargo
%description
This crate provides bindings to libapt-pkg.
%prep
%setup
%build
%rust_build
%install
%rust_install
%check
%rust_test
%files
%_bindir/*
%doc LICENSE-MIT README.md
%changelog
* Mon Jun 19 2023 Alexander Burmatov <thatman@altlinux.org> 0.3.2-alt1
- Initial build for Sisyphus.

2
.gear/rules Normal file
View File

@ -0,0 +1,2 @@
spec: .gear/apt-pkg-native.spec
tar: .

3
.gear/upstream/remotes Normal file
View File

@ -0,0 +1,3 @@
[remote "upstream"]
url = git@github.com:FauxFaux/apt-pkg-native-rs.git
fetch = +refs/heads/*:refs/remotes/upstream/*

View File

@ -30,3 +30,4 @@ itertools = "0.9"
[features]
default = []
ye-olde-apt = []
alt-linux = []

View File

@ -175,6 +175,8 @@ void init_config_system() {
pkgInitSystem(*_config, _system);
}
#ifndef ALT_LINUX
PCache *pkg_cache_create() {
pkgCacheFile *cache_file = new pkgCacheFile();
pkgCache *cache = cache_file->GetPkgCache();
@ -188,6 +190,8 @@ PCache *pkg_cache_create() {
return ret;
}
#endif
void pkg_cache_release(PCache *cache) {
// TODO: is cache->cache cleaned up with cache->cache_file?
delete cache->records;
@ -214,6 +218,8 @@ PPkgIterator *pkg_cache_find_name(PCache *cache, const char *name) {
return wrapper;
}
#ifndef ALT_LINUX
PPkgIterator *pkg_cache_find_name_arch(PCache *cache, const char *name, const char *arch) {
PPkgIterator *wrapper = new PPkgIterator();
wrapper->iterator = cache->cache->FindPkg(name, arch);
@ -221,6 +227,8 @@ PPkgIterator *pkg_cache_find_name_arch(PCache *cache, const char *name, const ch
return wrapper;
}
#endif
void pkg_iter_release(PPkgIterator *wrapper) {
delete wrapper;
}
@ -237,6 +245,8 @@ const char *pkg_iter_name(PPkgIterator *wrapper) {
return wrapper->iterator.Name();
}
#ifndef ALT_LINUX
const char *pkg_iter_arch(PPkgIterator *wrapper) {
return wrapper->iterator.Arch();
}
@ -253,6 +263,8 @@ const char *pkg_iter_candidate_version(PPkgIterator *wrapper) {
return it.VerStr();
}
#endif
PVerIterator *pkg_iter_ver_iter(PPkgIterator *wrapper) {
PVerIterator *new_wrapper = new PVerIterator();
new_wrapper->iterator = wrapper->iterator.VersionList();
@ -287,6 +299,7 @@ const char *ver_iter_priority_type(PVerIterator *wrapper) {
}
#ifndef YE_OLDE_APT
#ifndef ALT_LINUX
const char *ver_iter_source_package(PVerIterator *wrapper) {
return wrapper->iterator.SourcePkgName();
@ -302,6 +315,7 @@ int32_t ver_iter_priority(PVerIterator *wrapper) {
return wrapper->cache->cache_file->GetPolicy()->GetPriority(wrapper->iterator);
}
#endif
#endif
const char *ver_iter_arch(PVerIterator *wrapper) {
@ -390,11 +404,15 @@ const char *ver_file_parser_maintainer(PVerFileParser *parser) {
return to_c_string(maint);
}
#ifndef ALT_LINUX
const char *ver_file_parser_homepage(PVerFileParser *parser) {
std::string hp = parser->parser->Homepage();
return to_c_string(hp);
}
#endif
bool ver_file_iter_end(PVerFileIterator *wrapper) {
return wrapper->iterator.end();
}
@ -433,10 +451,14 @@ const char *pkg_file_iter_origin(PPkgFileIterator *wrapper) {
return wrapper->iterator.Origin();
}
#ifndef ALT_LINUX
const char *pkg_file_iter_codename(PPkgFileIterator *wrapper) {
return wrapper->iterator.Codename();
}
#endif
const char *pkg_file_iter_label(PPkgFileIterator *wrapper) {
return wrapper->iterator.Label();
}

View File

@ -15,6 +15,11 @@ fn main() {
build.define("YE_OLDE_APT", "1");
}
#[cfg(feature = "alt-linux")]
{
build.define("ALT_LINUX", "1");
}
build.compile("libapt-pkg-c.a");
println!("cargo:rustc-link-lib=apt-pkg");