Jump to content

How to add custom packages


Recommended Posts

Hi all,

 

  I need to add some packages to Armbian in the build phase.

 

I tried two ways, both failed:

 

1. Had run through docs (https://docs.armbian.com/Developer-Guide_User-Configurations/), and the suggestion is to add a var PACKAGE_LIST_ADDITIONAL in userpatches/lib.config

 

  PACKAGE_LIST_ADDITIONAL="$PACKAGE_LIST_ADDITIONAL watchdog modemmanager iptables iptables-persistent dnsmasq bridge-utils iproute2 openvpn"

 

  Building the image I get the following error:

 

   [🌱] Using user configuration override [ /home/andrea/armbian/build/userpatches/lib.config ]
   /home/andrea/armbian/build/userpatches/lib.config: line 1: PACKAGE_LIST_ADDITIONAL: readonly variable
   [💥] Exiting with error 1 [ at /home/andrea/armbian/build/userpatches/lib.config:1

                         source() --> userpatches/lib.config:1
         do_extra_configuration() --> lib/functions/configuration/main-config.sh:352
                do_with_logging() --> lib/functions/logging/section-logging.sh:81
    do_with_conditional_logging() --> lib/functions/logging/section-logging.sh:111
    prep_conf_main_build_single() --> lib/functions/main/config-prepare.sh:34
         cli_standard_build_run() --> lib/functions/cli/cli-build.sh:22
        armbian_cli_run_command() --> lib/functions/cli/utils-cli.sh:136
                 cli_entrypoint() --> lib/functions/cli/entrypoint.sh:176
                           main() --> compile.sh:50

]

[💥] Cleaning up [ please wait for cleanups to finish ]

 

2. Customizing userpatches/customize-image.sh:

 

  Added the following lines to the aforementioned file:

 

    CUST_PACKAGES="watchdog modemmanager iptables iptables-persistent dnsmasq bridge-utils iproute2 openvpn"

    apt-get install -yy $CUST_PACKAGES |& tee -a $DEST/${LOG_SUBPATH}/custom.log

 

  The build completes, but packages aren't added as the logging prevents the build to fail. Anyway the following info messages are displayed during the build:

 

    [🔨]   Reading package lists...
    [🔨]   Building dependency tree...
    [🔨]   Reading state information...
    [🔨]   Package modemmanager is not available, but is referred to by another package.
    [🔨]   This may mean that the package is missing, has been obsoleted, or
    [🔨]   is only available from another source
    [🔨]   
    [🔨]   Package iptables is not available, but is referred to by another package.
    [🔨]   This may mean that the package is missing, has been obsoleted, or
    [🔨]   is only available from another source
    [🔨]   However the following packages replace it:
    [🔨]     libxtables12
    [🔨]   
    [🔨]   E: Unable to locate package watchdog
    [🔨]   E: Package 'modemmanager' has no installation candidate
    [🔨]   E: Package 'iptables' has no installation candidate
    [🔨]   E: Unable to locate package iptables-persistent
    [🔨]   E: Unable to locate package dnsmasq
    [🔨]   E: Unable to locate package openvpn

 

Can you suggest a suitable way to add packages to the build?

 

Thanks very much in advance, kind regards

 

Andrea

Link to comment
Share on other sites

Hello,

 

having the problem myself I investigated this issue myself a bit and found this in build/lib/functions/configuration/main-config.sh:

 

	# Obsolete stuff, make sure not defined, then make readonly
	declare -g -r DEBOOTSTRAP_LIST
	declare -g -r PACKAGE_LIST
	declare -g -r PACKAGE_LIST_BOARD
	declare -g -r PACKAGE_LIST_ADDITIONAL
	declare -g -r PACKAGE_LIST_EXTERNAL
	declare -g -r PACKAGE_LIST_DESKTOP

 

The only fix that does not involve some sort of "hack" would be installing the packages via a custom script and adding it to the build process in build/userpatches

 

Did you add the repos and then a apt update before doing a apt install <packages>
When I tried this it worked for me.

 

If you don't want to do this you can also just set the value of this variable when you call the script like you did, but this can become quite a hassle if you do this multiple times and you need like 30 additional packages

 

./compile <optional custom config file> PACKAGE_LIST_ADDITIONAL="some packages"

 

PACKAGE_LIST_BOARD also works because at the end all these variables are being added anyway, but this variable is normally used to set the packages for a specific board type in build/config/boards.

Configuring the packages there will probably also not work, because this variable is like the other ones set to read only.

 

There is also no mention of that in the documentation and it still shows examples for this feature: https://docs.armbian.com/Developer-Guide_User-Configurations/#user-provided-configuration

Edited by christop
Forgot to ask if she added the repos
Link to comment
Share on other sites

Hi @christop, sorry for the late reply. I had run into the finest details of the build script:

  1. PACKAGE_LIST_ADDITIONAL env var has been removed;
  2. PACKAGE_LIST_BOARD may work, but only when it's not set into the board .conf file (as it would override the environment variable set while calling compile.sh);
  3. the only reliable way is to use EXTRA_PACKAGES_IMAGE (it will require EXTRA_PACKAGES_IMAGE_REFS to be added as well).

Example:

 

EXTRA_PACKAGES_IMAGE="btrfs-progs net-tools screen devmem2"

EXTRA_PACKAGES_IMAGE_REFS="build:compile.sh:0 build:compile.sh:0 build:compile.sh:0 build:compile.sh:0"

 

Link to comment
Share on other sites

Had to add some 60 packages for an embedded Rpi CM4 project and this thread in the forum proved very valuable since the documentation is completely outdated in the aspect of adding packages.

Added the packages that needed to be included to the variable EXTRA_PACKAGES_ROOTFS. This differs from  using EXTRA_PACKAGES_IMAGE in that the extra packages are cached.

The first compile of course takes time to download and install all the extra packages, but having the packages in cache saves a lot of time in repeated compilations with the same EXTRA packages definition.

Defined the extra packages in the config-<PROJECTNAME>.conf in the userpatches folder. Also the EXTRA_PACKAGES_ROOTFS_REFS variable must be defined there.

Did latter  in a loop:

for i in {1..60}
do
   EXTRA_PACKAGES_ROOTFS_REFS+="build:compile.sh:0 "
done

 

Would welcome some explanation about these REFS definitions. The package-lists.sh code, in /lib/functions/configuration, hints at it being a function name, source, and line no. of the calling function, but what one can achieve with these REFS lines remains unclear to me. Anybody here that can give some background that could be added to an updated documentation?

 

Edited by wwortel
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines