Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazarus #1159

Open
benjamimgois opened this issue Nov 26, 2024 · 25 comments
Open

Lazarus #1159

benjamimgois opened this issue Nov 26, 2024 · 25 comments

Comments

@benjamimgois
Copy link

  1. lazarus
  2. https://gitlab.com/freepascal.org/lazarus/lazarus
  3. https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.6/
  4. Lazarus is a Delphi compatible cross-platform IDE for Rapid Application Development.
  5. URL to the application icon
    lazarus
  6. the .desktop*
    [Desktop Entry]
    Name=Lazarus
    Comment=Lazarus IDE
    Exec=startlazarus %f
    Terminal=false
    Type=Application
    Icon=lazarus
    Categories=IDE;Development;GTK;GUIDesigner;
    StartupWMClass=Lazarus
    MimeType=text/x-pascal;text/lazarus-project-source;text/lazarus-project-information;text/lazarus-form;text/lazarus-resource;text/lazarus-package;text/lazarus-package-link;text/lazarus-code-inlay;
    Keywords=editor;Pascal;IDE;FreePascal;fpc;Design;Designer;
@Samueru-sama
Copy link
Contributor

Hey, it's my man from goverlay 👀 Glad to see you are using AM.

Note: If you need help with the goverlay appimage just let me know.

Sorry for the off topic comments btw.

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 26, 2024

hi @benjamimgois , sorry if I ask... I only see .deb packages, while the .zip in that page is for Mac OS x86_64 (darwin). Its there no portable version of Lazarus for Linux? Is the app inside the .deb package portable as well and without dependences if I extract it (I have just one like this in AM, windows95)?

@benjamimgois
Copy link
Author

Hey, it's my man from goverlay 👀 Glad to see you are using AM.

Note: If you need help with the goverlay appimage just let me know.

Sorry for the off topic comments btw.

Hi @Samueru-sama , yeah i'm making some tests with "am" on Kinoite and it's working pretty nice ! This project is really cool ! I still couldn't solve the issue with qt6pas on goverlay appimage, but will give it a new try soon. Thanks for the reception man !

@benjamimgois
Copy link
Author

hi @benjamimgois , sorry if I ask... I only see .deb packages, while the .zip in that page is for Mac OS x86_64 (darwin). Its there no portable version of Lazarus for Linux? Is the app inside the .deb package portable as well and without dependences if I extract it (I have just one like this in AM, windows95)?

Hi @ivan-hc , there's a .tar.gz package for it here. Sorry, my mistake.

https://sourceforge.net/projects/lazarus/files/Lazarus%20Zip%20_%20GZip/Lazarus%203.6/

Lazarus is a aplication that really need some portable way of using it. Since the developpers have no interest in flatpak, i thought that maybe "am" could be as solution. I'm still very noob in making appimages if there's any other needed info.

@Samueru-sama
Copy link
Contributor

Samueru-sama commented Nov 26, 2024

Lazarus is a aplication that really need some portable way of using it. Since the developpers have no interest in flatpak, i thought that maybe "am" could be as solution. I'm still very noob in making appimages if there's any other needed info.

If it is an IDE that depends on GTK2 it should be easy to make an AppImage of.

The only issue is that I normally set a ton of env variables when making appimages, which isn't ideal for an IDE because they would carry to the IDE as well and what gets run by it.

If you want an AppImage just let me know, I maintain this repo of truly portable appimages or the tar.gz is good enough?

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 26, 2024

After found the command to detect the URL...

version=$(curl -Ls "https://sourceforge.net/projects/lazarus/files/Lazarus%20Zip%20_%20GZip/$(curl -Ls "https://sourceforge.net/projects/lazarus/files/Lazarus%20Zip%20_%20GZip/" | tr '"></ ' '\n' | grep "^Lazarus.*[0-9]$" | grep -v RC | head -1)" | tr '"></ ' '\n' | grep tar.gz | head -1)
wget "https://sourceforge.net/projects/lazarus/files/Lazarus%20Zip%20_%20GZip/$(curl -Ls "https://sourceforge.net/projects/lazarus/files/Lazarus%20Zip%20_%20GZip/" | tr '"></ ' '\n' | grep "^Lazarus.*[0-9]$" | grep -v RC | head -1)/$version/download" -O Lazarus.tar.gz || exit 1

...and after I tested the script... just realized that the tar.gz archive have no binary or script... and it is just an archive containing the sources to be compiled. Dammit.

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 26, 2024

@Samueru-sama I have seen that Lazarus is in the "extra" repo on Arch Linux... are you able to test if it is possible to use it as a base for an AppImage?

EDIT: maybe using the Conty method?

@Samueru-sama
Copy link
Contributor

@Samueru-sama I have seen that Lazarus is in the "extra" repo on Arch Linux... are you able to test if it is possible to use it as a base for an AppImage?

EDIT: maybe using the Conty method?

sure thing, tomorrow I should have something ready.

@benjamimgois
Copy link
Author

Hey guys, thanks for the help. I'm sure the lazarus community will love to have it in appimage format if possible.

@Samueru-sama
Copy link
Contributor

Samueru-sama commented Nov 27, 2024

The lazarus package is 1.8 GiB? https://archlinux.org/packages/extra/x86_64/lazarus/ I also needed to install lazarus-gtk3 to have a .desktop entry to launch.

when I launch the app this is all I get:

image

The gtk2 version ""works"" but wtf is going on haha:

untitled.mp4

@benjamimgois
Copy link
Author

The lazarus package is 1.8 GiB? https://archlinux.org/packages/extra/x86_64/lazarus/ I also needed to install lazarus-gtk3 to have a .desktop entry to launch.

The 'lazarus-qt6' is a much better supported toolkit (that's one of the reasons i switched goverlay to qt). If possible, that would be a preferable version

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 27, 2024

The lazarus package is 1.8 GiB?

ok I think, once compressed into an AppImage it should be even smaller... much much smaller

@Samueru-sama
Copy link
Contributor

Okay will give another shot with the qt6 version, hopefully lazarus has means to relocate the /usr/lib/lazarus directory via an env variable.

@Samueru-sama
Copy link
Contributor

Alright I have good and bad news.

The good news is that an appimage is very likely possible.

The bad news is that it seems lazarus only works with full paths to find stuff lie its own /usr/lib/lazarus directory, so every time I launch the appimage I have to do stuff like manually type the path to the lazarus dir:

image

The appimage is a squashfs image that gets mounted with a random name on ${TMPDRI:-/tmp} so the ideal solution is for lazarus to provide an env variable like LAZARUS_DIR that I can set in the AppRun and that way everything goes smoothly.

The other method is preloading some library that overwrites /usr/lib/lazarus like this one, but I'm not sure it is a good idea to preload libraries on an IDE hehe.

And this issue also happens to some other stuff, for example this:

image

lazarus can find the fpc binary because I symlinked it to the ,/bin dir of the AppImage, which gets added to PATH by sharun, but it complains that there is no fpc.cfg, this is because that file is located on /etc and once again this would need an env variable to fix.

same with FPC Sources I had to type the path manually:

image

WIth that said it seems lazarus tries to find its directory in the location where the binary is locared, because by default the search path is the bin directory where the binaries are located, so I don't know if it needs to have a specific name for it to be found.

WIll continue later, but if lazarus provides means to have portable installation that doesn't rely on full paths this should be easy, the thing is that I can't find such info.


If all of this fails then the next step would be using something like conty and spin a container, the appimage when made with dwarfs goes down to just 218 MiB, which is a 10x reduction of the original size and launches very quickly as well.

@benjamimgois
Copy link
Author

I ask for help in the lazarus gitlab and link this thread. Maybe some developer might be able to help.

https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41262

@User4martin
Copy link

Maybe you should start the IDE with --pcp= to set the primary config path. That is where the config will be saved. By default that is ~/.lazarus

You can set that option inside a file called lazarus.cfg next to the lazarus executable.

I am not sure / needs to be tested: If that can be given relative to the current dir, or the lazarus executable dir.

The config can contain values for most of the directories. And they can be set using "ide macros" like $(LazarusDir)

You can also have templates for the config files (at least environmentoptions.xml, maybe others in the same directory as the lazarus executable. They will be used if no config exists yet. They will then be saved in the primary config path.
=> once you did the configuration, copy the environmentoptions.xml (and strip it down if needed)

A full list of IDE macros can be seen under menu: View > Ide internals > About IDE => then the tab IDE macros.

@Samueru-sama
Copy link
Contributor

Maybe you should start the IDE with --pcp= to set the primary config path. That is where the config will be saved. By default that is ~/.lazarus

Aren't those files user configurable and normally get written during the operation of the application? if that's the case then it would not work, the appimage is read only.

I am not sure / needs to be tested: If that can be given relative to the current dir, or the lazarus executable dir.

The config can contain values for most of the directories. And they can be set using "ide macros" like $(LazarusDir)

You can also have templates for the config files (at least environmentoptions.xml, maybe others in the same directory as the >lazarus executable. They will be used if no config exists yet. They will then be saved in the primary config path.
=> once you did the configuration, copy the environmentoptions.xml (and strip it down if needed)

A full list of IDE macros can be seen under menu: View > Ide internals > About IDE => then the tab IDE macros.

Looks like namespaces it is, but I will give it another shot and share the result tomorrow.

@User4martin
Copy link

I'm writing most of this from memory. And with a Windows background, but it should work the same on Linux (mostly).

Aren't those files user configurable and normally get written during the operation of the application?

In the "primary config path" (e.g. ~/.lazarus or in the %APPDATA% on windows) => yes, Lazarus will write to them.

In the install folder (where the lazarus executable is) can be templates. They will be copied once, if there is no pre existing config yet. They are only used as template.


About specifying a different config folder with --pcp=

You don't need to do that, but if the user had an old install, the folder has the old paths.

However, if indeed all pathes that are relative to the "install dir" are using $(LazarusDir) then they will all be correct. (There will still be a prompt that something changed if the install dir was changed.


Then of course the FPC dir, if not a default install must be found too. That depends on how FPC was installed.


If the install folder is write protected, the Lazarus must be started with startlazarus (and if you have a --pcp= then that must be given to startlazarus too, so better put it into lazarus.cfg if indeed you need it).

The reason is, that when the user installs a package, the IDE needs to be recompiled. The new lazarus executable can not be written to the write protected folder, so it is written to the config directory (somewhere within, I don't recall). startlazarus will check for that and start the updated IDE.

@Samueru-sama
Copy link
Contributor

Alright this is what I got so far: https://mega.nz/file/ZRQnjDwA#k2s0tayRQYbrRGUH3n4RcONmJz80l4UlML-ibYybIfk

You can pass the flag --appimage-extract to inspect the contents and see if anything can be fixed on the existing appimage.

The appimage bundles everything and even starts on alpine linux (no glibc) but of couse I need to set the path to some files manually each time I start it.

Here is the build script:
lazarus-qt6-appimage.sh.txt

There is no AppRun script as sharun is doing that automatically, if extra env variables need to be set those can be passed by creating a .env file next to AppRun.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 5, 2024

since they have a .deb package, I would try with https://github.com/ivan-hc/AppImaGen

I'll publish what I'm able to do as a proof of concept into another repo.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 6, 2024

I did a script using https://github.com/ivan-hc/AppImaGen

lazarus.sh.txt

the AppImage is 274 MB and it seems to work quite well, it only includes the three .deb packages provided on sourceforge and being not based on an Arch Linux container, it should not have issues with hardware accelleration.

Obvously, there are some things to be fixed, I redirected the custom AppRun to /usr/share/lazarus/$VERSION/startlazarus instead of the symlink /usr/bin/startlazarus (there are three symlinks I was unable to remove for some strange reason). I commented the steps of symlinking.

How to use

simplescreenrecorder-2024-12-06_01.38.18.mkv.mp4

Sorry if I won't take care of it myself. I don't know the program nor do I think I'll learn how to use it. So I don't know what any dependencies to add are. If you are familiar with configuring and installing via .deb packages, it will be easy to configure the recipe to create it.

I had to add some extra steps because the main .deb package was not extracted directly from pkg2appimage, I had to use tar for that, and the same to get the icon from "/usr/share/pixmaps".

I hope it helps.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 6, 2024

PS: in the recipe.yml I use "Debian oldstable" as a branch, but as you can see, I specified only the three .deb packages that are listed. This is the content of the "recipe.yml" file

app: lazarus
binpatch: true

ingredients:

  dist: oldstable
  script:
    - if ! test -f ./lazarus-project_3.6.0-0_amd64.deb; then wget "https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.6/lazarus-project_3.6.0-0_amd64.deb/download" -O lazarus-project_3.6.0-0_amd64.deb; fi
    - if ! test -f ./fpc-laz_3.2.2-210709_amd64.deb; then wget "https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.6/fpc-laz_3.2.2-210709_amd64.deb/download" -O fpc-laz_3.2.2-210709_amd64.deb; fi
    - if ! test -f ./fpc-src_3.2.2-210709_amd64.deb; then wget "https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.6/fpc-src_3.2.2-210709_amd64.deb/download" -O fpc-src_3.2.2-210709_amd64.deb; fi
  sources:
    - deb http://ftp.debian.org/debian/ oldstable main contrib non-free
    - deb http://security.debian.org/debian-security/ oldstable-security main contrib non-free
    - deb http://ftp.debian.org/debian/ oldstable-updates main contrib non-free
  packages:
    - lazarus-project
    - fpc-laz
    - fpc-src

because I had to set the dynamic URLs in variables that the script expands

host_dir=$(curl -Ls https://www.lazarus-ide.org/index.php?page=downloads | tr '><"' '\n' | grep -i "^http.*linux.*amd64.*deb")
dl_deb=$(curl -Ls "$host_dir" | tr '"><' '\n' | grep "http.*files.*lazarus-project.*download$" | head -1)
fpc_laz=$(curl -Ls "$host_dir" | tr '"><' '\n' | grep "http.*files.*fpc-laz.*download$" | head -1)
fpc_src=$(curl -Ls "$host_dir" | tr '"><' '\n' | grep "http.*files.*fpc-src.*download$" | head -1)
DEB=$(echo "$dl_deb" | sed 's#/download$##g; s:.*/::')
DEB_laz=$(echo "$fpc_laz" | sed 's#/download$##g; s:.*/::')
DEB_src=$(echo "$fpc_src" | sed 's#/download$##g; s:.*/::')

you can run the script several times, in the recipe I specified that if the three .deb packages if are not in place, you don't need to download them again.

BTW, also if I specified "oldstable" as a Debian branch, no other .deb package has been downloaded from the Debian repos. Only the three listed. Maybe you need to add something to made "compilers" work... I see the red warning message, like @Samueru-sama in its screenshots.

If you have other questions, I'm here

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 6, 2024

PPS: my release of pkg2appimage does not contain convert, you need to install imagemagick to have it... or maybe you can replace https://raw.githubusercontent.com/ivan-hc/AM-application-manager/main/tools/pkg2appimage with the original one https://github.com/AppImageCommunity/pkg2appimage/releases/download/continuous/pkg2appimage--x86_64.AppImage

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 6, 2024

Uhm... I suppose that by using only that three .deb packages, an AppRun with the right vairables that will point to a compatible compiler and something else... would easily convert Lazarus to an AppImage, without other stuff.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 6, 2024

Just noticed that fpc is provided by "fpc-laz" package, so it is already in the AppImage, same for the "rtl" directory, brovided by "fpc-src" instead... but when I go selecting them, this is what happens

simplescreenrecorder-2024-12-06_06.57.07.mkv.mp4
File: /tmp/.mount_LazaruIeOdli/usr/bin/fpc

Errore: fpc.cfg is missing.
Cartella:/tmp/.mount_LazaruIeOdli/usr/share/fpcsrc/3.2.2/rtl/

Errore: cartella rtl non trovata
Potete scaricare FPC e i sorgenti FPC da http://sourceforge.net/projects/lazarus/?source=directory

Just copied the errors.

What now?

EDIT: may it be that the AppRun is wrong?

EDIT2: I romoved my previous message, since all stuff I asked for is already into the AppImage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants