Recent

Author Topic: Two instances of Lazarus ( one is dpkg -i and the other is built using make )  (Read 4575 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 8184

Wow, this is perfect. Thank you. It has been a while since I wrote any shell scripts :-)

You will find that the same technique works for lazbuild and startlazarus. The key, obviously, is to have separate /usr/local/share.lazarus/3.0.0 etc. directories, for ease of maintenance set /usr/local/share.lazarus so that you can create a directory in it without having to use sudo.

Quote
Holy smokes you have 12 different versions? And way back from 2017 too..

On a 32-bit system I'd expect to have FPC running back to the early v2s and Lazarus in various 0.9 incarnations, and try to test some apps with GTK v1. By and large, it's possible to write code for FPC 2.6.4 and the equivalent Lazarus, go before that and you start losing some really useful things such as case applied to strings (for option parsing etc.) and there were almost-breaking changes in the LCL relating to tabbed controls etc.

Also see https://forum.lazarus.freepascal.org/index.php/topic,68273.msg527404.html#msg527404 where I give an example with some fairly aggressive version checking.

Quote
@MarkMLI I have a question? I have never seen a prompt such as yours '0 1>markMLl@kdg-dev-01:/usr/local/bin$ '. I am curious to know what the 0 1 > redirection is for please?

Ah. I normally chop that to forestall questions: the first number is the return code of the last program run and the second is the shell nesting depth, the remainder is fairly standard. Set up relatively easily in ~/.bashrc (hence /etc/skel/.bashrc etc.).

MarkMLl
« Last Edit: August 28, 2024, 05:36:24 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

wizzwizz4

  • New Member
  • *
  • Posts: 20
Hi, I recently lost my local repo and all the projects in it when I did a git --reset hard.

A little off-topic, but: no, you didn't. If you still have the .git directory from your "lost" repo, and the garbage collector hasn't pruned them yet, your projects are all still on your hard drive. Very first thing, create a copy of your .git directory, and mark the whole copy as read-only. This is your backup: don't touch it. Now run:

Code: Text  [Select][+][-]
  1. git log --graph --reflog

An orphaned commit will look something like:

Code: Text  [Select][+][-]
  1. |
  2. | * commit 0123456789abcdef00112233445566778899aabb
  3. |/  Author: wizzwizz4 <wizzwizz4@localhost>
  4. |   Date:   ...

You're looking for a star, no branch name in parentheses after the hash, and no commits connected to it above. Find any orphaned commits it looks like you might want to keep, and make new branches for them:

Code: Text  [Select][+][-]
  1. git branch branch-123 01234567

Use a different branch name each time. (This command should enforce that, but you never know with git.) You don't need the full commit hash, only an unambiguous prefix of it. If you did everything right, one of the orphaned commits should be the one containing all your "deleted" projects. Rename branches as appropriate until your repo is fixed. Then, set up a real backup system (git is not a backup, as you've just found out!).
« Last Edit: August 28, 2024, 08:52:52 pm by wizzwizz4 »

dbannon

  • Hero Member
  • *****
  • Posts: 3212
    • tomboy-ng, a rewrite of the classic Tomboy
I still maintain that building each source 'kit' down in user space and running any one (or even multiple instances) directly from there is a better way to work.

Lazarus needs to rebuilt it self, usually shortly after being installed. If its installed in root space, it does an incredibly clever but some times fragile fiddle to keep the changed files down in user space (in the config dir). So, you effectively run from user space (mostly) even with a root install ! 

The user install is easier managed, when no longer needed, just rm -Rf it, put it back just as easily. A hand full of scripts that set the path to an appropriate FPC, set an appropriate laz config dir, start the appropriate binary. Too easy.

Code: Pascal  [Select][+][-]
  1. dbannon@dell:$> ls -l ~/bin/Lazarus
  2. total 335352
  3. drwxrwxr-x  3 dbannon dbannon      4096 Feb 11  2019 Help
  4. drwxrwxr-x 21 dbannon dbannon      4096 Jan 28  2024 laz_2_0_10
  5. -rw-rw-r--  1 dbannon dbannon 289998078 Nov 21  2023 laz_2_0_10.tgz
  6. drwxrwxr-x 20 dbannon dbannon      4096 Mar 11 09:20 lazarus_2_2_6
  7. drwxrwxr-x 20 dbannon dbannon      4096 Jan 30  2024 lazarus_3_0
  8. drwxr-xr-x 20 dbannon dbannon      4096 Aug 19 20:53 lazarus_3_4
  9. drwxr-xr-x 20 dbannon dbannon      4096 Aug 15 22:12 lazarus_3_4-Test
  10. drwxr-xr-x 20 dbannon dbannon      4096 Aug 13 20:46 lazarus-fixes_3_0
  11. drwxrwxr-x 21 dbannon dbannon      4096 Jan 28  2024 lazarus-git
  12. -rw-rw-r--  1 dbannon dbannon  53343807 Mar 14  2023 lazarus-lazarus_2_2_6.zip
  13. drwxrwxr-x 12 dbannon dbannon      4096 Aug 19 20:18 LazConfigs
  14. drwxrwxr-x 20 dbannon dbannon      4096 Mar  3 15:52 laz_f_3_2a_Pico

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Aruna

  • Hero Member
  • *****
  • Posts: 574
Hi, I recently lost my local repo and all the projects in it when I did a git --reset hard.

A little off-topic, but: no, you didn't. If you still have the .git directory from your "lost" repo, and the garbage collector hasn't pruned them yet, your projects are all still on your hard drive. Very first thing, create a copy of your .git directory, and mark the whole copy as read-only. This is your backup: don't touch it. Now run:<snip>
Thank you @wizzwizz4 I will save this for future catastrophes. I never had the chance to 'commit' all I did was
Code: Pascal  [Select][+][-]
  1. git init
  2. git add .
  3. git --reset hard
. In this case, will your fix still bring things back from the dead?

Aruna

  • Hero Member
  • *****
  • Posts: 574
 
I still maintain that building each source 'kit' down in user space and running any one (or even multiple instances) directly from there is a better way to work.
To each his own I guess. Whatever works for you and your comfortable with? I prefer your way because it gives me access to the source, this thread started because I used dpkg and I could not for the life of me find the source. So I did things 'your' way and am a happy cookie!

I am also extremely grateful to all the others who shared how they do this. I get to learn many different ways to achieve the same result, which is a good thing!

Code: Pascal  [Select][+][-]
  1. dbannon@dell:$>
  2. drwxrwxr-x 20 dbannon dbannon      4096 Mar  3 15:52 laz_f_3_2a_Pico

@Davo what is that 'Pico' thingy? Raspberry Pi Pico? Or Arduino Pico ?? Or am just being a whacko as is usual?  ;)
« Last Edit: August 29, 2024, 05:28:57 am by Aruna »

dbannon

  • Hero Member
  • *****
  • Posts: 3212
    • tomboy-ng, a rewrite of the classic Tomboy
https://wiki.freepascal.org/ARM_Embedded_Tutorial_-_FPC_and_the_Raspberry_Pi_Pico

Very clever use of the Raspberry Pi's Pico libraries with FPC.  Works well. Back then, it needed special build of FPC and Lazarus (best provided by fpcupdelux) but, being an argumentative fellow, I felt the need to build both 'by hand'. Its doc'ed in the wiki.

Rather sadly, with the release of the Pico W, Raspberry Pi made the supporting libraries MUCH more involved making Michael's work a lot harder. My recent Pico W project was built using C I am afraid.    :(

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 8184
https://wiki.freepascal.org/ARM_Embedded_Tutorial_-_FPC_and_the_Raspberry_Pi_Pico

Very clever use of the Raspberry Pi's Pico libraries with FPC.  Works well. Back then, it needed special build of FPC and Lazarus (best provided by fpcupdelux) but, being an argumentative fellow, I felt the need to build both 'by hand'. Its doc'ed in the wiki.

Rather sadly, with the release of the Pico W, Raspberry Pi made the supporting libraries MUCH more involved making Michael's work a lot harder. My recent Pico W project was built using C I am afraid.    :(

And of course the Pico2 is unknown territory at present.

https://spotpear.com/index/study/detail/id/1101.html looks interesting: an RP2040 chip plus an ESP32 for networking. I know a couple of us have got them, but so far I've not explored the network stack etc.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

wizzwizz4

  • New Member
  • *
  • Posts: 20
all I did was
Code: Pascal  [Select][+][-]
  1. git init
  2. git add .
  3. git --reset hard
. In this case, will your fix still bring things back from the dead?

Ah, I misunderstood. No, that did instruct git to delete everything, without leaving any orphaned commits, so my first suggested fix won't do anything. (I assume you ran git reset --hard, since git --reset hard would have errored and done nothing.)

Since you staged all the files before wiping them out, it is possible that the objects (file contents) are still hanging around in git. Try git fsck --lost-found and see if anything gets put in .git/lost-found (which might be a hidden folder, depending on OS). If it does, then you've got the file contents, and there might be a way to recover the file structure (but I suspect the only copy of that was stored in the wiped-out index).

Otherwise, you should check places like wherever Lazarus saves its temporary files, but it's unlikely you'd be able to recover everything if git fsck --lost-found doesn't work.

Git is arcane and full of footguns, so once you've got everything back to a sensible state (whether you've recovered your files or not), I'd recommend only using Git GUI, at least until you know your way around Git. Other GUI clients are available, but I can't vouch for them.
« Last Edit: August 30, 2024, 12:44:50 pm by wizzwizz4 »

Aruna

  • Hero Member
  • *****
  • Posts: 574
Re: Two instances of Lazarus ( one is dpkg -i and the other is built using make )
« Reply #23 on: September 01, 2024, 03:59:08 am »
Rather sadly, with the release of the Pico W, Raspberry Pi made the supporting libraries MUCH more involved making Michael's work a lot harder. My recent Pico W project was built using C I am afraid.    :(
Maybe a shared library? :-)

Aruna

  • Hero Member
  • *****
  • Posts: 574
Re: Two instances of Lazarus ( one is dpkg -i and the other is built using make )
« Reply #24 on: September 01, 2024, 05:29:05 am »

Wow, this is perfect. Thank you. It has been a while since I wrote any shell scripts :-)

You will find that the same technique works for lazbuild and startlazarus. The key, obviously, is to have separate /usr/local/share.lazarus/3.0.0 etc. directories, for ease of maintenance set /usr/local/share.lazarus so that you can create a directory in it without having to use sudo.
Understood and will comply in the future. Thank you.

On a 32-bit system I'd expect to have FPC running back to the early v2s and Lazarus in various 0.9 incarnations, and try to test some apps with GTK v1. By and large, it's possible to write code for FPC 2.6.4 and the equivalent Lazarus, go before that and you start losing some really useful things such as case applied to strings (for option parsing etc.) and there were almost-breaking changes in the LCL relating to tabbed controls etc.
You have been doing this stuff for a long time, GTK v1 huh? When I started using linux with Ubuntu Karmic it was GTK v2 I believe.

Also see https://forum.lazarus.freepascal.org/index.php/topic,68273.msg527404.html#msg527404 where I give an example with some fairly aggressive version checking.
I am still trying to understand what you have done here ( Way over my head at this moment but am sure with time it will become clear )

Ah. I normally chop that to forestall questions: the first number is the return code of the last program run and the second is the shell nesting depth, the remainder is fairly standard. Set up relatively easily in ~/.bashrc (hence /etc/skel/.bashrc etc.).

Well, good thing you did not chop it off, I learnt something new :-)

MarkMLl

  • Hero Member
  • *****
  • Posts: 8184
Re: Two instances of Lazarus ( one is dpkg -i and the other is built using make )
« Reply #25 on: September 01, 2024, 09:13:16 am »
You will find that the same technique works for lazbuild and startlazarus. The key, obviously, is to have separate /usr/local/share.lazarus/3.0.0 etc. directories, for ease of maintenance set /usr/local/share.lazarus so that you can create a directory in it without having to use sudo.
Understood and will comply in the future. Thank you.

I missed a detail. I originally had /usr/local/share/lazarus-xxxx+yyyy to contain Lazarus version xxxx built with FPC version yyyy (binaries etc. elsewhere), with symlinks (lazarus-stable etc.) as appropriate. That was resulting in too much in /usr/local/share, so I added an extra later /usr/local/share.lazarus where . replacing / seems to be an accepted unix convention. Hence the list of directory names that I think I showed earlier in the thread.

Quote
You have been doing this stuff for a long time, GTK v1 huh? When I started using linux with Ubuntu Karmic it was GTK v2 I believe.

Yggdrassil Linux back in about '93. Wasn't the first unix I'd seen...

I'd stress that I'd not expect production code to still support GTK v1, but there again there's a lot of people in the wider community who'd frown at the LCL still favouring GTK v2 rather than moving on to something newer (or dropping GTK in favour of Qt, which seems to be a fairly common approach). But there's one or two things that favour at least a nodding acquaintance with older widget sets and kernel versions, and that's particularly the case if one looks at "containerised" build environments for SBCs etc.

Quote
Also see https://forum.lazarus.freepascal.org/index.php/topic,68273.msg527404.html#msg527404 where I give an example with some fairly aggressive version checking.
I am still trying to understand what you have done here ( Way over my head at this moment but am sure with time it will become clear )

No, that's fairly straightforward. The object of the exercise is to have a parsing function report its name in any error messages, and while the name can be extracted automatically using recent FPCs it can't for older ones. Hence what I'm doing is making sure that if it's compiled for recent FPC it also checks that the constant giving the filename (which would be used on older FPC) is correct. So

Code: Pascal  [Select][+][-]
  1. {$undef HAS_CURRENTROUTINE     }
  2. {$if FPC_FULLVERSION >= 030200 }        (* Requires FPC 2.2.4 minimum           *)
  3.  
  4. // FPC_FULLVERSION doesn't exist on FPC 2.2.2 etc., so if that's all we have we
  5. // can't check whether the version is recent enough for %CURRENTROUTINE%
  6. // to work.
  7.  
  8. {$define HAS_CURRENTROUTINE    }        (* Requires FPC 3.2.0 minimum           *)
  9. {$assertions on                }        (* Make sure name checks are operative  *)
  10. {$endif FPC_FULLVERSION        }
  11.  

Quote
Ah. I normally chop that to forestall questions: the first number is the return code of the last program run and the second is the shell nesting depth, the remainder is fairly standard. Set up relatively easily in ~/.bashrc (hence /etc/skel/.bashrc etc.).

Well, good thing you did not chop it off, I learnt something new :-)

Assuming that your OS is similar to Debian and that you're using bash rather than dash, in ~/.bashrc look for a line containing rxvt after which there will be a line setting up PS1. After that insert this block:

Code: Text  [Select][+][-]
  1. # This is ~/.bashrc hence is Bash-specific and will only be run in
  2. # interactive non-login sessions (e.g. from KDE's kconsole). Enhance
  3. # the prompt with return value from last command, with the depth of
  4. # nested shells, and with the user name relative to the current host.
  5. #
  6. # In total this appears to have to go into /etc/profile, /root/.bashrc
  7. # and per-user files such as /home/markMLl/.bashrc, as well as possibly
  8. # /etc/skel/.bashrc. MarkMLl.
  9.  
  10.     if [ $UID -eq 0 ]; then
  11.       PROMPT_COMMAND="PS1=\"\$? \$SHLVL>\u@\h:\w# \""
  12.     else
  13.       PROMPT_COMMAND="PS1=\"\$? \$SHLVL>\u@\h:\w\$ \""
  14.     fi
  15.     export HISTCONTROL=ignoreboth
  16.     alias ¬='history -d $((HISTCMD-2)) && history -d $((HISTCMD-1))'
  17. #    alias PP='pushd . > /dev/null && [ -e ~/.project ] && echo `head -1 < ~/.project`'
  18.  
  19. # An alias can't directly accept a parameter, use a function instead.
  20.  
  21.     PP() {
  22.       if [ "_$1_" = '_?_' ]; then
  23.         [ -e ~/.project ] && cat -n ~/.project
  24.       else
  25.         if [ "_$1_" = '_._' ]; then
  26.           printf '%s\n%s\n' `pwd` `cat ~/.project` > ~/.project
  27.         else
  28.           pushd . > /dev/null
  29.           [ -e ~/.project ] && cd `head -${1:-1} < ~/.project | tail -1`
  30.           [ -e ./.project ] && cat ./.project
  31.         fi
  32.       fi
  33.     }
  34.  

Doesn't actually need to be in /etc/profile, I think I wrote that when I inserted an early version of that stuff into a Slackware system in around '00. There's some useful stuff in there, but I won't spoil your fun working out the details :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018