bin/117855: [patch] pkg_updating: minor code cleanups
Beat Gaetzi
beat at chruetertee.ch
Mon Nov 5 13:10:02 PST 2007
>Number: 117855
>Category: bin
>Synopsis: [patch] pkg_updating: minor code cleanups
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Mon Nov 05 21:10:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator: Beat Gätzi
>Release: FreeBSD 8.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD daedalus.network.local 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Tue Oct 23 22:18:38 CEST 2007 root at daedalus.network.local:/usr/obj/usr/src/sys/GENERIC i386
>Description:
- include pkg_install/lib/lib.h
- remove stale getopt argument
- remove hard coded +CONTENTS file name
>How-To-Repeat:
>Fix:
--- pkg_updating.patch begins here ---
diff -Naur src.orig/usr.sbin/pkg_install/lib/lib.h src/usr.sbin/pkg_install/lib/lib.h
--- src.orig/usr.sbin/pkg_install/lib/lib.h 2007-10-23 20:38:35.000000000 +0200
+++ src/usr.sbin/pkg_install/lib/lib.h 2007-11-05 21:53:16.000000000 +0100
@@ -57,6 +57,13 @@
/* Usually "rm", but often "echo" during debugging! */
#define RMDIR_CMD "/bin/rmdir"
+/* Where the ports lives by default */
+#define DEF_PORTS_DIR "/usr/ports"
+/* just in case we change the environment variable name */
+#define PORTSDIR "PORTSDIR"
+/* macro to get name of directory where the ports lives */
+#define PORTS_DIR (getenv(PORTSDIR) ? getenv(PORTSDIR) : DEF_PORTS_DIR)
+
/* 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 */
diff -Naur src.orig/usr.sbin/pkg_install/updating/Makefile src/usr.sbin/pkg_install/updating/Makefile
--- src.orig/usr.sbin/pkg_install/updating/Makefile 2007-11-02 23:46:30.000000000 +0100
+++ src/usr.sbin/pkg_install/updating/Makefile 2007-11-04 23:33:27.000000000 +0100
@@ -8,4 +8,7 @@
WARNS?= 6
WFORMAT?= 1
+DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD}
+LDADD= ${LIBINSTALL} -lfetch -lmd
+
.include <bsd.prog.mk>
diff -Naur src.orig/usr.sbin/pkg_install/updating/main.c src/usr.sbin/pkg_install/updating/main.c
--- src.orig/usr.sbin/pkg_install/updating/main.c 2007-11-02 23:46:30.000000000 +0100
+++ src/usr.sbin/pkg_install/updating/main.c 2007-11-05 20:19:07.000000000 +0100
@@ -10,18 +10,11 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/usr.sbin/pkg_install/updating/main.c,v 1.1 2007/11/02 22:46:30 krion Exp $");
-#include <sys/stat.h>
-#include <sys/param.h> /* For MAXPATHLEN */
-
-#include <dirent.h>
#include <errno.h>
#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sysexits.h>
-#include <unistd.h>
+#include "lib.h"
#include "pathnames.h"
typedef struct installedport {
@@ -81,7 +74,7 @@
DIR *dir;
FILE *fd;
- while ((ch = getopt(argc, argv, "f:p:d:")) != -1) {
+ while ((ch = getopt(argc, argv, "f:d:")) != -1) {
switch (ch) {
case 'd':
dflag = 1;
@@ -146,7 +139,9 @@
}
if(attribute.st_mode & S_IFREG)
continue;
- (void)strlcat(tmp_file + n, "/+CONTENTS",
+ (void)strlcat(tmp_file + n, "/",
+ sizeof(tmp_file) - n);
+ (void)strlcat(tmp_file + n, CONTENTS_FNAME,
sizeof(tmp_file) - n);
/* Open +CONTENT file */
@@ -255,3 +250,10 @@
"usage: pkg_updating [-d YYYYMMDD] [-f file] [portname ...]\n");
exit(EX_USAGE);
}
+
+void
+cleanup(int sig)
+{
+ if (sig)
+ exit(1);
+}
diff -Naur src.orig/usr.sbin/pkg_install/updating/pathnames.h src/usr.sbin/pkg_install/updating/pathnames.h
--- src.orig/usr.sbin/pkg_install/updating/pathnames.h 2007-11-02 23:46:30.000000000 +0100
+++ src/usr.sbin/pkg_install/updating/pathnames.h 2007-11-05 21:53:25.000000000 +0100
@@ -10,19 +10,8 @@
*
*/
-/* Copy from ../version/version.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 */
+/* Where the updating file lives by default */
+#define DEF_UPDATING "/usr/ports/UPDATING"
+/* macro to define location of the UPDATING file */
#define UPDATING (getenv(PORTSDIR) ? strcat(getenv(PORTSDIR), \
- "/UPDATING") : DEF_PORTS_DIR)
-
-/* 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)
+ "/UPDATING") : DEF_UPDATING)
diff -Naur src.orig/usr.sbin/pkg_install/version/version.h src/usr.sbin/pkg_install/version/version.h
--- src.orig/usr.sbin/pkg_install/version/version.h 2005-07-27 09:55:12.000000000 +0200
+++ src/usr.sbin/pkg_install/version/version.h 2007-11-05 18:51:56.000000000 +0100
@@ -23,13 +23,6 @@
#ifndef _INST_VERSION_H_INCLUDE
#define _INST_VERSION_H_INCLUDE
-/* Where the ports lives by default */
-#define DEF_PORTS_DIR "/usr/ports"
-/* just in case we change the environment variable name */
-#define PORTSDIR "PORTSDIR"
-/* macro to get name of directory where we put logging information */
-#define PORTS_DIR (getenv(PORTSDIR) ? getenv(PORTSDIR) : DEF_PORTS_DIR)
-
struct index_entry {
SLIST_ENTRY(index_entry) next;
char *name;
--- pkg_updating.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list