From 4a3708c0c32da7c70de4a7ece2f3e37951bf40cf Mon Sep 17 00:00:00 2001 From: krion Date: Sat, 10 Nov 2007 10:21:29 +0000 Subject: Some code cleanups, including removing of stale getopt argument and hardcoded +CONTENTS defines. PR: bin/117855 Submitted by: Beat Gaetzi MFC after: 14 days --- usr.sbin/pkg_install/lib/lib.h | 7 +++++++ usr.sbin/pkg_install/updating/Makefile | 3 +++ usr.sbin/pkg_install/updating/main.c | 22 ++++++++++++---------- usr.sbin/pkg_install/updating/pathnames.h | 19 ++++--------------- usr.sbin/pkg_install/version/version.h | 7 ------- 5 files changed, 26 insertions(+), 32 deletions(-) (limited to 'usr.sbin/pkg_install') diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index 14d4377..cfa95ca 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -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 --git a/usr.sbin/pkg_install/updating/Makefile b/usr.sbin/pkg_install/updating/Makefile index 980747e..cf8bfc8 100644 --- a/usr.sbin/pkg_install/updating/Makefile +++ b/usr.sbin/pkg_install/updating/Makefile @@ -8,4 +8,7 @@ CFLAGS+= -I${.CURDIR}/../lib WARNS?= 6 WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd + .include diff --git a/usr.sbin/pkg_install/updating/main.c b/usr.sbin/pkg_install/updating/main.c index 84d089e..cb594de 100644 --- a/usr.sbin/pkg_install/updating/main.c +++ b/usr.sbin/pkg_install/updating/main.c @@ -10,18 +10,11 @@ #include __FBSDID("$FreeBSD$"); -#include -#include /* For MAXPATHLEN */ - -#include #include #include -#include -#include -#include #include -#include +#include "lib.h" #include "pathnames.h" typedef struct installedport { @@ -81,7 +74,7 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) } 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(void) "usage: pkg_updating [-d YYYYMMDD] [-f file] [portname ...]\n"); exit(EX_USAGE); } + +void +cleanup(int sig) +{ + if (sig) + exit(1); +} diff --git a/usr.sbin/pkg_install/updating/pathnames.h b/usr.sbin/pkg_install/updating/pathnames.h index d5ec1a0..7eed1b4 100644 --- a/usr.sbin/pkg_install/updating/pathnames.h +++ b/usr.sbin/pkg_install/updating/pathnames.h @@ -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 --git a/usr.sbin/pkg_install/version/version.h b/usr.sbin/pkg_install/version/version.h index c93d503..412c395 100644 --- a/usr.sbin/pkg_install/version/version.h +++ b/usr.sbin/pkg_install/version/version.h @@ -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; -- cgit v1.1