Skip to content
Snippets Groups Projects
database.c 25 KiB
Newer Older
					   APK_SCRIPT_POST_DEINSTALL);
			return 0;
		}
	}

	/* Install the new stuff */
	if (newpkg->filename == NULL) {
		snprintf(file, sizeof(file),
			 "%s/%s-%s.apk",
			 db->repos[0].url, newpkg->name->name, newpkg->version);
		bs = apk_bstream_from_url(file);
		bs = apk_bstream_from_file(newpkg->filename);
	if (bs == NULL) {
		apk_error("%s: %s", file, strerror(errno));

	ctx = (struct install_ctx) {
		.db = db,
		.pkg = newpkg,
		.script = (oldpkg == NULL) ?
			APK_SCRIPT_PRE_INSTALL : APK_SCRIPT_PRE_UPGRADE,
		.cb = cb,
		.cb_ctx = cb_ctx,
	if (apk_parse_tar_gz(bs, apk_db_install_archive_entry, &ctx) != 0)
Timo Teräs's avatar
Timo Teräs committed
	bs->close(bs, csum, NULL);
	apk_pkg_set_state(db, newpkg, APK_STATE_INSTALL);

	if (memcmp(csum, newpkg->csum, sizeof(csum)) != 0)
		apk_warning("%s-%s: checksum does not match",
			    newpkg->name->name, newpkg->version);

	r = apk_pkg_run_script(newpkg, db->root_fd,
			       (oldpkg == NULL) ?
			       APK_SCRIPT_POST_INSTALL : APK_SCRIPT_POST_UPGRADE);
		apk_error("%s-%s: Failed to execute post-install/upgrade script",
			  newpkg->name->name, newpkg->version);
Timo Teräs's avatar
Timo Teräs committed
	bs->close(bs, NULL, NULL);