summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/database.c b/src/database.c
index 261011c..c30550b 100644
--- a/src/database.c
+++ b/src/database.c
@@ -840,7 +840,7 @@ int apk_db_install_pkg(struct apk_database *db,
struct install_ctx ctx;
csum_t csum;
char file[256];
- int fd, r;
+ int r;
if (fchdir(db->root_fd) < 0)
return errno;
@@ -866,22 +866,15 @@ int apk_db_install_pkg(struct apk_database *db,
snprintf(file, sizeof(file),
"%s/%s-%s.apk",
db->repos[0].url, newpkg->name->name, newpkg->version);
-
- fd = open(file, O_RDONLY);
+ bs = apk_bstream_from_url(file);
} else
- fd = open(newpkg->filename, O_RDONLY);
+ bs = apk_bstream_from_file(newpkg->filename);
- if (fd < 0) {
+ if (bs == NULL) {
apk_error("%s: %s", file, strerror(errno));
return errno;
}
- fcntl(fd, F_SETFD, FD_CLOEXEC);
-
- bs = apk_bstream_from_fd(fd);
- if (bs == NULL)
- goto err_close;
-
ctx = (struct install_ctx) {
.db = db,
.pkg = newpkg,
@@ -909,8 +902,7 @@ int apk_db_install_pkg(struct apk_database *db,
write(STDOUT_FILENO, ".", 1);
}
return r;
-
err_close:
- close(fd);
+ bs->close(bs, NULL);
return -1;
}