Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

python/rust ebuild with maturin - GIT_CRATES issue [SOLVED]

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
5 posts • Page 1 of 1
Author
Message
xiwi
n00b
n00b
Posts: 23
Joined: Wed Aug 21, 2024 9:57 am

python/rust ebuild with maturin - GIT_CRATES issue [SOLVED]

  • Quote

Post by xiwi » Wed Aug 21, 2024 10:55 am

Hello,

I've been trying to make an up-to-date ebuild for mitmproxy (the current package in the gentoo repo is unmaintained and out of date), and I'm running into an issue for a dependency mitmproxy_rs (which replaces mitmproxy_wireguard). It uses "Maturin" as it's build back-end, but I don't understand how it has to work with a GIT_CRATES declaration.

mitmproxy_rs ebuild
build.log
emerge --info output


So it seems to me that Maturin is trying to get the git dependency itself rather than using the one provided by portage? I looked at the documentation of Maturin, but it did not make me any wiser.

Thanks!
Last edited by xiwi on Sat Aug 24, 2024 5:01 pm, edited 1 time in total.
Top
salahx
Guru
Guru
Posts: 572
Joined: Sat Mar 12, 2005 6:39 am

  • Quote

Post by salahx » Wed Aug 21, 2024 4:50 pm

The problem is this construction in Cargo.toml:

[patch.crates-io]
# tokio = { path = "../tokio/tokio" }
smoltcp = { git = 'https://github.com/smoltcp-rs/smoltcp', rev = 'ef67e7b46cabf49783053cbf68d8671ed97ff8d4' }
boringtun = { git = 'https://github.com/cloudflare/boringtun', rev = 'e3252d9c4f4c8fc628995330f45369effd4660a1' }

What this does is it tells cargo to patch the upstream frozen sources with unreleased git sources, which is cannot do offline. You need to patch Cargo.toml in src_prepare with sed.

See the dev-python/uv ebuild and https://github.com/robert7k/gentoo-over ... 9.3.ebuild for some idea how to patch around this.
Top
salahx
Guru
Guru
Posts: 572
Joined: Sat Mar 12, 2005 6:39 am

  • Quote

Post by salahx » Wed Aug 21, 2024 11:26 pm

This was my solution I used in an old ebuild:

Code: Select all

src_prepare() {
	local crate commit mypath _uri sedexpr
	local -a sedexpr
	for crate in "${!GIT_CRATES[@]}"; do
		IFS=";" read -r _uri commit mypath <<< "${GIT_CRATES[${crate}]}"
		if [ -z "${mypath}" ]; then
			mypath="${crate}-%commit%"
		fi
		sedexpr+=(
			"s@^(${crate}[[:space:]]*=[[:space:]]*[{].*)([[:space:]]*git[[:space:]]*=[[:space:]]*\"[[:graph:]]+\"[[:space:]]*)(.*[}])@\1path = \"${WORKDIR}/${mypath//%commit%/${commit}}\"\3@ ;"
			"s@^(${crate}[[:space:]]*=[[:space:]]*[{].*)([[:space:]]*git[[:space:]]*=[[:space:]]*'[[:graph:]]+'[[:space:]]*)(.*[}])@\1path = '${WORKDIR}/${mypath//%commit%/${commit}}'\3@ ;"
			"s@^(${crate}[[:space:]]*=[[:space:]]*[{].*)([,][[:space:]]*rev[[:space:]]*=[[:space:]]*\"[[:graph:]]+\"[[:space:]]*)(.*[}])@\1\3@ ;"
		)
	done
	sed -r -i "${sedexpr[*]}" "${S}/Cargo.toml" || die

        default
}
Top
xiwi
n00b
n00b
Posts: 23
Joined: Wed Aug 21, 2024 9:57 am

  • Quote

Post by xiwi » Sat Aug 24, 2024 5:00 pm

Thanks, I got it working with

Code: Select all

src_prepare() {
	local COMMIT="ef67e7b46cabf49783053cbf68d8671ed97ff8d4"
	sed -i -e "/^\[patch/,\$s@^\(smoltcp = \).*@\1 { path = \"${WORKDIR}/smoltcp-${COMMIT}/\" }@" Cargo.toml || die
	default

}
I got the rest working but i need to clean the ebuild up a bit :roll:
Top
Ionen
Developer
Developer
User avatar
Posts: 3013
Joined: Thu Dec 06, 2018 2:23 pm

  • Quote

Post by Ionen » Sat Aug 24, 2024 5:08 pm

Yeah upstreams using [patch] with a git crate been becoming more common, unfortunately eclass doesn't have a clean solution to deal with that at the moment so a sed/patch is the best one can do.

Thankfully [patch] tend to be temporary and may be able to drop the hack on a future bump.
Top
Post Reply

5 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic