PERFORCE change 179508 for review
Garrett Cooper
gcooper at FreeBSD.org
Sat Jun 12 03:34:10 UTC 2010
On Fri, Jun 11, 2010 at 5:38 PM, Ivan Voras <ivoras at freebsd.org> wrote:
> http://p4web.freebsd.org/@@179508?ac=10
>
> Change 179508 by ivoras at betelgeuse on 2010/06/12 00:37:31
>
> Start 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 ...
>
> ==== //depot/projects/soc2010/pkg_patch/src/patch/Makefile#12 (text+ko) ====
>
>
> ==== //depot/projects/soc2010/pkg_patch/src/patch/applypatch.c#2 (text+ko) ====
>
> @@ -34,7 +34,89 @@
> #include "hashjob.h"
>
>
> +enum PPACTION { PPACTION_UNKNOWN, PPACTION_ADD, PPACTION_REMOVE,
> + PPACTION_RMDIR, PPACTION_PATCH };
> +enum PPMETHOD { PPMETHOD_UNKNOWN, PPMETHOD_CP, PPMETHOD_BSDIFF };
> +
> +
> +SLIST_HEAD(pplist_head, pplist);
> +struct pplist {
> + char filename[PATH_MAX];
> + enum PPACTION action;
> + enum PPMETHOD method;
> + SLIST_ENTRY(pplist) linkage;
> +};
> +
> +
> +struct pkgpatch {
> + short int version_major;
> + short int version_minor;
> + char source[PATH_MAX];
> + char target[PATH_MAX];
> + struct pplist_head pplist;
> +};
> +
> +
> +static void
> +read_pkgpatch_file(char *filename, struct pkgpatch *pp)
> +{
> + FILE *fp;
> + char line[PATH_MAX], *p, *p2, *cmd;
> +
> + fp = fopen(filename, "r");
> + if (fp == NULL)
> + err(1, "Cannot open file: %s", filename);
> + memset(pp, 0, sizeof(*pp));
> + SLIST_INIT(&pp->pplist);
> + while (fgets(line, PATH_MAX, fp) != NULL) {
> + cmd = line;
> + p = strchr(line, ' ');
> + *p++ = '\0';
> + if (strcmp(cmd, "@version") == 0) {
> + p2 = strchr(p, '.');
> + *p2++ = '\0';
> + pp->version_major = atoi(p);
> + pp->version_minor = atoi(p2);
> + } else if (strcmp(cmd, "@source") == 0) {
> + } else if (strcmp(cmd, "@target") == 0) {
> + } else if (strcmp(cmd, "@add") == 0) {
> + } else if (strcmp(cmd, "@remove") == 0) {
> + } else if (strcmp(cmd, "@rmdir") == 0) {
> + } else if (strcmp(cmd, "@patch") == 0) {
> + } else
> + errx(1, "Unknown command: %s", cmd);
> +
> + }
> + fclose(fp);
> +}
> +
> +
> void
> perform_applypatch()
> {
> + char fpatch[PATH_MAX], dpatch[PATH_MAX], tmp[PATH_MAX];
> + struct pkgxjob xpatch;
> + struct pkgpatch pp;
> +
> + if (argc < 1)
> + errx(1, "Expecting argument: patch filename");
> + if (realpath(argv[0], fpatch) == NULL)
> + err(1, "Error resolving path: %s", argv[0]);
> + if (access(fpatch, F_OK) != 0)
> + err(1, "File not found: %s", fpatch);
> + if (access(fpatch, R_OK) != 0)
> + err(1, "Access error reading file: %s", fpatch);
> + snprintf(dpatch, PATH_MAX, "%s/patch", my_tmp);
> + if (mkdir(dpatch, 0700) != 0)
> + err(1, "Cannot create directory: %s", dpatch);
> + if (pkgxjob_start(&xpatch, dpatch, fpatch) != 0)
> + err(1, "Canot extract package %s to %s (start)", fpatch,
1. Typo. 2. Does pkgxjob_start set a meaningful errno?
> + dpatch);
> + if (pkgxjob_finish(&xpatch) != 0)
> + err(1, "Cannot extract package %s to %s (finish)", fpatch,
> + dpatch);
> +
> + snprintf(tmp, PATH_MAX, "%s/%s", dpatch, PKGPATCH_FNAME);
> + read_pkgpatch_file(tmp, &pp);
Does this function ever fail?
> }
Thanks!
-Garrett
More information about the p4-projects
mailing list