summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-11-28 15:03:27 +0200
committerTimo Teras <timo.teras@iki.fi>2008-11-28 15:03:27 +0200
commit4bafa681feb2b902553e26fd88df0f06b0c0778a (patch)
treea1d1ee116c71ac59572c040f05603380e581848b /src/database.c
parent5ea81ca564534e4ef5eefbe723a74dbf490e6e07 (diff)
downloadapk-tools-4bafa681feb2b902553e26fd88df0f06b0c0778a.tar.gz
apk-tools-4bafa681feb2b902553e26fd88df0f06b0c0778a.tar.bz2
apk-tools-4bafa681feb2b902553e26fd88df0f06b0c0778a.tar.xz
apk-tools-4bafa681feb2b902553e26fd88df0f06b0c0778a.zip
io: prepartions for url handling
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;
}