maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   Compiling / packaging modern command line software on MeeGo (https://talk.maemo.org/showthread.php?t=101447)

dredlok706 2023-09-17 09:16

Compiling / packaging modern command line software on MeeGo
 
Hello

I recently had some fun compiling modern CLI things for Nokia N9.
So far I did:

- Python 3.9.18 (CPython) compiled against OpenSSL 1.1.0h. This resulted in Python having all modules except tkinker (although some cmath / float tests failed during optimizing - but only few. Modules itself work.). Even with working ssl (TLS 1.2) and pip.

./configure arguments used:

Code:

--prefix=/opt/python.3.9.18 --enable-shared --enable-optimizations --with-ensurepip=install --with-openssl=/opt/openssl.1.1.0h --with-ssl-default-suites=openssl
- OpenSSL 1.1.0h. TLS 1.2 supported, but there are no any certs yet, so curl / wget rejects downloading, unless --insecure / --no-check-certificate specified.

./config arguments used:

[CODE]shared --prefix=/opt/openssl.1.1.0h --openssldir=/opt/openssl.1.1.0h -Wl,-rpath=/opt/openssl.1.1.0h/lib

- Curl 8.3.0 against OpenSSL 1.1.0h. postinst adds insecure to config so it won't check certs - temporary workaround.

./configure arguments used:

Code:

--prefix=/opt/curl.8.3.0 --with-ssl=/opt/openssl.1.1.0h
- diffutils 3.10 - to provide cmp and diff often used in makefiles / configure.

./configure arguments used:

Code:

--prefix=/opt/diffutils.3.10
- Bash 5.2.15

./configure arguments used:

Code:

--prefix=/opt/bash.5.2.15
- Viu (terminal image viewer)

Compiled using cross (Viu is written in Rust) with
Code:

armv7-unknown-linux-musleabihf
as target.

- OpenSSH 9.3p2 Compiled against OpenSSL 1.1.0h.

-------------------------------------

What I use for compiling? An old 2017 X1 Carbon running Arch Linux and QEMU User Static. I mount Harmattan SDK, bind-mount a directory in my /home to SDK so I have much space.

I use what SDK provided with Thecust repo mirror. GCC 4.4. If I need more libs, I try to compile them too - usually works.

Now the important part - how to package the program properly? For now I do it as following:

- compile with /opt/<package>.<version> prefix
- right after make install I do
Code:

tar cvzf package-ready.tgz /opt/<package>.<version>
. If there are more steps like generating ssh keys in OpenSSH - I search how they are done in Makefile and add to postinst.
- I make symlinks. I.e. everything in /opt/<package>.<version>/lib to /opt/lib, /opt/<package>.<version>/bin to /opt/bin. I made an Optified PATH package which adds them to PATH.
- package into DEB with N9-specific things like digsigsums, md5sums, etc. Using
Code:

dpkg-deb -b -Zgzip --root-owner-group
.

But I believe it's not the right way to do so. Packages should be in one /opt/<dir> directory. But how to package them, then? Checkinstall seems to be very outdated and better not to be used - but in past it was used to exactly the same thing.

Also what is the best way to edit environment variables on N9? /etc/profile doesn't seem to be always sourced by ash.

Anyway, you can grab current results here:

http://wunderwungiel.pl/MeeGo/apt-repo/pool/testing/

In addition, I packaged pfetch and neofetch for MeeGo :)
My next goal is to build new GCC and BusyBox.

Thanks for all tips!

dredlok706 2023-09-19 18:33

Re: Compiling / packaging modern command line software on MeeGo
 
I found another method - seems to be much better.

I now have two Harmattan SDKs - let's name it SDK1 and SDK2.
A directory inside my host's home "MeeGo-workdir" is mounted as /home/user/MyDocs/workdir inside both SDK1 and SDK2.

I compile everything in SDK1 with "/opt/wunderw" prefix. Then I install it in SDK2 with make install, create .tgz archive from "/opt/wunderw" directory, uninstall program with make uninstall and finally delete "/opt/wunderw". This way contents of tgz file is only the freshly compiled program and only its files.

I will check how it behaves in real use. In short this method avoids creating multiple directories in /opt for each program and creating symlinks.

Maemish 2023-09-19 20:00

Re: Compiling / packaging modern command line software on MeeGo
 
Nice job! Keeping meego alive.

dredlok706 2023-09-21 16:37

Re: Compiling / packaging modern command line software on MeeGo
 
I also had a unusual problem - I had to make a gcc wrapper with custom arguments, because apparently GCC 4.4 doesn't use compiler-specific variables like C_INCLUDE_PATH or CXXFLAGS and similar. sh couldn't work, because it has problem with dealing with quotation marks. In the end I just used Python, and wrote below.

GCC:

Code:

#!/usr/bin/env python3.1

import subprocess
import sys

args = ["gcc-4.4", "-D_Static_assert(a,b)=(1)", "-I/opt/wunderw/include", "-L/opt/wunderw/lib", "-lncursesw", "-lpng", "-lunistring"]

for i, arg in enumerate(sys.argv):
    if i == 0:
        continue
    else:
        args.append(arg)

result = subprocess.call(args)
sys.exit(result)

G++:

Code:

#!/usr/bin/env python3.1

import subprocess
import sys

args = ["g++-4.4", "-I/opt/wunderw/include", "-L/opt/wunderw/lib", "-lncursesw", "-lpng", "-lunistring"]

for i, arg in enumerate(sys.argv):
    if i == 0:
        continue
    args.append(arg)

result = subprocess.call(args)
sys.exit(result)

It will add some paths to library and include paths, and include some libraries. Seems to work well.
How to use? Put into /usr/bin/gcc and /usr/bin/g++ and chmod 755 both of files.

dredlok706 2023-10-21 12:50

Re: Compiling / packaging modern command line software on MeeGo
 
Great news!

1. I compiled OpenSSL 1.1.1w (!!!) (not 1.1.0h) - with TLS 1.3 support!!!
2. I packaged full set of Mozilla certificates from Arch Linux for above OpenSSL
3. Latest curl compiled against above OpenSSL 1.1.1w gives NO errors when downloading TLS 1.3-only sites (also NO errors related to certificates!)
4. I compiled Python 3.11.3 with full SSL/TLS support and even things like SQLite3 and even Tkinter should work after my latest work!

Everything is already packaged and will be published soon!

Maemish 2023-10-21 12:54

Re: Compiling / packaging modern command line software on MeeGo
 
Nice job again!

nieldk 2023-10-21 17:29

Re: Compiling / packaging modern command line software on MeeGo
 
Quote:

Originally Posted by dredlok706 (Post 1575735)
Great news!

1. I compiled OpenSSL 1.1.1w (!!!) (not 1.1.0h) - with TLS 1.3 support!!!
2. I packaged full set of Mozilla certificates from Arch Linux for above OpenSSL
3. Latest curl compiled against above OpenSSL 1.1.1w gives NO errors when downloading TLS 1.3-only sites (also NO errors related to certificates!)
4. I compiled Python 3.11.3 with full SSL/TLS support and even things like SQLite3 and even Tkinter should work after my latest work!

Everything is already packaged and will be published soon!

Just curious. Does 1.1.1 Co-exist with the original version?

Great job!

dredlok706 2023-10-21 18:43

Re: Compiling / packaging modern command line software on MeeGo
 
Yes. When building I specify "--prefix=/opt/wunderw" with each thing to compile. This way each package lives in /opt/wunderw directory, not conflicting with system packages.


All times are GMT. The time now is 07:22.

vBulletin® Version 3.8.8