package

simple and robust package manager
Log | Files | Refs | README

commit 1fc4aa8923d93a1060269cef29cfddcd34462e94
parent c87c6153def76d08b8e72f4c5cc51f3771fa28c3
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 19 Jan 2019 14:35:29 +0100

fix package-build's patch()

Diffstat:
Mlock.h | 6+++---
Mpackage-add.c | 2+-
Mpackage-build.c | 17+++++++++--------
3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/lock.h b/lock.h @@ -4,8 +4,8 @@ #include <sys/file.h> #include <fcntl.h> -#define lock_shared(fd) (!flock((fd), LOCK_SH)) -#define lock_exclusive(fd) (!flock((fd), LOCK_EX)) -#define lock_release(fd) (!flock((fd), LOCK_UN)) +#define lock_shared(fd) flock((fd), LOCK_SH) +#define lock_exclusive(fd) flock((fd), LOCK_EX) +#define lock_release(fd) flock((fd), LOCK_UN) #endif diff --git a/package-add.c b/package-add.c @@ -51,7 +51,7 @@ main(int argc, char **argv) log_fatal_2(1, "invalid packageage name: ", *av); if (!package_version(&p, def)) - log_fatal_sys_3(101, "could not read ", *av,"'s version"); + log_fatal_sys_3(101, "not read ", *av,"'s version"); genalloc_init(&ga); if (!package_dep(&p, &ga, def)) diff --git a/package-build.c b/package-build.c @@ -40,7 +40,7 @@ patch(package const *p, char *def) struct dirent *de; int i; int fd = -1; - int ret = 0; + int ret = -1; stralloc_init(&sa); if (!stralloc_cats(&sa, def)) goto err; @@ -70,14 +70,12 @@ patch(package const *p, char *def) if (!stralloc_cats(&sa, de->d_name)) goto err; if (!stralloc_cat0(&sa)) goto err; if ((fd = open_read(sa.x)) == -1) goto err; - if (forkexec_redir(argv, 0, fd) != 0) goto err; + if ((ret = forkexec_redir(argv, 0, fd)) != 0) goto err; if (write(1, "\n", 1) == -1) goto err; close(fd); } closedir(dp); } - - ret = 1; err: if (fd >= 0) close(fd); stralloc_free(&sa); @@ -259,7 +257,7 @@ main(int argc, char **argv) log_fatal_sys_4(101, "version ", def, "/", p.name); if (mkdir(p.ver, 075) == -1 && errno != EEXIST) log_fatal_sys_6(101, "mkdir ", pkg, "/", p.name, "/", p.ver); - if (!lock_exclusive(open_read("source.tar")) == -1) + if (!lock_exclusive(open_read("source.tar"))) log_fatal_7(101, "flock ", pkg, "/", p.name, "/", p.ver, "/source.tar"); if (chdir(p.ver) == -1) log_fatal_sys_6(101, "chdir ", pkg, "/", p.name, "/", p.ver); @@ -289,8 +287,11 @@ main(int argc, char **argv) write(1, "=== end ===\n", 12); write(1, "\n=== patch ===\n", 15); - if (!patch(&p, def)) - log_fatal_sys_3(100, "patching ", p.name, "'s source"); + if ((x = patch(&p, def)) != 0) { + char fmt[50]; + fmt_long(fmt, x); + log_fatal_8(100, "patch -N ", def, "/", p.name, "/", p.ver, "/patch/* -> exit ", fmt); + } write(1, "=== end ===\n", 12); write(1, "\n=== copy ===\n", 14); @@ -311,7 +312,7 @@ main(int argc, char **argv) } write(1, "=== end ===\n", 12); - write(1, "\n=== release ==\n", 17); + write(1, "\n=== symlink ===\n", 17); if (symlink(id, "../current") == -1 && errno != EEXIST) log_fatal_sys_9(101, "symlink ", pkg, "/", p.name, "/", p.ver, "/", id, "/current"); if (rename("../current", "../../current") == -1 && errno != EEXIST)