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 77 commits into
base: main
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:

  • Implement something like CONFIG_CLEAN_IPKG @dangowrt
  • add ABIVersion to both package metadata and installdb @dangowrt
  • Ability to distinguish between actively and passively (dependency) installed packages @dangowrt
    APK got /etc/apk/world which unfortunately is not quite like gentoo emerge's @world, but rather just stores a list of explicitely installed packages (while gentoo's emerge @world store a record of the manually selected dependency atoms, ie. it would remember if the user asked for an explicit version or if a package had been selected as a provider for something the user requested). However, using that gets us the same data we previously had with opkg: if a package is user-selected or not.
  • rpcd-sys @dangowrt
    • package list (add / remove / update remote list can be added later)
  • fix apk version of itself output on cmdline (always 3.0.0pre0, should be 3.0.0pre20240205)
    • fixed apk-tools 3.0.0_pre20240324, compiled for aarch64.
  • version definition handling opkg vs apk @aparcar
  • lua: add HOST_FPIC for host builds #4907
  • Alternatives are not handled (upstream problem).
    • via a post-install and pre-remove script.
  • Don't compress help text
  • install to ./staging_dir/host/bin no ./staging_dir/hostpkg/bin
  • handle multiple lines of maintainers
  • signing keys are not automatically generated
  • Fix ImageBuilder @aparcar

Optional:

  • Replace libfetch with uclient/curl/wget

@aparcar aparcar self-assigned this Jun 20, 2021
@aparcar aparcar marked this pull request as draft June 20, 2021 20:32
@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 June 21, 2021 08:52
@aparcar aparcar added RFC pull request ready for comments ugly work in progress pull request the author is still working on 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 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 September 18, 2021 02:15
package/utils/apk/Makefile Outdated Show resolved Hide resolved
@dangowrt
Copy link
Member

dangowrt commented Sep 18, 2021 via email

@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 and others added 22 commits April 18, 2024 23:41
Signed-off-by: Paul Spooren <mail@aparcar.org>
cleanup should be more sophisticated since APK can actually handle
multiple versions of the same package - take that opkg
Instead of attaching the `-stable` suffix, only handle it within the
build system.

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>
This adds support for mbedtls 3.6.0.
The 3.6 version is the next LTS version of mbedtls.
This version supports TLS 1.3.

This switches to download using git. The codeload tar file misses some
git submodules.

Add some extra options added in mbedtls 3.6.0.

The size of the compressed ipkg increases:
230933 bin/packages/mips_24kc/base/libmbedtls13_2.28.7-r2_mips_24kc.ipk
300154 bin/packages/mips_24kc/base/libmbedtls14_3.6.0-r1_mips_24kc.ipk

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
keylen and ivlen are of type long and not size_t.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This makes it compile with mbedtls 3.6.0.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Fix compile of the mbedtls extension for hostapd.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
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>
In package-defaults.mk the VERSION variable contains the final package
version, which is a combination of `PKG_VERSION`, `PKG_RELEASE` and if
used, parameters of `PKG_SOURCE_VERSION`. While this works fine for
building, within the package Makefile the content VERSION varies:

When building a package from a release tarball, the content of VERSION
contains the actual package version, however when building from source
(i.e. Git), the VERSION is overwritten by `PKG_SOURCE_VERSION`.

To fix the overwrite, this commit switches from `VERSION` in download.mk
to `SOURCE_VERSION` which isn't used anywhere else yet.

As a result, Makefiles may pass the package version to be included
inside the binary.

Signed-off-by: Paul Spooren <mail@aparcar.org>
@Ansuel Ansuel force-pushed the apk branch 2 times, most recently from 3382048 to 18b55a0 Compare April 20, 2024 14:24
@github-actions github-actions bot added the toolchain pull request/issue with toolchain related changes label Apr 20, 2024
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
…chain

Currently when external toolchain is used, a info.mk is created (with
to-be-filled values) but is never actually filled with real values and
is never actually used in rules.mk.

This info.mk is used down the code with special packages like libgcc to
reference info like gcc version and package special library.

To mimic what is done with internal toolchain, add the include in
rules.mk for info.mk also for external library and in fix
toolchain/wrapper to fill the staging_dir info.mk.

The logic is to check if the external toolchain provide an info.mk and
if it doesn't we at least fill the GCC_VERSION with the value set in the
.config file.

With this special library like libgcc correctly reference and have set the
GCC_VERSION variable.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/scripts/tools pull request/issues for build, scripts and tools related changes core packages pull request/issue for core (in-tree) packages GitHub/CI pull requests/issues for GitHub, CI and related stuff RFC pull request ready for comments target/imagebuilder pull request/issue for imagebuilder target toolchain pull request/issue with toolchain related changes work in progress pull request the author is still working on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet