Port complex build shell scripts to Python
(Splitting #11198 into smaller pieces.)
team: hefee, muri, intrigeri (reviewer); kurono?
Blueprint: https://tails.boum.org/blueprint/Port_shell_scripts_to_Python/
Parent Task: #11198
Original created by @intrigeri on 11754 (Redmine)