summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-12-03 14:52:07 +0200
committerTimo Teräs <timo.teras@iki.fi>2021-12-03 14:53:30 +0200
commit1ab81fdd4cb9b88dad35cc93521650f85837fd6e (patch)
treee446d4db5c60e1dddca717d19030880428cbc5ef /src/database.c
parent4dde7e7e0fc79708119644b14b7123213d0de10d (diff)
downloadapk-tools-1ab81fdd4cb9b88dad35cc93521650f85837fd6e.tar.gz
apk-tools-1ab81fdd4cb9b88dad35cc93521650f85837fd6e.tar.bz2
apk-tools-1ab81fdd4cb9b88dad35cc93521650f85837fd6e.tar.xz
apk-tools-1ab81fdd4cb9b88dad35cc93521650f85837fd6e.zip
db: convert v3 scripts to ipkg on install
fixes #10796
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/database.c b/src/database.c
index 3776bb1..589a505 100644
--- a/src/database.c
+++ b/src/database.c
@@ -2334,10 +2334,19 @@ static int apk_db_install_v2meta(struct apk_extract_ctx *ectx, struct apk_istrea
static int apk_db_install_v3meta(struct apk_extract_ctx *ectx, struct adb_obj *pkg)
{
+ static const int script_type_to_field[] = {
+ [APK_SCRIPT_PRE_INSTALL] = ADBI_SCRPT_PREINST,
+ [APK_SCRIPT_POST_INSTALL] = ADBI_SCRPT_POSTINST,
+ [APK_SCRIPT_PRE_DEINSTALL] = ADBI_SCRPT_PREDEINST,
+ [APK_SCRIPT_POST_DEINSTALL] = ADBI_SCRPT_POSTDEINST,
+ [APK_SCRIPT_PRE_UPGRADE] = ADBI_SCRPT_PREUPGRADE,
+ [APK_SCRIPT_POST_UPGRADE] = ADBI_SCRPT_POSTUPGRADE,
+ [APK_SCRIPT_TRIGGER] = ADBI_SCRPT_TRIGGER,
+ };
struct install_ctx *ctx = container_of(ectx, struct install_ctx, ectx);
struct apk_database *db = ctx->db;
struct apk_installed_package *ipkg = ctx->ipkg;
- struct adb_obj triggers, pkginfo, obj;
+ struct adb_obj scripts, triggers, pkginfo, obj;
int i;
// Extract the information not available in index
@@ -2346,6 +2355,14 @@ static int apk_db_install_v3meta(struct apk_extract_ctx *ectx, struct adb_obj *p
ipkg->replaces_priority = adb_ro_int(&pkginfo, ADBI_PI_PRIORITY);
ipkg->v3 = 1;
+ adb_ro_obj(pkg, ADBI_PKG_SCRIPTS, &scripts);
+ for (i = 0; i < ARRAY_SIZE(script_type_to_field); i++) {
+ apk_blob_t b = adb_ro_blob(&scripts, script_type_to_field[i]);
+ if (APK_BLOB_IS_NULL(b)) continue;
+ apk_ipkg_assign_script(ipkg, i, apk_blob_dup(b));
+ ctx->script_pending |= (i == ctx->script);
+ }
+
apk_string_array_resize(&ipkg->triggers, 0);
adb_ro_obj(pkg, ADBI_PKG_TRIGGERS, &triggers);
for (i = ADBI_FIRST; i <= adb_ra_num(&triggers); i++)