aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--.wakatime-project0
-rw-r--r--Makefile13
-rw-r--r--mbpk.c33
4 files changed, 49 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 4e7bf47..82b3789 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
build/
.cache
+*.o
+*.d
+mbpk
diff --git a/.wakatime-project b/.wakatime-project
deleted file mode 100644
index e69de29..0000000
--- a/.wakatime-project
+++ /dev/null
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a0f5625
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,13 @@
+# This Makefile requires bmake (BSD make).
+# If you are on a Linux system, install bmake from your distribution's package manager before continuing.
+PROG= mbpk
+SRCS= mbpk.c
+
+# todo: add manpages later
+NOMAN= yes
+
+CFLAGS+= -Wall -Wextra -O2 -Werror -std=c99 -O2 -I/usr/local/include
+LDFLAGS+= -L/usr/local/lib
+LDADD+= -lxbps
+
+.include <bsd.prog.mk>
diff --git a/mbpk.c b/mbpk.c
new file mode 100644
index 0000000..30ec82d
--- /dev/null
+++ b/mbpk.c
@@ -0,0 +1,33 @@
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <xbps.h>
+#include <stdlib.h>
+#include <limits.h>
+
+int main(void) {
+ /* init xbps stuff */
+ struct xbps_handle x;
+
+ memset(&x, 0, sizeof(x));
+ const char* home = getenv("HOME");
+ if (home == NULL) {
+ struct passwd *pw = getpwuid(getuid());
+ if (pw != NULL) {
+ home = pw->pw_dir;
+ }
+ }
+ snprintf(x.rootdir, sizeof(x.rootdir), "%s/.local/mbpk/prefix", home);
+ snprintf(x.cachedir, sizeof(x.cachedir), "%s/.local/mbpk/cache", home);
+ snprintf(x.confdir, sizeof(x.confdir), "%s/.local/mbpk/conf.d", home);
+ x.flags = XBPS_FLAG_VERBOSE;
+
+ int r = xbps_init(&x);
+ if (r != 0) {
+ fprintf(stderr, "xbps_init failed: %s\n", strerror(r));
+ return r;
+ }
+
+ return 0;
+}