Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-02

Creating config files in primary config path for bootstrap installer

10 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

Hi list,

Thanks to help from the FPC list, my FPCUp FPC/Lazarus SVN installer/updater seems to take a plain vanilla Windows machine and
- download+install an SVN client
- download the binutils (make etc)
- download/update FPC from SVN and compile/install it
- download/update Lazarus from SVN
- compile lazarus.exe

I'd also like Lazarus to compile Lazdatadesktop etc and perhaps some extra packages, and perhaps offline help.

For that to happen, I will need valid config files. I'm now creating an empty directory for use as primary-config-path.

How can I best fill it with config files?
1. Add them from an existing install as resources, extract them, probably modify paths etc.
2. Perhaps there's some kind of command line argument for startlazarus that does this
3. Use Lazarus source code to create default config files
4. Other suggestions from the mighty collective wisdom of this list ;) *)

I would be in favour of option 2 as that decouples my tool from changes in config files (option 1) and source code locations/function names etc (option 3).
If 2. doesn't already exist, would it be easy to add? Where would I start looking in order to write a patch?

Thanks,
Reinier

*) Well, actually I'm fairly serious...

Reply by email

Reinier Olislagers
to Reinier Olislagers
Reinier Olislagers wrote
Hi list, Thanks to help from the FPC list, my FPCUp FPC/Lazarus SVN installer/updater seems to take a plain vanilla Windows machine and

<bla>

Show quoted text 7 lines
I'd also like Lazarus to compile Lazdatadesktop etc and perhaps some extra packages, and perhaps offline help. For that to happen, I will need valid config files. I'm now creating an empty directory for use as primary-config-path. How can I best fill it with config files?

Short term solution - is a kludge so not going to do it, I think:
1. call lazarus.exe --primary-config-path=bla which should create config files. Then kill it.
2. Go through the xml files in the primary config path and replace compiler path, binutils path

Longer term solution:
Use TEnvironmentOptions:
CreateConfig //to create default config
set properties:
LazarusDirectory property
CompilerFileName
FPCSourceDirectory
MakeFilename
DebuggerFilename
Save to save config

Write a new command line tool, e.g.:
UpdateConfig --primary-config-path=c:\windows\temp\testconfig --fpc=c:\development\fpc\bin\i386-win32\fpc.exe
--fpcsourcedirectory=c:\development\fpc
--make=c:\development\fpcbootrap\make.exe
--debugger=c:\development\fpcbootstrap\gdb.exe
--lazarusdirectory=c:\development\lazarus

... which will create or update any config in primary-config-path

Am I going in the right direction? Can I just use TEnvironmentOptions or do I need more units?

Thanks,
Reinier

Reply by email

Mattias Gaertner
to Reinier Olislagers: Thanks to help from the FPC list, my FPCUp FPC/Lazarus SVN installer/updater seems to…
Show quoted text 12 lines
Hi list, Thanks to help from the FPC list, my FPCUp FPC/Lazarus SVN installer/updater seems to take a plain vanilla Windows machine and - download+install an SVN client - download the binutils (make etc) - download/update FPC from SVN and compile/install it - download/update Lazarus from SVN - 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

Show quoted text 17 lines
For that to happen, I will need valid config files. I'm now creating an empty directory for use as primary-config-path. How can I best fill it with config files? 1. Add them from an existing install as resources, extract them, probably modify paths etc. 2. Perhaps there's some kind of command line argument for startlazarus that does this 3. Use Lazarus source code to create default config files 4. Other suggestions from the mighty collective wisdom of this list ;) *) I would be in favour of option 2 as that decouples my tool from changes in config files (option 1) and source code locations/function names etc (option 3). If 2. doesn't already exist, would it be easy to add? Where would I start looking in order to write a patch?

Mattias

Reply by email

Reinier Olislagers
to Mattias Gaertner
Mattias Gaertner wrote
On Fri, 03 Feb 2012 14:36:23 +0100 Reinier Olislagers 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>

Show quoted text 7 lines
> - 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. Lazbuild doesn't. Would it make sense to patch Lazbuild to match Lazarus behaviour?

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 ;)

Thanks,
Reinier

Reply by email

Vincent Snijders
to Reinier Olislagers

Op 4 februari 2012 12:03 heeft Reinier Olislagers
het volgende geschreven:

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...

Why do you want to start the IDE to generate the config?

On startup, Lazarus creates config files when they don't exist yet. Lazbuild doesn't. Would it make sense to patch Lazbuild to match Lazarus behaviour?

Vincent

Reply by email

Reinier Olislagers
to Vincent Snijders
Vincent Snijders wrote 8 lines
Op 4 februari 2012 12:03 heeft Reinier Olislagers het volgende geschreven: > 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... Why do you want to start the IDE to generate the config?

Actually, I don't; it seems to me it's one of the ways to generate the config.

Running my installer: after compiling lazarus.exe, it runs lazbuild with --primary-config-path to compile e.g. lazdatadesktop

Not surprisingly, lazbuild errored out; it couldn't find a valid compiler. Turns out no config files exist in the primary config path (I only see compilertest.pas), and apparently lazbuild doesn't generate them.

So, I surmised I need to generate configs. Running the IDE seems to be one way.

Is there a better/easier way?

Thanks,
Reinier

Reply by email

Mattias Gaertner
to Reinier Olislagers: <bla> Short term solution - is a kludge so not going to do it, I think: 1. call…
Show quoted text 43 lines
On 3-2-2012 14:36, Reinier Olislagers wrote: > Hi list, > > Thanks to help from the FPC list, my FPCUp FPC/Lazarus SVN > installer/updater seems to take a plain vanilla Windows machine and <bla> > I'd also like Lazarus to compile Lazdatadesktop etc and perhaps some > extra packages, and perhaps offline help. > > For that to happen, I will need valid config files. I'm now creating an > empty directory for use as primary-config-path. > > How can I best fill it with config files? Short term solution - is a kludge so not going to do it, I think: 1. call lazarus.exe --primary-config-path=bla which should create config files. Then kill it. 2. Go through the xml files in the primary config path and replace compiler path, binutils path Longer term solution: Use TEnvironmentOptions: CreateConfig //to create default config set properties: LazarusDirectory property CompilerFileName FPCSourceDirectory MakeFilename DebuggerFilename Save to save config Write a new command line tool, e.g.: UpdateConfig --primary-config-path=c:\windows\temp\testconfig --fpc=c:\development\fpc\bin\i386-win32\fpc.exe --fpcsourcedirectory=c:\development\fpc --make=c:\development\fpcbootrap\make.exe --debugger=c:\development\fpcbootstrap\gdb.exe --lazarusdirectory=c:\development\lazarus ... which will create or update any config in primary-config-path Am I going in the right direction? Can I just use TEnvironmentOptions or do I need more units?

You do not need TEnvironmentOptions. You only need a TXMLConfig from unit laz2_xmlcfg.

Mattias

Reply by email

Mattias Gaertner
to Reinier Olislagers: <snip> Thanks Mattias... While the approach you mention on the page surely will work…
Show quoted text 22 lines
On 4-2-2012 11:51, Mattias Gaertner wrote: > On Fri, 03 Feb 2012 14:36:23 +0100 > Reinier Olislagers 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

Reply by email

Reinier Olislagers
to Mattias Gaertner
Mattias Gaertner wrote
On Sat, 04 Feb 2012 12:03:28 +0100 If you need a tool to set some config variables, then please write one.

Ok.

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.

Ok.

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

I think I did ;)

Show quoted text 16 lines
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.

Thanks, yes, that doesn't seem too difficult ;)

<snip>

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.

Thanks a lot, Mattias, that's very clear.

I'll report back when I have something usable...

Thanks for the help,
Reinier

Reply by email

Reinier Olislagers
to Reinier Olislagers
Reinier Olislagers wrote 7 lines
On 4-2-2012 17:59, Mattias Gaertner wrote: > On Sat, 04 Feb 2012 12:03:28 +0100 > If you need a tool to set some config variables, then please write one. Ok. I'll report back when I have something usable...

Mattias & all,

Seems I've got FPCUp
https://bitbucket.org/reiniero/fpcup
working now for bare metal installs on Windows.

I didn't write a command line tool to create/modify configs as I had planned, but was able to incorporate that functionality within my code.

Attached FYI/for reference is the class I wrote that creates a simple config if it doesn't yet exist and updates it if it does.

I use it like this (indentation/try..except removed for clarity):
// Set up a minimal config so we can use LazBuild
LazarusConfig:=TUpdateLazConfig.Create(LazarusPrimaryConfigPath);
LazarusConfig.CompilerFilename:=FInstalledCompiler;
LazarusConfig.LazarusDirectory:=LazarusDirectory;
{$IFDEF WINDOWS}
LazarusConfig.DebuggerFilename:=FBinutilsDir+'gdb'+FExecutableExtension;
LazarusConfig.MakeFilename:=FBinutilsDir+'make'+FExecutableExtension;
{$ENDIF WINDOWS}
{$IFDEF UNIX}
//todo: fix this for more variants?!?
azarusConfig.DebuggerFilename:='gdb'+FExecutableExtension;
LazarusConfig.MakeFilename:='make'+FExecutableExtension;
{$ENDIF UNIX}
LazarusConfig.FPCSourceDirectory:=FPCDirectory;
LazarusConfig.Free;

Hints, suggestions, criticism welcome as always,

Thanks a lot,
Reinier
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed... Name: updatelazconfig.pas
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120205/8a7ecf52/attachment.ksh>

Reply by email