Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add APK package building capabilities to OpenWrt #4294

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

aparcar
Copy link
Member

@aparcar aparcar commented Jun 20, 2021

APK is the main package manager of Alpine Linux. This is just a proof of concept to double create package for OPKG and APK in parrallel.

(Personal) motivation is a long time replacement of OPKG with APK and join forces with Alpine Linux to create a great package manager for embedded devices rather than maintaining OPKG.

This is a follow up of the accidentally (mystically) closed #3811

Open Issues:

@aparcar aparcar self-assigned this Jun 20, 2021
@aparcar aparcar marked this pull request as draft Jun 20, 2021
@ptpt52
Copy link
Contributor

ptpt52 commented Jun 21, 2021

cool to add this util

@ptpt52
Copy link
Contributor

ptpt52 commented Jun 21, 2021

on my case, I have to use apk command to install packages like openjdk11-jdk, and it depends on busybox, so busybox and musl pkgs would be installed via apk and overwrite the system busybox/musl, and it cause system soft broken.

@aparcar aparcar requested review from lynxis, blogic and dangowrt and removed request for lynxis Jun 21, 2021
@aparcar aparcar added RFC ugly work in progress and removed ugly labels Jun 21, 2021
@ptpt52
Copy link
Contributor

ptpt52 commented Jun 21, 2021

so how to mark busybox.apk and/or musl.apk installed and avoid apk auto install them?

@aparcar
Copy link
Member Author

aparcar commented Jun 21, 2021

@ptpt52 these are issues for packages.git since there apk is added as a on device package. This PR is for build integration.

Sure, if Alpine is up for it I'm happy to merge package building but I don't see this to happen any time soon.

@KOLANICH
Copy link

KOLANICH commented Sep 9, 2021

I am a bit sorry to ask here, but I wonder if it makes sense to improve some aspect of opkg.

Opkg stores information about installed packages as plain text in files in /usr/lib/opkg/info (dpkg does the similar thing). Space analyser has showed that this dir is one of the largest in an image. The paths are duplicated, i.e. if 2 files have the same prefix in a path (the same parent dir), then it is duplicated. The search is also inefficient, since to search a package manager has to crawl all the files.

IDK if apk is immune to this problem, it seems for search it stores the info in form of a hash of a path, but for efficient proper uninstallation it must store original paths somehow.

I have encountered a similar problem in ubuntu (I needed a fast search of a package by a path). I have solved it by creating a library for storing such information in an own format and a framework for converting the info from various distros into its format and a backend for dpkg.

The format consists of an SQLite database, which has 2 tables. One stores strings, and another one (in fact, 2) stores a prefix tree (using datrie library) of primary keys of these strings. The prefix tree is then compressed.

I wonder if it makes sense for OpenWRT to utilise a similar format in own package managers.

@aparcar aparcar force-pushed the apk branch 4 times, most recently from 62ec5e4 to 5155a53 Compare Sep 18, 2021
@aparcar aparcar changed the title [RFC] Add APK package building capabilities to OpenWrt Add APK package building capabilities to OpenWrt Sep 18, 2021
@aparcar aparcar marked this pull request as ready for review Sep 18, 2021
MESON_HOST_ARGS += \
-Ddocs=disabled

MESON_ARGS += \
Copy link
Contributor

@neheb neheb Sep 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why get rid of -Dlua=disabled ?

Copy link
Member Author

@aparcar aparcar Sep 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To have --help

Copy link
Contributor

@neheb neheb Sep 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--help requires libluaapk.so AFAIK

Copy link

@kaniini kaniini Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lua is only required to build the help database. It can also be pre-built.

Copy link
Member Author

@aparcar aparcar Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thak you, updated and it works.

@dangowrt
Copy link
Member

dangowrt commented Sep 18, 2021

@aparcar
Copy link
Member Author

aparcar commented Sep 18, 2021

Okay great, I will fix that.

@aparcar
Copy link
Member Author

aparcar commented Oct 5, 2021

I am a bit sorry to ask here, but I wonder if it makes sense to improve some aspect of opkg.

Opkg stores information about installed packages as plain text in files in /usr/lib/opkg/info (dpkg does the similar thing). Space analyser has showed that this dir is one of the largest in an image. The paths are duplicated, i.e. if 2 files have the same prefix in a path (the same parent dir), then it is duplicated. The search is also inefficient, since to search a package manager has to crawl all the files.

IDK if apk is immune to this problem, it seems for search it stores the info in form of a hash of a path, but for efficient proper uninstallation it must store original paths somehow.

I have encountered a similar problem in ubuntu (I needed a fast search of a package by a path). I have solved it by creating a library for storing such information in an own format and a framework for converting the info from various distros into its format and a backend for dpkg.

The format consists of an SQLite database, which has 2 tables. One stores strings, and another one (in fact, 2) stores a prefix tree (using datrie library) of primary keys of these strings. The prefix tree is then compressed.

I wonder if it makes sense for OpenWRT to utilise a similar format in own package managers.

I think this is indeed the wrong place to suggest changes to opkg.

APK uses a flat buffer like database to store for packages, I'll ask the dev on compression is a possibility.

Proper file handling of (un)installed packages is part of both opkg and apk, and so is dependency tracking.

Motivation for apk is that we no longer maintain our own fork of a package manager but share tooling with similar minded projects (alpine).

@kaniini
Copy link

kaniini commented Oct 6, 2021

I'm not Timo, but compression of the database should be possible in apk3, as it would use the same access methods as the packaging side. So the appropriate compression flags would just need to be added to the file header, basically.

aparcar added 25 commits Jun 2, 2022
APK (Alpine Package Keeper) is the package manager of Alpine Linux and
has multiple advantages over OPKG, add the manager as an alternative.

Signed-off-by: Paul Spooren <mail@aparcar.org>
The build system now uses APK to create firmware images.

Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
OPKG was removed by APK

Signed-off-by: Paul Spooren <mail@aparcar.org>
This feature replaced by apk's own `audit` feature.
By replacing OPKG with APK the folder /etc/opkg/keys becomes obsolete.
Instead use the /etc/usign/keys folder. APK uses a different key format
which is currently not compatible with usign/ucert.

Signed-off-by: Paul Spooren <mail@aparcar.org>
This key is used during development to allow the installation of CI
created repositories.

Signed-off-by: Paul Spooren <mail@aparcar.org>
Always sign packages, security by default

Signed-off-by: Paul Spooren <mail@aparcar.org>
This feed contains Kernel specific kmods. Previously it was only added
for buildbots, however other users or developers may want to use it.

Signed-off-by: Paul Spooren <mail@aparcar.org>
Generate all required keys automatically, required to build packages
with APK.

Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Drop merged patch

Signed-off-by: Paul Spooren <mail@aparcar.org>
No longer needed

Signed-off-by: Paul Spooren <mail@aparcar.org>
usign isn't needed except for sysupgrades, apk uses it's own crypto
openwrt-keyring should be autoamtically selected

Signed-off-by: Paul Spooren <mail@aparcar.org>
aparcar added 3 commits Jun 2, 2022
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
@aparcar
Copy link
Member Author

aparcar commented Jun 2, 2022

Just a heads up, this is still alive. Next major tasks are to get rid of libfetch an the hard dependency on OpenSSL. Once that's done I'll rework this massive PR to work side by side to OPKG so people can set a config option like CONFIG_APK compiling everything for APK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants