aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordacctal <donotcontactmevia@email.invalid>2026-08-17 15:07:02 +0000
committerdacctal <donotcontactmevia@email.invalid>2026-08-17 15:07:02 +0000
commit51983b47b22db7bf819e9880caa2b72bdb8c9942 (patch)
tree489119bbd32a9fb67b6d917457001c52c888e913
parent7db56ed3f9d1fcb8b6780b7c30ad93904625a0a3 (diff)
added dynamic version & updated try_pkg_fn macro
-rw-r--r--Makefile10
-rw-r--r--include/common.h1
-rw-r--r--src/recipes.c43
3 files changed, 31 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index fb247c1..a86e04f 100644
--- a/Makefile
+++ b/Makefile
@@ -16,13 +16,21 @@
.PHONY: default debug install defconfig rmconfig clean uninstall
+GIT_HASH := $(shell git rev-parse --short HEAD)
+GIT_DATE := $(shell git log -1 --format='%ad' --date='format:%y.%m.%d')
+GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
+GIT_REMOTE := $(shell git remote get-url origin)
+GIT_TAG := $(shell git describe --tags --exact-match HEAD 2>/dev/null)
+VERSION := $(if $(GIT_TAG),$(GIT_TAG),$(GIT_DATE)_$(GIT_BRANCH) ($(GIT_HASH)))
+
CC ?= cc
RM = rm -f
PREFIX ?= /usr/local
OBJDIR = obj
SRCS = $(wildcard src/*.c)
OBJS = $(SRCS:src/%.c=$(OBJDIR)/%.o)
-CFLAGS += $(shell pkg-config --cflags luajit) -I./include -Wno-format-truncation -std=c99
+CFLAGS += $(shell pkg-config --cflags luajit) -I./include
+CFLAGS += -Wno-format-truncation -std=c99 -DVERSION='"$(VERSION)"'
# pretty print for compilation. To enable verbose (show commands), run with
# `make V=1`
diff --git a/include/common.h b/include/common.h
index 32d8741..9ed5fd1 100644
--- a/include/common.h
+++ b/include/common.h
@@ -20,7 +20,6 @@
#ifndef PKGIT_COMMON_H
#define PKGIT_COMMON_H
-#define VERSION "2.0.0_INDEV"
#define RED "\x1b[0;31m"
#define GREEN "\x1b[0;32m"
#define YELLOW "\x1b[0;33m"
diff --git a/src/recipes.c b/src/recipes.c
index b84a026..206d7d2 100644
--- a/src/recipes.c
+++ b/src/recipes.c
@@ -26,13 +26,19 @@
#include "pkg.h"
#include "state.h"
-#define try_pkg_fn(fn, pkg, operation) \
+#define try_pkg_fn(fn, pkg, operation, smol) \
do { \
- log_info("attempting to %s '%.*s'", operation, str_fmt(&(pkg)->name)); \
+ if (pkg_read_status(smol, pkg)) return true; \
+ if (!flags.quiet) log_info("'%.*s' %s in progress...", \
+ str_fmt(&(pkg)->name), operation); \
if (!(fn((pkg)))) { \
log_error("%s failed", operation); \
return false; \
} \
+ char big[2] = "\0"; \
+ big[0] = smol; \
+ if (!pkg_write_status(big, pkg)) return false; \
+ log_info("'%.*s' %s done", str_fmt(&(pkg)->name), operation); \
} while (0)
static bool pkg_write_status(const char *status, package_t *pkg) {
@@ -92,34 +98,28 @@ static bool pkg_enter(package_t *pkg) {
bool pkg_setup(package_t *pkg) {
if (pkg_read_status('s', pkg)) return true;
- try_pkg_fn(pkg_enter, pkg, "enter");
- try_pkg_fn(pkg_hook_setup, pkg, "setup");
- if (!pkg_write_status("s", pkg)) return false;
+ try_pkg_fn(pkg_enter, pkg, "enter", 'e');
+ try_pkg_fn(pkg_hook_setup, pkg, "setup", 's');
+ log_success("'%.*s' set up", str_fmt(&pkg->name));
return true;
}
bool pkg_build(package_t *pkg) {
if (pkg_read_status('b', pkg)) return true;
- try_pkg_fn(pkg_enter, pkg, "enter");
- try_pkg_fn(pkg_hook_build, pkg, "build");
- if (!pkg_write_status("b", pkg)) return false;
+ try_pkg_fn(pkg_enter, pkg, "enter", 'e');
+ try_pkg_fn(pkg_hook_build, pkg, "build", 'b');
+ log_success("'%.*s' built", str_fmt(&pkg->name));
return true;
}
bool pkg_install(package_t *pkg) {
if (is_pkg_installed(pkg) && !flags.force) return true;
- log_info("fetching '%.*s'", str_fmt(&pkg->name));
- if (!pkg_read_status('f', pkg) && !pkg_fetch_sources(pkg)) return false;
- log_info("entering '%.*s'", str_fmt(&pkg->src));
- if (!pkg_read_status('e', pkg) && !pkg_enter(pkg)) return false;
- log_info("setting up '%.*s'", str_fmt(&pkg->name));
- if (!pkg_read_status('s', pkg) && !pkg_hook_setup(pkg)) return false;
- log_info("building '%.*s'", str_fmt(&pkg->name));
- if (!pkg_read_status('b', pkg) && !pkg_hook_build(pkg)) return false;
- log_info("installing '%.*s'", str_fmt(&pkg->name));
- if (!pkg_hook_install(pkg)) return false;
- if (!pkg_write_status("i", pkg)) return false;
- log_success("installed '%.*s'", str_fmt(&pkg->name));
+ try_pkg_fn(pkg_fetch_sources, pkg, "fetch", 'f');
+ try_pkg_fn(pkg_enter, pkg, "enter", 'e');
+ try_pkg_fn(pkg_hook_setup, pkg, "setup", 's');
+ try_pkg_fn(pkg_hook_build, pkg, "build", 'b');
+ try_pkg_fn(pkg_hook_install, pkg, "install", 'i');
+ log_success("'%.*s' installed", str_fmt(&pkg->name));
return true;
}
@@ -127,11 +127,12 @@ bool pkg_remove(package_t *pkg) {
if (!pkg_enter(pkg)) return false;
if (!pkg_hook_remove(pkg)) return false;
if (!rmrf(&pkg->root)) return false;
- log_success("removed '%.*s'", str_fmt(&pkg->name));
+ log_success("'%.*s' removed", str_fmt(&pkg->name));
return true;
}
bool pkg_update(package_t *pkg) {
pkg_install(pkg);
+ log_success("'%.*s' updated", str_fmt(&pkg->name));
return true;
}