Custom build package inside image builder image

Hi all

I've compiled a custom version of squid with auth support and I would like my own package installed with my custom build image (made with image builder). However, I've NOT found a way to replace the official squid package inside my image, each time I build it, it always end up with the official one. Could someone give me some tips to do it right ? I have seen another thread with the same question in 2018 which is still unanswered. thanks in advance

I would build all from source using the full build system. Same prerequisites.

You might be able to hack the image builder to use a local mirror, but having everything built against the same libraries seems a huge advantage to me.

thanks but it would take to much time to do it especially since I rebuild the whole image frequently.

I recently tested a 2-core VM and a full build, including tool chain, was about an hour. Incremental packages 5-10 min, as I recall. Clean build after tool chain done about 1/2 hour.

The image builder is intended to assemble images, not for ā€œcustom developmentā€.

I understand, howerver, it's not custom developpement, it's just about embedding my own .ipk (already build with the sdk) instead of using the one in the repos.

Preface: I never tried this myself, but here's an idea. The Image Generator allows to configure package repositories through repositories.conf, including the line

## This is the local package repository, do not remove!
src imagebuilder file:packages

Clearly this defines a local repository in the packages directory. It may be worth a try to
a) throw your custom .ipk into the packages directory, or
b) insert a similar line at the top or the bottom of the repositories list (choose a different name for the repository than "imagebuilder", of course), referencing a local directory you put your .ipk in.

(Edit: I would try the latter option first and switch up the position of the line, firstly to be able to keep it even if you replace the stock packages directory, and secondly in case the Image Generator goes off the Packages file and not filenames and you need to roll your own Packages file for it to recognize packages. Again, never tried it, not intimately familiar with the inner workings of the Generator, some experimentation required.)

You might luck out using one of those ways, and the local .ipk gets preference over the one pulled from external sources. I am pretty sure the Image Generator has to give preference in some way if a package is available in more than one repository.

3 Likes

I don't think that will work because the repos give a list of the packages with a HASH, so my own package will not match the given hash and image builder will certainly pick the one in the repos, espcially if it has the same name. I may be should find a way to setup a local repo instead ? How to do that ? is it the only way ?

There's nothing stopping you to supply a Packages file with your own little repository, including the matching hash. Basically you roll your own third-party repository, which is not unheard of. You just do it in the file system and not from your own server.

Which package from which repository gets preference is up to the Image Generator, but I am taking a wild guess and say it's going through the repositories sequentially, either top to bottom or bottom to top, and picks the first match.

And no, I don't see another way to slip in your own packages. I wish there were one, similar to the FILES parameter to slip in custom files, but alas there doesn't seem to be such a thing.

thanks again for your time, I may try to setup my own repo locally, any clues how to set it up ?

Take the local packages directory and its Packages file as clues?

just tried it. It seems to pick it up and install it IF I change the package name, for exemple, squid-custom instead of squid but then luci-app-squid fail to install because of squid package not installed and the imagebuilder fail. If I don't change the package name, it picks the package in the repos. Weird

Did you try inserting your local repo in different places in the list, i.e. top or bottom? (And make clean in between so the packages list gets rebuilt?) I don't see any indication of priority of repositories, so the order must matter.

ok so after trials and errors, this seems to be working :slight_smile:

  • put your custom .ipk in the packages folder
  • cd in imagebuilder root folder
  • type "make clean"
  • type make image
    you see a message saying :
    "Package list missing or not up-to-date, generating it.
    Building package index..."
  • wait for the image to be build. your package should be automatically included

To bad that this information was not clearly available, I wasted hours to find this. Thanks you anyway takimata :wink:

2 Likes

So the Image Generator does purely go off filenames? You didn't modify the Packages file?

I can't shake the feeling that it's still a bit dirty to do it this way. An additional local repository inserted into the repository configuration at the correct place would probably be the intended, or at the very least a much more elegant, way. But I'm happy it worked for you.

maybe someone more knowledgeable or a dev can tell us if it is the intended behavior, but it appear that this method has been used before, I've found a thread afterwards talking about this way of installing new ipk with imagebuilder

FYI I had the OP's issue when trying to replace an official package with a custom .ipk in 18.06.8.

What I finally had to do was comment out the relevant remote package repo line in repositories.conf and make the image again. In retrospect it may been related to the version field format of the package filename changing, so renaming the file might have worked.

(I later did the same thing in 19.07.2 and didn't have any issues at all.)

Wow thank you, I was looking for this :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.