View previous topic :: View next topic |
Author |
Message |
JarzaClay n00b
Joined: 21 Aug 2024 Posts: 23
|
Posted: Wed Aug 21, 2024 8:36 pm Post subject: Automatically modifying custom "forked" .ebuilds |
|
|
I want to modify the gentoo-sources ebuild to include this snippet:
Code: | post_pkg_postinst() {
# Eselect the new kernel or genkernel will build the current one
eselect kernel set linux-"${KV}"
CURRENT_KV=$(uname -r)
# Check if genkernel has been run previously for the running kernel and use that config
if [[ -f "${EROOT}/etc/kernels/kernel-config-${CURRENT_KV}" ]] ; then
genkernel --no-module-rebuild --kernel-config="${EROOT}/etc/kernels/kernel-config-${CURRENT_KV}" all
# Use latest kernel config from current kernel
elif [[ -f "${EROOT}/usr/src/linux-${CURRENT_KV}/.config" ]] ; then
genkernel --no-module-rebuild --kernel-config="${EROOT}/usr/src/linux-${CURRENT_KV}/.config" all
# Use known running good kernel
elif [[ -f /proc/config.gz ]] ; then
zcat /proc/config.gz >> "${EROOT}/tmp/genkernel.config"
genkernel --no-module-rebuild --kernel-config="${EROOT}/tmp/genkernel.config" all
rm "${EROOT}/tmp/genkernel.config"
# No valid configs known, compile a clean one
else
genkernel --no-module-rebuild all
fi
} |
How can I do this, and also pull the lastest version when updating with portage, without having to rewrite it every update?
Last edited by JarzaClay on Mon Aug 26, 2024 3:51 pm; edited 1 time in total |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20476
|
|
Back to top |
|
|
JarzaClay n00b
Joined: 21 Aug 2024 Posts: 23
|
Posted: Wed Aug 21, 2024 10:50 pm Post subject: |
|
|
How could I do this by hosting my own repository? I wouldn't like to necessarily maintain it, I just want it to automatically pull the latest package version, while maintaining the same post_pkg_postinst() declaration. Is there a way that I could just add changes from other parts of the ebuild, and disregard updates to post_pkg_postinst()? |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22602
|
Posted: Wed Aug 21, 2024 11:09 pm Post subject: |
|
|
Isn't post_pkg_postinst reserved for use outside the ebuild, such that you can guarantee the ebuild will not define that function? Anything the ebuild needs for this phase should be in pkg_postinst. If so, a bashrc hook defining post_pkg_postinst for this package should suffice, and would let you avoid ever modifying the ebuild. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20476
|
Posted: Thu Aug 22, 2024 12:20 am Post subject: |
|
|
JarzaClay wrote: | How could I do this by hosting my own repository? I wouldn't like to necessarily maintain it, I just want it to automatically pull the latest package version, while maintaining the same post_pkg_postinst() declaration. Is there a way that I could just add changes from other parts of the ebuild, and disregard updates to post_pkg_postinst()? | You mentioned wanting to modify an ebuild. The only way to really do that is to put it in a local repository. I wasn't familiar with post_pkg_postinst() and didn't realize it wasn't a "real" ebuild function. So that wouldn't modify the ebuild itself.
The portage bashrc concept would be the correct method. One thing to remember is that it runs for every package. So instead...
You'd put your function in:
/etc/portage/env/sys-kernel/gentoo-sources
I don't know if putting it in there itself is sufficient. I've used it without a function and added my own checks, so that's probably not the best method, but it works. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
JarzaClay n00b
Joined: 21 Aug 2024 Posts: 23
|
Posted: Thu Aug 22, 2024 1:46 pm Post subject: |
|
|
Thank you guys for all of your help! I was under the impression that this was a function of an ebuild, but it isn't. Thanks again for all of your help, I will test this tonight! |
|
Back to top |
|
|
sam_ Developer
Joined: 14 Aug 2020 Posts: 1946
|
Posted: Fri Aug 23, 2024 2:03 pm Post subject: |
|
|
That said, what you're doing is essentially what gentoo-kernel does. Please consider using that. |
|
Back to top |
|
|
spica Guru
Joined: 04 Jun 2021 Posts: 329
|
Posted: Sun Sep 01, 2024 7:39 am Post subject: Re: |
|
|
JarzaClay wrote: | I want to modify the gentoo-sources ebuild [...] and also pull the lastest version when updating with portage, without having to rewrite it every update? |
In general programming, when we re-use code from another file, we either copy the block of code or include the whole file.
Since the https://projects.gentoo.org/qa/policy-guide/ebuild-format.html#pg0102 policy requires that code be contained in ebuild/class files, and sourceing/evaling is not allowed for non-ebuild/class files, this makes it semiacceptable/semiforbiddable to source other ebuild files in a locally managed ebuild.This approach seems unpredictable and is not recommended https://forums.gentoo.org/viewtopic-t-1163131-highlight-.html |
|
Back to top |
|
|
|