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 https://hexdocs.pm/nerves/systems.html#customizing-your-own-nerves-system

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

Tee
can someone please explain to me how Enum.reduce works with maps
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New

We're in Beta

About us Mission Statement