[Lazarus] Creating config files in primary config path for bootstrap installer

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Feb 4 17:59:40 CET 2012


On Sat, 04 Feb 2012 12:03:28 +0100
Reinier Olislagers <reinierolislagers at gmail.com> wrote:

> On 4-2-2012 11:51, Mattias Gaertner wrote:
> > On Fri, 03 Feb 2012 14:36:23 +0100
> > Reinier Olislagers <reinierolislagers at gmail.com> wrote:
> >> Thanks to help from the FPC list, my FPCUp FPC/Lazarus SVN
> >> installer/updater seems to take a plain vanilla Windows machine and
> <snip>
> >> - compile lazarus.exe
> >>
> >> I'd also like Lazarus to compile Lazdatadesktop etc and perhaps some
> >> extra packages, and perhaps offline help.
> > 
> > I started a page about this here:
> > http://wiki.lazarus.freepascal.org/Distributing_Lazarus_-_Installers
> 
> Thanks Mattias...
> 
> While the approach you mention on the page surely will work (letting the
> IDE copy/create missing config files), I'm looking for a totally
> unattended way to get Lazarus installed and set up, including some tools.
> This means I prefer not to start the IDE to generate the config...
> 
> On startup, Lazarus creates config files when they don't exist yet.

Yes

> Lazbuild doesn't.

Yes. It sole purpose was to compile things.
Eventually it will update some caches, e.g. the lpk and fpc cache.


> Would it make sense to patch Lazbuild to match Lazarus behaviour?

Lazbuild is a non interactive command line tool, without the plugins
the IDE has. It can not match the behavior of the IDE.

If you need a tool to set some config variables, then please write one.
The configs are plain xml files, so this is simple enough. In fact for a
start config you don't even need TXMLConfig, a TStringList would be
sufficient. I can put it into the Lazarus "tools" folder.

 
> See my other mail for my plans to write a config creator/updater. If
> Lazbuild were to create missing config files on the fly, I can scale
> that back to only a config updater ;)

Maybe you overrate the config files and/or underestimate the
IDE/lazbuild.

A simple environmentoptions.xml looks like this:

<?xml version="1.0"?>
<CONFIG>
  <EnvironmentOptions>
    <Version Value="106"/>
    <LazarusDirectory Value="/usr/share/lazarus"/>
    <CompilerFilename Value="/usr/bin/fpc"/>
    <FPCSourceDirectory Value="/usr/share/fpcsrc/$(FPCVer)/fpc/"/>
    <MakeFilename Value="make"/>
    <TestBuildDirectory Value="/tmp"/>
    <DebuggerFilename Value="/usr/bin/gdb"/>
  </EnvironmentOptions>
</CONFIG>

See the wiki page for more details.

To update a value, use something like this:

var
  cfg: TXMLConfig;
begin
  cfg:=TXMLConfig.Create('/home/username/.lazarus/environmentoptions.xml');
  try
    cfg.SetDeleteValue('EnvironmentOptions/LazarusDirectory/Value','/home/username/new/path/lazarus','');
    cfg.Flush;
  finally
    cfg.Free;
  end;
end;

The IDE saves all file names relative (except for history lists and
some minors). So stop the IDE, change the value in the xml and start
the IDE and that's it. The IDE will automatically load the new lpk
files, the new fpdoc files, etc.


Mattias




More information about the Lazarus mailing list