summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-11-07 13:05:55 +0200
committerTimo Teras <timo.teras@iki.fi>2008-11-07 13:05:55 +0200
commit36f73847ee4faa9fd84d2bd5be3f28ff70c7bf19 (patch)
treec3210191279f1aad40ee58b2b0546aa512245ecb /src/database.c
parent1c342b3eba1fd86734085a220cf0b2b590f72b9b (diff)
downloadapk-tools-36f73847ee4faa9fd84d2bd5be3f28ff70c7bf19.tar.gz
apk-tools-36f73847ee4faa9fd84d2bd5be3f28ff70c7bf19.tar.bz2
apk-tools-36f73847ee4faa9fd84d2bd5be3f28ff70c7bf19.tar.xz
apk-tools-36f73847ee4faa9fd84d2bd5be3f28ff70c7bf19.zip
pkg: support for new scripts
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/database.c b/src/database.c
index 168df04..6b32255 100644
--- a/src/database.c
+++ b/src/database.c
@@ -673,12 +673,16 @@ static int apk_db_install_archive_entry(struct apk_archive_entry *ae,
struct apk_db_dir *dir;
struct apk_db_file *file;
const char *p;
- int r = 0, type;
+ int r = 0, type = APK_SCRIPT_INVALID;
- if (strcmp(ae->name, ".PKGINFO") == 0)
- return 0;
-
- if (strncmp(ae->name, "var/db/apk/", 11) == 0) {
+ /* Package metainfo and script processing */
+ if (ae->name[0] == '.') {
+ /* APK 2.0 format */
+ if (strcmp(ae->name, ".INSTALL") != 0)
+ return 0;
+ type = APK_SCRIPT_GENERIC;
+ } else if (strncmp(ae->name, "var/db/apk/", 11) == 0) {
+ /* APK 1.0 format */
p = &ae->name[11];
if (strncmp(p, pkg->name->name, strlen(pkg->name->name)) != 0)
return 0;
@@ -688,13 +692,17 @@ static int apk_db_install_archive_entry(struct apk_archive_entry *ae,
p += strlen(pkg->version) + 1;
type = apk_script_type(p);
- if (type < 0)
+ if (type != APK_SCRIPT_INVALID)
return 0;
+ }
+ /* Handle script */
+ if (type != APK_SCRIPT_INVALID) {
ae->size -= apk_pkg_add_script(pkg, ae->read_fd,
type, ae->size);
- if (type == ctx->script) {
+ if (type == APK_SCRIPT_GENERIC ||
+ type == ctx->script) {
r = apk_pkg_run_script(pkg, db->root_fd, type);
if (r != 0)
apk_error("%s-%s: Failed to execute pre-install/upgrade script",
@@ -704,6 +712,7 @@ static int apk_db_install_archive_entry(struct apk_archive_entry *ae,
return r;
}
+ /* Installable entry */
if (ctx->file_pkg_node == NULL)
ctx->file_pkg_node = hlist_tail_ptr(&pkg->owned_files);