Date: Mon, 21 Oct 2002 01:50:03 -0700 (PDT) From: "Denis N. Peplin" <info@volginfo.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/35451: PATCH: pkg_add -r able to save local copy to PKG_SAVEDIR Message-ID: <200210210850.g9L8o3lq018104@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/35451; it has been noted by GNATS. From: "Denis N. Peplin" <info@volginfo.ru> To: freebsd-gnats-submit@FreeBSD.org, markhannon@optushome.com.au Cc: Subject: Re: bin/35451: PATCH: pkg_add -r able to save local copy to PKG_SAVEDIR Date: Mon, 21 Oct 2002 12:49:22 +0400 I wrote my own small patch before looking to 35451. This patch is not ready-to-use (but I use it), just a bit simple :) And I have one question - why previous patches was not added to source tree? diff -r -u pkg_install.old/lib/file.c pkg_install/lib/file.c --- pkg_install.old/lib/file.c Fri Oct 18 11:34:35 2002 +++ pkg_install/lib/file.c Mon Oct 21 10:50:43 2002 @@ -143,12 +143,15 @@ char *cp, *rp; char fname[FILENAME_MAX]; char pen[FILENAME_MAX]; + char lspec[FILENAME_MAX]; + char pspec[FILENAME_MAX]; char buf[8192]; FILE *ftp; pid_t tpid; int pfd[2], pstat, r, w; char *hint; - int fd; + int fd, lfd; + char *tok, *ftok; rp = NULL; /* Special tip that sysinstall left for us */ @@ -227,10 +230,22 @@ _exit(2); } close(pfd[0]); + strcpy(pspec, spec); + strtok(pspec, "/"); + while ((tok = strtok(NULL, "/"))) { + ftok = tok; + } + strcpy(lspec, "/tmp/"); + strcat(lspec, ftok); + lfd = open(lspec, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (lfd == FAIL) { + cleanup(0); + errx(2, "%s: unable to open '%s' for for writing", __func__, lspec); + } for (;;) { if ((r = fread(buf, 1, sizeof buf, ftp)) < 1) break; - if ((w = write(pfd[1], buf, r)) != r) + if (write(lfd, buf, r) != r || (w = write(pfd[1], buf, r)) != r) break; } if (ferror(ftp)) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210210850.g9L8o3lq018104>