Merge branch 'master' of github.com:voidlinux/xbps

This commit is contained in:
Wolfgang Draxinger 2015-08-11 18:29:30 +02:00
commit 13f73ef41a
16 changed files with 81 additions and 17 deletions

4
NEWS
View File

@ -1,5 +1,9 @@
xbps-0.48 (???):
* xbps-checkvers(1): fixed an endless loop while processing templates containing
extra alphanumeric characters in the `reverts' object. Added a new testcase
to verify its correctness.
xbps-0.47 (2015-07-18):
* When executing pkg configuration, override the umask with sane defaults.

View File

@ -533,7 +533,7 @@ check_reverts(const char *repover, const map_item_t reverts)
* Check if it's the first character or the previous character is a
* whitespace.
*/
if (p > sreverts && !isspace(p[-1]))
if (p > sreverts && !isalpha(p[-1]) && !isspace(p[-1]))
continue;
p += strlen(repover);
/*

View File

@ -843,9 +843,11 @@ main(int argc, char **argv)
/*
* Create a temp file to store archive data.
*/
tname = xbps_xasprintf(".xbps-pkg-XXXXXX");
tname = xbps_xasprintf(".xbps-pkg-XXXXXXXXX");
myumask = umask(S_IXUSR|S_IRWXG|S_IRWXO);
pkg_fd = mkstemp(tname);
assert(pkg_fd != -1);
umask(myumask);
/*
* Process the binary package's archive (ustar compressed with xz).
*/

View File

@ -202,7 +202,7 @@ processCompletion(struct item *item)
else
logdir = "bad";
logpath2 = xbps_xasprintf("%s/%s/%s", LogDir, logdir, item->pkgn);
rename(logpath1, logpath2);
(void)rename(logpath1, logpath2);
free(logpath1);
free(logpath2);
}
@ -345,7 +345,7 @@ runBuilds(const char *bpath)
* attempts.
*/
logpath = xbps_xasprintf("%s/bad/%s", LogDir, item->pkgn);
remove(logpath);
(void)remove(logpath);
free(logpath);
logpath = xbps_xasprintf("%s/run/%s", LogDir, item->pkgn);

View File

@ -322,14 +322,16 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
if (xbps_humanize_number(instsize, (int64_t)isize) == -1) {
xbps_error_printf("humanize_number2 returns "
"%s\n", strerror(errno));
return -1;
rv = -1;
goto out;
}
xbps_dictionary_get_uint64(xhp->transd,
"disk-free-size", &fsize);
if (xbps_humanize_number(freesize, (int64_t)fsize) == -1) {
xbps_error_printf("humanize_number2 returns "
"%s\n", strerror(errno));
return -1;
rv = -1;
goto out;
}
fprintf(stderr, "Transaction aborted due to insufficient disk "
"space (need %s, got %s free).\n", instsize, freesize);

View File

@ -63,6 +63,8 @@ idx_cleaner_cb(struct xbps_handle *xhp,
* broken or simply unexistent; either way, remove it.
*/
pkgname = xbps_pkg_name(pkgver);
if (pkgname == NULL)
goto out;
xbps_dictionary_remove(dest, pkgname);
free(pkgname);
printf("index: removed pkg %s\n", pkgver);
@ -74,11 +76,14 @@ idx_cleaner_cb(struct xbps_handle *xhp,
"filename-sha256", &sha256);
if (xbps_file_hash_check(filen, sha256) != 0) {
pkgname = xbps_pkg_name(pkgver);
if (pkgname == NULL)
goto out;
xbps_dictionary_remove(dest, pkgname);
free(pkgname);
printf("index: removed pkg %s\n", pkgver);
}
}
out:
free(filen);
return 0;
}
@ -104,11 +109,13 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
repo = xbps_repo_open(xhp, repodir);
if (repo == NULL) {
rv = errno;
if (rv == ENOENT)
if (rv == ENOENT) {
xbps_repo_unlock(rlockfd, rlockfname);
return 0;
}
fprintf(stderr, "%s: cannot read repository data: %s\n",
_XBPS_RINDEX, strerror(errno));
xbps_repo_unlock(rlockfd, rlockfname);
return rv;
}
if (repo->idx == NULL) {

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2013-2014 Juan Romero Pardines.
* Copyright (c) 2013-2015 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -44,13 +44,16 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir,
struct archive *ar;
char *repofile, *tname, *buf;
int rv, repofd = -1;
mode_t mask;
/* Create a tempfile for our repository archive */
repofile = xbps_repo_path(xhp, repodir);
tname = xbps_xasprintf("%s.XXXXXXXXXX", repofile);
mask = umask(S_IXUSR|S_IRWXG|S_IRWXO);
if ((repofd = mkstemp(tname)) == -1)
return false;
umask(mask);
/* Create and write our repository archive */
ar = archive_write_new();
assert(ar);

View File

@ -139,6 +139,8 @@ load_rsa_key(const char *privkey)
fprintf(stderr, "%s: failed to read the RSA privkey\n", _XBPS_RINDEX);
exit(EXIT_FAILURE);
}
free(defprivkey);
defprivkey = NULL;
return rsa;
}
@ -272,7 +274,7 @@ sign_pkg(struct xbps_handle *xhp, const char *binpkg, const char *privkey, bool
rv = EINVAL;
goto out;
}
fstat(binpkg_fd, &st);
(void)fstat(binpkg_fd, &st);
buf = malloc(st.st_size);
assert(buf);
if (read(binpkg_fd, buf, st.st_size) != st.st_size) {
@ -281,6 +283,7 @@ sign_pkg(struct xbps_handle *xhp, const char *binpkg, const char *privkey, bool
goto out;
}
close(binpkg_fd);
binpkg_fd = -1;
rsa = load_rsa_key(privkey);
if (!rsa_sign_buf(rsa, buf, st.st_size, &sig, &siglen)) {

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2012-2013 Juan Romero Pardines.
* Copyright (c) 2012-2015 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -43,6 +43,7 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp,
const char *tmpdir, *version;
char *pkgname, *fpath;
int fd, rv;
mode_t mask;
assert(blob);
assert(pkgver);
@ -71,12 +72,15 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp,
}
/* Create temp file to run script */
mask = umask(S_IXUSR|S_IRWXG|S_IRWXO);
if ((fd = mkstemp(fpath)) == -1) {
umask(mask);
rv = errno;
xbps_dbg_printf(xhp, "%s: mkstemp %s\n",
__func__, strerror(errno));
goto out;
}
umask(mask);
/* write blob to our temp fd */
ret = write(fd, blob, blobsiz);
if (ret == -1) {

View File

@ -291,7 +291,7 @@ unpack_archive(struct xbps_handle *xhp,
*/
if (file_exists &&
((entry_statp->st_mode & S_IFMT) != (st.st_mode & S_IFMT)))
remove(entry_pname);
(void)remove(entry_pname);
if (!force && (entry_type == AE_IFREG)) {
buf = strchr(entry_pname, '.') + 1;

View File

@ -158,6 +158,7 @@ pkgdb_map_vpkgs(struct xbps_handle *xhp)
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
for (unsigned int i = 0; i < xbps_array_count(provides); i++) {
const char *vpkg;

View File

@ -600,7 +600,7 @@ _prop_object_internalize_by_tag(struct _prop_object_internalize_context *ctx)
match_start:
for (poi = _prop_object_internalizer_table;
poi->poi_tag != NULL; poi++) {
poi != NULL && poi->poi_tag != NULL; poi++) {
if (_prop_object_internalize_match(ctx->poic_tagname,
ctx->poic_tagname_len,
poi->poi_tag,
@ -849,8 +849,12 @@ _prop_object_externalize_write_file(const char *fname, const char *xml,
strcat(tname, PLISTTMP);
#undef PLISTTMP
if ((fd = mkstemp(tname)) == -1)
myumask = umask(S_IXUSR|S_IRWXG|S_IRWXO);
if ((fd = mkstemp(tname)) == -1) {
umask(myumask);
return (false);
}
umask(myumask);
if (do_compress) {
if ((gzf = gzdopen(fd, "a")) == NULL)

View File

@ -127,7 +127,6 @@ xbps_rpool_release(struct xbps_handle *xhp _unused)
while ((repo = SIMPLEQ_FIRST(&rpool_queue))) {
SIMPLEQ_REMOVE(&rpool_queue, repo, xbps_repo, entries);
xbps_repo_close(repo);
free(repo);
}
if (xhp->repositories)
xbps_object_release(xhp->repositories);

View File

@ -121,8 +121,12 @@ xbps_transaction_package_replace(struct xbps_handle *xhp, xbps_array_t pkgs)
*/
xbps_dictionary_set_cstring_nocopy(instd,
"transaction", "remove");
if (!xbps_array_add_first(pkgs, instd))
if (!xbps_array_add_first(pkgs, instd)) {
xbps_object_iterator_release(iter);
free(pkgname);
free(curpkgname);
return EINVAL;
}
free(curpkgname);
}
xbps_object_iterator_release(iter);

View File

@ -437,7 +437,7 @@ xbps_sanitize_path(const char *src)
len = strlen(src);
assert(len != 0);
dest = malloc(len);
dest = malloc(len+1);
assert(dest);
d = dest;

View File

@ -301,6 +301,36 @@ EOF
atf_check_equal "$out" "pkgname: A repover: 1.1_1 srcpkgver: 1.0_1"
}
atf_test_case reverts_alpha
reverts_alpha_head() {
atf_set "descr" "xbps-checkvers(8): test with reverts containing an alphanumeric character"
}
reverts_alpha_body() {
mkdir -p some_repo pkg_A void-packages/srcpkgs/fs-utils
touch pkg_A/file00
cat > void-packages/srcpkgs/fs-utils/template <<EOF
pkgname=fs-utils
reverts=v1.10_1
version=1.10
revision=1
do_install() {
:
}
EOF
cd some_repo
xbps-create -A noarch -n fs-utils-1.10_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages
out=`xbps-checkvers -R $PWD/some_repo -D $PWD/void-packages`
atf_check_equal $? 0
atf_check_equal "$out" "pkgname: fs-utils repover: 1.10_1 srcpkgver: 1.10_1"
}
atf_init_test_cases() {
atf_add_test_case srcpkg_newer
atf_add_test_case srcpkg_newer_with_refs
@ -313,4 +343,5 @@ atf_init_test_cases() {
atf_add_test_case srcpkg_missing_pkgver
atf_add_test_case srcpkg_missing_pkgverrev
atf_add_test_case reverts
atf_add_test_case reverts_alpha
}