Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 May 2010 21:15:37 GMT
From:      Ivan Voras <ivoras@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 178837 for review
Message-ID:  <201005262115.o4QLFbRb019891@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@178837?ac=10

Change 178837 by ivoras@betelgeuse on 2010/05/26 21:14:59

	Skeleton for patch operations

Affected files ...

.. //depot/projects/soc2010/pkg_patch/src/patch/Makefile#3 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/hashjob.c#2 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/hashjob.h#2 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/main.c#3 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.c#1 add
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.h#1 add
.. //depot/projects/soc2010/pkg_patch/src/patch/pkg_patch.h#1 add

Differences ...

==== //depot/projects/soc2010/pkg_patch/src/patch/Makefile#3 (text+ko) ====

@@ -3,11 +3,11 @@
 .include <bsd.own.mk>
 
 PROG=	pkg_patch
-SRCS=	main.c hashjob.c
+SRCS=	main.c mkpatch.c hashjob.c
 
 WARNS?=	4
 WFORMAT?=	1
 
-LDADD=	-lmd
+LDADD=	-lmd -pthread
 
 .include <bsd.prog.mk>

==== //depot/projects/soc2010/pkg_patch/src/patch/hashjob.c#2 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/hashjob.h#2 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/main.c#3 (text+ko) ====

@@ -1,8 +1,6 @@
-/*
+/*-
+ * Copyright 2010. Ivan Voras <ivoras@freebsd.org>
  *
- * FreeBSD install - a package for the installation and maintainance
- * of non-core utilities.
- *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -11,9 +9,10 @@
  * 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.
- *
- * Ivan Voras
- * 21 May 2010
+ */
+/*
+ * FreeBSD install - a package for the installation and maintainance
+ * of non-core utilities.
  *
  * This is the "binary patch"  module.
  */
@@ -27,21 +26,74 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <err.h>
 
+#include <pkg.h>
+#define PKG_PATCH_MAIN
+#include "pkg_patch.h"
+#include "mkpatch.h"
 
-#include <pkg.h>
 
 int argc;
 char **argv;
+enum PP_OP patch_op = PP_NONE;
+
+
+static void usage_short(void);
+static void proc_args(void);
+
+
+static void
+usage_short() {
+	printf("usage: %s -m [flags] package_file_1 package_file_2\n", argv[0]);
+}
+
+
+static void
+proc_args() {
+	int ch;
+	
+	while ((ch = getopt(argc, argv, "mh")) != -1) {
+		switch (ch) {
+		case 'm':
+			patch_op = PP_MKPATCH;
+			break;
+		case 'h':
+			usage_short();
+			exit(0);
+			break;
+		default:
+			usage_short();
+			exit(1);
+		}
+	}
+	argc -= optind;
+	argv += optind;
+}
+
 
 void
 cleanup(int __unused sig)
 {
 }
 
+
 int main(int _argc, char **_argv)
 {
 	argc = _argc;
 	argv = _argv;
+	
+	proc_args();
+	if (patch_op == PP_NONE)
+		errx(1, "No operation switch given");
+	
+	switch (patch_op) {
+	case PP_MKPATCH:
+		perform_mkpatch();
+		break;
+	default:
+		errx(1, "This should not happen - unknown patch_op");
+	}
+	
 	return (0);
 }



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