OK so I updated my desktop to 18.04 about a month ago (its coming in to release date). And one of the apps that I use that is a bit crusty is OpenSCAD.
One option is to run it in a snap (https://github.com/plars/openscad-snap). Yeah, that sort of worked, but I had a mystery problem where it was looking for some directory to store ‘backups’ in, and just kept giving an error (should be ~/.local/share/OpenSCAD/backups/ but, well). so ‘snap install openscad; openscad’ almost works, except for that. Drat.
OK, so i’ll ignore the snap for now. Sad, that is a pretty simple method.
Method, 2, well, its code, i can just build it? So many dependencies, this thing hasn’t been built since 2015. Um, maybe park that for a second.
Method 3, lets try an lxd container. And this worked great. Normally containers are a PITA to get GPU acceleration in (which is important for a CAD program). But, well, w/ lxd, it just worked!
And here was the recipe. Easy.
First I install a new ubuntu lxc container (called openscad). Then I install mesa (for opengl) and openscad in it. Then I map it to run non-privileged as my uid. I then add X11 (no wayland for me just yet cuz reasons), I enable the GPU, I mount my Documents/Downloads/src dir, and I’m off to the races.
lxc launch ubuntu:x openscad lxc exec openscad apt update lxc exec openscad install mesa-utils openscad lxc config set openscad raw.idmap "both $UID $(id -u)" lxc restart openscad lxc config device add openscad X0 disk path=/tmp/.X11-unix/X0 source=/tmp/.X11-unix/X0 lxc config device add openscad Xauthority disk path=/home/ubuntu/.Xauthority source=$XAUTHORITY lxc config device add openscad gpu gpu lxc config device set openscad gpu uid 1000 lxc config device set openscad gpu gid 1000 lxc config device add openscad Documents disk path=/home/ubuntu/Documents source=~/Documents/ lxc config device add openscad Downloads disk path=/home/ubuntu/Downloads source=~/Downloads lxc config device add openscad src disk path=/home/ubuntu/src source=~/src # Now just run this each time to run openscad lxc exec openscad -- sudo --login --user ubuntu DISPLAY=:0 openscad
Now this might look like a lot of mumbo-jumbo, but the net affect is having a completely isolated machine, with 3D acceleration, running at native speed, in only a few seconds.
Leave a Reply