From 536b651f4086fe01d0bd1f743f54ef650524b122 Mon Sep 17 00:00:00 2001 From: dacctal Date: Fri, 14 Aug 2026 07:37:03 +0000 Subject: i made the install work (kinda) --- src/recipes.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/recipes.c (limited to 'src/recipes.c') diff --git a/src/recipes.c b/src/recipes.c new file mode 100644 index 0000000..5f387b4 --- /dev/null +++ b/src/recipes.c @@ -0,0 +1,78 @@ +/* + + pkgit - package it! + + Copyright (C) 2026 dacctal + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#include + +#include "common.h" +#include "files.h" +#include "log.h" +#include "pkg.h" + +static bool pkg_fetch_sources(package_t *pkg) { + if (!pkg_hook_fetch_sources(pkg)) { + log_error(GREEN "%.*s" COLOR_RESET " fetch failed", + str_fmt(&pkg->name)); + return false; + } + return true; +} + +static bool pkg_enter(package_t *pkg) { + if (!is_directory(pkg->src.data)) { + log_error(GREEN "%.*s" COLOR_RESET " is not a directory", + str_fmt(&pkg->src)); + return false; + } + chdir(pkg->src.data); + return true; +} + +bool pkg_setup(package_t *pkg) { + if (!pkg_enter(pkg)) return false; + if (!pkg_hook_setup(pkg)) return false; + return true; +} + +bool pkg_build(package_t *pkg) { + if (!pkg_enter(pkg)) return false; + if (!pkg_hook_build(pkg)) return false; + return true; +} + +bool pkg_install(package_t *pkg) { + if (!pkg_fetch_sources(pkg)) return false; + if (!pkg_enter(pkg)) return false; + if (!pkg_hook_setup(pkg)) return false; + if (!pkg_hook_build(pkg)) return false; + if (!pkg_hook_install(pkg)) return false; + return true; +} + +bool pkg_remove(package_t *pkg) { + if (!pkg_enter(pkg)) return false; + if (!pkg_hook_setup(pkg)) return false; + return true; +} + +bool pkg_update(package_t *pkg) { + if (!pkg_enter(pkg)) return false; + if (!pkg_hook_setup(pkg)) return false; + return true; +} -- cgit v1.2.3