Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Modifying source code before installing it
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
9a3eedi
n00b
n00b


Joined: 12 Jul 2007
Posts: 14

PostPosted: Wed Mar 09, 2022 8:53 am    Post subject: Modifying source code before installing it Reply with quote

Hi,

I am currently primarily a Windows user looking to move back to using Linux full-time at home, and I am considering different distros. I have used Gentoo in the past, but eventually I moved away from it and settled on Ubuntu-based distros because of their ease of use and stability. I use Linux at work for development purposes and consider myself an advanced Linux user.

Gentoo's unique feature is that compiles all its packages from source. To me, the real power of this feature is that, as a user, I should be able to inspect and modify the source code of any package however I see fit before installing, but do it in a way that it doesn't break the package manager. I.e. I would like to be able to install a package, then if I find a bug or something I don't like in it, I would like to go through the same source code that was used to install it, modify the source code, and then reinstall it. This keeps the true spirit of free software in my opinion: that people have the freedom to change whatever they don't like in their software. Does Gentoo allow for a workflow like that?

For context, I have used Gentoo a very long time ago (perhaps 10 years ago), but I was not an experienced programmer at the time. Nowadays, I am an experienced C programmer and familiar with other languages as well, and I find myself very comfortable with changing other people's source code. Many times I felt that I would like to do some quick modifications to particular applications (e.g. to fix a bug or to add a feature), but compiling these packages was often daunting because distros like Ubuntu/Debian/etc. used older packages and getting their source code was not trivial, or perhaps I haven't done enough research on how to do that. So I was wondering how Gentoo fares in that regard.
Back to top
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 2070
Location: Germany

PostPosted: Wed Mar 09, 2022 9:02 am    Post subject: Reply with quote

It sounds like you want this: https://wiki.gentoo.org/wiki/Patches
Or you can also create your own overlay: https://wiki.gentoo.org/wiki/Creating_an_ebuild_repository
_________________
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Back to top
View user's profile Send private message
9a3eedi
n00b
n00b


Joined: 12 Jul 2007
Posts: 14

PostPosted: Wed Mar 09, 2022 9:51 am    Post subject: Reply with quote

This looks like what I'm looking for, though it's a little more complicated than simply modifying a c file and recompiling. I think I understand why though, it's to allow for contributing back to the community and to keep track of patches.

Thanks, I'll check it out.
Back to top
View user's profile Send private message
C5ace
Guru
Guru


Joined: 23 Dec 2013
Posts: 495
Location: Brisbane, Australia

PostPosted: Wed Mar 09, 2022 10:00 am    Post subject: Reply with quote

9a3eedi:

Have look at "Linux from Scratch".
_________________
Observation after 30 years working with computers:
All software has known and unknown bugs and vulnerabilities. Especially software written in complex, unstable and object oriented languages such as perl, python, C++, C#, Rust and the likes.
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4143
Location: Rasi, Finland

PostPosted: Wed Mar 09, 2022 11:41 am    Post subject: Reply with quote

Patches feature (mentioned by Banana) provided by Portage is your best bet, if you want to integrate your patches to the package manager system.

Easiest is maybe to just unpack the sources to whatever location and then edit sources and then compiling. Finally you can optionally install the package, preferably, under /usr/local. You can install the dependencies using emerge with --onlydeps switch.

If you want to keep your manually installed program in /usr/local then you can tell Portage that you have provided the package by yourself (if it is a such package that others depend on) via package.provided. Just be aware of the possible incompatibilities and read the warning. You may need to add /usr/local/lib etc to your library paths etc...
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
logrusx
Advocate
Advocate


Joined: 22 Feb 2018
Posts: 3089

PostPosted: Wed Mar 09, 2022 12:54 pm    Post subject: Reply with quote

This might be useful, but ultimately you should only use it for testing if the source compiles and then produce patches and supply them to portage as suggested above. In the same time if patches become not-applicable, emerge will fail with the appropriate message.

Regards,
Georgi
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23576

PostPosted: Wed Mar 09, 2022 4:26 pm    Post subject: Reply with quote

9a3eedi wrote:
This looks like what I'm looking for, though it's a little more complicated than simply modifying a c file and recompiling. I think I understand why though, it's to allow for contributing back to the community and to keep track of patches.
Also, you generally want Portage to remember your changes and apply them to every subsequent revision it can. You don't want to come back and manually edit the same C file again next week when a rebuild is required. Patches stored in /etc/portage/patches let Portage handle this for you.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum