adrian

adrian

Add packages to the nerves firmware

Hello,

I have a project with a Phoenix based UI, and one of the requirements is to get a PDF report.

I’m using Raspberry Pi 3, and I’ve read Systems — nerves v1.14.3

when running make menuconfig I see some packages that can be installed.

In the case I need wkhtmltopdf (required for many elixir libraries), which is not in the list, do I have to create it somehow for buildroot?

using ssh nerves.local I can get into Elixir session, but is it possible to ssh into a shell?

I’m very confused with this part of Nerves System, buildroot, busybox…

Thanks!

Most Liked

fhunleth

fhunleth

Co-author of Nerves

This is one of those things that is surprisingly hard and a reason to seriously thank package maintainers. There are several issues: Qt and Webkit have a lot of dependencies, Qt switched to Chromium for their web engine a while back so there’s more effort to get their Webkit integration, and the main one is that wkhtmltopdf hasn’t already been ported to Buildroot. If the last one weren’t the case, then this would be soooo much easier.

Here’s what I’d try:

  1. See if someone has built a static linked binary of wkhtmltopdf for ARM. If yes, then try including that in a priv directory or a rootfs_overlay. If you can run it and it doesn’t crash immediately, you’re probably good.
  2. See if you can upload the data to a server for pdf conversion.
  3. Port wkhtmltopdf to plain-vanilla Buildroot (no Nerves). Try setting the “all static libraries” option and see if you can generate a static wkhtmltopdf binary. I.e. make option #1.
  4. If there are issues making a static version of wkhtmltopdf, then try making one that uses dynamic libraries in plain-vanilla Buildroot. I’m certain this will work. Once you do this, the path to integrating it with Nerves will make a lot more sense.

I’m not going to lie, there’s some work here if #1 or #2 don’t pan out. I recently had to deal with this and ended up using a Qt PDF report generator (NCReport). That solution has some different challenges, but is much faster than wkhtmltopdf if you are running on a slow processor.

Good luck, and please let us know how you end up.

ConnorRigby

ConnorRigby

Nerves Core Team

I’ve never looked for this package, but you may have to add it manually. Nerves supports this and there is a great talk from last year’s ElixirConf about it. I’ll try to find it if you would like.

We had a sort of shell a while back. You can add the dep from here but it isn’t your normal shell. It is usually easier to do cmd("echo hello world") but sometimes you need a bit more control in which case i do usually: _ = Nerves.Runtime.cmd("echo", ["hello", "world"], :return). The only issue with those two approaches is when you need something that does fancy stuff to the terminal such as top. (which is disabled in the default systems iirc). What are you trying to do in a regular shell? maybe i can recommend an approach.

fhunleth

fhunleth

Co-author of Nerves

@cokron It has been a LONG time since I’ve used NCReport.

You’ll have to fork whatever Nerves system that you’re using and create a package/ncreport directory where you’ll put the Buildroot recipe files for building NCReport. You’ll also need to add a Config.in with the contents source "$NERVES_DEFCONFIG_DIR/package/ncreport/Config.in"

The Buildroot docs describe what to put in the Config.in and ncreport.mk files that you’ll need in the package/ncreport directory.

Here’s what I had from an old project that used NCReport. The project is OLD, so please, please refer to the Buildroot docs to double check it. I don’t remember why I didn’t use Buildroot’s QMake infrastructure, but maybe it didn’t exist back then. If I were to do this today, I’d use it .

Config.in

config BR2_PACKAGE_NCREPORT
        depends on BR2_PACKAGE_QT
        select BR2_PACKAGE_QT_SCRIPT
        select BR2_PACKAGE_QT_XML
        bool "ncreport"
        help
          NCReport is a lightweight, fast, multi-platform and easy
          to use report generator tool written in C++ based on the
          Qt Application framework

ncreport.mk

################################################################################
#
# ncreport
#
################################################################################

NCREPORT_VERSION = <fill in>
NCREPORT_SITE = git@github.com:fork/NCReport.git
NCREPORT_SITE_METHOD = git
NCREPORT_DEPENDENCIES = qt

NCREPORT_INSTALL_STAGING = YES

define NCREPORT_CONFIGURE_CMDS
        cd $(@D)/src/ncreport && $(QT_QMAKE) -r "DEFINES += LABEL_QT_TRANSLATOR_INTEGRATION" "DISABLED_FEATURES = SVG SQL PREVIEW_WINDOW PRINT_DIALOG CURSOR EMAIL TABLE_VIEW" -after "target.path=$(STAGING_DIR)/usr/lib" -after "headers.path=$(STAGING_DIR)/usr/include/NCReport" -after "documentation.path=$(STAGING_DIR)/usr/doc/NCReport" -after "reports.path=$(STAGING_DIR)/usr/reports"  ncreport.pro
endef

define NCREPORT_BUILD_CMDS
        $(MAKE) -C $(@D)/src/ncreport
endef

define NCREPORT_INSTALL_STAGING_CMDS
        $(MAKE) -C $(@D)/src/ncreport install
endef

define NCREPORT_INSTALL_TARGET_CMDS
        cp -dpf $(STAGING_DIR)/usr/lib/libNCReport.so.* $(TARGET_DIR)/usr/lib
endef

$(eval $(generic-package))

I can’t help with CUPS. I don’t often have to interface with printers and when I do, it seems like there’s some easier non-generic interface that I can use.

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New

Other popular topics Top

WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54120 245
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement