Second, just out of curiosity.
Would it be harder to use traditional Bash shell script instead of Python since you were already on Linux?
https://en.wikipedia.org/wiki/Shell_script
https://en.wikipedia.org/wiki/Bash_(Unix_shell)
Yeah, it would be much harder. I'm actually quite a fan of bash scripts, but json parsing alone can give you a real headache, and these scripts actually only do 3 things: 1. parse json, 2. download files, 3. call lazbuild. While bash has a slight edge in ease for calling programs (and therefore downloading thanks to wget, curl or lynx), it is not much easier to weigh out the pain it would be to handle complex datastructures with it.
Python on the other hand supports OOP, which makes handling datastructures represented by json rather easy. Example to downlad a tar.gz and unzip it:
# bash
wget -O- url | tar -xz
# python
with request.open(url) as req:
p = Popen(["tar", "-xz"], stdin=req)
p.communicate()
Sure python is a little more complicated about this, but after all it's rather easy. Then when it comes to parsing json:
serialized = json.load(req)
for key, value in serialized.items():
...
While in bash I would need to either write some really dreadful sed queries or use specified tools and first convert the json to a string array which i can than iterate, and here python wins hands down
That's good news! I will try that later!
for installing local packages there is already lazbuild. However it lacks the feature of removing packages as well. This would be handy sometimes if you installed a package and broke your lazarus this way, because the package makes it crash.
Yeah I use internally simply lazbuilds -add-package-link to register the packages (I currently don't know if this is enough for design time packages, but from my understanding lazarus should build them with the project as long as they are registered), and the fact that my tool can't remove packages also relies on the fact that lazbuild can't do this.
When I break my lazarus with new components I usually use make to rebuild it withouth the components (simple make all) and then can start it and uninstall these components before rebuilding it from the IDE. This is especially funny when I'm using it on my raspi, because I don't use a DE on it and only connect via SSH, so to install packages I can easiely use lazbuild but for uninstalling I need to use X11 forwarding.
I really like lazbuild and think it's great to have a CLI interface for building lazarus projects, but it's missing some functionality.
I am also toying with the Idea to make this thing fully OPM compatible (i.e. using OPM configurations and locations) and integrate it directly into Lazbuild, I was looking into it, and decided that for now this is to complicated for what I want to accomplish, but is on my todo list for the future. The goal is to simply do something like calling "lazbuild opm install Indy10" or so.
But as I said, my current goal is to create a toolchain for building lazarus projects within docker, and a python script is more than enough for now.