xbps_xasprintf: do not return NULL anymore; remove checks for this.
This commit is contained in:
@ -373,7 +373,6 @@ process_entry_file(struct archive *ar, struct xentry *xe, const char *filematch)
|
|||||||
entry = archive_entry_new();
|
entry = archive_entry_new();
|
||||||
assert(entry);
|
assert(entry);
|
||||||
p = xbps_xasprintf("%s/%s", destdir, xe->file);
|
p = xbps_xasprintf("%s/%s", destdir, xe->file);
|
||||||
assert(p);
|
|
||||||
archive_entry_set_pathname(entry, xe->file);
|
archive_entry_set_pathname(entry, xe->file);
|
||||||
archive_entry_copy_sourcepath(entry, p);
|
archive_entry_copy_sourcepath(entry, p);
|
||||||
|
|
||||||
@ -710,7 +709,6 @@ main(int argc, char **argv)
|
|||||||
* Create a temp file to store archive data.
|
* Create a temp file to store archive data.
|
||||||
*/
|
*/
|
||||||
tname = xbps_xasprintf(".xbps-pkg-XXXXXX");
|
tname = xbps_xasprintf(".xbps-pkg-XXXXXX");
|
||||||
assert(tname);
|
|
||||||
pkg_fd = mkstemp(tname);
|
pkg_fd = mkstemp(tname);
|
||||||
assert(pkg_fd != -1);
|
assert(pkg_fd != -1);
|
||||||
/*
|
/*
|
||||||
@ -734,7 +732,6 @@ main(int argc, char **argv)
|
|||||||
* perspective it's atomic.
|
* perspective it's atomic.
|
||||||
*/
|
*/
|
||||||
binpkg = xbps_xasprintf("%s.%s.xbps", pkgver, arch);
|
binpkg = xbps_xasprintf("%s.%s.xbps", pkgver, arch);
|
||||||
assert(binpkg);
|
|
||||||
|
|
||||||
(void)fsync(pkg_fd);
|
(void)fsync(pkg_fd);
|
||||||
myumask = umask(0);
|
myumask = umask(0);
|
||||||
|
@ -269,9 +269,6 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
|
|||||||
if (strcmp(keyname, optional_objs[x]) == 0) {
|
if (strcmp(keyname, optional_objs[x]) == 0) {
|
||||||
optnode = xbps_xasprintf("[style=\"%s\"",
|
optnode = xbps_xasprintf("[style=\"%s\"",
|
||||||
cfprop);
|
cfprop);
|
||||||
if (optnode == NULL)
|
|
||||||
die("alloc optnode");
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -495,8 +492,6 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (outfile == NULL) {
|
if (outfile == NULL) {
|
||||||
outfile = xbps_xasprintf("%s.dot", argv[0]);
|
outfile = xbps_xasprintf("%s.dot", argv[0]);
|
||||||
if (outfile == NULL)
|
|
||||||
die("alloc outfile");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -71,10 +71,6 @@ check_pkg_files(struct xbps_handle *xhp,
|
|||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||||
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||||
if (path == NULL) {
|
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
prop_dictionary_get_cstring_nocopy(obj,
|
prop_dictionary_get_cstring_nocopy(obj,
|
||||||
"sha256", &sha256);
|
"sha256", &sha256);
|
||||||
rv = xbps_file_hash_check(path, sha256);
|
rv = xbps_file_hash_check(path, sha256);
|
||||||
@ -124,10 +120,6 @@ check_pkg_files(struct xbps_handle *xhp,
|
|||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||||
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||||
if (path == NULL) {
|
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ((rv = access(path, R_OK)) == -1) {
|
if ((rv = access(path, R_OK)) == -1) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
xbps_error_printf(
|
xbps_error_printf(
|
||||||
|
@ -78,9 +78,6 @@ check_pkg_symlinks(struct xbps_handle *xhp,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||||
if (path == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if ((buf = realpath(path, NULL)) == NULL) {
|
if ((buf = realpath(path, NULL)) == NULL) {
|
||||||
xbps_error_printf("%s: broken symlink `%s': "
|
xbps_error_printf("%s: broken symlink `%s': "
|
||||||
"%s\n", pkgname, file, strerror(errno));
|
"%s\n", pkgname, file, strerror(errno));
|
||||||
@ -91,7 +88,6 @@ check_pkg_symlinks(struct xbps_handle *xhp,
|
|||||||
/* relative symlink target */
|
/* relative symlink target */
|
||||||
dname = dirname(path);
|
dname = dirname(path);
|
||||||
buf2 = xbps_xasprintf("%s/%s", dname, tgt);
|
buf2 = xbps_xasprintf("%s/%s", dname, tgt);
|
||||||
assert(buf2);
|
|
||||||
buf3 = realpath(buf2, NULL);
|
buf3 = realpath(buf2, NULL);
|
||||||
assert(buf3);
|
assert(buf3);
|
||||||
free(buf2);
|
free(buf2);
|
||||||
|
@ -85,9 +85,6 @@ ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
|
|||||||
unsigned int i, count;
|
unsigned int i, count;
|
||||||
|
|
||||||
path = xbps_xasprintf("%s/metadata", xhp->metadir);
|
path = xbps_xasprintf("%s/metadata", xhp->metadir);
|
||||||
if (path == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if ((dirp = opendir(path)) == NULL) {
|
if ((dirp = opendir(path)) == NULL) {
|
||||||
free(path);
|
free(path);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -161,7 +161,6 @@ cachedir_clean(struct xbps_handle *xhp)
|
|||||||
}
|
}
|
||||||
/* Internalize props.plist dictionary from binary pkg */
|
/* Internalize props.plist dictionary from binary pkg */
|
||||||
binpkg = xbps_xasprintf("%s/%s", xhp->cachedir, dp->d_name);
|
binpkg = xbps_xasprintf("%s/%s", xhp->cachedir, dp->d_name);
|
||||||
assert(binpkg != NULL);
|
|
||||||
pkg_propsd = xbps_dictionary_metadata_plist_by_url(binpkg,
|
pkg_propsd = xbps_dictionary_metadata_plist_by_url(binpkg,
|
||||||
"./props.plist");
|
"./props.plist");
|
||||||
if (pkg_propsd == NULL) {
|
if (pkg_propsd == NULL) {
|
||||||
|
@ -44,7 +44,6 @@ remove_pkg(const char *repodir, const char *arch, const char *file)
|
|||||||
|
|
||||||
/* Remove real binpkg */
|
/* Remove real binpkg */
|
||||||
filepath = xbps_xasprintf("%s/%s/%s", repodir, arch, file);
|
filepath = xbps_xasprintf("%s/%s/%s", repodir, arch, file);
|
||||||
assert(filepath);
|
|
||||||
if (remove(filepath) == -1) {
|
if (remove(filepath) == -1) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
xbps_error_printf("failed to remove old binpkg `%s': %s\n",
|
xbps_error_printf("failed to remove old binpkg `%s': %s\n",
|
||||||
@ -56,7 +55,6 @@ remove_pkg(const char *repodir, const char *arch, const char *file)
|
|||||||
|
|
||||||
/* Remove symlink to binpkg */
|
/* Remove symlink to binpkg */
|
||||||
filepath = xbps_xasprintf("%s/%s", repodir, file);
|
filepath = xbps_xasprintf("%s/%s", repodir, file);
|
||||||
assert(filepath);
|
|
||||||
if (remove(filepath) == -1) {
|
if (remove(filepath) == -1) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
xbps_error_printf("failed to remove old binpkg `%s': %s\n",
|
xbps_error_printf("failed to remove old binpkg `%s': %s\n",
|
||||||
|
@ -79,10 +79,7 @@ index_files_clean(struct xbps_handle *xhp, const char *repodir)
|
|||||||
/* pkg found, do nothing */
|
/* pkg found, do nothing */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((str = xbps_xasprintf("%s,%s", ipkgver, iarch)) == NULL) {
|
str = xbps_xasprintf("%s,%s", ipkgver, iarch);
|
||||||
rv = ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (!prop_array_add_cstring(obsoletes, str)) {
|
if (!prop_array_add_cstring(obsoletes, str)) {
|
||||||
free(str);
|
free(str);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
|
@ -206,7 +206,6 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
buf = xbps_xasprintf("`%s' (%s)",
|
buf = xbps_xasprintf("`%s' (%s)",
|
||||||
oldpkgver, oldarch);
|
oldpkgver, oldarch);
|
||||||
assert(buf);
|
|
||||||
rv = remove_pkg(repodir,
|
rv = remove_pkg(repodir,
|
||||||
oldarch, oldfilen);
|
oldarch, oldfilen);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
@ -226,7 +225,6 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
* index version.
|
* index version.
|
||||||
*/
|
*/
|
||||||
buf = xbps_xasprintf("`%s' (%s)", oldpkgver, oldarch);
|
buf = xbps_xasprintf("`%s' (%s)", oldpkgver, oldarch);
|
||||||
assert(buf);
|
|
||||||
buf2 = strdup(oldpkgver);
|
buf2 = strdup(oldpkgver);
|
||||||
assert(buf2);
|
assert(buf2);
|
||||||
rv = remove_pkg(repodir, oldarch, oldfilen);
|
rv = remove_pkg(repodir, oldarch, oldfilen);
|
||||||
|
@ -124,10 +124,6 @@ xbps_fetch_file(struct xbps_handle *xhp,
|
|||||||
* Compute destination file path.
|
* Compute destination file path.
|
||||||
*/
|
*/
|
||||||
destfile = xbps_xasprintf("%s/%s", outputdir, filename);
|
destfile = xbps_xasprintf("%s/%s", outputdir, filename);
|
||||||
if (destfile == NULL) {
|
|
||||||
rv = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Check if we have to resume a transfer.
|
* Check if we have to resume a transfer.
|
||||||
*/
|
*/
|
||||||
|
@ -145,7 +145,6 @@ xbps_init(struct xbps_handle *xhp)
|
|||||||
|
|
||||||
buf = xbps_xasprintf("repositories = { %s }",
|
buf = xbps_xasprintf("repositories = { %s }",
|
||||||
xhp->repository);
|
xhp->repository);
|
||||||
assert(buf);
|
|
||||||
if ((rv = cfg_parse_buf(xhp->cfg, buf)) != 0)
|
if ((rv = cfg_parse_buf(xhp->cfg, buf)) != 0)
|
||||||
return rv;
|
return rv;
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@ -105,11 +105,6 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
|
|||||||
prop_dictionary_get_cstring_nocopy(obj2,
|
prop_dictionary_get_cstring_nocopy(obj2,
|
||||||
"file", &cffile);
|
"file", &cffile);
|
||||||
buf = xbps_xasprintf(".%s", cffile);
|
buf = xbps_xasprintf(".%s", cffile);
|
||||||
if (buf == NULL) {
|
|
||||||
prop_object_iterator_release(iter2);
|
|
||||||
rv = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (strcmp(entry_pname, buf) == 0) {
|
if (strcmp(entry_pname, buf) == 0) {
|
||||||
prop_dictionary_get_cstring(obj2, "sha256",
|
prop_dictionary_get_cstring(obj2, "sha256",
|
||||||
&sha256_orig);
|
&sha256_orig);
|
||||||
@ -138,10 +133,6 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
|
|||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "file", &cffile);
|
prop_dictionary_get_cstring_nocopy(obj, "file", &cffile);
|
||||||
buf = xbps_xasprintf(".%s", cffile);
|
buf = xbps_xasprintf(".%s", cffile);
|
||||||
if (buf == NULL) {
|
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (strcmp(entry_pname, buf)) {
|
if (strcmp(entry_pname, buf)) {
|
||||||
free(buf);
|
free(buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
@ -232,10 +223,6 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
|
|||||||
(strcmp(sha256_orig, sha256_new))) {
|
(strcmp(sha256_orig, sha256_new))) {
|
||||||
buf = xbps_xasprintf(".%s.new-%s",
|
buf = xbps_xasprintf(".%s.new-%s",
|
||||||
cffile, version);
|
cffile, version);
|
||||||
if (buf == NULL) {
|
|
||||||
rv = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIG_FILE,
|
xbps_set_cb_state(xhp, XBPS_STATE_CONFIG_FILE,
|
||||||
0, pkgname, version,
|
0, pkgname, version,
|
||||||
"Installing new configuration file to "
|
"Installing new configuration file to "
|
||||||
|
@ -113,9 +113,6 @@ xbps_configure_pkg(struct xbps_handle *xhp,
|
|||||||
|
|
||||||
buf = xbps_xasprintf("%s/metadata/%s/INSTALL",
|
buf = xbps_xasprintf("%s/metadata/%s/INSTALL",
|
||||||
XBPS_META_PATH, pkgname);
|
XBPS_META_PATH, pkgname);
|
||||||
if (buf == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
if (chdir(xhp->rootdir) == -1) {
|
if (chdir(xhp->rootdir) == -1) {
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL,
|
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL,
|
||||||
errno, pkgname, version,
|
errno, pkgname, version,
|
||||||
|
@ -57,7 +57,6 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
|||||||
"pkgver", &pkgver);
|
"pkgver", &pkgver);
|
||||||
buf = xbps_xasprintf("%s conflicts with "
|
buf = xbps_xasprintf("%s conflicts with "
|
||||||
"installed pkg %s", repopkgver, pkgver);
|
"installed pkg %s", repopkgver, pkgver);
|
||||||
assert(buf != NULL);
|
|
||||||
prop_array_add_cstring(trans_cflicts, buf);
|
prop_array_add_cstring(trans_cflicts, buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
continue;
|
continue;
|
||||||
@ -72,7 +71,6 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
|||||||
"pkgver", &pkgver);
|
"pkgver", &pkgver);
|
||||||
buf = xbps_xasprintf("%s conflicts with "
|
buf = xbps_xasprintf("%s conflicts with "
|
||||||
"%s in transaction", repopkgver, pkgver);
|
"%s in transaction", repopkgver, pkgver);
|
||||||
assert(buf != NULL);
|
|
||||||
prop_array_add_cstring(trans_cflicts, buf);
|
prop_array_add_cstring(trans_cflicts, buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
continue;
|
continue;
|
||||||
|
@ -88,9 +88,6 @@ remove_pkg_metadata(struct xbps_handle *xhp,
|
|||||||
|
|
||||||
metadir = xbps_xasprintf("%s/%s/metadata/%s", xhp->rootdir,
|
metadir = xbps_xasprintf("%s/%s/metadata/%s", xhp->rootdir,
|
||||||
XBPS_META_PATH, pkgname);
|
XBPS_META_PATH, pkgname);
|
||||||
if (metadir == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
dirp = opendir(metadir);
|
dirp = opendir(metadir);
|
||||||
if (dirp == NULL) {
|
if (dirp == NULL) {
|
||||||
free(metadir);
|
free(metadir);
|
||||||
@ -103,12 +100,6 @@ remove_pkg_metadata(struct xbps_handle *xhp,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
path = xbps_xasprintf("%s/%s", metadir, dp->d_name);
|
path = xbps_xasprintf("%s/%s", metadir, dp->d_name);
|
||||||
if (path == NULL) {
|
|
||||||
(void)closedir(dirp);
|
|
||||||
free(metadir);
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlink(path) == -1) {
|
if (unlink(path) == -1) {
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_PURGE_FAIL,
|
xbps_set_cb_state(xhp, XBPS_STATE_PURGE_FAIL,
|
||||||
errno, pkgname, version,
|
errno, pkgname, version,
|
||||||
@ -168,10 +159,6 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
|
|||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||||
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||||
if (path == NULL) {
|
|
||||||
rv = ENOMEM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((strcmp(key, "files") == 0) ||
|
if ((strcmp(key, "files") == 0) ||
|
||||||
(strcmp(key, "conf_files") == 0)) {
|
(strcmp(key, "conf_files") == 0)) {
|
||||||
@ -282,16 +269,8 @@ xbps_remove_pkg(struct xbps_handle *xhp,
|
|||||||
|
|
||||||
buf = xbps_xasprintf("%s/metadata/%s/REMOVE",
|
buf = xbps_xasprintf("%s/metadata/%s/REMOVE",
|
||||||
XBPS_META_PATH, pkgname);
|
XBPS_META_PATH, pkgname);
|
||||||
if (buf == NULL) {
|
|
||||||
rv = ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgver = xbps_xasprintf("%s-%s", pkgname, version);
|
pkgver = xbps_xasprintf("%s-%s", pkgname, version);
|
||||||
if (pkgver == NULL) {
|
|
||||||
rv = ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((rv = xbps_pkg_state_installed(xhp, pkgname, &state)) != 0)
|
if ((rv = xbps_pkg_state_installed(xhp, pkgname, &state)) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -71,7 +71,6 @@ again:
|
|||||||
|
|
||||||
file = xbps_xasprintf(".%s",
|
file = xbps_xasprintf(".%s",
|
||||||
prop_string_cstring_nocopy(oldstr));
|
prop_string_cstring_nocopy(oldstr));
|
||||||
assert(file);
|
|
||||||
|
|
||||||
if ((strcmp(array_str, "files") == 0) ||
|
if ((strcmp(array_str, "files") == 0) ||
|
||||||
(strcmp(array_str, "conf_files") == 0)) {
|
(strcmp(array_str, "conf_files") == 0)) {
|
||||||
|
@ -71,10 +71,6 @@ extract_metafile(struct xbps_handle *xhp,
|
|||||||
}
|
}
|
||||||
buf = xbps_xasprintf("%s/metadata/%s/%s",
|
buf = xbps_xasprintf("%s/metadata/%s/%s",
|
||||||
XBPS_META_PATH, pkgname, file);
|
XBPS_META_PATH, pkgname, file);
|
||||||
if (buf == NULL) {
|
|
||||||
free(pkgname);
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
archive_entry_set_pathname(entry, buf);
|
archive_entry_set_pathname(entry, buf);
|
||||||
dirc = strdup(buf);
|
dirc = strdup(buf);
|
||||||
if (dirc == NULL) {
|
if (dirc == NULL) {
|
||||||
@ -133,10 +129,6 @@ remove_metafile(struct xbps_handle *xhp,
|
|||||||
}
|
}
|
||||||
buf = xbps_xasprintf("%s/metadata/%s/%s",
|
buf = xbps_xasprintf("%s/metadata/%s/%s",
|
||||||
XBPS_META_PATH, pkgname, file);
|
XBPS_META_PATH, pkgname, file);
|
||||||
if (buf == NULL) {
|
|
||||||
free(pkgname);
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
if (unlink(buf) == -1) {
|
if (unlink(buf) == -1) {
|
||||||
if (errno && errno != ENOENT) {
|
if (errno && errno != ENOENT) {
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||||
@ -291,10 +283,6 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
*/
|
*/
|
||||||
buf = xbps_xasprintf("%s/metadata/%s/INSTALL",
|
buf = xbps_xasprintf("%s/metadata/%s/INSTALL",
|
||||||
XBPS_META_PATH, pkgname);
|
XBPS_META_PATH, pkgname);
|
||||||
if (buf == NULL) {
|
|
||||||
rv = ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
rv = extract_metafile(xhp, ar, entry,
|
rv = extract_metafile(xhp, ar, entry,
|
||||||
"INSTALL", pkgver, true, flags);
|
"INSTALL", pkgver, true, flags);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
@ -470,7 +458,6 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
assert(buf2);
|
assert(buf2);
|
||||||
dname = dirname(buf2);
|
dname = dirname(buf2);
|
||||||
p2 = xbps_xasprintf("%s/%s", dname, tgtlnk);
|
p2 = xbps_xasprintf("%s/%s", dname, tgtlnk);
|
||||||
assert(p2);
|
|
||||||
free(buf2);
|
free(buf2);
|
||||||
} else {
|
} else {
|
||||||
p2 = strdup(tgtlnk);
|
p2 = strdup(tgtlnk);
|
||||||
@ -539,7 +526,6 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
* file but renaming it to <file>.old.
|
* file but renaming it to <file>.old.
|
||||||
*/
|
*/
|
||||||
buf = xbps_xasprintf("%s.old", entry_pname);
|
buf = xbps_xasprintf("%s.old", entry_pname);
|
||||||
assert(buf);
|
|
||||||
(void)rename(entry_pname, buf);
|
(void)rename(entry_pname, buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
@ -593,10 +579,6 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
*/
|
*/
|
||||||
pkgfilesd = xbps_xasprintf("%s/metadata/%s/%s",
|
pkgfilesd = xbps_xasprintf("%s/metadata/%s/%s",
|
||||||
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
|
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
|
||||||
if (pkgfilesd == NULL) {
|
|
||||||
rv = ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (skip_obsoletes || preserve || (!softreplace && !update))
|
if (skip_obsoletes || preserve || (!softreplace && !update))
|
||||||
goto out1;
|
goto out1;
|
||||||
/*
|
/*
|
||||||
@ -631,10 +613,6 @@ out1:
|
|||||||
* Create pkg metadata directory if doesn't exist.
|
* Create pkg metadata directory if doesn't exist.
|
||||||
*/
|
*/
|
||||||
buf = xbps_xasprintf("%s/metadata/%s", XBPS_META_PATH, pkgname);
|
buf = xbps_xasprintf("%s/metadata/%s", XBPS_META_PATH, pkgname);
|
||||||
if (buf == NULL) {
|
|
||||||
rv = ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (access(buf, R_OK|X_OK) == -1) {
|
if (access(buf, R_OK|X_OK) == -1) {
|
||||||
if (xbps_mkpath(buf, 0755) == -1) {
|
if (xbps_mkpath(buf, 0755) == -1) {
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||||
@ -661,10 +639,6 @@ out1:
|
|||||||
}
|
}
|
||||||
pkgpropsd = xbps_xasprintf("%s/metadata/%s/%s",
|
pkgpropsd = xbps_xasprintf("%s/metadata/%s/%s",
|
||||||
XBPS_META_PATH, pkgname, XBPS_PKGPROPS);
|
XBPS_META_PATH, pkgname, XBPS_PKGPROPS);
|
||||||
if (pkgpropsd == NULL) {
|
|
||||||
rv = ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (!prop_dictionary_externalize_to_file(propsd, pkgpropsd)) {
|
if (!prop_dictionary_externalize_to_file(propsd, pkgpropsd)) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||||
|
@ -88,8 +88,6 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
|
|||||||
return cached_rv;
|
return cached_rv;
|
||||||
|
|
||||||
plist = xbps_xasprintf("%s/%s", xhp->metadir, XBPS_PKGDB);
|
plist = xbps_xasprintf("%s/%s", xhp->metadir, XBPS_PKGDB);
|
||||||
assert(plist);
|
|
||||||
|
|
||||||
if (xhp->pkgdb && flush) {
|
if (xhp->pkgdb && flush) {
|
||||||
pkgdb_storage = prop_array_internalize_from_zfile(plist);
|
pkgdb_storage = prop_array_internalize_from_zfile(plist);
|
||||||
if (pkgdb_storage == NULL ||
|
if (pkgdb_storage == NULL ||
|
||||||
|
@ -280,8 +280,6 @@ xbps_dictionary_from_metadata_plist(struct xbps_handle *xhp,
|
|||||||
savedpkgname = pkgname;
|
savedpkgname = pkgname;
|
||||||
plistf = xbps_xasprintf("%s/metadata/%s/%s", xhp->metadir,
|
plistf = xbps_xasprintf("%s/metadata/%s/%s", xhp->metadir,
|
||||||
savedpkgname, plist);
|
savedpkgname, plist);
|
||||||
if (plistf == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (access(plistf, R_OK) == -1) {
|
if (access(plistf, R_OK) == -1) {
|
||||||
pkgd = xbps_find_virtualpkg_dict_installed(xhp, pkgname, false);
|
pkgd = xbps_find_virtualpkg_dict_installed(xhp, pkgname, false);
|
||||||
@ -294,8 +292,6 @@ xbps_dictionary_from_metadata_plist(struct xbps_handle *xhp,
|
|||||||
"pkgname", &savedpkgname);
|
"pkgname", &savedpkgname);
|
||||||
plistf = xbps_xasprintf("%s/metadata/%s/%s",
|
plistf = xbps_xasprintf("%s/metadata/%s/%s",
|
||||||
xhp->metadir, savedpkgname, plist);
|
xhp->metadir, savedpkgname, plist);
|
||||||
if (plistf == NULL)
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,6 @@ find_virtualpkg_user_in_conf(struct xbps_handle *xhp,
|
|||||||
vpkgver = cfg_getnstr(sec, "targets", j);
|
vpkgver = cfg_getnstr(sec, "targets", j);
|
||||||
if (strchr(vpkgver, '_') == NULL) {
|
if (strchr(vpkgver, '_') == NULL) {
|
||||||
tmp = xbps_xasprintf("%s_1", vpkgver);
|
tmp = xbps_xasprintf("%s_1", vpkgver);
|
||||||
assert(tmp != NULL);
|
|
||||||
vpkgname = xbps_pkg_name(tmp);
|
vpkgname = xbps_pkg_name(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,7 +71,6 @@ xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
|
|||||||
prop_array_get_cstring_nocopy(provides, i, &vpkgver);
|
prop_array_get_cstring_nocopy(provides, i, &vpkgver);
|
||||||
if (strchr(vpkgver, '_') == NULL) {
|
if (strchr(vpkgver, '_') == NULL) {
|
||||||
tmp = xbps_xasprintf("%s_1", vpkgver);
|
tmp = xbps_xasprintf("%s_1", vpkgver);
|
||||||
assert(tmp != NULL);
|
|
||||||
vpkgver = tmp;
|
vpkgver = tmp;
|
||||||
}
|
}
|
||||||
for (x = 0; x < prop_array_count(rundeps); x++) {
|
for (x = 0; x < prop_array_count(rundeps); x++) {
|
||||||
@ -117,7 +116,6 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
|
|||||||
pkgdep = prop_string_cstring_nocopy(obj);
|
pkgdep = prop_string_cstring_nocopy(obj);
|
||||||
if (strchr(pkgdep, '_') == NULL) {
|
if (strchr(pkgdep, '_') == NULL) {
|
||||||
tmp = xbps_xasprintf("%s_1", pkgdep);
|
tmp = xbps_xasprintf("%s_1", pkgdep);
|
||||||
assert(tmp != NULL);
|
|
||||||
curpkgname = xbps_pkg_name(tmp);
|
curpkgname = xbps_pkg_name(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
} else {
|
} else {
|
||||||
@ -136,7 +134,6 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
|
|||||||
pkgdep = prop_string_cstring_nocopy(obj);
|
pkgdep = prop_string_cstring_nocopy(obj);
|
||||||
if (strchr(pkgdep, '_') == NULL) {
|
if (strchr(pkgdep, '_') == NULL) {
|
||||||
tmp = xbps_xasprintf("%s_1", pkgdep);
|
tmp = xbps_xasprintf("%s_1", pkgdep);
|
||||||
assert(tmp != NULL);
|
|
||||||
pkgdep = tmp;
|
pkgdep = tmp;
|
||||||
}
|
}
|
||||||
if (xbps_pkgpattern_match(pkgdep, str)) {
|
if (xbps_pkgpattern_match(pkgdep, str)) {
|
||||||
@ -153,7 +150,6 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
|
|||||||
pkgdep = prop_string_cstring_nocopy(obj);
|
pkgdep = prop_string_cstring_nocopy(obj);
|
||||||
if (strchr(pkgdep, '_') == NULL) {
|
if (strchr(pkgdep, '_') == NULL) {
|
||||||
tmp = xbps_xasprintf("%s_1", pkgdep);
|
tmp = xbps_xasprintf("%s_1", pkgdep);
|
||||||
assert(tmp != NULL);
|
|
||||||
pkgdep = tmp;
|
pkgdep = tmp;
|
||||||
}
|
}
|
||||||
if (xbps_pkgpattern_match(str, pkgdep)) {
|
if (xbps_pkgpattern_match(str, pkgdep)) {
|
||||||
|
@ -70,9 +70,6 @@ xbps_get_remote_repo_string(const char *uri)
|
|||||||
url->host, url->doc);
|
url->host, url->doc);
|
||||||
|
|
||||||
fetchFreeURL(url);
|
fetchFreeURL(url);
|
||||||
if (p == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < strlen(p); i++) {
|
for (i = 0; i < strlen(p); i++) {
|
||||||
if (p[i] == '.' || p[i] == '/' || p[i] == ':')
|
if (p[i] == '.' || p[i] == '/' || p[i] == ':')
|
||||||
p[i] = '_';
|
p[i] = '_';
|
||||||
@ -128,28 +125,16 @@ xbps_repository_sync_pkg_index(struct xbps_handle *xhp,
|
|||||||
* Remote repository plist index full URL.
|
* Remote repository plist index full URL.
|
||||||
*/
|
*/
|
||||||
rpidx = xbps_xasprintf("%s/%s", uri, plistf);
|
rpidx = xbps_xasprintf("%s/%s", uri, plistf);
|
||||||
if (rpidx == NULL) {
|
|
||||||
rv = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Save temporary file in metadir, and rename if it
|
* Save temporary file in metadir, and rename if it
|
||||||
* was downloaded successfully.
|
* was downloaded successfully.
|
||||||
*/
|
*/
|
||||||
tmp_metafile = xbps_xasprintf("%s/%s", xhp->metadir, plistf);
|
tmp_metafile = xbps_xasprintf("%s/%s", xhp->metadir, plistf);
|
||||||
if (tmp_metafile == NULL) {
|
|
||||||
rv = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Full path to repository directory to store the plist
|
* Full path to repository directory to store the plist
|
||||||
* index file.
|
* index file.
|
||||||
*/
|
*/
|
||||||
lrepodir = xbps_xasprintf("%s/%s", xhp->metadir, uri_fixedp);
|
lrepodir = xbps_xasprintf("%s/%s", xhp->metadir, uri_fixedp);
|
||||||
if (lrepodir == NULL) {
|
|
||||||
rv = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* If directory exists probably the plist index file
|
* If directory exists probably the plist index file
|
||||||
* was downloaded previously...
|
* was downloaded previously...
|
||||||
@ -195,10 +180,6 @@ xbps_repository_sync_pkg_index(struct xbps_handle *xhp,
|
|||||||
prop_object_release(array);
|
prop_object_release(array);
|
||||||
|
|
||||||
lrepofile = xbps_xasprintf("%s/%s", lrepodir, plistf);
|
lrepofile = xbps_xasprintf("%s/%s", lrepodir, plistf);
|
||||||
if (lrepofile == NULL) {
|
|
||||||
rv = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Create local repodir to store plist index file.
|
* Create local repodir to store plist index file.
|
||||||
*/
|
*/
|
||||||
|
@ -163,14 +163,12 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
buf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
buf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
||||||
xhp->rootdir, XBPS_META_PATH, curpkgname,
|
xhp->rootdir, XBPS_META_PATH, curpkgname,
|
||||||
XBPS_PKGFILES);
|
XBPS_PKGFILES);
|
||||||
assert(buf != NULL);
|
|
||||||
filesd = prop_dictionary_internalize_from_zfile(buf);
|
filesd = prop_dictionary_internalize_from_zfile(buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
assert(filesd != NULL);
|
assert(filesd != NULL);
|
||||||
buf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
buf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
||||||
xhp->rootdir, XBPS_META_PATH, pkgname,
|
xhp->rootdir, XBPS_META_PATH, pkgname,
|
||||||
XBPS_PKGFILES);
|
XBPS_PKGFILES);
|
||||||
assert(buf != NULL);
|
|
||||||
dirc = strdup(buf);
|
dirc = strdup(buf);
|
||||||
assert(dirc != NULL);
|
assert(dirc != NULL);
|
||||||
dname = dirname(dirc);
|
dname = dirname(dirc);
|
||||||
|
@ -346,7 +346,6 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
|||||||
j, &vpkgdep);
|
j, &vpkgdep);
|
||||||
if (strchr(vpkgdep, '_') == NULL) {
|
if (strchr(vpkgdep, '_') == NULL) {
|
||||||
vpkg = xbps_xasprintf("%s_1", vpkgdep);
|
vpkg = xbps_xasprintf("%s_1", vpkgdep);
|
||||||
assert(vpkg);
|
|
||||||
vpkgname = xbps_pkg_name(vpkg);
|
vpkgname = xbps_pkg_name(vpkg);
|
||||||
free(vpkg);
|
free(vpkg);
|
||||||
} else {
|
} else {
|
||||||
|
@ -245,9 +245,6 @@ xbps_path_from_repository_uri(struct xbps_handle *xhp,
|
|||||||
* First check if binpkg is available in cachedir.
|
* First check if binpkg is available in cachedir.
|
||||||
*/
|
*/
|
||||||
lbinpkg = xbps_xasprintf("%s/%s", xhp->cachedir, filen);
|
lbinpkg = xbps_xasprintf("%s/%s", xhp->cachedir, filen);
|
||||||
if (lbinpkg == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (access(lbinpkg, R_OK) == 0)
|
if (access(lbinpkg, R_OK) == 0)
|
||||||
return lbinpkg;
|
return lbinpkg;
|
||||||
|
|
||||||
@ -294,14 +291,15 @@ char *
|
|||||||
xbps_xasprintf(const char *fmt, ...)
|
xbps_xasprintf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *buf;
|
char *buf = NULL;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if (vasprintf(&buf, fmt, ap) == -1) {
|
if (vasprintf(&buf, fmt, ap) == -1) {
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return NULL;
|
assert(buf);
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
assert(buf);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,6 @@ xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
|
|||||||
rv = xbps_file_hash_check(file, sha256d);
|
rv = xbps_file_hash_check(file, sha256d);
|
||||||
} else {
|
} else {
|
||||||
buf = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
buf = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||||
assert(buf != NULL);
|
|
||||||
rv = xbps_file_hash_check(buf, sha256d);
|
rv = xbps_file_hash_check(buf, sha256d);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@ ATF_TC_BODY(find_virtualpkg_dict_installed_test, tc)
|
|||||||
/* get test source dir */
|
/* get test source dir */
|
||||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||||
cffile = xbps_xasprintf("%s/xbps.conf", tcsdir);
|
cffile = xbps_xasprintf("%s/xbps.conf", tcsdir);
|
||||||
ATF_REQUIRE(cffile != NULL);
|
|
||||||
|
|
||||||
/* initialize xbps */
|
/* initialize xbps */
|
||||||
memset(&xh, 0, sizeof(xh));
|
memset(&xh, 0, sizeof(xh));
|
||||||
|
Reference in New Issue
Block a user