Skip to content

Add option to enable new Rust based mDNS backend - #209

Merged
Biswa96 merged 1 commit into
nmeum:masterfrom
luk1337:luk/mdns
Aug 13, 2026
Merged

Add option to enable new Rust based mDNS backend#209
Biswa96 merged 1 commit into
nmeum:masterfrom
luk1337:luk/mdns

Conversation

@luk1337

@luk1337 luk1337 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Fixes: #181

@luk1337
luk1337 force-pushed the luk/mdns branch 2 times, most recently from 023d174 to e4dd9f8 Compare August 2, 2026 09:25
@luk1337

luk1337 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author
diff --git a/android-tools.spec b/android-tools.spec
index 7ead2af..89edc79 100644
--- a/android-tools.spec
+++ b/android-tools.spec
@@ -13,7 +13,10 @@ Source0:       https://github.com/nmeum/%{name}/releases/download/%{version}/%{n
 Patch:         https://github.com/nmeum/android-tools/pull/208.patch
 
 BuildRequires: brotli-devel
+BuildRequires: cargo
+BuildRequires: cargo-rpm-macros
 BuildRequires: cmake
+BuildRequires: corrosion
 BuildRequires: fmt-devel
 BuildRequires: gcc
 BuildRequires: gcc-c++
@@ -58,13 +61,18 @@ setup between the host and the target phone as adb.
 %autosetup -p1
 
 %build
-%cmake -DBUILD_SHARED_LIBS:BOOL=OFF
+%cmake -DANDROID_TOOLS_ADB_ENABLE_MDNS:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=OFF
 %cmake_build
 
+pushd vendor/adb/client/adbmdns
+%cargo_vendor_manifest
+popd
+
 %install
 %cmake_install
 
 %files
+%license vendor/adb/client/adbmdns/cargo-vendor.txt
 %{_bindir}/adb
 %{_bindir}/avbtool
 %{_bindir}/mke2fs.android

spec diff for those that do rpm packaging.

@Biswa96

Biswa96 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Is it required to vendor rust crates? Those increase tarball size and total rust vendor directory is 220 MB.

@luk1337

luk1337 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Is it required to vendor rust crates? Those increase tarball size and total rust vendor directory is 220 MB.

if you want to support distro packaging - yes.

@Biswa96

Biswa96 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Would it be difficult for distributions to follow similar steps as other Rust packages?

@luk1337

luk1337 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Would it be difficult for distributions to follow similar steps as other Rust packages?

for anything but nix the chance that all dependencies are already packaged is slim and getting them packaged (or updated) might take a lot of time.

@luk1337

luk1337 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Would it be difficult for distributions to follow similar steps as other Rust packages?

for anything but nix the chance that all dependencies are already packaged is slim and getting them packaged (or updated) might take a lot of time.

https://github.com/nmeum/android-tools/compare/934b9680c5a0e84406f142daf8b54e695bd6cf9c..ed9993bdaf60ba2634fbb1130abfc45c61fa4b9d should at least slightly help with that.

but on fedora there are still 2 missing crates (and probably their dependencies, if they aren't standalone):

Problem 1: nothing provides requested (crate(if-addrs/default) >= 0.14.0 with crate(if-addrs/default) < 0.15.0~)
Problem 2: nothing provides requested (crate(simple-dns/default) >= 0.11.0 with crate(simple-dns/default) < 0.12.0~)

@luk1337

luk1337 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Would it be difficult for distributions to follow similar steps as other Rust packages?

for anything but nix the chance that all dependencies are already packaged is slim and getting them packaged (or updated) might take a lot of time.

https://github.com/nmeum/android-tools/compare/934b9680c5a0e84406f142daf8b54e695bd6cf9c..ed9993bdaf60ba2634fbb1130abfc45c61fa4b9d should at least slightly help with that.

but on fedora there are still 2 missing crates (and probably their dependencies, if they aren't standalone):

Problem 1: nothing provides requested (crate(if-addrs/default) >= 0.14.0 with crate(if-addrs/default) < 0.15.0~)
Problem 2: nothing provides requested (crate(simple-dns/default) >= 0.11.0 with crate(simple-dns/default) < 0.12.0~)

https://bugzilla.redhat.com/show_bug.cgi?id=2512796
https://bugzilla.redhat.com/show_bug.cgi?id=2512797

I guess it's better for me to not depend on vendored deps anyway.

@luk1337
luk1337 force-pushed the luk/mdns branch 3 times, most recently from 3241556 to 8ee281f Compare August 9, 2026 08:16
@luk1337

luk1337 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

moved rust vendor tree to a separate tarball to match go2rpm style packaging.

@munix9

munix9 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

I created a local build on openSUSE Tumbleweed using the artifacts from build #326 and it looks good.

@luk1337

luk1337 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author
diff --git a/adb_mdns-fix-metadata.diff b/adb_mdns-fix-metadata.diff
new file mode 100644
index 0000000..9e9e268
--- /dev/null
+++ b/adb_mdns-fix-metadata.diff
@@ -0,0 +1,23 @@
+--- a/vendor/adb/client/adbmdns/Cargo.toml
++++ b/vendor/adb/client/adbmdns/Cargo.toml
+@@ -11,18 +11,10 @@ crate-type = ["staticlib"]
+ [dependencies]
+ socket2 = { version = "0.4.0", features = ["all"] }
+ log = {  version = "0.4.27" , features = ["std"] }
+-simple-dns = "0.11.0"
++simple-dns = "0.12.0"
+ zerocopy = { version = "0.8.26", features = ["derive"] }
+ libc = "0.2.174"
+ anyhow = "1.0.99"
+ nix = { version = "0.29.0", features = ["net", "socket", "uio"] }
+-if-addrs = "0.14.0"
++if-addrs = "0.15.0"
+ mio = { version = "1.1.0", features = ["net", "os-poll"] }
+-
+-[target.'cfg(windows)'.dependencies.windows-sys]
+-version = "0.61.1"
+-features = [
+-    "Win32_Foundation",
+-    "Win32_Networking_WinSock",
+-    "Win32_NetworkManagement_WiFi",
+-]
diff --git a/android-tools.spec b/android-tools.spec
index 7ead2af..50ebc9d 100644
--- a/android-tools.spec
+++ b/android-tools.spec
@@ -11,9 +11,15 @@ URL:           http://developer.android.com/guide/developing/tools/
 Source0:       https://github.com/nmeum/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz
 # https://github.com/nmeum/android-tools/pull/208
 Patch:         https://github.com/nmeum/android-tools/pull/208.patch
+# https://github.com/nmeum/android-tools/pull/209
+Patch:         209.patch
+# Update dependencies to match available packages
+Patch:         adb_mdns-fix-metadata.diff
 
 BuildRequires: brotli-devel
+BuildRequires: cargo-rpm-macros
 BuildRequires: cmake
+BuildRequires: corrosion
 BuildRequires: fmt-devel
 BuildRequires: gcc
 BuildRequires: gcc-c++
@@ -57,14 +63,29 @@ setup between the host and the target phone as adb.
 %prep
 %autosetup -p1
 
+pushd vendor/adb/client/adbmdns > /dev/null
+%cargo_prep
+popd > /dev/null
+
+%generate_buildrequires
+pushd vendor/adb/client/adbmdns > /dev/null
+%cargo_generate_buildrequires
+popd > /dev/null
+
 %build
-%cmake -DBUILD_SHARED_LIBS:BOOL=OFF
+%cmake -DANDROID_TOOLS_ADB_ENABLE_MDNS:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=OFF
 %cmake_build
 
+pushd vendor/adb/client/adbmdns > /dev/null
+%{cargo_license_summary}
+%{cargo_license} > LICENSE.dependencies
+popd > /dev/null
+
 %install
 %cmake_install
 
 %files
+%license vendor/adb/client/adbmdns/LICENSE.dependencies
 %{_bindir}/adb
 %{_bindir}/avbtool
 %{_bindir}/mke2fs.android

builds across all fedora arches - https://copr.fedorainfracloud.org/coprs/luk1337/test/build/10840424/

@munix9

munix9 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

I've now built the vendor archive using cargo_vendor for openSUSE and ended up with a significantly smaller file size:

-rw-r--r-- 1 abuild abuild  13M Aug  9 10:34 android-tools-37.0.0-vendor.tar.xz
-rw-r--r-- 1 abuild abuild 1.6M Aug 10 06:36 vendor.tar.zst

Even though zst is used here instead of xz, the difference is considerable.

As it stands now, openSUSE doesn’t need the corresponding android-tools-37.0.0-vendor.tar.xz, since the build works without any issues using the generated vendor.tar.zst.
However, I don’t think it’s a bad idea to offer it, since it might be necessary for other distributions.

@luk1337, is there a specific reason why you modified the Cargo.toml, particularly the versions of simple-dns and if-addrs?

https://build.opensuse.org/package/show/home:munix9:test/android-tools

@luk1337

luk1337 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

I've now built the vendor archive using cargo_vendor for openSUSE and ended up with a significantly smaller file size:

-rw-r--r-- 1 abuild abuild  13M Aug  9 10:34 android-tools-37.0.0-vendor.tar.xz
-rw-r--r-- 1 abuild abuild 1.6M Aug 10 06:36 vendor.tar.zst

Even though zst is used here instead of xz, the difference is considerable.

As it stands now, openSUSE doesn’t need the corresponding android-tools-37.0.0-vendor.tar.xz, since the build works without any issues using the generated vendor.tar.zst. However, I don’t think it’s a bad idea to offer it, since it might be necessary for other distributions.

@luk1337, is there a specific reason why you modified the Cargo.toml, particularly the versions of simple-dns and if-addrs?

https://build.opensuse.org/package/show/home:munix9:test/android-tools

I'm packaging newer versions of those, that's why.

@luk1337

luk1337 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

I've now built the vendor archive using cargo_vendor for openSUSE and ended up with a significantly smaller file size:

-rw-r--r-- 1 abuild abuild  13M Aug  9 10:34 android-tools-37.0.0-vendor.tar.xz
-rw-r--r-- 1 abuild abuild 1.6M Aug 10 06:36 vendor.tar.zst

Even though zst is used here instead of xz, the difference is considerable.
As it stands now, openSUSE doesn’t need the corresponding android-tools-37.0.0-vendor.tar.xz, since the build works without any issues using the generated vendor.tar.zst. However, I don’t think it’s a bad idea to offer it, since it might be necessary for other distributions.
@luk1337, is there a specific reason why you modified the Cargo.toml, particularly the versions of simple-dns and if-addrs?
https://build.opensuse.org/package/show/home:munix9:test/android-tools

I'm packaging newer versions of those, that's why.

and %cargo_generate_buildrequires puts version constraint on them.

@Biswa96
Biswa96 merged commit 0b7aaaf into nmeum:master Aug 13, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[F-req] adb mdns service

3 participants