Support of libjson-perl possible

Hi all,
I am checking a new option for my FHEM installation to support “Shelly” modules.
And this option needs the module " libjson-perl"

I did not found this module in the package list.
Is it supported by IPFire ? Do I have the chance to install it.

Best regards and stay save
R.

Hi @ritchie

No it is not available in IPFire.

You can build it as an addon that you can install and use locally
https://wiki.ipfire.org/devel/ipfire-2-x/addon-howto

and if you think it would be useful for others then you could submit a patch of your addon, once you have proven it out, to the IPFire development list for consideration to become a standard installed addon.
https://wiki.ipfire.org/devel/git
https://wiki.ipfire.org/devel/submit-patches
https://wiki.ipfire.org/devel/contact

1 Like

hi,
Is this the only way to add a existing library to the system ?
I will need a lot of knowledge just to create a package of a existing perl-lib.
Best regards
R.

Hi @ritchie

I am afraid not.

Any method of installing perl modules requires make to be run and there are no compiler tools on IPFire and shouldn’t be on any firewall.

1 Like

Hi,

o.k. I understand.
But is there a sample existing, where I do not need the source code of the program.
So far I understand, I have to compile the lib on my computer ?
Since the compiling of the project is running already one or two hours and
I guess this is the base to start with the work.
Within the documentation it means, compile is running a long time.

Edit:
Where are the addon “perl-Date-Calc” and all the other libs. located. Maybe I can take a
look how these libs are created and do the same for the JSON Lib.
Within the “git” I do not found a separate folder of addons.

Edit 2:
maybe this will help me:

(it is in german)

Best regards
R.

Yes it does take some time. The first build is always longer as the ccache directory is empty. Further builds are a bit faster.

The first time I built IPFire it took 13 hours. I then upgraded my computer, which I had intended to anyway, and my builds now take around 2 to 2.5 hours.

For the lfs files they are all together (core and add-on) in the lfs folder. In your cloned git repository the top level will be ipfire-2.x and below that is the lfs directory. perl-Date-Calc is just called that. It makes sense to use that as a template for your JSON lib file.

If you are more comfortable with German then I think that will help. I have seen the English version of that article and it covers the basic steps to create an add-on. You should ignore the bits about 32 bit systems and needing to add linux32 to the ./make.sh build commands. I am presuming that you are using a 64 bit system for the build.

Good luck and feel free to come back here and ask questions. I will try and help with any difficulties you encounter. Alternatively, you could join the ipfire development mailing list and raise any questions or problems you encounter on there.
https://wiki.ipfire.org/devel/mailing-lists

Hi,
Compiling is finished. Just a other question, can I create a virtual machine in some way to test my add on. I wouldn’t like to test this on my production system.

Edit:
I just notice the ISO File in the main folder. I will try it with this one.

Best regards
R.

It work ! :slight_smile:

1 Like

That’s great news. Well done. :+1:

I am trying to create the addon, but I stuck by this message and do not know what is
missing:

Checking Logfiles for new Files
Rootfile for libjson-perl_2.90_missing_rootfile missing!
Changes in libjson-perl_2.90 check rootfile!

Where is the problem ?

Best regards
R.

Nothing to panic about.

Each core or add-on program needs to have a rootfile file which defines which files will be installed and where.
As your add-on is new then this file is missing.
However the build process creates the file for you. It is in the log directory and will be called libjson-perl_2.90 based on your message.

All the entries for that file will have a + at the start of the line. You need to decide which lines should have the + removed and which should have the + replaced by #. If the program is basically providing you with library files then normally everything the library files would be commented out (# used). Comment out the .so file but the .so.x and .so.x.y files that may exist are the ones you want to keep.
That article in German should mention the rootfiles. The wiki article of creating an add-on definitely does.
You can also look at the rootfile for perl-Date-Calc in config/rootfiles/packages/perl-Date-Calc to use as a template for what to comment out and what to keep.

After editing the file save it to config/rootfiles/packages/libjson-perl

Add-on rootfiles all go in config/rootfiles/packages
The core program rootfiles go into config/rootfiles/common

After saving the rootfile then normally you would need to do a ./make.sh clean followed by ./make.sh build

However as it is just a single perl module and won’t have an interaction with other main programs you can do a remove of the log files called libjson-perl_2.90 and libjson-perl_2.90_missing_rootfile and then do a ./make.sh build
That will just do a build of your module and leave all the other programs as they were. If there is no message at the end of that build then the .ipfire package is ready to take and install, which you can do on a vm machine to test out that everything works.
If you still get an error message then you will need to do the clean followed by the build which will take a long time to do again but should be clear of error messages at the end.

Let us know how it goes.

Good Morning Adolf,
thanks for the support. It maybe was to later yesterday. I will continue the build now and
you are right. Both description (even the german) will describe the handling of the rootfile.
Build is running now.
I will inform you about the results.
Best regards
R.

Good morning Ritchie,

It can appear confusing the first time round but believe me it will be easier when the libjson file is updated.

I have been there myself when I wanted the bacula add-on updated.
Also there are always people around in the forum here willing to help you.

All the best Adolf.

Hello,
the rebuild took it little bit longer. As well I updated the lib to the version 4.02000
which I guess is the actual table version.
At the end I still get the following message at the end of the building

Checking Logfiles for new Files
Error! ‘/i586’ in rootfiles files found!
./config/rootfiles/packages/libjson-perl_4.02000:usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON
./config/rootfiles/packages/libjson-perl_4.02000:usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON/.packlist
Replace by xxxMACHINExxx !
*** Build finished in 12:21

But I could not find any error file within the log folder.
But where can I check, that the package was correct build ?

When I run the installed version of the ISO I do not see any packages within
the web gui on the page “pakfire”.

Edit:
In addition. I do not find the perl-json… file as well anymore.

Edit 2:
The package is not created in the folder ./packages so far.
I removed the to files from the config/rootfiles/packages/ file and recompile it again.
See what happen.

Best regards
R.

Hi,

still the same.

Error is shown:

Checking Logfiles for new Files
Error! ‘/i586’ in rootfiles files found!
./config/rootfiles/packages/libjson-perl_4.02000:#usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON
./config/rootfiles/packages/libjson-perl_4.02000:#usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON/.packlist
Replace by xxxMACHINExxx !
*** Build finished in 12:49 [ DONE ]

Best regards
R.

Hi Ritchie,

The error should not be a problem for you in using the addon locally.

If you were providing the build to IPFire then you would have to replace any architecture specific naming with xxxMACHINExxx, then when the installation is done from the iso the appropriate architecture name is used in place of the xxxMACHINExxx entry.

What I don’t understand is that you are saying that you are not finding the libjson-perl package in the packages directory.

Maybe you can attach a copy of the lfs file and the rootfile that you have created. I can have a look at them and see if I can find anything that needs to be changed.

You will not be able to install your addon using the iso. The standard pakfire menu option looks at the addons that are available on the IPFire server. Yours is not there because you only have it locally.

Normally you would then transfer the libjson-perl.ipfire file from the top level packages directory at the ipfire-2.x level to your IPFire system that you want to install the addon into. This is described in the wiki but first we need to find your package file.

You are very close now. I am sure we will find the solution for you.

Hello Adolf,

please find here the files placed in the package folder as a screen shoot:

Here the screen shoot of the package file place

Here is the change of the make.sh File, I have done
lfsmake2 ipvsadm
lfsmake2 perl-Carp-Clan
lfsmake2 perl-Date-Calc
lfsmake2 perl-json
lfsmake2 perl-Date-Manip
lfsmake2 perl-File-Tail
lfsmake2 perl-TimeDate
lfsmake2 swatch

Here is the filename of the rootfiles/Packages

Here is a small look into the .tar.gz file, to show what files are in:
The file is from the debian website:

Here is the file itself:

usr/lib/perl5/site_perl/5.30.0/JSON
usr/lib/perl5/site_perl/5.30.0/JSON.pm
usr/lib/perl5/site_perl/5.30.0/JSON/backportPP
usr/lib/perl5/site_perl/5.30.0/JSON/backportPP.pm
usr/lib/perl5/site_perl/5.30.0/JSON/backportPP/Boolean.pm
usr/lib/perl5/site_perl/5.30.0/JSON/backportPP/Compat5005.pm
usr/lib/perl5/site_perl/5.30.0/JSON/backportPP/Compat5006.pm
#usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON
#usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON/.packlist
#usr/share/man/man3/JSON.3
#usr/share/man/man3/JSON::backportPP.3
#usr/share/man/man3/JSON::backportPP::Boolean.3
#usr/share/man/man3/JSON::backportPP::Compat5005.3
#usr/share/man/man3/JSON::backportPP::Compat5006.3

Here is the file name of the lfs folder:

Here is the file itself (only the definition part):
###############################################################################
Definitions
###############################################################################
include Config
VER = 4.02000

THISAPP = libjson-perl_$(VER)
DL_FILE = ${THISAPP}.tar.gz
DL_FROM = $(URL_IPFIRE)
DIR_APP = $(DIR_SRC)/$(THISAPP)
TARGET = $(DIR_INFO)/$(THISAPP)
PROG = perl-json
PAK_VER = 4

Please tell me, if you need any additional information.
So far i remember, these are the placed I have modified for the changes.

Thanks for help
Ritchie

That is fine

Looks good. The location just needs to be chosen to occur after any dependency programs that libjson-perl requires. If it was in the wrong place then the build would stop and there would be an error message about something not being present. This would occur before the cdrom build step.

the only change I would make here is to comment out the directories. However this would not cause a big issue if it was not done.

#usr/lib/perl5/site_perl/5.30.0/JSON
usr/lib/perl5/site_perl/5.30.0/JSON.pm
#usr/lib/perl5/site_perl/5.30.0/JSON/backportPP
usr/lib/perl5/site_perl/5.30.0/JSON/backportPP.pm
usr/lib/perl5/site_perl/5.30.0/JSON/backportPP/Boolean.pm
usr/lib/perl5/site_perl/5.30.0/JSON/backportPP/Compat5005.pm
usr/lib/perl5/site_perl/5.30.0/JSON/backportPP/Compat5006.pm
#usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON
#usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON/.packlist
#usr/share/man/man3/JSON.3
#usr/share/man/man3/JSON::backportPP.3
#usr/share/man/man3/JSON::backportPP::Boolean.3
#usr/share/man/man3/JSON::backportPP::Compat5005.3
#usr/share/man/man3/JSON::backportPP::Compat5006.3

That is good.

Only thing here is the PAK_VER should be 1
This is just an incremental version everytime the addon is updated. So as this is the first version you have every made this should be 1. Again this would not cause a problem to use it. This is the number at the end of the .ipfire name

Here you need to change the rootfiles name from libjson-perl_4.02000 to perl-json

The rootfile name needs to be the same as the PROG in the lfs. Most of the time people also use the same name in the make.sh file and also for the name of the lfs file itself. This will be where you are having a problem. You have a rootfile but it is not the one that the IPFire build will be looking for.

The package file will probably be called libjson-perl_4.02000-1.ipfire where the -1 is the PAK_VER number. The other possibility is it could be called perl-json…ipfire I am not totally sure here and I don’t have a completed build at the moment to check other addons and see where the package name comes from.

Hopefully this gives you the final push to successfully get your package.

If not just come back with what you find and we’ll see what we can do.

If you get the package then the following link to the wiki shows the section covering how to install it.
https://wiki.ipfire.org/devel/ipfire-2-x/addon-howto#testing
In the .ipfire package there will be a file called ROOTFILES. This lists all the files that were installed and where. You should keep a record of this as there will be no automatic removal of the files if you uninstall. You will need to manually remove the files so you need to have a record of which ones they were.

Hello Adolf,

the module is now created.

The problem was located in the name of the package in the rootfile.
I renamed it to “perl-json” and then it works.

Checking Logfiles for new Files
Error! ‘/i586’ in rootfiles files found!
./config/rootfiles/packages/perl-json:#usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON
./config/rootfiles/packages/perl-json:#usr/lib/perl5/site_perl/5.30.0/i586-linux-thread-multi/auto/JSON/.packl

But I still get the message:
The JSON Modul is now running and I have the “shelly” module already running on my production system. :slight_smile:

Thanks for your support :slight_smile:

What steps do I have to do, to give it into the official version ?
These once ?
wiki.ipfire.org/devel/git
wiki.ipfire.org/devel/submit-patches
wiki.ipfire.org/devel/contact

Best regards
R.

1 Like

Hi Ritchie

That’s great to hear. Well done.

This is not a problem while you are using the addon locally. When you want to submit a patch to have the addon included within IPFire then you need to follow the instructions the message gives, which is to replace all the i586 sections in the filenames in your rootfile by xxxMACHINExxx.

Glad to have been of help.

Yes, these are the ones to follow. You need to join the developers mailing list as all communications related to patch submission are done via that. The contact link will provide help with that.

To submit patches you will need to run git format-patch and setup and run git send-email. The git and submit-patches links help with how to do that.

Any questions on how to do any of the above should be raised in the developers mailing list.