Date: Fri, 8 Dec 2006 11:26:02 -0500 (EST) From: Wesley Shields <wxs@atarininja.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/106483: [PATCH]: embed distfile information in +CONTENTS Message-ID: <20061208162602.D48915C57@syn.atarininja.org> Resent-Message-ID: <200612081700.kB8H0Qma002186@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 106483 >Category: ports >Synopsis: [PATCH]: embed distfile information in +CONTENTS >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Dec 08 17:00:21 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Wesley Shields >Release: FreeBSD 6.1-RELEASE-p10 amd64 >Organization: >Environment: System: FreeBSD syn.csh.rit.edu 6.1-RELEASE-p10 FreeBSD 6.1-RELEASE-p10 #5: Sat Sep 30 21:50:55 EDT 2006 root@syn.csh.rit.edu:/usr/obj/usr/src/sys/SMP amd64 >Description: It appears that some tools, specifically portmaster and maybe others, would benefit from being able to know the files used to create a package. Currently the closest they can get to that is looking for @comment ORIGIN:foo/bar and digging through the port (make -V probably) to get that. My proposed way of doing this is adding an @comment DISTFILE: line in +CONTENTS such as: @comment DISTFILE:jlj_2.12.tar.gz:SIZE=32480:SHA256=da3e1626338c5337e28bb4bc8da0b64d7a8ab441a52aa2364037e9eea152bc27:MD5=55724c4d6d26211f34803ef856075234 I chose to overload the @comment structure because any other way would require a change to pkg_create which just seems like a bad idea for such a minor change. I've also attached a second patch which is the necessary bits to pkg_info(1) to be able to parse and display the distfile information. The full discussion is at: http://lists.freebsd.org/pipermail/freebsd-ports/2006-December/037302.html The bsd.port.mk patch is Doug Barton's rework of my original attempt. Many thanks to him and Ade for their help. >How-To-Repeat: N/A >Fix: Index: bsd.port.mk =================================================================== RCS file: /usr/local/ncvs/ports/Mk/bsd.port.mk,v retrieving revision 1.544 diff -u -r1.544 bsd.port.mk --- bsd.port.mk 30 Sep 2006 19:25:45 -0000 1.544 +++ bsd.port.mk 8 Dec 2006 06:11:25 -0000 @@ -5395,11 +5395,20 @@ # files exist. .if !target(generate-plist) +.if defined(DIST_SUBDIR) +PDS= ${DIST_SUBDIR}/ +.endif generate-plist: @${ECHO_MSG} "===> Generating temporary packing list" @${MKDIR} `${DIRNAME} ${TMPPLIST}` @if [ ! -f ${DESCR} ]; then ${ECHO_CMD} "** Missing pkg-descr for ${PKGNAME}."; exit 1; fi @>${TMPPLIST} + @for file in ${ALLFILES}; do \ + distsize=`${GREP} "^SIZE (${PDS}$${file})" ${MD5_FILE} | ${CUT} -f4 -d' '`; \ + distsha256=`${GREP} "^SHA256 (${PDS}$${file})" ${MD5_FILE} | ${CUT} -f4 -d' '`; \ + distmd5=`${GREP} "^MD5 (${PDS}$${file})" ${MD5_FILE} | ${CUT} -f4 -d' '`; \ + ${ECHO_CMD} "@comment DISTFILE:${PDS}$${file}:SIZE=$${distsize}:SHA256=$${distsha256}:MD5=$${distmd5}" >> ${TMPPLIST}; \ + done @for file in ${PLIST_FILES}; do \ ${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} >> ${TMPPLIST}; \ done And the patch for pkg_info... Index: info/info.h =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/info.h,v retrieving revision 1.29 diff -u -r1.29 info.h --- info/info.h 9 Jan 2006 18:27:21 -0000 1.29 +++ info/info.h 7 Dec 2006 18:23:42 -0000 @@ -52,6 +52,7 @@ #define SHOW_PTREV 0x10000 #define SHOW_DEPEND 0x20000 #define SHOW_PKGNAME 0x40000 +#define SHOW_DISTFILE 0x80000 struct which_entry { TAILQ_ENTRY(which_entry) next; Index: info/main.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/main.c,v retrieving revision 1.50 diff -u -r1.50 main.c --- info/main.c 12 Jun 2006 22:39:31 -0000 1.50 +++ info/main.c 7 Dec 2006 18:23:42 -0000 @@ -26,7 +26,7 @@ #include "info.h" #include <err.h> -static char Options[] = "abcdDe:EfgGhiIjkKl:LmoO:pPqQrRst:vVW:xX"; +static char Options[] = "abcdDe:EfFgGhiIjkKl:LmoO:pPqQrRst:vVW:xX"; int Flags = 0; match_t MatchType = MATCH_GLOB; @@ -103,6 +103,10 @@ Flags |= SHOW_PLIST; break; + case 'F': + Flags |= SHOW_DISTFILE; + break; + case 'g': Flags |= SHOW_CKSUM; break; @@ -266,7 +270,7 @@ usage() { fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", - "usage: pkg_info [-bcdDEfgGiIjkKLmopPqQrRsvVxX] [-e package] [-l prefix]", + "usage: pkg_info [-bcdDEfFgGiIjkKLmopPqQrRsvVxX] [-e package] [-l prefix]", " [-t template] -a | pkg-name ...", " pkg_info [-qQ] -W filename", " pkg_info [-qQ] -O origin", Index: info/perform.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/perform.c,v retrieving revision 1.54 diff -u -r1.54 perform.c --- info/perform.c 9 Jan 2006 18:27:21 -0000 1.54 +++ info/perform.c 7 Dec 2006 18:23:42 -0000 @@ -213,6 +213,8 @@ show_file("mtree file:\n", MTREE_FNAME); if (Flags & SHOW_PREFIX) show_plist("Prefix(s):\n", &plist, PLIST_CWD, FALSE); + if ((Flags & SHOW_DISTFILE) && plist.distinfo == TRUE) + show_plist("Distfile(s):\n", &plist, PLIST_DISTFILE, FALSE); if (Flags & SHOW_FILES) show_files("Files:\n", &plist); if ((Flags & SHOW_SIZE) && installed) Index: info/pkg_info.1 =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/pkg_info.1,v retrieving revision 1.57 diff -u -r1.57 pkg_info.1 --- info/pkg_info.1 29 Sep 2006 17:57:03 -0000 1.57 +++ info/pkg_info.1 7 Dec 2006 18:23:42 -0000 @@ -25,7 +25,7 @@ .Nd a utility for displaying information on software packages .Sh SYNOPSIS .Nm -.Op Fl bcdDEfgGiIjkKLmopPqQrRsvVxX +.Op Fl bcdDEfFgGiIjkKLmopPqQrRsvVxX .Op Fl e Ar package .Op Fl l Ar prefix .Op Fl t Ar template @@ -94,6 +94,8 @@ Show the install-message file for each package. .It Fl f Show the packing list instructions for each package. +.It Fl F +Show the distfile information (relative to $PORTSDIR) for each package. This option is silently ignored when no distfile information is found. .It Fl g Show files that do not match the recorded checksum. .It Fl i Index: info/show.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/show.c,v retrieving revision 1.40 diff -u -r1.40 show.c --- info/show.c 7 Jan 2006 22:10:58 -0000 1.40 +++ info/show.c 7 Dec 2006 18:23:42 -0000 @@ -87,6 +87,9 @@ PackingList p; Boolean ign = FALSE; char *prefix = NULL; + char **ap, *distinfo[DISTINFO_ELEMENTS]; + int i; + if (!Quiet) printf("%s%s", InfoPrefix, title); @@ -178,6 +181,24 @@ printf(Quiet ? "@conflicts %s\n" : "Conflicts: %s\n", p->name); break; + case PLIST_DISTFILE: + if (Quiet) + printf("@comment DISTFILE:%s\n", p->name); + else { + for (ap = distinfo; (*ap = strsep(&p->name, ":")) != NULL;) + if (**ap != '\0') + if (++ap >= &distinfo[DISTINFO_ELEMENTS]) + break; + + printf("\tDistfile:\n"); + for (i = 0; i <= (DISTINFO_ELEMENTS - 1); i++) { + if (distinfo[i] == NULL) + break; + printf("\t\t%s\n", distinfo[i]); + } + } + break; + case PLIST_MTREE: printf(Quiet ? "@mtree %s\n" : "\tPackage mtree file: %s\n", p->name); break; Index: lib/lib.h =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/lib/lib.h,v retrieving revision 1.59 diff -u -r1.59 lib.h --- lib/lib.h 12 Jun 2006 22:39:32 -0000 1.59 +++ lib/lib.h 7 Dec 2006 18:23:42 -0000 @@ -105,13 +105,16 @@ #define PLIST_FMT_VER_MAJOR 1 #define PLIST_FMT_VER_MINOR 1 +/* Number of elements embedded in an @comment DISTFILE: line */ +#define DISTINFO_ELEMENTS 4 /* name:size:SHA256:MD5 */ + enum _plist_t { PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD, PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY, PLIST_PKGDEP, PLIST_CONFLICTS, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST, PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN, - PLIST_NOINST + PLIST_NOINST, PLIST_DISTFILE }; typedef enum _plist_t plist_t; @@ -135,6 +138,7 @@ struct _plist *head, *tail; const char *name; const char *origin; + Boolean distinfo; int fmtver_maj, fmtver_mnr; }; typedef struct _pack Package; Index: lib/plist.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/lib/plist.c,v retrieving revision 1.51 diff -u -r1.51 plist.c --- lib/plist.c 7 Jan 2006 22:10:58 -0000 1.51 +++ lib/plist.c 7 Dec 2006 18:23:42 -0000 @@ -231,6 +231,9 @@ } else if (!strncmp(*arg, "DEPORIGIN:", 10)) { *arg += 10; return PLIST_DEPORIGIN; + } else if (!strncmp(*arg, "DISTFILE:", 9)) { + *arg += 9; + return PLIST_DISTFILE; } return PLIST_COMMENT; } else if (!strcmp(cmd, "ignore")) @@ -302,6 +305,9 @@ exit(2); } } + if (cmd == PLIST_DISTFILE && cp) + pkg->distinfo = TRUE; + bottom: add_plist(pkg, cmd, cp); } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061208162602.D48915C57>