CudaText icon indicating copy to clipboard operation
CudaText copied to clipboard

Package for Haiku OS

Open Alexey-T opened this issue 5 years ago • 62 comments

https://discuss.haiku-os.org/t/need-help-with-running-cudatext-editor/9717/5?u=alextp

Alexey-T avatar Jun 27 '20 13:06 Alexey-T

Hello @Alexey-T although we've got an older version on Haiku, I've been on and off trying to update our version. I was looking for the command used last time to build it but can't find it anymore (should be in some comment burried deep down somewhere). Could you give me a hint or do you know how I got it to build (been a long time) :)

EDIT used/using cudaup to build it with (currently): ./cudaup.sh -g -m -l/boot/home/fpcupdeluxe/lazarus -o haiku

EDIT2 nvm, found it: ./cudaup.sh -g -m -w qt5 - Qt 5 -l /boot/system/non-packaged/bin/fpcupdeluxe/lazarus

Begasus avatar Jun 11 '23 14:06 Begasus

sorry, but I don't have this info. it is buried in this GIthub issues somewhere. or not?

Alexey-T avatar Jun 11 '23 15:06 Alexey-T

Found it here (after a long search): https://github.com/Alexey-T/ATSynEdit/issues/291#issuecomment-997708529

Begasus avatar Jun 11 '23 15:06 Begasus

./cudaup.sh -g -m -w qt5 - Qt 5 -l /boot/system/non-packaged/bin/fpcupdeluxe/lazarus

can you tell me what does it mean: - Qt 5? it is not looking like a supported option.

Alexey-T avatar Jun 11 '23 15:06 Alexey-T

Build failure atm (maybe needs a new ticket?): https://bpa.st/K2HBY

Begasus avatar Jun 11 '23 15:06 Begasus

Fatal: (10022) Can't find unit system used by fcllaz

this means that FPC is not setup properly - mabe fpc.cfg file is missing something, I don't have knowledge.

Alexey-T avatar Jun 11 '23 15:06 Alexey-T

https://wiki.freepascal.org/Lazarus_Can%27t_find_unit_system_used_by_fcllaz

veksha avatar Jun 11 '23 15:06 veksha

Build it with fpcupdeluxe with the default path given there, will investigate further, ps, the cmd was wrong indeed, a bit further along the issue linked there is the right one. Thanks for the quick reply!

Begasus avatar Jun 11 '23 15:06 Begasus

Will Haiku be released? When??

Alexey-T avatar Jun 11 '23 16:06 Alexey-T

So far we're still in beta, and in no rush to release a R1 version (small developer pool), but things are running pretty fine so far.

Begasus avatar Jun 11 '23 16:06 Begasus

OK, with some checking I was able to build Cudatext from a checkout, build done with Lazarus (cudaup or lazbuild failed in Terminal but building the dependencies seperatly inside a project in Lazarus did the trick) :) 👍

Cuda-Text-1-195-0-6

Begasus avatar Jun 12 '23 07:06 Begasus

Great, thanks. Maybe you can make the full package?

Alexey-T avatar Jun 12 '23 09:06 Alexey-T

I see the sidebar icons (and Copy icon in the About dlg) are missing … it means that app cannot find its folder “data”.

Alexey-T avatar Jun 12 '23 09:06 Alexey-T

You can click the sidebar place with 3 blue number and read which errors app writes.

Alexey-T avatar Jun 12 '23 09:06 Alexey-T

Great, thanks. Maybe you can make the full package?

Already got a 32bit package locally done, will check on a build/package for 64bit later. :)

I see the sidebar icons (and Copy icon in the About dlg) are missing … it means that app cannot find its folder “data”.

Have to check that out, where in the source does it check for the "data" folder?

Begasus avatar Jun 12 '23 09:06 Begasus

File proc_globdata.pas . Search there for Haiku default path… I am not at home to tell more.

Alexey-T avatar Jun 12 '23 09:06 Alexey-T

I see the sidebar icons (and Copy icon in the About dlg) are missing … it means that app cannot find its folder “data”.

This is done with a postinstall script that comes with the package, better would be if this wasn't needed :)

Cuda-Text-1-195-0-6-2

Begasus avatar Jun 12 '23 10:06 Begasus

File proc_globdata.pas . Search there for Haiku default path… I am not at home to tell more.

So far haven't figure out how to separate AppDir_Data (only data) from AppDir_Settings (user specific data/settings) ...

EDIT this works but I'm not sure it's the best sollution:

diff --git a/app/proc_globdata.pas b/app/proc_globdata.pas
index 28470fa..b573fb1 100644
--- a/app/proc_globdata.pas
+++ b/app/proc_globdata.pas
@@ -1335,9 +1335,9 @@ begin
 
   {$ifdef haiku}
     {$ifdef CPU64}
-    exit('/boot/system/develop/lib/libpython3.7m.so');
+    exit('/boot/system/lib/libpython3.9.so.1.0');
     {$else}
-    exit('/boot/system/develop/lib/x86/libpython3.7m.so');
+    exit('/boot/system/lib/x86/libpython3.9.so.1.0');
     {$endif}
   {$endif}
 
@@ -1511,6 +1511,8 @@ begin
   HomeConfig:= AppDir_Home+'/config/settings';
   OpDirLocal:= HomeConfig+'/cudatext';
   CreateDirUTF8(OpDirLocal);
+  AppDir_Py:= '/boot/system/data/cudatext/'+DirectorySeparator+'py';
+  AppDir_Data:= '/boot/system/data/cudatext/'+DirectorySeparator+'data';
 end;
 
 procedure InitDirs_UnixCommon;
@@ -1622,8 +1624,10 @@ begin
         ], S);
   {$endif}
 
-  AppDir_Py:= OpDirLocal+DirectorySeparator+'py';
-  AppDir_Data:= OpDirLocal+DirectorySeparator+'data';
+  {$ifndef haiku}
+    AppDir_Py:= OpDirLocal+DirectorySeparator+'py';
+    AppDir_Data:= OpDirLocal+DirectorySeparator+'data';
+  {$endif}
   AppDir_Lexers:= AppDir_Data+DirectorySeparator+'lexlib';
   AppDir_LexersLite:= AppDir_Data+DirectorySeparator+'lexliblite';
   AppDir_DataThemes:= AppDir_Data+DirectorySeparator+'themes';

Begasus avatar Jun 12 '23 11:06 Begasus

Although it launches fine and looks OK getting some output when launched from Terminal with different python versions (only python3.7 produces no errors), first launch (python3.9), second launch (python3.7), third launch (python3.8) and last launch (python3.10), when launched with LD_PRELOAD=/boot/system/develop/lib/x86/libpython3.10.so ./cudatext it produces no errors, looking with readelf -d ./cudatext it doesn't seem to link to the python library?:

Terminal launches

~/CudaText_up/src/CudaText/app> ./cudatext
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "_Py_NoneStruct" returned: -2147478780
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "_PyLong_One" returned: -2147478780
~/CudaText_up/src/CudaText/app> ./cudatext
~/CudaText_up/src/CudaText/app> ./cudatext
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "_PyLong_One" returned: -2147478780
~/CudaText_up/src/CudaText/app> ./cudatext
resolve symbol "_Py_NoneStruct" returned: -2147478780
resolve symbol "PyExc_RuntimeError" returned: -2147478780
resolve symbol "_Py_NoneStruct" returned: -2147478780

readelf output

~/CudaText_up/src/CudaText/app> readelf -d cudatext

Dynamic section at offset 0xdd9010 contains 26 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libroot.so]
 0x00000001 (NEEDED)                     Shared library: [libnetwork.so]
 0x00000001 (NEEDED)                     Shared library: [libtextencoding.so]
 0x00000001 (NEEDED)                     Shared library: [libiconv.so.2]
 0x00000001 (NEEDED)                     Shared library: [libQt5Pas.so.1]
 0x00000010 (SYMBOLIC)                   0x0
 0x0000000f (RPATH)                      Library rpath: [./:7375ORIGIN]
 0x0000000c (INIT)                       0x6ce034
 0x0000000d (FINI)                       0xd65ebd
 0x00000004 (HASH)                       0xb4
 0x00000005 (STRTAB)                     0x1867f0
 0x00000006 (SYMTAB)                     0x67bd0
 0x0000000a (STRSZ)                      3483344 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000003 (PLTGOT)                     0xdea940
 0x00000002 (PLTRELSZ)                   12832 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x6cae14
 0x00000011 (REL)                        0x4fcc74
 0x00000012 (RELSZ)                      1892768 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0x4fcc44
 0x6fffffff (VERNEEDNUM)                 1
 0x6ffffff0 (VERSYM)                     0x4d8ec0
 0x6ffffffa (RELCOUNT)                   236592
 0x00000000 (NULL)                       0x0

Trying to build the seperate packages works fine on 32bit, on 64bit I'm running into Access violation (not sure it's related to the package of bogus fpcupdeluxe which seems somewhat bogus on 64bit):

Lazarus build 64bit

Hint: (lazarus) compile package BGRABitmapPack 11.5.4 Flags=[]
Hint: (lazarus) Compiler file changed for BGRABitmapPack 11.5.4
  File="/boot/home/config/non-packaged/bin/fpc/bin/x86_64-haiku/fpc.sh"
  State file="/boot/home/CudaText_up/src/bgrabitmap/bgrabitmap/lib/x86_64-haiku-qt5-3.2.2/BGRABitmapPack.compiled"
Info: (lazarus) Execute Title="Compile package BGRABitmapPack 11.5.4"
Info: (lazarus) Working Directory="/boot/home/CudaText_up/src/bgrabitmap/bgrabitmap/"
Info: (lazarus) Executable="/boot/home/config/non-packaged/bin/fpc/bin/x86_64-haiku/fpc.sh"
Info: (lazarus) Param[0]="-B"
Info: (lazarus) Param[1]="-MObjFPC"
Info: (lazarus) Param[2]="-Scgi"
Info: (lazarus) Param[3]="-O3"
Info: (lazarus) Param[4]="-OoREGVAR"
Info: (lazarus) Param[5]="-l"
Info: (lazarus) Param[6]="-vewnhibq"
Info: (lazarus) Param[7]="-Fu/boot/home/config/non-packaged/bin/lazarus/packager/units/x86_64-haiku"
Info: (lazarus) Param[8]="-Fu/boot/home/config/non-packaged/bin/lazarus/components/lazutils/lib/x86_64-haiku"
Info: (lazarus) Param[9]="-Fu/boot/home/config/non-packaged/bin/lazarus/components/freetype/lib/x86_64-haiku"
Info: (lazarus) Param[10]="-Fu/boot/home/config/non-packaged/bin/lazarus/lcl/units/x86_64-haiku"
Info: (lazarus) Param[11]="-Fu/boot/home/config/non-packaged/bin/lazarus/lcl/units/x86_64-haiku/qt5"
Info: (lazarus) Param[12]="-Fu/boot/home/CudaText_up/src/bgrabitmap/bgrabitmap/"
Info: (lazarus) Param[13]="-FU/boot/home/CudaText_up/src/bgrabitmap/bgrabitmap/lib/x86_64-haiku-qt5-3.2.2/"
Info: (lazarus) Param[14]="-dLCL"
Info: (lazarus) Param[15]="-dLCLqt5"
Info: (lazarus) Param[16]="bgrabitmappack.pas"
TApplication.HandleException: EAccessViolation
Access violation
  Stack trace:
  $0000017FB352CA30
  $00000183F4AF51E0
  $00000183F4BBC3DE
  $00000183F4ADEFAB
  $00000183F5064EB7
  $00000183F5062FDE
  $00000183F519AD81
  $00000183F51B6ACB
  $00000183F51A886D
  $00000183F5847C90
  $00000183F5845D5D
  $00000183F5840664
  $00000183F4D21217
  $00000183F4E0F652
  $00000183F4E0D201
  $00000183F4D2016A
  $00000183F4D20F2F

Begasus avatar Jun 13 '23 07:06 Begasus

Created a 32bit release at: https://github.com/Begasus/CudaText-Haikuports/releases/tag/1.195.0.6 (still no luck on 64bit) For this I created a new repository not containing unneeded clutter.

Added a release note at the forum: https://discuss.haiku-os.org/t/new-updated-in-haikudepot/4169/359?u=begasus

Begasus avatar Jun 13 '23 13:06 Begasus

-    exit('/boot/system/develop/lib/libpython3.7m.so');
+    exit('/boot/system/lib/libpython3.9.so.1.0');
     {$else}
-    exit('/boot/system/develop/lib/x86/libpython3.7m.so');
+    exit('/boot/system/lib/x86/libpython3.9.so.1.0');

added this fix. OK.

-  AppDir_Py:= OpDirLocal+DirectorySeparator+'py';
-  AppDir_Data:= OpDirLocal+DirectorySeparator+'data';
+  {$ifndef haiku}
+    AppDir_Py:= OpDirLocal+DirectorySeparator+'py';
+    AppDir_Data:= OpDirLocal+DirectorySeparator+'data';
+  {$endif}

this fix is not ok. but maybe this is better: adjust OpDirLocal for Haiku. in this code:

procedure InitDirs;
var
  S: string;
begin
  OpFileExe:= ParamStr(0);
  OpDirExe:= ExtractFileDir(OpFileExe);
  OpDirPrecopy:= GetDirPrecopy;
  OpDirLocal:= OpDirExe;

add:

  ...
  OpDirLocal:= OpDirExe;
  {$ifdef haiku}
  OpDirLocal:= '/boot/system/data/cudatext';
  {$endif}

test it.

Alexey-T avatar Jun 13 '23 14:06 Alexey-T

index a7ba2d1..2e60d4b 100644
--- a/app/proc_globdata.pas
+++ b/app/proc_globdata.pas
@@ -1565,6 +1565,9 @@ begin
   OpDirExe:= ExtractFileDir(OpFileExe);
   OpDirPrecopy:= GetDirPrecopy;
   OpDirLocal:= OpDirExe;
+  {$ifdef haiku}
+    OpDirLocal:= '/boot/system/data/cudatext';
+  {$endif}
 
   {$ifdef windows}
   InitDirs_Windows;

With the suggestion it expects the data in ~/config/settings/cudatext as set in line: https://github.com/Alexey-T/CudaText/blob/e0ac522dc381ebb08a963f21942af4b4c90f7fa8/app/proc_globdata.pas#L1512

While the data 'currently' is in /boot/system/data/cudatext

Begasus avatar Jun 13 '23 16:06 Begasus

so you suggest to add some dirs initing to procedure InitDirs_Haiku; ? please do it and show the diff, when tested.

Alexey-T avatar Jun 13 '23 17:06 Alexey-T

Even if I add AppDir_Py and AppDir_Data in the procedure they overuled by the lines here: https://github.com/Alexey-T/CudaText/blob/e0ac522dc381ebb08a963f21942af4b4c90f7fa8/app/proc_globdata.pas#L1625

A variant of my first attempt seems to work, but as you mentioned not the correct one:

diff --git a/app/proc_globdata.pas b/app/proc_globdata.pas
index a7ba2d1..c7a884c 100644
--- a/app/proc_globdata.pas
+++ b/app/proc_globdata.pas
@@ -1624,6 +1624,10 @@ begin
 
   AppDir_Py:= OpDirLocal+DirectorySeparator+'py';
   AppDir_Data:= OpDirLocal+DirectorySeparator+'data';
+  {$ifdef haiku}
+    AppDir_Py:= '/boot/system/data/cudatext/data';
+    AppDir_Data:= '/boot/system/data/cudatext/data';
+  {$endif}
   AppDir_Lexers:= AppDir_Data+DirectorySeparator+'lexlib';
   AppDir_LexersLite:= AppDir_Data+DirectorySeparator+'lexliblite';
   AppDir_DataThemes:= AppDir_Data+DirectorySeparator+'themes';

Begasus avatar Jun 13 '23 18:06 Begasus

Ok, diff looks correct. But installer must place actual dirs there - /boot/system/data/…… - does installer do it?

Alexey-T avatar Jun 14 '23 07:06 Alexey-T

Ok, diff looks correct. But installer must place actual dirs there - /boot/system/data/…… - does installer do it?

Yeah, when creating the package data will be installed in $dataDir (/boot/system/data) with cp -rf data/cudatext $dataDir The postinstall script will cp the default_settins dir to ~/config/settings/cudatext (now CudaText finds and can edit the default.json etc files) Need to switch back to python3.7m for the library, seems to be an import error with python3.9 https://ibb.co/2P1qwcB, while this is still ok with python3.7 https://ibb.co/GWHh8Dk (PS these screenshots are made on 64bit :) )

Begasus avatar Jun 14 '23 08:06 Begasus

made the fix. I don't know which path is ok:

  • '/boot/system/develop/lib/libpython3.7m.so' or
  • '/boot/system/lib/libpython3.7m.so'

please test.

Alexey-T avatar Jun 14 '23 08:06 Alexey-T

Checking on both arch's now that that is possible, thanks so far!

Begasus avatar Jun 14 '23 09:06 Begasus

Hold off on changes for now :) still figuring out some things. Changed AppDir_Py and AppDir_Data again to writable location (that works for installing add-ons importing python ...) (progress :) ) Switching to another python version (checked with python3.9 and python3.10 now (on 32bit)) gives me another error in the log, don't know how to fix that, only one that really works seems to be python3.7 (python3.9 is default in Haiku atm):

Python 3.9.17
Loaded session: "history session.json", 10ms, 3 file(s)
Startup: 400ms, plugins: 0ms ()
Init: cuda_prefs
Traceback (most recent call last):
  File "/boot/system/data/cudatext//py/cuda_prefs/__init__.py", line 1, in <module>
    from .cd_opts_dlg import Command, OptEdD
  File "/boot/system/data/cudatext//py/cuda_prefs/cd_opts_dlg.py", line 9, in <module>
    import  re, os, sys, json, collections, tempfile
  File "/packages/python3.9_x86-3.9.17-1/.self/lib/python3.9/tempfile.py", line 45, in <module>
    from random import Random as _Random
  File "/packages/python3.9_x86-3.9.17-1/.self/lib/python3.9/random.py", line 49, in <module>
    from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: Symbol not found
ERROR: Exception in CudaText for cuda_prefs.dlg_cuda_options: ImportError: Symbol not found
Saved session: "history session.json", 3 file(s), by timer at 11:13:02

Running with LD_PRELOAD=/boot/system/lib/x86/libpython3.9.so.1.0 ./cudatext (when build with python3.9 set) works and things are running fine), not sure why it 'links' with python3.7 fine but not for the other python versions ...

Begasus avatar Jun 14 '23 13:06 Begasus

I cannot help with Haiku python 3.9, sorry.

Alexey-T avatar Jun 14 '23 13:06 Alexey-T