How to add preinstalled packages to the final image

I got the source, successfully configured and built an image. I don't understand though how to add a preinstalled package to the result image. What I mean is for example I'd like to add vsftpd to the image. Yes, I can generate the image and after installing it to the target device or a virtual machine execute opkg install vsftpd but I want to avoid it and have it preinstalled and properly configured. How can I do that? Can somebody give a step by step instructions, I'm rather new to Linux in general and sometimes it's difficult to understand short hints.

Thank you,
Alex

You configure your build root to compile and install (=y, in contrast to =m which would just build but not install the package) vsftpd.

For preconfiguration, use uci-defaults or custom files.

"Custom files" works better, as the settings would be directly in /etc/vsftpd.conf

(If you use uci-defaults to modify config at the first boot, you first have the settings in the uci-defaults script, which then writes those settings into /etc/vsftpd.conf )

Frankly speaking I didn't understand a thing. Once again. I have the OpenWRT source, then I do

make menuconfig

If you assume I can select vsftpd from the settings menu then no. There is no vsftpd in there. I found it here though http://downloads.openwrt.org/snapshots/packages/i386_pentium4/packages/ and what I was thinking about is that I either can somehow add this URL to the build configuration so that I would be able to select vsftpd from the configuration menu or just copy vsftpd_3.0.3-2_i386_pentium4.ipk somewhere local and configure something for the image generating process making this package to get to the final image as installed package but I don't understand how to do the one of the other.

How did you get the source? Did you follow this guide to get the feeds? https://openwrt.org/docs/guide-developer/quickstart-build-images

You forgot the "feed update & install" step mentioned in wiki, like Per says above.

./scripts/feeds update -a
./scripts/feeds install -a

only then menuconfig

(only the core packages are in the main source, while most of the packages are in a separate "feed".)

Once you have updated the feeds you will find it under

make menuconfig
Networlk--->File Transfer--->

Yes, this is what I did to get the source

git clone https://git.openwrt.org/openwrt/openwrt.git/

Yes, initially I didn't do ./scripts/feeds update -a and ./scripts/feeds install -a I skipped right to the helloworld series of articles https://openwrt.org/docs/guide-developer/helloworld/start. One page of that series describes how to add a custom package and I followed that. Now when I run feeds script I see this. AddOnPackage is the name of my feed.

alex@AlexVM:~/Development/openwrt$ ./scripts/feeds update -a
Updating feed 'AddOnPackage' from '/home/alex/Development/AddOnPackage' ...
Create index file './feeds/AddOnPackage.index' 

alex@AlexVM:~/Development/openwrt$ ./scripts/feeds install -a
WARNING: Makefile 'package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/busybox/Makefile' has a build dependency on 'libpam', which does not exist
WARNING: Makefile 'package/network/utils/curl/Makefile' has a dependency on 'libgnutls', which does not exist
WARNING: Makefile 'package/network/utils/curl/Makefile' has a dependency on 'libopenldap', which does not exist
WARNING: Makefile 'package/network/utils/curl/Makefile' has a dependency on 'libidn2', which does not exist
WARNING: Makefile 'package/network/utils/curl/Makefile' has a dependency on 'libssh2', which does not exist
WARNING: Makefile 'package/boot/kexec-tools/Makefile' has a dependency on 'liblzma', which does not exist
WARNING: Makefile 'package/network/services/lldpd/Makefile' has a dependency on 'libnetsnmp', which does not exist
WARNING: Makefile 'package/network/utils/nftables/Makefile' has a dependency on 'jansson', which does not exist
Installing all packages from feed AddOnPackage.

That didn't add vsftpd to the Network > File Transfer. There is only curl in there. Is it possible that I already broke something and I cannot successfully run that feeds script?

Yes, you will get a broken config when you run menuconfig before you have checked out the feeds. The easiest solution is to remove the openwrt directory and start over.

That is unexpected. Thank you for clearing this up. Just for better understanding of how this whole system works. What it does when I run make menuconfig? Is it creating a text file with configuration in accordance to certain rules? Where those rules are? Where the final configuration files is? Maybe there is an article to read about all that? I don't mind to start over from getting the source and stick to the instructions but blindly following instructions does not give understanding. Is it theoretically possible to recover from this situation without starting over?

Wont make distclean be equivalent to restarting fresh ?

Possibly, I haven't bothered to learn all the make commands.

The first time you run menuconfig it will find all the options that are defined in Config.in files, and possibly other places. I don't know for sure how to recover. It's possible that it will work if you make a backup of .config, run make distclean, check out the feeds, copy .config back to the root, run make oldconfig and select the default for all the choices, and then make menuconfig. Someone will probably correct me if I'm wrong, but either way I would find it safer to start from scratch.

I'd like to let you know distclean didn't help. It did something so that ./script/feeds showed different result. It was as if it downloaded something, reconfigured something but in the result the lists of packages in make menuconfig were the same.

Starting over helped. Now I see vsftpd in the list.

Now, I wonder what if a new package is added to the openwrt server. It seems there is no way this new package gets to the list of make menuconfig until everything is started over from getting openwrt source. Is my guess right? Or it will run diff and find and add new packages to the list after running ./script/feeds again and in my case it didn't work simply because the internal index of feed packages was already incomplete or broken?

Starting over is not necessary, here are some bits that might prove useful, but once you install packages everything should be available to select.

I see that the friend's problem regarding the vsftpd package has been solved, but I have the same doubt, as it adds a package that is not in the list, or a third party package, such as EasyCwmp