0

I'm trying to include my Python scripts in my Linux image (for Raspberry Pi). I have 11 scripts and I would like to have them in a file who looks like: /app/scripts/all_my_python_scripts.py Thanks to that, I will be able to call script after boot time to start daemon automatically.

Currently, I am having these .mk and Config.in files in /path-to-buildroot/buildroot/package/python-scripts :

Config.in

config BR2_PACKAGE_PYTHON_SCRIPTS
    bool "python-scripts"
    default "y"
    help
      Import all Python (3.7.2) scripts

python-scripts.mk

PYTHON_PYTHON_SCRIPTS_VERSION = 1.0
PYTHON_PYTHON_SCRIPTS_SOURCE = ../../scripts/
PYTHON_PYTHON_SCRIPTS_LICENSE = BSD-3-Clause
PYTHON_PYTHON_SCRIPTS_TYPE = distutils

define PYTHON_PYTHON_SCRIPTS_COPY
    @$(call MESSAGE,"Syncing python scripts to $(TARGET_DIR)")
    cp ../../scripts/* $(TARGET_DIR)/scripts/
endef
$(eval $(generic-package))

I tried to modify the source path and the "generic-package" but still the same issue. I also correctly update buildroot/package/Confin.in and I double-checked with make menuconfig. I am currently trying to tar my python scripts (before compilation) store them in buildroot/dl and exact them via the makefile, but it doesn't sound logic at all ... I suppose an easier way exist.

Sometime buildroot try to download some file ... sometime it compiling but nothing happen. However, I notice I can't see my 'call MESSAGE', I am missing something ...

Rekoc
  • 438
  • 6
  • 17

2 Answers2

2

First, the prefix of variables in the .mk file must have a prefix equal to the file name, without '.mk', uppercased and with underscores instead of dashes:

  • PYTHON_PYTHON_SCRIPTS_VERSION -> PYTHON_SCRIPTS_VERSION
  • PYTHON_PYTHON_SCRIPTS_SOURCE -> PYTHON_SCRIPTS_SOURCE
  • etc

Additionally there's no "COPY" step in Buildroot, so the variable PYTHON_SCRIPTS_COPY is ignored. You probably want to use the "INSTALL" step:

  • PYTHON_PYTHON_SCRIPTS_COPY -> PYTHON_SCRIPTS_INSTALL_TARGET_CMDS

Finally, the "SCRIPTS_TYPE" step is specific to the Python package infrastructure. Since you are using the generic package infrastructure that variable will be ignored.


Note: a completely different solution if you just need to copy files in your rootfs is to use a root filesystem overlay (BR2_ROOTFS_OVERLAY). It's simpler, check it out and see if it fits your needs.

Arnout
  • 2,927
  • 16
  • 24
Luca Ceresoli
  • 1,591
  • 8
  • 19
0

I fixed my problem, it was variable name issue, I rename PYTHON_SCRIPTS in SCRIPTS, below the correct Makefile:

buildroot/package/scripts/scripts.mk

    ################################################################################
#
# scripts
#
################################################################################

SCRIPTS_VERSION = 1.0
SCRIPTS_DEV_DIR = ../scripts/
SCRIPTS_SITE = ../scripts
SCRIPTS_SITE_METHOD = local
SCRIPTS_INSTALL_TARGET = YES

define SCRIPTS_INSTALL_TARGET_CMDS
    rm -v $(TARGET_DIR)/scripts/*
    rsync -av $(SCRIPTS_DEV_DIR) $(TARGET_DIR)/scripts/
endef

$(eval $(generic-package))
Rekoc
  • 438
  • 6
  • 17