8.3 Surgical overrides: patch one package without rebuilding the world
Lesson 54 of 68 · 6:36
Video chapters
-
0:00 Intro to overlay examples
-
0:35 Overriding OpenCV4 globally
-
2:06 Creating a separate OpenCV4 variant
-
3:28 Using final vs prev in overlays
-
5:13 Preview of lazy evaluation and next steps
Transcript
Intro to overlay examples
0:00 So after we just learned how to write a simple overlay, I want to show you some other examples before we vanish in the depth of how this works, fixed point recursion and so on. This is an overlay that I wrote myself once for a real project and what I needed was, I needed the OpenCV4 library that is for optical image recognition, computer vision stuff and so on and it's a very nice library and I used it in the Python project and the idea was to detect stuff and encode information from video input and automate that and that's very easy to
Overriding OpenCV4 globally
0:44 unit test. You just throw in pictures and videos into your project and then you have unit tests running there because you already know what you expect but maybe sometimes you also want to open a window because OpenCV can open a GTK window for you and show you like bounding boxes or whatever you detected there and then the thing is that OpenCV4 is typically being used as a library on headless robotic computers so the default version of it or the default variant has no windowing support. So OpenCV4 has a parameter enable GTK three which is set to false by default which totally makes sense but then if you're a developer and you want to build an exceptional version of OpenCV4 that has window support then you're going to enable that and override does that.
1:34 What does it look like? We say we override the existing OpenCV4 symbol by saying OpenCV4 equals the previous version of OpenCV4 so prev means the previous version of nix packages before our overlay was applied ignore final for now and then that version that one before our overlay we override it and we enable GTK three and Tesseract which is for optical character recognition too that is now the definitive version of OpenCV4 which is pretty cool because if any other application depends on
The full transcript comes with the lesson.
About this lesson
A real overlay from a real project: rebuilding OpenCV with GTK window support for a computer vision setup in Python. There are two ways to do it, and they have very different costs. Replace opencv4 for every consumer and trigger a rebuild avalanche, or add a renamed variant and inject it into exactly one application. This lesson shows both, and uses final for the first time.
In this video
- Overriding
opencv4in an overlay to enableenableGtk3and Tesseract support, and what that does to every package that depends on it - The surgical alternative: a renamed
opencv4twin that only your own app gets, while everything else keeps the cached original - Why the surgical route can save you half an hour of OpenCV compile time per machine, times every affected package
finalvsprevin practice: which reference survives when someone stacks another overlay after yours
After this lesson
You can decide per package whether a change should reach the whole system or exactly one application, and write the overlay for either case.