#############################################################################*/
#include <ctype.h>
-#include <errno.h>
#include <fcntl.h>
#include <gpgme.h>
#include <stdlib.h>
r = pakfire_filelist_create_from_file(&archive->filelist,
archive->pakfire, data, archive->format);
if (r)
- ERROR(archive->pakfire, "Could not parse filelist: %s\n", strerror(errno));
+ ERROR(archive->pakfire, "Could not parse filelist: %m\n");
if (data)
free(data);
int r = stat(archive->path, &buf);
if (r) {
- ERROR(archive->pakfire, "Could not stat %s: %s\n",
- archive->path, strerror(errno));
+ ERROR(archive->pakfire, "Could not stat %s: %m\n", archive->path);
return -1;
}
// Open the source script
FILE* f = fopen(path, "r");
if (!f) {
- ERROR(pakfire, "Could not open %s: %s\n", path, strerror(errno));
+ ERROR(pakfire, "Could not open %s: %m\n", path);
return 1;
}
// Read the script into memory
int r = pakfire_read_file_into_buffer(f, &script, &size);
if (r) {
- ERROR(pakfire, "Could not read script into memory: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not read script into memory: %m\n");
goto ERROR;
}
r = pakfire_filelist_export(filelist, f);
fclose(f);
if (r) {
- ERROR(pakfire, "Could not export filelist: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not export filelist: %m\n");
goto ERROR;
}
// Find dependencies
r = pakfire_build_find_dependencies(pakfire, pkg, filelist, buildroot);
if (r) {
- ERROR(pakfire, "Finding dependencies failed: %s\n", strerror(errno));
+ ERROR(pakfire, "Finding dependencies failed: %m\n");
goto ERROR;
}
// Add scriptlet requirements
r = pakfire_build_add_scriptlet_requires(pakfire, pkg, scriptlet);
if (r) {
- ERROR(pakfire, "Could not add scriptlet requirements: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not add scriptlet requirements: %m\n");
goto ERROR;
}
// Expand the handle into the package name
char* name = pakfire_parser_expand(makefile, "packages", namespace);
if (!name) {
- ERROR(pakfire, "Could not get package name: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not get package name: %m\n");
goto ERROR;
}
// Fetch package from makefile
r = pakfire_parser_create_package(makefile, &pkg, repo, namespace, arch);
if (r) {
- ERROR(pakfire, "Could not create package from makefile: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not create package from makefile: %m\n");
goto ERROR;
}
// Write the finished package
r = pakfire_packager_finish_to_directory(packager, target);
if (r) {
- ERROR(pakfire, "pakfire_packager_finish() failed: %s\n", strerror(errno));
+ ERROR(pakfire, "pakfire_packager_finish() failed: %m\n");
goto ERROR;
}
// Fetch a list all all packages
char** packages = pakfire_parser_list_namespaces(makefile, "packages.package:*");
if (!packages) {
- ERROR(pakfire, "Could not find any packages: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not find any packages: %m\n");
goto ERROR;
}
// Create the build script
char* script = pakfire_parser_expand(makefile, "build", template);
if (!script) {
- ERROR(pakfire, "Could not generate the build script for stage '%s': %s\n",
- stage, strerror(errno));
+ ERROR(pakfire, "Could not generate the build script for stage '%s': %m\n", stage);
goto ERROR;
}
pakfire_parser_error_get_message(error));
pakfire_parser_error_unref(error);
} else {
- ERROR(pakfire, "Could not parse makefile %s: %s\n", path,
- strerror(errno));
+ ERROR(pakfire, "Could not parse makefile %s: %m\n", path);
}
goto ERROR;
// Create the packages
r = pakfire_build_packages(pakfire, makefile, id, buildroot_rel, target);
if (r) {
- ERROR(pakfire, "Could not create packages: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not create packages: %m\n");
goto ERROR;
}
pakfire_cgroups_supported = 0;
}
} else if (r < 0) {
- ERROR(pakfire, "Could not stat %s: %s\n", CGROUP_ROOT, strerror(errno));
+ ERROR(pakfire, "Could not stat %s: %m\n", CGROUP_ROOT);
pakfire_cgroups_supported = 0;
}
}
FILE* f = fopen(path, mode);
if (!f) {
- ERROR(pakfire, "Could not open %s: %s\n", path, strerror(errno));
+ ERROR(pakfire, "Could not open %s: %m\n", path);
return NULL;
}
return 0;
default:
- ERROR(pakfire, "Could not create cgroup %s: %s\n", group, strerror(errno));
+ ERROR(pakfire, "Could not create cgroup %s: %m\n", group);
return r;
}
}
// Remove the directory
r = rmdir(path);
if (r) {
- ERROR(pakfire, "Could not destroy cgroup %s: %s\n", group, strerror(errno));
+ ERROR(pakfire, "Could not destroy cgroup %s: %m\n", group);
return r;
}
int pakfire_cgroup_attach(Pakfire pakfire, const char* group, pid_t pid) {
int r = pakfire_cgroup_fprintf(pakfire, group, "cgroup.procs", "%d", pid);
if (r < 0) {
- ERROR(pakfire, "Could not attach process %d to cgroup %s: %s\n",
- pid, group, strerror(errno));
+ ERROR(pakfire, "Could not attach process %d to cgroup %s: %m\n", pid, group);
return r;
}
int r = kill(pid, *signum);
if (r < 0 && errno != ESRCH) {
- ERROR(pakfire, "Could not send signal %d to PID %d: %s\n",
- *signum, pid, strerror(errno));
+ ERROR(pakfire, "Could not send signal %d to PID %d: %m\n", *signum, pid);
return r;
}
int r = pakfire_cgroup_fprintf(pakfire, group, "cpu.weight.nice", "%d", level);
if (r) {
- ERROR(pakfire, "Could not change nice level of cgroup %s: %s\n",
- group, strerror(errno));
+ ERROR(pakfire, "Could not change nice level of cgroup %s: %m\n", group);
return r;
}
r = pakfire_dist_add_source(pakfire, packager, pkg, downloader, mirrorlist, *source);
if (r) {
- ERROR(pakfire, "Could not add '%s' to package: %s\n", *source, strerror(errno));
+ ERROR(pakfire, "Could not add '%s' to package: %m\n", *source);
goto ERROR;
}
}
// Move the temporary file to its destination
r = link(transfer->tempfile, transfer->path);
if (r) {
- ERROR(downloader->pakfire, "Could not link destination file %s: %s\n",
- transfer->path, strerror(errno));
+ ERROR(downloader->pakfire, "Could not link destination file %s: %m\n",
+ transfer->path);
return r;
}
}
// Filetime
curl_easy_getinfo(transfer->handle, CURLINFO_FILETIME_T, ×.modtime);
r = utime(transfer->path, ×);
- if (r) {
- ERROR(downloader->pakfire, "Could not set mtime of %s: %s\n",
- transfer->path, strerror(errno));
- }
+ if (r)
+ ERROR(downloader->pakfire, "Could not set mtime of %s: %m\n", transfer->path);
return 0;
}
char* url = pakfire_url_join(transfer->mirror->url, transfer->url);
if (!url) {
- ERROR(downloader->pakfire, "Error composing download URL: %s\n",
- strerror(errno));
+ ERROR(downloader->pakfire, "Error composing download URL: %m\n");
return 1;
}
} else if (*transfer->baseurl) {
char* url = pakfire_url_join(transfer->baseurl, transfer->url);
if (!url) {
- ERROR(downloader->pakfire, "Error composing download URL: %s\n",
- strerror(errno));
+ ERROR(downloader->pakfire, "Error composing download URL: %m\n");
return 1;
}
transfer->f = pakfire_mktemp(transfer->tempfile);
if (!transfer->f) {
- ERROR(downloader->pakfire, "Could not create temporary file for download %s: %s\n",
- transfer->tempfile, strerror(errno));
+ ERROR(downloader->pakfire, "Could not create temporary file for download %s: %m\n",
+ transfer->tempfile);
return 1;
}
}
struct json_object* json = pakfire_json_parse_from_file(ml->pakfire, path);
if (!json) {
- ERROR(ml->pakfire, "Could not parse mirrorlist from %s: %s\n",
- path, strerror(errno));
+ ERROR(ml->pakfire, "Could not parse mirrorlist from %s: %m\n", path);
return 1;
}
// Add the mirror to the downloader
r = pakfire_mirrorlist_add_mirror(ml, url);
if (r) {
- ERROR(ml->pakfire, "Could not add mirror %s: %s\n",
- url, strerror(errno));
+ ERROR(ml->pakfire, "Could not add mirror %s: %m\n", url);
goto NEXT;
}
if (errno == ENOTEMPTY)
return 0;
- ERROR(file->pakfire, "Could not remove %s (%s): %s\n",
- file->path, file->abspath, strerror(errno));
+ ERROR(file->pakfire, "Could not remove %s (%s): %m\n", file->path, file->abspath);
}
// Create a working copy of abspath
r = archive_read_disk_entry_from_file(reader, entry, -1, node->fts_statp);
if (r) {
- ERROR(list->pakfire, "Could not read from %s: %s\n",
- node->fts_path, strerror(errno));
+ ERROR(list->pakfire, "Could not read from %s: %m\n", node->fts_path);
goto ERROR;
}
// Check if any error occured
if (ferror(f)) {
- ERROR(packager->pakfire, "Error reading from file: %s\n", strerror(errno));
+ ERROR(packager->pakfire, "Error reading from file: %m\n");
return 1;
}
// Stat the payload file
int r = fstat(fd, &st);
if (r) {
- ERROR(packager->pakfire, "stat() on fd %d failed: %s\n", fd, strerror(errno));
+ ERROR(packager->pakfire, "stat() on fd %d failed: %m\n", fd);
return 1;
}
for (unsigned int i = 0; i < packager->num_scriptlets; i++) {
r = pakfire_packager_write_scriptlet(packager, a, mtree, packager->scriptlets[i]);
if (r) {
- ERROR(packager->pakfire, "Could not add scriptlet to the archive: %s\n",
- strerror(errno));
+ ERROR(packager->pakfire, "Could not add scriptlet to the archive: %m\n");
goto ERROR;
}
}
// Get the filename of the package
const char* filename = pakfire_packager_filename(packager);
if (!filename) {
- ERROR(packager->pakfire, "Could not generate filename for package: %s\n",
- strerror(errno));
+ ERROR(packager->pakfire, "Could not generate filename for package: %m\n");
r = 1;
goto ERROR;
}
fclose(f);
if (r) {
- ERROR(packager->pakfire, "pakfire_packager_finish() failed: %s\n",
- strerror(errno));
+ ERROR(packager->pakfire, "pakfire_packager_finish() failed: %m\n");
goto ERROR;
}
// Move the temporary file to destination
r = rename(tmppath, path);
if (r) {
- ERROR(packager->pakfire, "Could not move %s to %s: %s\n",
- tmppath, path, strerror(errno));
+ ERROR(packager->pakfire, "Could not move %s to %s: %m\n", tmppath, path);
goto ERROR;
}
// Read all attributes from file
int r = archive_read_disk_entry_from_file(packager->reader, entry, -1, NULL);
if (r) {
- ERROR(packager->pakfire, "Could not read attributes from %s: %s\n",
- path, strerror(errno));
+ ERROR(packager->pakfire, "Could not read attributes from %s: %m\n", path);
goto ERROR;
}
if (archive_entry_filetype(entry) == AE_IFREG) {
f = fopen(sourcepath, "r");
if (!f) {
- ERROR(packager->pakfire, "Could not open %s: %s\n", sourcepath, strerror(errno));
+ ERROR(packager->pakfire, "Could not open %s: %m\n", sourcepath);
r = errno;
goto ERROR;
}
goto RETRY;
}
- ERROR(pakfire, "Could not mount /%s: %s\n", mp->target, strerror(errno));
+ ERROR(pakfire, "Could not mount /%s: %m\n", mp->target);
return r;
}
}
goto RETRY;
}
- ERROR(pakfire, "Could not umount %s: %s\n", mp->path, strerror(errno));
+ ERROR(pakfire, "Could not umount %s: %m\n", mp->path);
}
free(mp);
r = mknod(path, devnode->mode, dev);
if (r) {
- ERROR(pakfire, "Could not create %s: %s\n", devnode->path, strerror(errno));
+ ERROR(pakfire, "Could not create %s: %m\n", devnode->path);
return r;
}
}
r = symlink(s->target, path);
if (r) {
- ERROR(pakfire, "Could not create symlink %s: %s\n", s->path, strerror(errno));
+ ERROR(pakfire, "Could not create symlink %s: %m\n", s->path);
return r;
}
}
r = __mount(pakfire, interpreter, target, NULL, MS_BIND|MS_RDONLY, NULL);
if (r)
- ERROR(pakfire, "Could not mount interpreter %s to %s: %s\n",
- interpreter, target, strerror(errno));
+ ERROR(pakfire, "Could not mount interpreter %s to %s: %m\n", interpreter, target);
return r;
}
if (*default_path && errno == ENOENT)
return 0;
- ERROR(pakfire, "Could not open configuration file %s: %s\n", path, strerror(errno));
+ ERROR(pakfire, "Could not open configuration file %s: %m\n", path);
return 1;
}
// Read configuration from file
int r = pakfire_config_read(pakfire->config, f);
if (r) {
- ERROR(pakfire, "Could not parse configuration file %s: %s\n", path, strerror(errno));
+ ERROR(pakfire, "Could not parse configuration file %s: %m\n", path);
goto ERROR;
}
goto ERROR;
}
- ERROR(pakfire, "Could not open %s: %s\n", path, strerror(errno));
+ ERROR(pakfire, "Could not open %s: %m\n", path);
goto ERROR;
}
// Make sure that our private directory exists
r = pakfire_mkdir(private_dir, 0);
if (r && errno != EEXIST) {
- ERROR(p, "Could not create private directory %s: %s\n", private_dir, strerror(errno));
+ ERROR(p, "Could not create private directory %s: %m\n", private_dir);
goto ERROR;
}
r = stat(src, &st);
if (r < 0) {
- ERROR(pakfire, "Could not stat %s: %s\n", src, strerror(errno));
+ ERROR(pakfire, "Could not stat %s: %m\n", src);
return 1;
}
// Read everything from source file
r = archive_read_disk_entry_from_file(reader, entry, -1, NULL);
if (r) {
- ERROR(pakfire, "Could not read from %s: %s", src, strerror(errno));
+ ERROR(pakfire, "Could not read from %s: %m", src);
goto ERROR;
}
// Write file to destination
r = archive_write_header(writer, entry);
if (r) {
- ERROR(pakfire, "Could not write %s: %s\n", dst, strerror(errno));
+ ERROR(pakfire, "Could not write %s: %m\n", dst);
goto ERROR;
}
// Check if any error occured
if (ferror(f)) {
- ERROR(pakfire, "Error reading from file: %s\n", strerror(errno));
+ ERROR(pakfire, "Error reading from file: %m\n");
goto ERROR;
}
// Find a matching entry in /etc/passwd
struct passwd* entry = pakfire_getpwuid(pakfire, uid);
if (!entry) {
- ERROR(pakfire, "Could not retrieve uname for %ld: %s\n", uid, strerror(errno));
+ ERROR(pakfire, "Could not retrieve uname for %ld: %m\n", uid);
return 0;
}
// Find a matching entry in /etc/group
struct group* entry = pakfire_getgrgid(pakfire, gid);
if (!entry) {
- ERROR(pakfire, "Could not retrieve gname for %ld: %s\n", gid, strerror(errno));
+ ERROR(pakfire, "Could not retrieve gname for %ld: %m\n", gid);
return 0;
}
// Find a matching entry in /etc/passwd
struct passwd* entry = pakfire_getpwnam(pakfire, name);
if (!entry) {
- ERROR(pakfire, "Could not retrieve UID for '%s': %s\n", name, strerror(errno));
+ ERROR(pakfire, "Could not retrieve UID for '%s': %m\n", name);
return 0;
}
// Find a matching entry in /etc/group
struct group* entry = pakfire_getgrnam(pakfire, name);
if (!entry) {
- ERROR(pakfire, "Could not retrieve GID for '%s': %s\n", name, strerror(errno));
+ ERROR(pakfire, "Could not retrieve GID for '%s': %m\n", name);
return 0;
}
// Check for any errors
else if (r > 0) {
- ERROR(parser->pakfire, "fnmatch failed: %s\n", strerror(errno));
+ ERROR(parser->pakfire, "fnmatch failed: %m\n");
if (namespaces)
free(namespaces);
// Assign a new UUID to this package
char* uuid = pakfire_generate_uuid();
if (!uuid) {
- ERROR(parser->pakfire, "Generating a UUID failed: %s\n", strerror(errno));
+ ERROR(parser->pakfire, "Generating a UUID failed: %m\n");
goto CLEANUP;
}
char hostname[HOST_NAME_MAX + 1];
r = gethostname(hostname, HOST_NAME_MAX + 1);
if (r) {
- ERROR(parser->pakfire, "gethostname() failed: %s\n", strerror(errno));
+ ERROR(parser->pakfire, "gethostname() failed: %m\n");
goto CLEANUP;
}
// Create a new repository
PakfireRepo repo = pakfire_repo_create(pakfire, name);
if (!repo) {
- ERROR(pakfire, "Could not create repository '%s': %s\n", name, strerror(errno));
+ ERROR(pakfire, "Could not create repository '%s': %m\n", name);
r = 1;
goto ERROR;
}
int r = pakfire_mirrorlist_create(&repo->mirrorlist, repo->pakfire);
if (r) {
- ERROR(repo->pakfire, "Could not create mirrorlist: %s\n", strerror(errno));
+ ERROR(repo->pakfire, "Could not create mirrorlist: %m\n");
return NULL;
}
// Read the mirrorlist
r = pakfire_mirrorlist_read(repo->mirrorlist, repo->appdata->mirrorlist);
if (r) {
- ERROR(repo->pakfire, "Could not read mirrorlist %s: %s\n",
- repo->appdata->mirrorlist, strerror(errno));
+ ERROR(repo->pakfire, "Could not read mirrorlist %s: %m\n",
+ repo->appdata->mirrorlist);
// Destroy what we have created
pakfire_mirrorlist_unref(repo->mirrorlist);
if (!refresh && errno == ENOENT)
return 0;
- ERROR(repo->pakfire, "Could not parse metadata from %s: %s\n", path, strerror(errno));
+ ERROR(repo->pakfire, "Could not parse metadata from %s: %m\n", path);
return 1;
}
if (!refresh && errno == ENOENT)
goto NOERROR;
- ERROR(repo->pakfire, "Could not read SOLV file %s: %s\n",
- database_cache_path, strerror(errno));
+ ERROR(repo->pakfire, "Could not read SOLV file %s: %m\n", database_cache_path);
goto ERROR;
}
}
// Allocate a libsolv repository
repo->repo = repo_create(pool, name);
if (!repo->repo) {
- ERROR(repo->pakfire, "Could not allocate repo: %s\n", strerror(errno));
+ ERROR(repo->pakfire, "Could not allocate repo: %m\n");
goto ERROR;
}
// Try loading metadata
r = pakfire_repo_read_metadata(repo, repo->appdata->metadata, 0);
if (r) {
- ERROR(repo->pakfire, "Could not initialize repository metadata: %s\n",
- strerror(errno));
+ ERROR(repo->pakfire, "Could not initialize repository metadata: %m\n");
goto ERROR;
}
PAKFIRE_EXPORT int pakfire_request_solve(struct pakfire_request* request, int flags) {
int r = init_solver(request, flags);
if (r) {
- ERROR(request->pakfire, "Could not initialize the solver: %s\n", strerror(errno));
+ ERROR(request->pakfire, "Could not initialize the solver: %m\n");
return r;
}
// Stat the input file
r = fstat(fileno(f), &st);
if (r) {
- ERROR(pakfire, "Could not stat snapshot: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not stat snapshot: %m\n");
return 1;
}
// Extract payload to the root of the Pakfire instance
int r = pakfire_archive_extract(archive, NULL);
if (r) {
- ERROR(transaction->pakfire, "Could not extract package %s: %s\n",
- pakfire_package_get_nevra(pkg), strerror(errno));
+ ERROR(transaction->pakfire, "Could not extract package %s: %m\n",
+ pakfire_package_get_nevra(pkg));
return r;
}
// End loop if action was unsuccessful
if (r) {
- DEBUG(transaction->pakfire, "Step %d failed: %s\n", i, strerror(errno));
+ DEBUG(transaction->pakfire, "Step %d failed: %m\n", i);
break;
}
}
transaction->archives[i] = pakfire_package_get_archive(pkg);
if (!transaction->archives[i]) {
- ERROR(transaction->pakfire, "Could not open archive for %s: %s\n",
- pakfire_package_get_nevra(pkg), strerror(errno));
+ ERROR(transaction->pakfire, "Could not open archive for %s: %m\n",
+ pakfire_package_get_nevra(pkg));
return 1;
}
}
// Initialize the downloader
r = pakfire_downloader_create(&downloader, transaction->pakfire);
if (r) {
- ERROR(transaction->pakfire, "Could not initialize downloader: %s\n",
- strerror(errno));
+ ERROR(transaction->pakfire, "Could not initialize downloader: %m\n");
return 1;
}
// Create tokener
tokener = json_tokener_new();
if (!tokener) {
- ERROR(pakfire, "Could not allocate JSON tokener: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not allocate JSON tokener: %m\n");
goto ERROR;
}
// Fetch current configuration
if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
- ERROR(pakfire, "Could not read RLIMIT_NOFILE: %s\n", strerror(errno));
+ ERROR(pakfire, "Could not read RLIMIT_NOFILE: %m\n");
return 1;
}
// Set the new limit
if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
- ERROR(pakfire, "Could not set RLIMIT_NOFILE to %lu: %s\n",
- rl.rlim_cur, strerror(errno));
+ ERROR(pakfire, "Could not set RLIMIT_NOFILE to %lu: %m\n", rl.rlim_cur);
return 1;
}
r = pakfire_create(&t->pakfire, root, NULL, TEST_SRC_PATH "/pakfire.conf", 0,
pakfire_log_stderr, NULL);
if (r) {
- LOG("ERROR: Could not initialize Pakfire: %s\n", strerror(errno));
+ LOG("ERROR: Could not initialize Pakfire: %m\n");
exit(1);
}