Skip to content

Commit a6c248e

Browse files
committed
apk: fix long package description handling
Currently its not possible to generate apk package.adb package index if the package has longer description field, which leads to following failure: (2352/2353) Installing zoneinfo-all (2024b-r1) (2353/2353) Installing zstd (1.5.6-r1) ERROR: System state may be inconsistent: failed to write database: No buffer space available 1 error; 2704 MiB in 2353 packages The code to read/write installeddb does not really handle long description well. Until the database is converted to apkv3 format, truncate the apkv3 descriptions to allow existing code to work. APKv3 index and packages still contain the original long description unmodified, so no package rebuild will be needed. Fixing the issue by backporting the single upstream fix as its not possible to to upstep apk to the latest Git HEAD due to some regressions, see commit 692052cdc0e7 ("Revert "apk: update to Git 417a93ceae540444fdbd3f76d1dadf0e15621fdc (2024-11-13)"") for more details. Fixes: #16929 References: https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/11038 Upstream-Status: Backport [https://gitlab.alpinelinux.org/alpine/apk-tools/-/commit/417a93ceae540444fdbd3f76d1dadf0e15621fdc] Link: openwrt/openwrt#16951 Signed-off-by: Petr Štetiar <[email protected]>
1 parent 1e8505a commit a6c248e

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

package/system/apk/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=apk
4-
PKG_RELEASE:=1
4+
PKG_RELEASE:=2
55

66
PKG_SOURCE_URL=https://gitlab.alpinelinux.org/alpine/apk-tools.git
77
PKG_SOURCE_PROTO:=git
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 417a93ceae540444fdbd3f76d1dadf0e15621fdc Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <[email protected]>
3+
Date: Wed, 13 Nov 2024 09:40:21 +0200
4+
Subject: [PATCH] pkg: truncate apkv3 description to 256 bytes
5+
6+
The code to read/write installeddb does not really handle long
7+
description well. Until the database is converted to apkv3 format,
8+
truncate the apkv3 descriptions to allow existing code to work.
9+
10+
APKv3 index and packages still contain the original long description
11+
unmodified, so no package rebuild will be needed.
12+
13+
fixes #11038
14+
15+
Upstream-Status: Backport [https://gitlab.alpinelinux.org/alpine/apk-tools/-/commit/417a93ceae540444fdbd3f76d1dadf0e15621fdc]
16+
---
17+
src/apk_blob.h | 5 +++++
18+
src/package.c | 2 +-
19+
2 files changed, 6 insertions(+), 1 deletion(-)
20+
21+
--- a/src/apk_blob.h
22+
+++ b/src/apk_blob.h
23+
@@ -48,6 +48,11 @@ static inline apk_blob_t apk_blob_trim(a
24+
return b;
25+
}
26+
27+
+static inline apk_blob_t apk_blob_truncate(apk_blob_t blob, int maxlen)
28+
+{
29+
+ return APK_BLOB_PTR_LEN(blob.ptr, min(blob.len, maxlen));
30+
+}
31+
+
32+
char *apk_blob_cstr(apk_blob_t str);
33+
apk_blob_t apk_blob_dup(apk_blob_t blob);
34+
int apk_blob_split(apk_blob_t blob, apk_blob_t split, apk_blob_t *l, apk_blob_t *r);
35+
--- a/src/package.c
36+
+++ b/src/package.c
37+
@@ -577,7 +577,7 @@ void apk_pkgtmpl_from_adb(struct apk_dat
38+
39+
pkg->name = apk_db_get_name(db, adb_ro_blob(pkginfo, ADBI_PI_NAME));
40+
pkg->version = apk_atomize_dup(&db->atoms, adb_ro_blob(pkginfo, ADBI_PI_VERSION));
41+
- pkg->description = apk_atomize_dup0(&db->atoms, adb_ro_blob(pkginfo, ADBI_PI_DESCRIPTION));
42+
+ pkg->description = apk_atomize_dup0(&db->atoms, apk_blob_truncate(adb_ro_blob(pkginfo, ADBI_PI_DESCRIPTION), 512));
43+
pkg->url = apk_atomize_dup(&db->atoms, adb_ro_blob(pkginfo, ADBI_PI_URL));
44+
pkg->license = apk_atomize_dup(&db->atoms, adb_ro_blob(pkginfo, ADBI_PI_LICENSE));
45+
pkg->arch = apk_atomize_dup(&db->atoms, adb_ro_blob(pkginfo, ADBI_PI_ARCH));

0 commit comments

Comments
 (0)