Recent

Author Topic: [Solved] Possible backup of the primary config path?  (Read 552 times)

devEric69

  • Sr. Member
  • ****
  • Posts: 438
[Solved] Possible backup of the primary config path?
« on: January 14, 2021, 05:31:30 pm »
Hello,

The primary config path contains important configuration files, such as packagefiles.xml, and so on...
In the IDE's environment options, there is the possibility to say that we can create in a /backup directory, containing an histories of *.pas, *.pp, ..., files.

Is it possible to configure the same thing (a backup, made by the IDE, each time they are modified) for the files contained in the primary config path (I didn't find it)?
« Last Edit: January 15, 2021, 03:28:46 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2094
Re: Possible backup of the primary config path?
« Reply #1 on: January 14, 2021, 07:08:23 pm »
I don't believe so, but it it bothers you you could easily (tar the directory and) commit it to a local RCS or a Subversion server. After all, you're probably already using a shell script to make sure that you don't forget the --pcp option.

If you aren't using a script, here's mine: it relies on $0 taking the name of the symlink that's invoked it so I automatically get things like  --pcp=/home/markMLl/.lazarus-trunk-working

Code: [Select]
#!/bin/sh

PROGRAM=lazarus
VERSION=`basename $0`
BINARY="/usr/local/share/$VERSION/$PROGRAM"
CONFIG="$HOME/.$VERSION"

if [ ! -x "$BINARY" ]; then
  echo "File $BINARY does not exist or is not executable"
  exit 1
fi

if [ ! -d "$CONFIG" ]; then
  echo "WARNING: configuration directory $CONFIG does not exist"
fi

echo $BINARY --pcp=$CONFIG $@
exec $BINARY --pcp=$CONFIG $@

# Backup content of \$CONFIG here


MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6906
  • Debugger - SynEdit - and more
    • wiki
Re: Possible backup of the primary config path?
« Reply #2 on: January 14, 2021, 08:19:18 pm »
After all, you're probably already using a shell script to make sure that you don't forget the --pcp option.

The pcp option can be put into the "lazarus.cfg" file. Same directory as the lazarus or startlazarus exe.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2094
Re: Possible backup of the primary config path?
« Reply #3 on: January 14, 2021, 08:42:18 pm »
The pcp option can be put into the "lazarus.cfg" file. Same directory as the lazarus or startlazarus exe.

I've not got one of those... presumably it's a file that doesn't exist by default.  lazarus --help  doesn't mention it, in any case I'd still need symlinks or scripts to locate the right binary and working directory.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6906
  • Debugger - SynEdit - and more
    • wiki
Re: Possible backup of the primary config path?
« Reply #4 on: January 14, 2021, 08:59:35 pm »
https://wiki.lazarus.freepascal.org/Multiple_Lazarus#Using_lazarus.cfg_file

On Windows the installer can create it. On Linux one needs to do that manually.

The normal "path detection" for starting the IDE on Linux is
- User calls "startlazarus"
- startlazarus determines the pcp (it should honour a lazarus.cfg file)
- It checks for an updated build in the pcp
- Either the build from the pcp, or the main install is started.

Only shortcoming is, that if your global install is used by more than one user (account/login), then it does not work for pcp. Because the file only takes one pcp. But it needs one pcp per user. (actually I do not know if pcp takes any macros that could resolve to the users home.... no idea - that would be independent of this file)

The file was originally invented for secondary installs. (Trying a diff IDE version).
Such installs are often installed in a users home. So then you only need one pcp for that one user.

anyway getting offtopic to the original post.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2094
Re: Possible backup of the primary config path?
« Reply #5 on: January 14, 2021, 09:06:29 pm »
Noting that some of this might be on-topic since I think Eric- like me- runs multiple versions.

- User calls "startlazarus"

Which in my case wouldn't work since most of my systems have multiple Lazarus+FPC versions in different directories. So having lazarus, lazbuild and startlazarus scripts plus appropriately-named symlinks on the path is something that works quite well and is simple to maintain.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6906
  • Debugger - SynEdit - and more
    • wiki
Re: Possible backup of the primary config path?
« Reply #6 on: January 14, 2021, 09:14:44 pm »
Not saying you should re-invent the wheel. It's clearly working for you.

Also I have not tested most of it under Linux. Especially I do not know how well this works with symlinks on Linux (probably not with hard symlinks).

I have (but on Windows) several Folders. Each contains an IDE.
I start the IDE (lazarus executable) in one of the folders (usually by symlink/shortcut from Desktop).
The IDE then finds the folder in which the lazarus exe resides, and looks in the same folder for the lazarus.cfg.

So that is similar to your dir layout. Just a diff way to detect the pcp.

Btw, as a side effect, you can also put other options into the lazarus.cfg file. If you want your ide with a log file --debug-log=......


devEric69

  • Sr. Member
  • ****
  • Posts: 438
Re: Possible backup of the primary config path?
« Reply #7 on: January 15, 2021, 10:33:15 am »
@MarkMLl: thanks you for the script: I will use it. In fact, until now, I was using a simple command line in a launcher:

Code: Bash  [Select][+][-]
  1. gnome-terminal -e "bash -c '/home/.../.../lazarus --pcp=/home/.../.../Working_copies_all_projects/primary_config_path_files --log-enable=DBG_STATE, and so one...'"

@Martin_fr: thank you for reminding us of the basics of a Lazarus launch, "as it should be". I didn't know that lazarus.cfg was containing --pcp. And since I am currently satisfied with my configuration, I will continue as I do.

As I said, I will use the MarkLi method. Of course, I'm using Subversion. But, I want to trace the primary configuration files only for a real important change. However, among the roughly thirty files of the "--pcp", only 3 or 4 are always changing due to an IDE loading and subsequent compilations, nothing more. These files are too volatile for me: I only want to trace in SVN, big changes (first, a change of the Lazarus + fpc combo, and then the modification of the loaded packages. No more).
With MarkLi's script, I can try to remove from a real time SVN monitoring, all these files too volatile for my purposes, but nevertheless backup them with a YYYMMDD timestamp prefix (out of Subversion):

Code: Bash  [Select][+][-]
  1. FILE_BACKUP=$(date +%Y%m%d)-backup
  2. DIR_BACKUP=$CONFIG/backup
  3. FULL_PATH_FILE_BACKUP=$DIR_BACKUP/$FILE_BACKUP
  4. cd $CONFIG
  5. tar -cvzf $FULL_PATH_FILE_BACKUP.tar.gz -T ./a_List_of_files_to_tar_and_zip.txt
« Last Edit: January 15, 2021, 03:28:28 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

 

TinyPortal © 2005-2018