Author Topic: OPM CLI version  (Read 209 times)


  • New member
  • *
  • Posts: 8
OPM CLI version
« on: March 25, 2020, 06:04:31 pm »

the short version of this question is: How does the OPM work, and how complicated would it be to create a command line interface for it.

But let me explain a little bit further.
So I'm currently working on a toolchain for building lazarus projects from scratch. The main focus is for this to be able to use in a Docker-Image to allow for easy building (and cross compiling) of projects, especially for continuous integration/continuous delivery.
For those who don't know this is basically a mechanism to automatically build and package your projects on a server, whenever you update it, e.g. when pushing new stuff into the git. This can for example execute tests, or simply provide the build artifact for download.

The way the toolchain works is basically, the developer adds a file to the project which describes: which projects to build, which lazarus and fpc version to use, as well as the required packages for the projects. The toolchain then first uses fpcup to download and install the required lazarus and fpc versions (if nessecary), then it downloads the required packages and adds them via lazbuild to Lazarus. Lastly The projects are getting build via lazbuild.
This is (even though it is still in a very early stage) not such big of a problem, and providing the packages via git, svn or simply a download link also works fine. But most packages I use when developing an application are downloaded via the OPM, so it would only make sense for the toolchain to also be able to access the OPM repository.

This script should also work with exsisting lazarus installations (so it can be used to make a lazarus version "ready" for the given project, or to create a lazarus version for development on the given project), so If possible I would want to use the real OPM infrastructure, so that if packages are installed, the real OPM recognizes these packages as if they are installed via itself.

I've started looking into the OPM code, but reading code is hard, if you have initally no idea where to look out for (especially if you, like me, don't know much about lazarus package development). So my question is, can someone who might know a thing or two about the Inner-workings of the OPM, can tell me 1. how the OPM fetches it's data and 2. where it stores which packages are downloaded. Even some references to the lazarus code would be great.


  • Hero Member
  • *****
  • Posts: 8162
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: OPM CLI version
« Reply #1 on: March 26, 2020, 06:12:05 am »
The main code is somewhat self contained in opkman_intf.pas, I believe you can start just from there. But the code is tightly coupled with the IDE interface for it (components/buildintf/packagelinkintf.pas), so reusing for CLI is kind of difficult, you'll need to refactor them first.