How do you containerize stuff you install from source in a way that you can completely remove later?

I’m doing a bunch of AI stuff that needs compiling to try various unrelated apps. I’m making a mess of config files and extras. I’ve been using distrobox and conda. How could I do this better? Chroot? Different user logins for extra home directories? Groups? Most of the packages need access to CUDA and localhost. I would like to keep them out of my main home directory.

Sims,

Haven’t tried it (and don’t use docker), so a wild shot: github.com/jupyterhub/repo2docker

‘repo2docker fetches a repository (from GitHub, GitLab, Zenodo, Figshare, Dataverse installations, a Git repository or a local directory) and builds a container image in which the code can be executed. The image build process is based on the configuration files found in the repository.’

That way you can perhaps just delete the docker image and everything is gone. Doesn’t seem to depend on jupyter…

voluntaryexilecat,

I use a mixture of systemd-nspawn and different user logins. This is sufficient for experimentation, for actual use I try to package (makepkg) those tools to have them organized by my package manager.

Also LVM thinpools with snapshots are a great tool. You can mount a dedicated LV to each single user home to keep everything separated.

Gamey,

I think Podman should do a good job but I never used it myself, Distrobox is build on it and a lot easier to use so that’s what I would recommend!

epocsquadron,
@epocsquadron@kbin.social avatar

There’s a method using systemd-sysext that would work well for this on any distro without dealing with poking holes in containers. One of the gnome folks blogged about it recently here: https://blogs.gnome.org/alatiera/2023/08/04/developing-gnome-os-systemd-sysext/

Kangie,

I use Gentoo where builds from source are supported by the package manager. ;)

Overall though, any containerisation option such as Docker / Podman or Singularity is what I would typically do to put things in boxes.

For semi-persistent envs a chroot is fine, and I have a nice Gentoo-specific chroot script that makes my life easier when reproing bugs or testing software.

j4k3,
@j4k3@lemmy.world avatar

Wait. Does emerge support building packages natively when they are not from Gentoo?

Most of the stuff I’m messing with is mixed repos with entire projects that include binaries for the LLMs, weights, and such. Most of the “build” is just setting up the python environment with the right dependency versions for each tool. The main issues are the tools and libraries like transformers, pytorch, and anything that interacts with CUDA. These get placed all over the file system for each build.

Kangie,

Ebuilds (Gentoo packages) are trivial to create for almost anything, so while the answer is ‘no the package manager doesn’t manage non PM packages’, typically you’ll make an ebuild (or two or three) to handle that because it’s (typically) as easy as running make yourself. :)

akik,

<span style="color:#323232;">export LDFLAGS="-Wl,-rpath=/sw/app/version/lib"
</span><span style="color:#323232;">./configure --prefix=/sw/app/version
</span><span style="color:#323232;">make
</span><span style="color:#323232;">sudo make install
</span><span style="color:#323232;">unset LDFLAGS
</span>
gabriele97,
@gabriele97@lemmy.g97.top avatar

Give a look at distrobox

InverseParallax, (edited )

Have an lxc config that enables glx on x11 in the container, spin one up and throw stuff in there, temp zfs volume.

Lxc-rm when done.

socphoenix,

Chroot would be fine for this and not overly complicated

sneaky_b45tard,

Not sure if that’s a good idea but if you use Fedora, you also have your root on a BTRFS partition after a default installation. You could utilize the snapshot features of BTRFS to roll back after testing.

j4k3,
@j4k3@lemmy.world avatar

I need to explore this BTRFS feature, I just don’t have a good place or reason to start Dow that path yet. I’ve been on Silverblue for years, but decided to try Workstation for now. Someone in the past told me I should have been using BTRFS for FreeCAD saves, but I never got around to trying it.

triplenadir,
@triplenadir@lemmygrad.ml avatar

software like stow keeps track of files installed, and helps you remove it later

Reborn2966,

it it does not need a gui, use docker and log in into it. do the stuff and when you are done, docker rm and everything disappear.

you can enable cuda inside the container, follow the docs for that.

bonus point, vs code can open itself inside a container.

DryTomatoes,

I did Linux From Scratch recently and they have a brilliant solution. Here’s the full text but it’s a long read so I’ll briefly explain it. linuxfromscratch.org/…/more_control_and_pkg_man.t…

Basically you make a new user with the name of the package you want to install. Login to that user then compile and install the package.

Now when you search for files owned by the user with the same name as the package you will find every file that package installed.

You can document that somewhere or just use the find command when you are ready to remove all files related to the package.

I didn’t actually do this for my own LFS build so I have no further experience on the matter. I think it will eventually lead to dependency hell when two packages want to install the same file.

I guess flatpaks are better about keeping libraries separate but I’m not sure if they leave random files all over your hard drive the way apt remove/apt purge does. (Getting really annoyed about all the crud left in my home dir)

FarraigePlaisteach,

That’s clever. It should work on any system, shouldn’t it?

DryTomatoes,

Any POSIX compliant system as far as I know.

FarraigePlaisteach,

Thanks. I’ll keep that in mind for again.

j4k3,
@j4k3@lemmy.world avatar

Thanks for the read. This is what I was thinking about trying but hadn’t quite fleshed out yet. It is right on the edge of where I’m at in my learning curve. Perfect timing, thanks.

Do you have any advice when the packages are mostly python based instead of makefiles?

doot,

for python, a bunch of venvs should do it

DryTomatoes,

This method should work with any command that’s installing files on your disk but it’s probably not worth the headache when virtual environments exist for python.

j4k3,
@j4k3@lemmy.world avatar

Python, in these instances, is being used as the installer script. As far as I can tell it involves all of the same packaging and directory issues as what make is doing. Like, most of the packages have a Python startup script that takes a text file and installs everything from it. This usually includes a pip git+address or two. So far, just getting my feet wet to try out AI has been enough for me to overlook what all is happening behind the curtain. The machine is behind an external whitelist firewall all by itself. I am just starting to get to the point where I want to dial everything in so I know exactly what is happening.

I’ve noticed a few oddball times during installations pip said something like “package unavailable; reverting to base system.” This was while it is inside conda, which itself is inside a distrobox container. I’m not sure what “base system” it might be referring to here or if this is something normal. I am probing for any potential gotchas revolving around python and containers. I imagine it is still just a matter of reading a lot of code in the installation path.

DryTomatoes,

I hope someone who has more info comes along. It might be time for you to make a new post though since we’re getting to the heart of the problem now.

Also it will be a lot easier for people to diagnose if you are specific about which programs you are failing to install.

I’ve only experimented with Python in docker and it gave me a lot of headaches.

That’s why I prefer to pip install things inside venvs because I can just tar them myself and have decent portability.

But since your installing files across the system I’m not sure what the best solution is.

fossisfun,

Flatpak apps can be uninstalled without leaving a trace: flatpak uninstall --delete-data com.google.Chrome

But you might need some global overrides to make all apps write their configuration into ~/.var. Personally I globally revoke apps the permission to access filesystem= host, home, xdg-config, xdg-data.

That was actually the main reason that made me switch to Flatpak. Previously I used VMs to try out software, but with Flatpak I know that I can get rid of the application completely.

DryTomatoes,

Thanks for the info! I’m definitely gonna look into flatpak.

I built nodejs from source yesterday and it took forever. I’d definitely prefer something huge like that in a flatpak.

user8e8f87c,
@user8e8f87c@berlin.social avatar
Ayhem,

Use Nixos ( learn about it )

j4k3,
@j4k3@lemmy.world avatar

I have read up on it some, but Fedora does UEFI, secure boot, and a self compiling Nvidia driver that gets built for each kernel update so well that I hesitate to leave. I tried installing the NIX package manager on fedora, but having a user owned directory folder mounted in root is the ugliest thing I’ve ever seen and immediately removed it.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • [email protected]
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • oklahoma
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • SuperSentai
  • feritale
  • KamenRider
  • All magazines