Skip to content

Commit

Permalink
apk: add package
Browse files Browse the repository at this point in the history
APK (Alpine Package Keeper) is the package manager of Alpine Linux and
has multiple advantages over OPKG. While Alpine uses APK version 2, this
commit adds version 3 with a heavily optimised database structure and
additional feature making it suitable for OpenWrt.

This commit will be followed by many more to add APK build capabilities
to the OpenWrt build system, firstly enabling side by side builds of APK
and OPKG packages, later replacing OPKG entirely.

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Apr 29, 2024
1 parent 7d5f7b8 commit 00b8616
Show file tree
Hide file tree
Showing 3 changed files with 1,025 additions and 0 deletions.
87 changes: 87 additions & 0 deletions package/system/apk/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=apk
PKG_RELEASE:=1

PKG_SOURCE_URL=https://gitlab.alpinelinux.org/alpine/apk-tools.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2024-04-16
PKG_SOURCE_VERSION:=ba6c31a5469ef74fb85119508e55de9631ffef41
PKG_MIRROR_HASH:=3455d5799481add9ece3db685576d58be6303f3a13140133979b965cbd3c9966

PKG_VERSION=3.0.0_pre$(subst -,,$(PKG_SOURCE_DATE))

PKG_MAINTAINER:=Paul Spooren <[email protected]>
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE
PKG_INSTALL:=1

HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST)
HOST_BUILD_DEPENDS:=lua/host
PKG_BUILD_DEPENDS:=$(HOST_BUILD_DEPENDS)

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/meson.mk

define Package/apk/default
SECTION:=base
CATEGORY:=Base system
TITLE:=apk package manager
DEPENDS:=+zlib
URL:=$(PKG_SOURCE_URL)
endef

define Package/apk-mbedtls
$(Package/apk/default)
TITLE += (mbedtls)
DEPENDS +=+libmbedtls
VARIANT:=mbedtls
DEFAULT_VARIANT:=1
CONFLICTS:=apk-openssl
endef

define Package/apk-openssl
$(Package/apk/default)
TITLE += (openssl)
DEPENDS +=+libopenssl
VARIANT:=openssl
endef

MESON_HOST_VARS+=VERSION=$(PKG_VERSION)
MESON_VARS+=VERSION=$(PKG_VERSION)

MESON_HOST_ARGS += \
-Dlua_version=5.1 \
-Dcompressed-help=false \
-Ddocs=disabled \
-Dcrypto_backend=openssl \
-Dzstd=false

MESON_ARGS += \
-Dlua_version=5.1 \
-Dcompressed-help=false \
-Ddocs=disabled \
-Durl_backend=wget \
-Dcrypto_backend=$(BUILD_VARIANT) \
-Dzstd=false

HOST_LDFLAGS += \
-Wl,-rpath $(STAGING_DIR_HOST)/lib

define Package/apk/default/install
$(INSTALL_DIR) $(1)/lib/apk/db

$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/apk $(1)/usr/bin/apk

$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libapk.so.* $(1)/usr/lib/
endef

Package/apk-mbedtls/install = $(Package/apk/default/install)
Package/apk-openssl/install = $(Package/apk/default/install)

$(eval $(call BuildPackage,apk-mbedtls))
$(eval $(call BuildPackage,apk-openssl))
$(eval $(call HostBuild))
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
From 9918c683fcc2f148328332d58d030ec5750a1473 Mon Sep 17 00:00:00 2001
From: Paul Spooren <[email protected]>
Date: Sat, 19 Feb 2022 17:20:37 +0100
Subject: [PATCH 1/4] openwrt: move layer db to temp folder

Signed-off-by: Paul Spooren <[email protected]>
---
src/database.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/src/database.c
+++ b/src/database.c
@@ -1604,7 +1604,7 @@ const char *apk_db_layer_name(int layer)
{
switch (layer) {
case APK_DB_LAYER_ROOT: return "lib/apk/db";
- case APK_DB_LAYER_UVOL: return "lib/apk/db-uvol";
+ case APK_DB_LAYER_UVOL: return "tmp/run/uvol/.meta/apk";
default:
assert("invalid layer");
return 0;
Loading

0 comments on commit 00b8616

Please sign in to comment.