From owner-freebsd-ports@FreeBSD.ORG Sat Oct 20 12:22:23 2007 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA33E16A420 for ; Sat, 20 Oct 2007 12:22:23 +0000 (UTC) (envelope-from carpetsmoker@rwxrwxrwx.net) Received: from mail.rwxrwxrwx.net (rwxrwxrwx.net [82.93.23.199]) by mx1.freebsd.org (Postfix) with ESMTP id 5291813C467 for ; Sat, 20 Oct 2007 12:22:22 +0000 (UTC) (envelope-from carpetsmoker@rwxrwxrwx.net) Received: from localhost (unknown [127.0.0.1]) by mail.rwxrwxrwx.net (Postfix) with ESMTP id 087BA6D445; Sat, 20 Oct 2007 14:24:39 +0200 (CEST) Received: from mail.rwxrwxrwx.net ([127.0.0.1]) by localhost (mail.rwxrwxrwx.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k424emSzlrLe; Sat, 20 Oct 2007 14:24:37 +0200 (CEST) Received: by mail.rwxrwxrwx.net (Postfix, from userid 1001) id 1F05B6D444; Sat, 20 Oct 2007 14:24:37 +0200 (CEST) Date: Sat, 20 Oct 2007 14:24:36 +0200 From: Martin Tournoij To: freebsd-ports@freebsd.org Message-ID: <20071020122436.GA64007@glitch.rwxrwxrwx.net> Mail-Followup-To: freebsd-ports@freebsd.org, beat@chruetertee.ch References: <4719CE07.5000904@chruetertee.ch> <6eb82e0710200344s2ef687fct7bb8f01f46fc6767@mail.gmail.com> <4719E490.2070506@chruetertee.ch> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline In-Reply-To: <4719E490.2070506@chruetertee.ch> User-Agent: mutt-ng/devel-r804 (FreeBSD) Cc: beat@chruetertee.ch Subject: Re: Project ideas page: UPDATING parser and displayer X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Oct 2007 12:22:24 -0000 --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat 20 Oct 2007 13:10, Beat Gtzi wrote: > Rong-en Fan wrote: > >> Known issues: > >> - pkg_updating needs a colon at the end of the date line. Some entries > >> don't have this colon. This patch adds the missing colons: > >> http://tmp.chruetertee.ch/pkg_updating/UPDATING.patch > > > > I just committed this. Thanks! > > Thanks! > > >> pkg_updating is available here: > >> http://tmp.chruetertee.ch/pkg_updating/ > > > > One question, do you support PORTSDIR environment variable? > > No, pkg_updating doesn't support the PORTSDIR environment variable yet. > But I think this would be useful therefore I will add it. > > Beat Here's a little patch. It changes: - variable tmpfile was renamed to tmp_file, I got a warning that it shadowed a global declaration - Add support for PORTSDIR and PKG_DBDIR - Don't exit if we can't open +CONTENTS file, since pkgdb may be in /var/db/pkg - Add Makefile for sourcetree TODO: Write a manpage Note that I'm so hungry that I'm almost falling down (I always forget to eat...) and than I'm not a particular good C programmer, but I needed to modify it anyway to get it running... Regards, Martin Tournoij --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="updating.patch" diff -urN updating/Makefile /usr/src/usr.sbin/pkg_install/updating/Makefile --- updating/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/usr.sbin/pkg_install/updating/Makefile 2007-10-20 14:08:20.000000000 +0200 @@ -0,0 +1,9 @@ +PROG= pkg_updating +SRCS= pkg_updating.c + +CFLAGS+= -I${.CURDIR}/../lib + +WARNS?= 6 +WFORMAT?= 1 + +.include diff -urN updating/pathnames.h /usr/src/usr.sbin/pkg_install/updating/pathnames.h --- updating/pathnames.h 2007-10-20 14:09:56.000000000 +0200 +++ /usr/src/usr.sbin/pkg_install/updating/pathnames.h 2007-10-20 13:54:05.000000000 +0200 @@ -7,5 +7,19 @@ * ---------------------------------------------------------------------------- */ -#define _PATH_UPDATING "/usr/ports/UPDATING" -#define _PATH_PKGDB "/var/db/pkg" +/* Copy from ../version/version.h, shouldn't this go in lib/lib.h? */ +/* Where the ports lives by default */ +#define DEF_PORTS_DIR "/usr/ports/UPDATING" +/* just in case we change the environment variable name */ +#define PORTSDIR "PORTSDIR" +/* macro to get name of directory where we put logging information */ +#define UPDATING (getenv(PORTSDIR) ? strcat(getenv(PORTSDIR), "/UPDATING") : DEF_PORTS_DIR) + +/* Including lib/lib.h gives an error(?!) */ +/* Where we put logging information by default, else ${PKG_DBDIR} if set */ +#define DEF_LOG_DIR "/var/db/pkg" +/* just in case we change the environment variable name */ +#define PKG_DBDIR "PKG_DBDIR" +/* macro to get name of directory where we put logging information */ +#define LOG_DIR (getenv(PKG_DBDIR) ? getenv(PKG_DBDIR) : DEF_LOG_DIR) + diff -urN updating/pkg_updating.c /usr/src/usr.sbin/pkg_install/updating/pkg_updating.c --- updating/pkg_updating.c 2007-10-20 14:10:01.000000000 +0200 +++ /usr/src/usr.sbin/pkg_install/updating/pkg_updating.c 2007-10-20 14:18:48.000000000 +0200 @@ -43,14 +43,14 @@ const char *end = "20"; /* Keyword for searching origin portname of installed port */ const char *origin = "@comment ORIGIN:"; - const char *pkgdbpath = _PATH_PKGDB; /* Location of pkgdb */ - const char *updatingfile = _PATH_UPDATING; /* Location of UPDATING */ + const char *pkgdbpath = LOG_DIR; /* Location of pkgdb */ + const char *updatingfile = UPDATING; /* Location of UPDATING */ char *date; /* Passed -d argument */ char *dateline; /* Saved date of an entry */ char *portname; /* Passed -p argument */ /* Temporary variable to create path to +CONTENTS for installed ports */ - char tmpfile[MAXPATHLEN]; + char tmp_file[MAXPATHLEN]; /* Tmp lines for parsing file */ char *tmpline1; char *tmpline2; @@ -100,23 +100,23 @@ /* UPDATING will be parsed for all installed ports if -p is not set */ if (pflag == 0) { /* Opens /var/db/pkg and search for all installed ports */ - if((dir = opendir(_PATH_PKGDB)) != NULL) { + if((dir = opendir(pkgdbpath)) != NULL) { while ((pkgdbdir = readdir(dir)) != NULL) { if (strcmp(pkgdbdir->d_name, ".") != 0 && strcmp(pkgdbdir->d_name, "..") !=0) { /* Create path to +CONTENTS file for each installed port */ - n = strlcpy(tmpfile, pkgdbpath, strlen(pkgdbpath)+1); - n = strlcpy(tmpfile + n, "/", sizeof(tmpfile) - n); - n = strlcat(tmpfile + n, pkgdbdir->d_name, sizeof(tmpfile) - n); - (void)strlcat(tmpfile + n, "/+CONTENTS", sizeof(tmpfile) - n); + n = strlcpy(tmp_file, pkgdbpath, strlen(pkgdbpath)+1); + n = strlcpy(tmp_file + n, "/", sizeof(tmp_file) - n); + n = strlcat(tmp_file + n, pkgdbdir->d_name, sizeof(tmp_file) - n); + (void)strlcat(tmp_file + n, "/+CONTENTS", sizeof(tmp_file) - n); /* Open +CONTENT file */ - fd = fopen(tmpfile, "r"); + fd = fopen(tmp_file, "r"); if(fd == NULL) { - fprintf(stderr, "can't open %s: %s\n", - tmpfile, strerror(errno)); - exit(EX_UNAVAILABLE); + fprintf(stderr, "Warning: can't open %s: %s\n", + tmp_file, strerror(errno)); + continue; } /* Parses +CONTENT for ORIGIN line and --YZ5djTAD1cGYuMQK--