How to add my own software to a Buildroot Linux package?
Minimal tested example on top of 2016.05
GitHub upstream:
https://github.com/cirosantilli/buildroot/tree/in-tree-package-2016.05
This example adds the package source in-tree, which is simple for educational purposes and the way to go if you want to merge back (kudos!),
If you do not intend on merging back (booooh!), it is more likely that you will want to use Buildroot as a git submodule and either:
- an out of tree package with
BR2_EXTERNAL
as shown at: https://github.com/cirosantilli/buildroot/tree/out-of-tree-2016.05 *_OVERRIDE_SRCDIR
+ other git submodules as explained at: How to modify the source of Buildroot packages for package development?
Files modified:
package/Config.in
menu "Misc"
source "package/hello/Config.in"
endmenu
package/hello/Config.in
config BR2_PACKAGE_HELLO
bool "hello"
help
Hello world package.
http://example.com
package/hello/hello.mk
################################################################################
#
# hello
#
################################################################################
HELLO_VERSION = 1.0
HELLO_SITE = ./package/hello/src
HELLO_SITE_METHOD = local
define HELLO_BUILD_CMDS
$(MAKE) CC="$(TARGET_CC)" LD="$(TARGET_LD)" -C $(@D)
endef
define HELLO_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/hello $(TARGET_DIR)/usr/bin
endef
$(eval $(generic-package))
package/hello/src/.gitignore
hello
package/hello/src/Makefile
CC = gcc
.PHONY: clean
hello: hello.c
$(CC) -o '$@' '$<'
clean:
rm hello
package/hello/src/hello.c
#include <stdio.h>
int main(void) {
puts("hello");
}
Usage:
make qemu_x86_64_defconfig
echo 'BR2_PACKAGE_HELLO=y' >> .config
make BR2_JLEVEL=2
qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append root=/dev/vda -net nic,model=virtio -net user
From inside qemu:
hello
Expected output:
hello
Tested in Ubuntu 16.04.
buildroot package from local source with snapshots
Section 8.3 of the buildroot manual explains how to rebuild a single package. The easiest way is with [package name]-rebuild
target. In your case it would be:
make customapp-rebuild
You may want to also trigger the buildroot post build actions to rebuild the target device file system images after your package re-build is complete:
make target-post-image
Buildroot custom package not built automatically
Enter make menuconfig
, enable your package, exit saving changes.
Now make
will build your package too.
This is because by default nearly all packages are disabled since Buildroot cannot know what you need on your target root filesystem.
Buildroot package management
Isn't opkg a package manager? Or just some kind of frontend to fetch packages?
opkg is based on ipkg. It looks like it tries to provide all the features of apt-get
.
Could someone explain what is really needed to implement that kind of manager, or where to find such information?
Package managers provide many different features. As they have evolved, different layers of ease for the end user has been added. Generally, they started in the Linux desktop or server space and have been ported for use in embedded systems.
Some differences; an embedded system is usually single tasked. A package management system allows the user to pick and choose what is installed. Often, an embedded system might not want to allow a user to pick and choose packages. Of course, it depends on the applications.
Some package management features,
- Building and patching.
- Package dependency and hence package database.
- Package migration.
- Package specialization.
- Automated download
- Minimize download time/bandwidth.
Rpm, dpkg, ipkg are typically only fulfilling items 1-4. Buildroot doesn't even do this, only item one is really relevant. The reason is that Buildroot is intended to build software for a fixed system that will never be updated. It doesn't make sense to have a file system with network update and package migration, it there is not network connection or external storage in the device. Also, Buildroot tries to be minimal and these extra features have a cost.
LTIB provide a system to create items 1-3, but not the network download. Also, out of the box, it is rather in-efficient in RPM size. Item 4, leads to typical devel and deploy packages. In order to build a library, you need header files to compile dependent packages. A typical LTIB rpm includes all the header files. It is an easy task to make sub-packages that exclude these headers and man pages, etc.
OpenWrt works well for routers, but if you need graphics, sound and other features the packages may not be available. There are various file system builders, but due to the amount of variations, each has costs and benefits. Just as there are many Linux desktop and server distributions, there are many root filesystem builder with different package management options. You have to evaluate the strengths for you application and system.
How to modify the source of Buildroot packages for package development?
Please read the Buildroot manual about the <pkg>_OVERRIDE_SRCDIR
functionality. It does exactly what you are looking for.
Related Topics
Black Color Showing on Cmy Channels When Converted to Cmyk Using Ghostscript
Serial Port Doesn't Work Properly After Reboot, Unless I Execute Minicom
Ansible Inside Script Command Not Found
Learning Kernel Hacking and Embedded Development at Home
How to Include File in a Bash Shell Script
How to Set the Grep After Context to Be "Until the Next Blank Line"
Are Tar.Gz and Tgz the Same Thing
How to Find Lines Containing a String in Linux
Error When Trying to Run .Asm File on Nasm on Ubuntu
Id_Rsa.Pub File Ssh Error: Invalid Format
What Context Does the Scheduler Code Run In
Linux Loopback Performance with Tcp_Nodelay Enabled
Bash: /Bin/Tar: Argument List Too Long When Compressing Many Files with Tar
How to Remove Jenkins Completely from Linux
Changing Contents of a File Through Shell Script
Groovy Process Not Working with Linux Shell (Grep and Awk and Ps)