static const char * packing_set_format(struct archive *a, pkg_formats format) { switch (format) { case TXZ: if (archive_write_set_compression_xz(a) == ARCHIVE_OK) { return ("txz"); } else { pkg_emit_event(PKG_EVENT_ARCHIVE_COMP_UNSUP, /*argc*/2, "xz", "bzip2"); } case TBZ: if (archive_write_set_compression_bzip2(a) == ARCHIVE_OK) { return ("tbz"); } else { pkg_emit_event(PKG_EVENT_ARCHIVE_COMP_UNSUP, /*argc*/2, "bzip2", "gzip"); } case TGZ: if (archive_write_set_compression_gzip(a) == ARCHIVE_OK) { return ("tgz"); } else { pkg_emit_event(PKG_EVENT_ARCHIVE_COMP_UNSUP, /*argc*/2, "gzip", "plain tar"); } case TAR: archive_write_set_compression_none(a); return ("tar"); } return (NULL); }
int packing_append_file(struct packing *pack, const char *filepath, const char *newpath) { int fd; int len; char linkdest[MAXPATHLEN]; char buf[BUFSIZ]; int retcode = EPKG_OK; struct stat st; archive_entry_clear(pack->entry); archive_entry_copy_sourcepath(pack->entry, filepath); retcode = archive_read_disk_entry_from_file(pack->aread, pack->entry, -1, NULL); if (retcode != ARCHIVE_OK) { pkg_emit_event(PKG_EVENT_ARCHIVE_ERROR, /*argc*/2, filepath, pack->aread); retcode = EPKG_FATAL; goto cleanup; } retcode = EPKG_OK; lstat(filepath, &st); archive_entry_copy_stat(pack->entry, &st); if (S_ISLNK(st.st_mode)) { bzero(linkdest, MAXPATHLEN); readlink(filepath, linkdest, MAXPATHLEN); archive_entry_set_symlink(pack->entry, linkdest); } if (newpath != NULL) archive_entry_set_pathname(pack->entry, newpath); if (archive_entry_filetype(pack->entry) != AE_IFREG) { archive_entry_set_size(pack->entry, 0); } archive_write_header(pack->awrite, pack->entry); if (archive_entry_size(pack->entry) > 0) { if ((fd = open(filepath, O_RDONLY)) < 0) { pkg_emit_event(PKG_EVENT_IO_ERROR, /*argc*/3, "open", filepath, strerror(errno)); retcode = EPKG_FATAL; goto cleanup; } while ((len = read(fd, buf, sizeof(buf))) > 0 ) archive_write_data(pack->awrite, buf, len); close(fd); } cleanup: archive_entry_clear(pack->entry); return (retcode); }
void pkg_emit_upgrade_finished(struct pkg *p) { struct pkg_event ev; bool syslog_enabled = false; char *name, *version, *newversion; ev.type = PKG_EVENT_UPGRADE_FINISHED; ev.e_upgrade_finished.pkg = p; pkg_config_bool(PKG_CONFIG_SYSLOG, &syslog_enabled); if (syslog_enabled) { const char *actions[] = { "upgraded", "reinstalled", "downgraded" }; int num_actions = sizeof(actions) / sizeof(*actions); int action; pkg_get(p, PKG_NAME, &name, PKG_VERSION, &version, PKG_NEWVERSION, &newversion); action = pkg_version_cmp(version, newversion) + 1; if (action >= 0 && action < num_actions) syslog(LOG_NOTICE, "%s %s: %s -> %s ", name, actions[action], version, newversion); } pkg_emit_event(&ev); }
void pkg_emit_integritycheck_begin(void) { struct pkg_event ev; ev.type = PKG_EVENT_INTEGRITYCHECK_BEGIN; pkg_emit_event(&ev); }
void pkg_emit_integritycheck_finished(void) { struct pkg_event ev; ev.type = PKG_EVENT_INTEGRITYCHECK_FINISHED; pkg_emit_event(&ev); }
void pkg_emit_nolocaldb(void) { struct pkg_event ev; ev.type = PKG_EVENT_NOLOCALDB; pkg_emit_event(&ev); }
void pkg_emit_newpkgversion(void) { struct pkg_event ev; ev.type = PKG_EVENT_NEWPKGVERSION; pkg_emit_event(&ev); }
void pkg_emit_integritycheck_finished(int conflicting) { struct pkg_event ev; ev.type = PKG_EVENT_INTEGRITYCHECK_FINISHED; ev.e_integrity_finished.conflicting = conflicting; pkg_emit_event(&ev); }
void pkg_emit_upgrade_begin(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_UPGRADE_BEGIN; ev.e_upgrade_begin.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_package_not_found(const char *p) { struct pkg_event ev; ev.type = PKG_EVENT_NOT_FOUND; ev.e_not_found.pkg_name = p; pkg_emit_event(&ev); }
void pkg_emit_fetch_finished(const char *url) { struct pkg_event ev; ev.type = PKG_EVENT_FETCH_FINISHED; ev.e_fetching.url = url; pkg_emit_event(&ev); }
void pkg_emit_noremotedb(const char *repo) { struct pkg_event ev; ev.type = PKG_EVENT_NOREMOTEDB; ev.e_remotedb.repo = repo; pkg_emit_event(&ev); }
void pkg_emit_delete_files_finished(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_DELETE_FILES_FINISHED; ev.e_delete_files_finished.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_already_installed(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_ALREADY_INSTALLED; ev.e_already_installed.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_delete_files_begin(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_DELETE_FILES_BEGIN; ev.e_delete_files_begin.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_add_deps_finished(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_ADD_DEPS_FINISHED; ev.e_add_deps_finished.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_extract_begin(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_EXTRACT_BEGIN; ev.e_extract_begin.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_locked(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_LOCKED; ev.e_locked.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_add_deps_begin(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_ADD_DEPS_BEGIN; ev.e_add_deps_begin.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_fetch_begin(const char *url) { struct pkg_event ev; ev.type = PKG_EVENT_FETCH_BEGIN; ev.e_fetching.url = url; pkg_emit_event(&ev); }
void pkg_emit_deinstall_begin(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_DEINSTALL_BEGIN; ev.e_deinstall_begin.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_extract_finished(struct pkg *p) { struct pkg_event ev; ev.type = PKG_EVENT_EXTRACT_FINISHED; ev.e_extract_finished.pkg = p; pkg_emit_event(&ev); }
void pkg_emit_missing_dep(struct pkg *p, struct pkg_dep *d) { struct pkg_event ev; ev.type = PKG_EVENT_MISSING_DEP; ev.e_missing_dep.pkg = p; ev.e_missing_dep.dep = d; pkg_emit_event(&ev); }
void pkg_emit_required(struct pkg *p, int force) { struct pkg_event ev; ev.type = PKG_EVENT_REQUIRED; ev.e_required.pkg = p; ev.e_required.force = force; pkg_emit_event(&ev); }
void pkg_emit_update_add(int total, int done) { struct pkg_event ev; ev.type = PKG_EVENT_UPDATE_ADD; ev.e_upd_add.total = total; ev.e_upd_add.done = done; pkg_emit_event(&ev); }
void pkg_emit_errno(const char *func, const char *arg) { struct pkg_event ev; ev.type = PKG_EVENT_ERRNO; ev.e_errno.func = func; ev.e_errno.arg = arg; pkg_emit_event(&ev); }
void pkg_emit_update_remove(int total, int done) { struct pkg_event ev; ev.type = PKG_EVENT_UPDATE_REMOVE; ev.e_upd_remove.total = total; ev.e_upd_remove.done = done; pkg_emit_event(&ev); }
void pkg_emit_file_mismatch(struct pkg *pkg, struct pkg_file *f, const char *newsum) { struct pkg_event ev; ev.type = PKG_EVENT_FILE_MISMATCH; ev.e_file_mismatch.pkg = pkg; ev.e_file_mismatch.file = f; ev.e_file_mismatch.newsum = newsum; pkg_emit_event(&ev); }
void pkg_emit_integritycheck_conflict(const char *uid, const char *path, struct pkg_event_conflict *conflicts) { struct pkg_event ev; ev.type = PKG_EVENT_INTEGRITYCHECK_CONFLICT; ev.e_integrity_conflict.pkg_uid = uid; ev.e_integrity_conflict.pkg_path = path; ev.e_integrity_conflict.conflicts = conflicts; pkg_emit_event(&ev); }
void pkg_emit_fetching(const char *url, off_t total, off_t done, time_t elapsed) { struct pkg_event ev; ev.type = PKG_EVENT_FETCHING; ev.e_fetching.url = url; ev.e_fetching.total = total; ev.e_fetching.done = done; ev.e_fetching.elapsed = elapsed; pkg_emit_event(&ev); }