Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Dec 2002 05:27:41 +0100 (CET)
From:      osgene@web.de
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        pelle@fukt.bth.se
Subject:   ports/46457: Update x11/temperature.app to 1.4 and use FreeBSDish libfetch instead of wget
Message-ID:  <200212220427.gBM4Rf6T065204@badger.home>

next in thread | raw e-mail | index | archive | help

>Number:         46457
>Category:       ports
>Synopsis:       Update x11/temperature.app to 1.4 and use FreeBSDish libfetch instead of wget
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 21 20:30:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Eugene Ossintsev
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
>Environment:
	
>Description:
	Update temperature.app to the latest release 1.4. Become independent
	from wget utility using the FreeBSD fetch library instead. Fix an
	installation error with wrong permissions for documentation directory
	containing README.
>How-To-Repeat:
	
>Fix:
diff -ruN temperature.app.orig/Makefile temperature.app/Makefile
--- temperature.app.orig/Makefile	Sun Jul 22 07:39:28 2001
+++ temperature.app/Makefile	Sun Dec 22 05:07:06 2002
@@ -6,24 +6,21 @@
 #
 
 PORTNAME=	temperature.app
-PORTVERSION=	1.3
+PORTVERSION=	1.4
 CATEGORIES=	x11 windowmaker
 MASTER_SITES=	http://www.fukt.bth.se/~per/temperature/
 DISTNAME=	Temperature.app-${PORTVERSION}
 
 MAINTAINER=	pelle@fukt.bth.se
 
-RUN_DEPENDS=	wget:${PORTSDIR}/ftp/wget
-
 USE_XPM=	yes
 USE_X_PREFIX=	yes
 
 do-install:
 	@${INSTALL_PROGRAM} ${WRKSRC}/Temperature.app ${PREFIX}/bin
 .ifndef(NOPORTDOCS)
-	@${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE} \
-		${PREFIX}/share/doc/${PORTNAME}
-	@${INSTALL_DATA} ${WRKSRC}/README ${PREFIX}/share/doc/${PORTNAME}
+	@${MKDIR} ${DOCSDIR}
+	@${INSTALL_DATA} ${WRKSRC}/README ${DOCSDIR}
 .endif
 
 .include <bsd.port.mk>
diff -ruN temperature.app.orig/distinfo temperature.app/distinfo
--- temperature.app.orig/distinfo	Sun Jul 22 07:39:28 2001
+++ temperature.app/distinfo	Sun Dec 22 04:10:33 2002
@@ -1 +1 @@
-MD5 (Temperature.app-1.3.tar.gz) = ee47fab0f27c8f5e702f95179ff6e9d8
+MD5 (Temperature.app-1.4.tar.gz) = fefedf57fb7ab799202b10a07bec2806
diff -ruN temperature.app.orig/files/patch-Makefile temperature.app/files/patch-Makefile
--- temperature.app.orig/files/patch-Makefile	Sun Jul 22 07:39:28 2001
+++ temperature.app/files/patch-Makefile	Sun Dec 22 03:38:39 2002
@@ -1,5 +1,5 @@
---- Makefile.orig	Mon Jun 25 12:03:07 2001
-+++ Makefile	Sun Jul  1 20:47:36 2001
+--- Makefile.orig	Sun Dec 22 03:37:52 2002
++++ Makefile	Sun Dec 22 03:37:34 2002
 @@ -3,12 +3,12 @@
  #
  
@@ -13,7 +13,7 @@
 -CXXFLAGS += -Wall -pedantic -fno-rtti -fno-exceptions -O2 -I/usr/X11R6/include
 -LDFLAGS += -L/usr/X11R6/lib -lXpm -lXext -lX11
 +CXXFLAGS += -Wall -pedantic -fno-rtti -fno-exceptions -I$(X11BASE)/include
-+LDFLAGS += -L$(X11BASE)/lib -lXpm -lXext -lX11
++LDFLAGS += -L$(X11BASE)/lib -lXpm -lXext -lX11 -lfetch
  
  OBJECTS = Main.o Temperature.o Xpm.o
  
diff -ruN temperature.app.orig/files/patch-README temperature.app/files/patch-README
--- temperature.app.orig/files/patch-README	Thu Jan  1 01:00:00 1970
+++ temperature.app/files/patch-README	Sun Dec 22 02:37:13 2002
@@ -0,0 +1,23 @@
+--- README.orig	Sun Dec 22 02:36:22 2002
++++ README	Sun Dec 22 01:58:16 2002
+@@ -10,7 +10,7 @@
+ --------------------------------------------------------------
+ Temperature.app is a Window Maker dock application which
+ fetches local temperature information every 15 minutes from 
+-ftp://weather.noaa.gov and displays it (in Celsius or Fahrenheit).
++http://weather.noaa.gov and displays it (in Celsius or Fahrenheit).
+ 
+ 
+ Hints
+@@ -21,10 +21,7 @@
+ 	If successful the led will stop blinking and go green.
+ 	If unsuccessful the led will stop blinking and go red.
+ 	Also, a error message will be printed in the console,
+-	describing what went wrong. If the error message is
+-	"wget failed" and you can't figure out why, try using
+-	option -V, which will cause wget to be run in verbose
+-	mode.
++	describing what went wrong.
+ 
+ Bugs
+ --------------------------------------------------------------
diff -ruN temperature.app.orig/files/patch-Temperature.cc temperature.app/files/patch-Temperature.cc
--- temperature.app.orig/files/patch-Temperature.cc	Thu Jan  1 01:00:00 1970
+++ temperature.app/files/patch-Temperature.cc	Sun Dec 22 02:38:18 2002
@@ -0,0 +1,148 @@
+--- Temperature.cc.orig	Sun Dec 22 02:36:30 2002
++++ Temperature.cc	Sun Dec 22 02:28:29 2002
+@@ -19,25 +19,23 @@
+ //  USA.
+ //
+ 
+-#include <X11/Xlib.h>
+-#include <iostream.h>
+-#include <fstream.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <unistd.h>
+ #include <signal.h>
+-#include <errno.h>
+-#include <sys/types.h>
+ #include <sys/wait.h>
+ #include <math.h>
+-#include <time.h>
++#include <sys/param.h>
++#include <fetch.h>
+ #include "Xpm.h"
+ #include "Temperature.h"
+ 
+ #include "pixmaps/main.xpm"
+ #include "pixmaps/redlight.xpm"
+ 
++const int MAX_LINE = 1024;
++
+ volatile static ChildStatus childStatus;
+ 
+ static void catchBrokenPipe(int sig) 
+@@ -61,7 +59,7 @@
+    }
+ 
+    if (childStatus == ChildError) {
+-      cerr << APPNAME << ": could not fetch temperature (wget failed), try option -V for more information" << endl;
++      cerr << APPNAME << ": could not fetch temperature" << endl;
+    }
+ }
+ 
+@@ -82,7 +80,6 @@
+    mFahrenheit = false;
+    mShowTime = false;
+    mTime12HourFormat = false;
+-   mVerbose = false;
+ 
+    // Parse command line
+    if (argc>1) {
+@@ -119,11 +116,6 @@
+             i++;
+          }
+ 
+-         // Verbose
+-         else if (!strcmp(argv[i], "-V")) {
+-            mVerbose = true;
+-         }
+-
+          // Instance name
+          else if (!strcmp(argv[i], "-n")) {
+             checkArgument(argv, argc, i);
+@@ -237,7 +229,6 @@
+         << " -s <id>         set station id (ICAO Location Indicator)" << endl
+         << " -t 12|24        display time of temperature observation (12 or 24 hour format)" << endl
+         << " -f              display degrees in Fahrenheit" << endl
+-        << " -V              display verbose messages from wget" << endl
+         << " -n <name>       set client instance name" << endl
+         << " -d <disp>       set display" << endl
+         << " -v              print version and exit" << endl
+@@ -333,9 +324,8 @@
+    sprintf(mTime, "%d:%.2d", hour, min);
+ }
+ 
+-bool Temperature::updateTemperture(ifstream& file)
++bool Temperature::updateTemperture(strstream& file)
+ {
+-   const int MAX_LINE = 1024;
+    char buffer[MAX_LINE];
+ 
+    if (mShowTime) {
+@@ -398,26 +388,30 @@
+    int counter = 0;
+    while(1) {
+       if (counter <= 0) {
+-         char tmpFile[sizeof(TMP_FILE)] = TMP_FILE;
+-         int fd = mkstemp(tmpFile);
+-         if (fd == -1) {
+-            cerr << APPNAME << ": could not create temporary file " << tmpFile << ": " << strerror(errno) << endl;
+-            exit(1);
+-         }
+-         close(fd);
+-
+          counter = UPDATE_INTERVAL;
+          childStatus = ChildRunning;
+          signal(SIGCHLD, catchChildExit);
+          showLed(true);
++         int pfd[2];
++         if (pipe(pfd) == -1) {
++            cerr << APPNAME << ": could not fetch temperature (pipe() failed)" << endl;
++            continue;
++         }
+          int pid = fork();
+          if (pid == 0) {
+-            const char* verbose = (mVerbose ? "--verbose" : "--quiet");
+             char* URL = new char[strlen(METAR_URL) + strlen(mStationId) + 1];
+             sprintf(URL, METAR_URL, mStationId);
+-            execlp("wget", "wget", "--cache=off", "--tries=0", verbose, "-O", tmpFile, URL, 0);
+-            cerr << APPNAME << ": could not fetch temperature (wget not found in $PATH)" << endl;
+-            remove(tmpFile);
++            FILE *file = fetchGetURL(URL, "p");
++            if (file == NULL)
++               exit(-1);
++            char buf[MAX_LINE];
++            close(pfd[0]);
++            for (;;) {
++               if (fgets(buf, sizeof(buf), file) == NULL)
++                  break;
++               write(pfd[1], buf, sizeof(buf));
++            }
++            close(pfd[1]);
+             exit(0);
+          } else if (pid == -1) {
+             cerr << APPNAME << ": could not fetch temperature (fork() failed)" << endl;
+@@ -430,15 +424,17 @@
+             }
+             showLed(true);
+             if (childStatus == ChildDone) {
+-               ifstream file(tmpFile);
+-               if (file) {
+-                  if (updateTemperture(file)) {
+-                     showLed(false);
+-                  }
+-                  file.close();
++               char buf[MAX_LINE];
++               close(pfd[1]);
++               strstream s;
++               while (read(pfd[0], buf, sizeof(buf)) > 0) {
++                  s << buf;
++               }
++               close(pfd[0]);
++               if (updateTemperture(s)) {
++                  showLed(false);
+                }
+             }
+-            remove(tmpFile);
+          }
+       } else {
+          counter--;
diff -ruN temperature.app.orig/files/patch-Temperature.h temperature.app/files/patch-Temperature.h
--- temperature.app.orig/files/patch-Temperature.h	Thu Jan  1 01:00:00 1970
+++ temperature.app/files/patch-Temperature.h	Sun Dec 22 02:37:42 2002
@@ -0,0 +1,36 @@
+--- Temperature.h.orig	Sun Dec 22 02:36:36 2002
++++ Temperature.h	Sun Dec 22 02:29:29 2002
+@@ -22,7 +22,7 @@
+ #ifndef _TEMPERATURE_H_
+ #define _TEMPERATURE_H_
+ 
+-#include <fstream.h>
++#include <strstream.h>
+ #include <X11/Xlib.h>
+ 
+ #define APPNAME                 "Temperature.app"
+@@ -40,7 +40,6 @@
+ #define UNIT_FONT               "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*"
+ #define LED_X                   57
+ #define LED_Y                   59
+-#define TMP_FILE                "/tmp/temperature.app-XXXXXX"
+ 
+ enum ChildStatus
+ {
+@@ -63,7 +62,7 @@
+    void showErrorLed(bool show);
+    void calcTimeDiff();
+    void setTime(char* utcTime);
+-   bool updateTemperture(ifstream& file);
++   bool updateTemperture(strstream& file);
+    void showLed(bool show);
+ 
+    Display*  mDisplay;
+@@ -80,7 +79,6 @@
+    bool      mFahrenheit;
+    bool      mShowTime;
+    bool      mTime12HourFormat;
+-   bool      mVerbose;
+ };
+ 
+ #endif
diff -ruN temperature.app.orig/pkg-descr temperature.app/pkg-descr
--- temperature.app.orig/pkg-descr	Sun May 27 21:03:50 2001
+++ temperature.app/pkg-descr	Sun Dec 22 01:55:51 2002
@@ -1,6 +1,6 @@
 Temperature.app is a Window Maker dock application which
 fetches local temperature information every 15 minutes from
-ftp://weather.noaa.gov and displays it (in Celsius or Fahrenheit).
+http://weather.noaa.gov and displays it (in Celsius or Fahrenheit).
 
 WWW: http://www.fukt.bth.se/~per/temperature/
 
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212220427.gBM4Rf6T065204>