Date: Fri, 11 Jun 2010 20:34:06 -0700 From: Garrett Cooper <gcooper@FreeBSD.org> To: Ivan Voras <ivoras@freebsd.org> Cc: Perforce Change Reviews <perforce@freebsd.org> Subject: Re: PERFORCE change 179508 for review Message-ID: <AANLkTikCStLImiHq76WzZRWLLyvT6dMvLWKfWB18yos8@mail.gmail.com> In-Reply-To: <201006120038.o5C0cUSG099427@repoman.freebsd.org> References: <201006120038.o5C0cUSG099427@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jun 11, 2010 at 5:38 PM, Ivan Voras <ivoras@freebsd.org> wrote: > http://p4web.freebsd.org/@@179508?ac=3D10 > > Change 179508 by ivoras@betelgeuse on 2010/06/12 00:37:31 > > =A0 =A0 =A0 =A0Start parsing the +PKGPATCH file > > Affected files ... > > .. //depot/projects/soc2010/pkg_patch/src/patch/Makefile#12 edit > .. //depot/projects/soc2010/pkg_patch/src/patch/applypatch.c#2 edit > .. //depot/projects/soc2010/pkg_patch/src/patch/applypatch.h#2 edit > .. //depot/projects/soc2010/pkg_patch/src/patch/hashjob.c#11 edit > .. //depot/projects/soc2010/pkg_patch/src/patch/hashjob.h#11 edit > .. //depot/projects/soc2010/pkg_patch/src/patch/main.c#12 edit > .. //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.c#10 edit > .. //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.h#10 edit > .. //depot/projects/soc2010/pkg_patch/src/patch/pkg_patch.h#10 edit > .. //depot/projects/soc2010/pkg_patch/src/patch/support.c#9 edit > > Differences ... > > =3D=3D=3D=3D //depot/projects/soc2010/pkg_patch/src/patch/Makefile#12 (te= xt+ko) =3D=3D=3D=3D > > > =3D=3D=3D=3D //depot/projects/soc2010/pkg_patch/src/patch/applypatch.c#2 = (text+ko) =3D=3D=3D=3D > > @@ -34,7 +34,89 @@ > =A0#include "hashjob.h" > > > +enum PPACTION { PPACTION_UNKNOWN, PPACTION_ADD, PPACTION_REMOVE, > + =A0 =A0PPACTION_RMDIR, PPACTION_PATCH }; > +enum PPMETHOD { PPMETHOD_UNKNOWN, PPMETHOD_CP, PPMETHOD_BSDIFF }; > + > + > +SLIST_HEAD(pplist_head, pplist); > +struct pplist { > + =A0 =A0 =A0 char =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0filename[PATH_M= AX]; > + =A0 =A0 =A0 enum PPACTION =A0 =A0 =A0 =A0 =A0 action; > + =A0 =A0 =A0 enum PPMETHOD =A0 =A0 =A0 =A0 =A0 method; > + =A0 =A0 =A0 SLIST_ENTRY(pplist) =A0 =A0 linkage; > +}; > + > + > +struct pkgpatch { > + =A0 =A0 =A0 short int =A0 =A0 =A0 =A0 =A0 =A0 =A0 version_major; > + =A0 =A0 =A0 short int =A0 =A0 =A0 =A0 =A0 =A0 =A0 version_minor; > + =A0 =A0 =A0 char =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0source[PATH_MAX= ]; > + =A0 =A0 =A0 char =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0target[PATH_MAX= ]; > + =A0 =A0 =A0 struct pplist_head =A0 =A0 =A0pplist; > +}; > + > + > +static void > +read_pkgpatch_file(char *filename, struct pkgpatch *pp) > +{ > + =A0 =A0 =A0 FILE *fp; > + =A0 =A0 =A0 char line[PATH_MAX], *p, *p2, *cmd; > + > + =A0 =A0 =A0 fp =3D fopen(filename, "r"); > + =A0 =A0 =A0 if (fp =3D=3D NULL) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err(1, "Cannot open file: %s", filename); > + =A0 =A0 =A0 memset(pp, 0, sizeof(*pp)); > + =A0 =A0 =A0 SLIST_INIT(&pp->pplist); > + =A0 =A0 =A0 while (fgets(line, PATH_MAX, fp) !=3D NULL) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 cmd =3D line; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 p =3D strchr(line, ' '); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 *p++ =3D '\0'; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (strcmp(cmd, "@version") =3D=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 p2 =3D strchr(p, '.'); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *p2++ =3D '\0'; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pp->version_major =3D atoi(= p); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pp->version_minor =3D atoi(= p2); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(cmd, "@source") =3D=3D 0)= { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(cmd, "@target") =3D=3D 0)= { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(cmd, "@add") =3D=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(cmd, "@remove") =3D=3D 0)= { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(cmd, "@rmdir") =3D=3D 0) = { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(cmd, "@patch") =3D=3D 0) = { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 errx(1, "Unknown command: %= s", cmd); > + > + =A0 =A0 =A0 } > + =A0 =A0 =A0 fclose(fp); > +} > + > + > =A0void > =A0perform_applypatch() > =A0{ > + =A0 =A0 =A0 char fpatch[PATH_MAX], dpatch[PATH_MAX], tmp[PATH_MAX]; > + =A0 =A0 =A0 struct pkgxjob xpatch; > + =A0 =A0 =A0 struct pkgpatch pp; > + > + =A0 =A0 =A0 if (argc < 1) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 errx(1, "Expecting argument: patch filename= "); > + =A0 =A0 =A0 if (realpath(argv[0], fpatch) =3D=3D NULL) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err(1, "Error resolving path: %s", argv[0])= ; > + =A0 =A0 =A0 if (access(fpatch, F_OK) !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err(1, "File not found: %s", fpatch); > + =A0 =A0 =A0 if (access(fpatch, R_OK) !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err(1, "Access error reading file: %s", fpa= tch); > + =A0 =A0 =A0 snprintf(dpatch, PATH_MAX, "%s/patch", my_tmp); > + =A0 =A0 =A0 if (mkdir(dpatch, 0700) !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err(1, "Cannot create directory: %s", dpatc= h); > + =A0 =A0 =A0 if (pkgxjob_start(&xpatch, dpatch, fpatch) !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err(1, "Canot extract package %s to %s (sta= rt)", fpatch, 1. Typo. 2. Does pkgxjob_start set a meaningful errno? > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dpatch); > + =A0 =A0 =A0 if (pkgxjob_finish(&xpatch) !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err(1, "Cannot extract package %s to %s (fi= nish)", fpatch, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dpatch); > + > + =A0 =A0 =A0 snprintf(tmp, PATH_MAX, "%s/%s", dpatch, PKGPATCH_FNAME); > + =A0 =A0 =A0 read_pkgpatch_file(tmp, &pp); Does this function ever fail? > =A0} Thanks! -Garrett
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikCStLImiHq76WzZRWLLyvT6dMvLWKfWB18yos8>