diff --git a/.gear/apt-pkg-native.spec b/.gear/apt-pkg-native.spec new file mode 100644 index 0000000..8e47225 --- /dev/null +++ b/.gear/apt-pkg-native.spec @@ -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 0.3.2-alt1 +- Initial build for Sisyphus. diff --git a/.gear/rules b/.gear/rules new file mode 100644 index 0000000..c286aec --- /dev/null +++ b/.gear/rules @@ -0,0 +1,2 @@ +spec: .gear/apt-pkg-native.spec +tar: . diff --git a/.gear/upstream/remotes b/.gear/upstream/remotes new file mode 100644 index 0000000..1b4201b --- /dev/null +++ b/.gear/upstream/remotes @@ -0,0 +1,3 @@ +[remote "upstream"] + url = git@github.com:FauxFaux/apt-pkg-native-rs.git + fetch = +refs/heads/*:refs/remotes/upstream/* diff --git a/Cargo.toml b/Cargo.toml index af74abb..bde18ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,3 +30,4 @@ itertools = "0.9" [features] default = [] ye-olde-apt = [] +alt-linux = [] \ No newline at end of file diff --git a/apt-pkg-c/lib.cpp b/apt-pkg-c/lib.cpp index 22dc5f7..3d87a50 100644 --- a/apt-pkg-c/lib.cpp +++ b/apt-pkg-c/lib.cpp @@ -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(); } diff --git a/build.rs b/build.rs index 92fe3e3..7ee980c 100644 --- a/build.rs +++ b/build.rs @@ -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");