pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

plist-utils: Add plist-add ad plist-del



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sun Jul 31 15:03:23 2016 +0200
Changeset:	babfabcaea743ea0abcb951c8e90e296ce930124

Modified Files:
	plist-utils/Makefile
	plist-utils/PLIST
	plist-utils/TODO
	plist-utils/files/Makefile
Added Files:
	plist-utils/files/add.c
	plist-utils/files/del.c
	plist-utils/files/plist-add.1
	plist-utils/files/plist-del.1

Log Message:
plist-utils: Add plist-add ad plist-del

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=babfabcaea743ea0abcb951c8e90e296ce930124

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 plist-utils/Makefile          |   2 +-
 plist-utils/PLIST             |   5 +-
 plist-utils/TODO              |   6 +--
 plist-utils/files/Makefile    |  12 ++++-
 plist-utils/files/add.c       | 116 ++++++++++++++++++++++++++++++++++++++++++
 plist-utils/files/del.c       | 116 ++++++++++++++++++++++++++++++++++++++++++
 plist-utils/files/plist-add.1 |  57 +++++++++++++++++++++
 plist-utils/files/plist-del.1 |  57 +++++++++++++++++++++
 8 files changed, 362 insertions(+), 9 deletions(-)

diffs:
diff --git a/plist-utils/Makefile b/plist-utils/Makefile
index 7799754..603215a 100644
--- a/plist-utils/Makefile
+++ b/plist-utils/Makefile
@@ -12,7 +12,7 @@ LICENSE=	2-clause-bsd
 USE_BSD_MAKEFILE=	yes
 USE_TOOLS=		nroff
 
-INSTALLATION_DIRS+=	bin ${PKGMANDIR}/man1 ${PKGMANDIR}/cat1
+INSTALLATION_DIRS+=	bin ${PKGMANDIR}/man1
 PKGSRC_LOCKTYPE=	none	# avoid "bootstrapping problem"
 
 do-extract:
diff --git a/plist-utils/PLIST b/plist-utils/PLIST
index 359b484..9bc17cf 100644
--- a/plist-utils/PLIST
+++ b/plist-utils/PLIST
@@ -1,4 +1,7 @@
 @comment $NetBSD$
+bin/plist-add
+bin/plist-del
 bin/plist-sort
+man/man1/plist-add.1
+man/man1/plist-del.1
 man/man1/plist-sort.1
-@pkgdir man/cat1
diff --git a/plist-utils/TODO b/plist-utils/TODO
index 58f4ee5..664c11d 100644
--- a/plist-utils/TODO
+++ b/plist-utils/TODO
@@ -3,8 +3,4 @@ Spawn a command like:
 make show-var VARNAME=KEY
 And get the KEY value
 
-2. Add plist-add
-
-3. Add plist-del
-
-4. Port to !NetBSD platforms with libnbcompat
+2. Port to !NetBSD platforms with libnbcompat
diff --git a/plist-utils/files/Makefile b/plist-utils/files/Makefile
index 478a31e..653a5a4 100644
--- a/plist-utils/files/Makefile
+++ b/plist-utils/files/Makefile
@@ -1,6 +1,14 @@
 #	$NetBSD:$
 
-PROG=	plist-sort
-SRCS=	plist_getline.c plist_tree.c sort.c
+PROGS=			plist-sort plist-add plist-del
+
+SRCS.plist-sort=	plist_getline.c plist_tree.c sort.c
+MAN.plist-sort=		plist-sort.1
+
+SRCS.plist-add=		plist_getline.c plist_tree.c add.c
+MAN.plist-add=		plist-add.1
+
+SRCS.plist-del=		plist_getline.c plist_tree.c del.c
+MAN.plist-del=		plist-del.1
 
 .include <bsd.prog.mk>
diff --git a/plist-utils/files/add.c b/plist-utils/files/add.c
new file mode 100644
index 0000000..2fb3700
--- /dev/null
+++ b/plist-utils/files/add.c
@@ -0,0 +1,116 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+#include "plist_getline.h"
+#include "plist_tree.h"
+
+int
+main(int argc, char **argv)
+{
+	int ch;
+	int iflag = 0;
+	char *buffer;
+	FILE *stream;
+	char *firstline;
+	int i;
+
+	setprogname(argv[0]);
+
+	while((ch = getopt(argc, argv, "i")) != -1) {
+		switch (ch) {
+		case 'i':
+			iflag = 1;
+			break;
+		default:
+			errx(EXIT_FAILURE, "Invalid parameter specified");
+			/* NOTREACHED */
+		}
+	}
+
+	argc -= optind;
+	argv += optind;
+
+	if (argc < 2)
+		errx(EXIT_FAILURE, "Missing arguments");
+
+	plist_tree_init();
+
+	/* No files specified - read from a file */
+	stream = fopen(argv[0], "r");
+	if (!stream) {
+		err(EXIT_FAILURE, "fopen");
+	}
+
+	/* Read entries and put into tree */
+	/* The first line is special */
+	if ((buffer = plist_getline(stream)) != NULL) {
+		firstline = buffer;
+	}
+
+	while ((buffer = plist_getline(stream)) != NULL) {
+		plist_tree_insert(buffer);
+		free(buffer);
+	}
+
+	/* Add entries from command line */
+	for (i = 1; i < argc; i++) {
+		plist_tree_insert(argv[i]);
+	}
+
+	/* Prepare for write */
+
+	if (iflag > 0) { /* If there is in-place mode, reopen the file */
+		/* Truncate file to 0 */
+		stream = freopen(argv[0], "w", stream);
+		if (!stream)
+			err(EXIT_FAILURE, "open");
+		/* Is this needed? */
+		rewind(stream);
+	} else { /* Set stream to stdout */
+		stream = stdout;
+	}
+
+	fprintf(stream, "%s\n", firstline);
+	plist_tree_dump(stream);
+
+	return EXIT_SUCCESS;
+}
diff --git a/plist-utils/files/del.c b/plist-utils/files/del.c
new file mode 100644
index 0000000..68f3d8e
--- /dev/null
+++ b/plist-utils/files/del.c
@@ -0,0 +1,116 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+#include "plist_getline.h"
+#include "plist_tree.h"
+
+int
+main(int argc, char **argv)
+{
+	int ch;
+	int iflag = 0;
+	char *buffer;
+	FILE *stream;
+	char *firstline;
+	int i;
+
+	setprogname(argv[0]);
+
+	while((ch = getopt(argc, argv, "i")) != -1) {
+		switch (ch) {
+		case 'i':
+			iflag = 1;
+			break;
+		default:
+			errx(EXIT_FAILURE, "Invalid parameter specified");
+			/* NOTREACHED */
+		}
+	}
+
+	argc -= optind;
+	argv += optind;
+
+	if (argc < 2)
+		errx(EXIT_FAILURE, "Missing arguments");
+
+	plist_tree_init();
+
+	/* No files specified - read from a file */
+	stream = fopen(argv[0], "r");
+	if (!stream) {
+		err(EXIT_FAILURE, "fopen");
+	}
+
+	/* Read entries and put into tree */
+	/* The first line is special */
+	if ((buffer = plist_getline(stream)) != NULL) {
+		firstline = buffer;
+	}
+
+	while ((buffer = plist_getline(stream)) != NULL) {
+		plist_tree_insert(buffer);
+		free(buffer);
+	}
+
+	/* Add entries from command line */
+	for (i = 1; i < argc; i++) {
+		plist_tree_remove(argv[i]);
+	}
+
+	/* Prepare for write */
+
+	if (iflag > 0) { /* If there is in-place mode, reopen the file */
+		/* Truncate file to 0 */
+		stream = freopen(argv[0], "w", stream);
+		if (!stream)
+			err(EXIT_FAILURE, "open");
+		/* Is this needed? */
+		rewind(stream);
+	} else { /* Set stream to stdout */
+		stream = stdout;
+	}
+
+	fprintf(stream, "%s\n", firstline);
+	plist_tree_dump(stream);
+
+	return EXIT_SUCCESS;
+}
diff --git a/plist-utils/files/plist-add.1 b/plist-utils/files/plist-add.1
new file mode 100644
index 0000000..0b7ac6c
--- /dev/null
+++ b/plist-utils/files/plist-add.1
@@ -0,0 +1,57 @@
+.\" $NetBSD$
+.\"
+.\" Copyright (c) 2016 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\"
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in
+.\"    the documentation and/or other materials provided with the
+.\"    distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd August 1, 2016
+.Dt PLIST-ADD 3
+.Os
+.Sh NAME
+.Nm plist-add
+.Sh SYNOPSIS
+.Nm
+.Op Fl i
+.Op Ar
+.Sh DESCRIPTION
+The
+.Nm
+program was written to facilitate management of PLIST files with optional files and macros replacing variables to strings.
+The primary reason was to handle quick changes of file-lists in packages tracking upstream development of projects.
+.Sh EXIT STATUS
+The
+.Nm
+utility exits 0 on success, and any other value if an error occurs.
+.Sh HISTORY  
+A  
+.Nm
+utility appeared in pkgsrc-2016Q3.
+.Sh AUTHORS
+.An -nosplit  
+The
+.Nm 
+utility was written by
+.An Kamil Rytarowski .
diff --git a/plist-utils/files/plist-del.1 b/plist-utils/files/plist-del.1
new file mode 100644
index 0000000..6fb3432
--- /dev/null
+++ b/plist-utils/files/plist-del.1
@@ -0,0 +1,57 @@
+.\" $NetBSD$
+.\"
+.\" Copyright (c) 2016 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\"
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in
+.\"    the documentation and/or other materials provided with the
+.\"    distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd August 1, 2016
+.Dt PLIST-DEL 3
+.Os
+.Sh NAME
+.Nm plist-del
+.Sh SYNOPSIS
+.Nm
+.Op Fl i
+.Op Ar
+.Sh DESCRIPTION
+The
+.Nm
+program was written to facilitate management of PLIST files with optional files and macros replacing variables to strings.
+The primary reason was to handle quick changes of file-lists in packages tracking upstream development of projects.
+.Sh EXIT STATUS
+The
+.Nm
+utility exits 0 on success, and any other value if an error occurs.
+.Sh HISTORY  
+A  
+.Nm
+utility appeared in pkgsrc-2016Q3.
+.Sh AUTHORS
+.An -nosplit  
+The
+.Nm 
+utility was written by
+.An Kamil Rytarowski .


Home | Main Index | Thread Index | Old Index