On Sat, Sep 22, 2018 at 01:35:05PM -0400, Jake Champlin wrote:
> Hi ports@,
>
> This adds a patch to the 2048 port to pledge the game.
>
> Index: patches/patch-pledge
> ===================================================================
> RCS file: patches/patch-pledge
> diff -N patches/patch-pledge
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-pledge 22 Sep 2018 17:25:16 -0000
> @@ -0,0 +1,26 @@
> +
> +Pledges 2048
> +
> +Index: src/main.c
> +--- src/main.c.orig
> ++++ src/main.c
> +@@ -1,5 +1,6 @@
> + #include <stdio.h>
> + #include <stdbool.h>
> ++#include <unistd.h>
> + #include "ai.h"
> + #include "engine.h"
> + #include "gfx.h"
> +@@ -13,5 +14,10 @@ void draw_then_sleep(struct gfx_state *s, struct
> gamestate *g)
> +
> + int main(int argc, char **argv)
> + {
> ++ if (pledge("stdio cpath rpath wpath tty", NULL) == -1) {
> ++ perror("pledge");
> ++ return 1;
> ++ }
> ++
> + struct gamestate *g = gamestate_init(argc, argv);
> + struct gfx_state *s = NULL;
> +
> +PROGRAM := 2048
>From mentions on bsd.network:
- Fixes pledge call to follow convention
- Adds REVISION to Makefile
- Adds `# uses pledge()` comment to Makefile
Index: Makefile
===================================================================
RCS file: /cvs/ports/games/2048-cli/Makefile,v
retrieving revision 1.1.1.1
diff -u -p -u -p -r1.1.1.1 Makefile
--- Makefile 10 Dec 2017 22:44:51 -0000 1.1.1.1
+++ Makefile 22 Sep 2018 18:44:16 -0000
@@ -1,6 +1,7 @@
# $OpenBSD: Makefile,v 1.1.1.1 2017/12/10 22:44:51 bcallah Exp $
COMMENT = terminal version of the 2048 sliding block puzzle game
+REVISION = 0
CATEGORIES = games
GH_ACCOUNT = tiehuis
@@ -12,6 +13,7 @@ MAINTAINER = Kaashif Hymabaccus <kaashif
# MIT
PERMIT_PACKAGE_CDROM = Yes
+# uses pledge()
WANTLIB += c curses
USE_GMAKE = Yes
Index: patches/patch-pledge
===================================================================
RCS file: patches/patch-pledge
diff -N patches/patch-pledge
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-pledge 22 Sep 2018 18:44:16 -0000
@@ -0,0 +1,26 @@
+
+Pledges 2048
+
+Index: src/main.c
+--- src/main.c.orig
++++ src/main.c
+@@ -1,5 +1,6 @@
+ #include <stdio.h>
+ #include <stdbool.h>
++#include <unistd.h>
+ #include "ai.h"
+ #include "engine.h"
+ #include "gfx.h"
+@@ -13,5 +14,10 @@ void draw_then_sleep(struct gfx_state *s, struct gamestate
*g)
+
+ int main(int argc, char **argv)
+ {
++ if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
++ perror("pledge");
++ return 1;
++ }
++
+ struct gamestate *g = gamestate_init(argc, argv);
+ struct gfx_state *s = NULL;
+
+PROGRAM := 2048