Re: Project ideas page: UPDATING parser and displayer

2007-10-21 Thread David E. Thiel
On Sat, Oct 20, 2007 at 12:23:51PM +0200, Hans Lambermont wrote:
> I assume the goal is to make it available for the ports upgrade system,
> for that pkg_updating needs the install date of the old port. I'm not
> sure where this is available. Do you ?

I ran into this problem recently - the best I could come up with
was the mtime of the +COMMENT or +DESC files, which is obviously
not great. It seems like install/update dates would be a good
thing to add to /var/db/pkg somewhere. Anyhow, nice tool! It
would be cool to see it used by tools like portmaster, warning the
user to follow UPDATING before upgrading a particular port.
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Project ideas page: UPDATING parser and displayer

2007-10-20 Thread Beat Gätzi
Miroslav Lachman wrote:
> It would be better if one can omit -p. Then pkg_updating will be more
> "compatible" with other pkg_* commands (e.g. pkg_info which shows all
> installed packages without any argument or just info for given package[s].
> (so one can use `pkg_updating apache mysql` and get information for both)

Yes, that's better. I removed the -p argument and updated the available
version. The new behavior is like you have suggested.

Regards,
Beat
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Project ideas page: UPDATING parser and displayer

2007-10-20 Thread Beat Gätzi
Martin Tournoij wrote:
> 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

Great! Thank you! I updated the available version with your patch.

> TODO:
> Write a manpage

Yes, I know that this should be done. But before writing the manpage I
will remove the -p argument as mentioned in a prior mail to make
pkg_updating more compatible with the other pkg_* commands.

Regards,
Beat

___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Project ideas page: UPDATING parser and displayer

2007-10-20 Thread Martin Tournoij
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
diff -urN updating/Makefile /usr/src/usr.sbin/pkg_install/updating/Makefile
--- updating/Makefile   1970-01-01 01:00:00.0 +0100
+++ /usr/src/usr.sbin/pkg_install/updating/Makefile 2007-10-20 
14:08:20.0 +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.h2007-10-20 14:09:56.0 +0200
+++ /usr/src/usr.sbin/pkg_install/updating/pathnames.h  2007-10-20 
13:54:05.0 +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.0 +0200
+++ /usr/src/usr.sbin/pkg_install/updating/pkg_updating.c   2007-10-20 
14:18:48.0 +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, 
pkgd

Re: Project ideas page: UPDATING parser and displayer

2007-10-20 Thread Miroslav Lachman

Beat Gätzi wrote:


Hi,

I read at the project idea page about the UPDATING parser and displayer.
 I wrote a small script that parses and displays entries from
/usr/ports/UPDATING: pkg_updating

With the -p argument only entries for the given portname are shown.
Without the -p argument entries for all installed ports are shown. The
-f defines an alternative location of the UPDATING file. With the -d
argument only newer entries than the given date are shown.

Examples:

Shows all entries of all installed ports:
# pkg_updating

Shows all entries of all installed ports since 2007-01-01
# pkg_updating -d 20070101

Shows all entries for all apache ports
# pkg_updating -p apache


It would be better if one can omit -p. Then pkg_updating will be more 
"compatible" with other pkg_* commands (e.g. pkg_info which shows all 
installed packages without any argument or just info for given package[s].

(so one can use `pkg_updating apache mysql` and get information for both)

Anyway your work is good!

regards
Miroslav Lachman
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Project ideas page: UPDATING parser and displayer

2007-10-20 Thread Beat Gätzi
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
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Project ideas page: UPDATING parser and displayer

2007-10-20 Thread Rong-en Fan
On 10/20/07, Beat Gätzi <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I read at the project idea page about the UPDATING parser and displayer.
>  I wrote a small script that parses and displays entries from
> /usr/ports/UPDATING: pkg_updating
>
[...]

Nice work ;-)

> 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!

> pkg_updating is available here:
> http://tmp.chruetertee.ch/pkg_updating/

One question, do you support PORTSDIR environment variable?

Regards,
Rong-En Fan

>
> Comments, suggestions and patches are very welcome!
>
> Beat
> ___
> freebsd-ports@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-ports
> To unsubscribe, send any mail to "[EMAIL PROTECTED]"
>
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Re: Project ideas page: UPDATING parser and displayer

2007-10-20 Thread Beat Gätzi
Hans Lambermont wrote:
>>  I wrote a small script that parses and displays entries from
>> /usr/ports/UPDATING: pkg_updating
> 
> Great work ! I just tried it, and it works really nice.

Thanks!

> I assume the goal is to make it available for the ports upgrade system,
> for that pkg_updating needs the install date of the old port. I'm not
> sure where this is available. Do you ?

I think this information is not available yet. For the ports upgrade
system, perhaps it's better to use a format in UPDATING like
"gettext<0.16 -> gettext>=0.16" (as mentioned on the idea page) instead
of working with the installation date.

> ps. I first tried 'pkg_updating apache', and got no complaint (about a
> missing -p).

Yes, this is a bug. I will correct this.

Beat
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Project ideas page: UPDATING parser and displayer

2007-10-20 Thread Hans Lambermont
Beat G?tzi wrote:

>  I wrote a small script that parses and displays entries from
> /usr/ports/UPDATING: pkg_updating

Great work ! I just tried it, and it works really nice.

I assume the goal is to make it available for the ports upgrade system,
for that pkg_updating needs the install date of the old port. I'm not
sure where this is available. Do you ?

ps. I first tried 'pkg_updating apache', and got no complaint (about a
missing -p).

regards,
   Hans Lambermont
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "[EMAIL PROTECTED]"