aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordacctal <donotcontactmevia@email.invalid>2026-06-28 03:00:32 +0000
committerdacctal <donotcontactmevia@email.invalid>2026-06-28 03:00:32 +0000
commiteaef169d7563ea5b426c7a51c9afea9177d92b72 (patch)
tree1e1b58196efe722a3954bf3002ed4ea62a37af19
parentfd9f38ea42b04d23203c1d407d8c6f19d673264b (diff)
added reason why i don't self host videos
-rw-r--r--.editorconfig4
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--Makefile19
-rw-r--r--README.md4
-rw-r--r--bldit.lua20
-rw-r--r--docs/pkgit.1188
-rw-r--r--include/add_repo.h20
-rw-r--r--include/build.h20
-rw-r--r--include/cla_parse.h20
-rw-r--r--include/cmd_out.h20
-rw-r--r--include/copy_install.h20
-rw-r--r--include/create_pkg.h20
-rw-r--r--include/declare.h20
-rw-r--r--include/fetch_git.h20
-rw-r--r--include/fetch_pwd.h20
-rw-r--r--include/fetch_src.h20
-rw-r--r--include/files.h20
-rw-r--r--include/help.h20
-rw-r--r--include/install_pkg.h20
-rw-r--r--include/is_updated.h20
-rw-r--r--include/link_install.h20
-rw-r--r--include/list_pkgs.h20
-rw-r--r--include/lua_build.h20
-rw-r--r--include/lua_state.h20
-rw-r--r--include/name_from_url.h20
-rw-r--r--include/remove_pkg.h20
-rw-r--r--include/resolve_deps.h20
-rw-r--r--include/search.h20
-rw-r--r--include/set_install_directories.h20
-rw-r--r--include/setup_dirs.h20
-rw-r--r--include/setup_pkgit.h20
-rw-r--r--include/update_all.h20
-rw-r--r--include/update_pkg.h20
-rw-r--r--include/vars.h20
-rw-r--r--src/add_repo.c20
-rw-r--r--src/build.c20
-rw-r--r--src/cla_parse.c20
-rw-r--r--src/cmd_out.c20
-rw-r--r--src/create_pkg.c20
-rw-r--r--src/declare.c20
-rw-r--r--src/fetch_git.c20
-rw-r--r--src/fetch_pwd.c20
-rw-r--r--src/fetch_src.c20
-rw-r--r--src/files.c20
-rw-r--r--src/help.c20
-rw-r--r--src/install_pkg.c20
-rw-r--r--src/is_updated.c21
-rw-r--r--src/list_pkgs.c20
-rw-r--r--src/lua_build.c20
-rw-r--r--src/lua_state.c1377
-rw-r--r--src/main.c34
-rw-r--r--src/name_from_url.c45
-rw-r--r--src/remove_pkg.c164
-rw-r--r--src/resolve_deps.c58
-rw-r--r--src/search.c39
-rw-r--r--src/set_install_directories.c113
-rw-r--r--src/setup_dirs.c35
-rw-r--r--src/setup_pkgit.c25
-rw-r--r--src/update_all.c58
-rw-r--r--src/update_pkg.c40
-rw-r--r--src/vars.c223
61 files changed, 2319 insertions, 990 deletions
diff --git a/.editorconfig b/.editorconfig
index 88f5c63..5976dad 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,8 +1,8 @@
root = true
[*]
-indent_style = space
-indent_size = 2
+indent_style = tab
+indent_size = 4
max_line_length = 80
[Makefile]
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6809b8f..7d09d0a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -26,7 +26,7 @@ Please write your code to be as extensible as reasonably possible.
# Code Styling
Please follow the following styling guidelines:
- Try not to make your lines longer than 80 characters.
-- All indentation should be 2 spaces long.
+- All indentation should be 1 tab character long.
- Comments should only be used to explain your thought process for writing the code you wrote. Don't explain what it does.
- Variable/Function names should concisely describe what they are/do. All of which are styled in snake_case.
- Version numbers will loosely follow the guidelines of [Semantic Versioning 2.0.0](https://semver.org/)
diff --git a/Makefile b/Makefile
index f1c6e22..9ed03c9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,19 @@
+# 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 <https://www.gnu.org/licenses/>.
+
.PHONY: default debug install defconfig clean
CC ?= clang
@@ -25,9 +41,12 @@ debug: pkgit
install: pkgit
install -d ${DESTDIR}${PREFIX}/bin
install -m 755 pkgit ${DESTDIR}${PREFIX}/bin/pkgit
+ install -d ${DESTDIR}${PREFIX}/share/man/man1
+ install -m 644 docs/pkgit.1 ${DESTDIR}${PREFIX}/share/man/man1/pkgit.1
uninstall: ${DESTDIR}${PREFIX}/bin/pkgit
${RM} ${DESTDIR}${PREFIX}/bin/pkgit
+ ${RM} ${DESTDIR}${PREFIX}/share/man/man1/pkgit.1
defconfig:
@if [ "$$(id -u)" -eq 0 ]; then dir=/etc/pkgit; else dir=~/.config/pkgit; fi; \
diff --git a/README.md b/README.md
index 7a9765f..c5d3913 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,10 @@
# What is this?
pkgit is an unconventional package manager designed to compile & install packages directly from their git repository.
+# License
+pkgit is licensed under the GNU-GPL-2.0-or-later.
+if you did not get a copy, please see <https://www.gnu.org/licenses/>.
+
> ***[DISCLAIMER]***
>
> Due to the nature of pkgit, you are solely responsible for vetting the repos that you add to your system.
diff --git a/bldit.lua b/bldit.lua
index 6efe80f..3054e9b 100644
--- a/bldit.lua
+++ b/bldit.lua
@@ -1,3 +1,23 @@
+--[[
+
+ 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 <https://www.gnu.org/licenses/>.
+
+]]
+
bldit_version = "1.0.0"
package_version = "1.0.0"
diff --git a/docs/pkgit.1 b/docs/pkgit.1
new file mode 100644
index 0000000..4606acd
--- /dev/null
+++ b/docs/pkgit.1
@@ -0,0 +1,188 @@
+.TH PKGIT 1 "2026-06-22" "git.symlinx.net/pkgit" "User Commands"
+.SH NAME
+pkgit \- an unconventional package manager
+.SH SYNOPSIS
+.B pkgit
+.RI [ options ] " " <package>
+.br
+.B pkgit
+.RI [ options ] " " <command> " " [arguments]
+.SH DESCRIPTION
+.B pkgit
+is an unconventional package manager designed to compile and install packages directly from their git repository.
+.PP
+Commands in
+.B pkgit
+follow a standard structure:
+.PP
+.RS
+.B pkgit
+.RI [ \-\-flag | \-f ] " " <package>
+.RE
+.PP
+Flags have two forms: long (e.g., \fB\-\-install\fR) and short (e.g., \fB\-i\fR).
+The short form uses the first letter of the long counterpart. Short flags
+can be chained together into a single argument. For example,
+.B \-qif
+combines
+.BR \-\-quiet ,
+.BR \-\-install ,
+and
+.BR \-\-force .
+.SH WARNING
+Due to the nature of
+.BR pkgit ,
+you are solely responsible for vetting the repositories that you add to your system. Use at your own risk.
+.SH COMPILATION
+To compile
+.B pkgit
+from source, enter the project directory and run one of the following:
+.PP
+.RS
+.B make
+.RE
+or
+.RS
+.B pkgit \-\-build
+.RE
+.PP
+Both methods will create an executable in the root directory of the project.
+.PP
+You may also want to generate a base configuration file. Run the following as a regular user to generate the config in
+.IR ~/.config/pkgit :
+.PP
+.RS
+.B make defconfig
+.RE
+.PP
+Alternatively, run as root (using
+.B sudo
+or
+.BR doas )
+to generate the system-wide config in
+.IR /etc/pkgit :
+.PP
+.RS
+.B sudo make defconfig
+.RE
+.SH INSTALLATION
+After compiling, install the package with root privileges:
+.PP
+.RS
+.B make install
+.RE
+.PP
+If you do not have root privileges, or prefer a local installation, you can specify an install location using the
+.B PREFIX
+variable. A common choice is
+.IR ~/.local :
+.PP
+.RS
+.B make install PREFIX="~/.local"
+.RE
+.SH ENVIRONMENT
+Before using programs installed via
+.BR pkgit ,
+ensure the binary path is added to your shell's
+.BR PATH .
+For a local installation (e.g.,
+.IR ~/.local/bin ),
+add the following to your shell configuration:
+.PP
+.TP
+.B Bash / Zsh
+export PATH="$HOME/.local/bin:$PATH"
+.TP
+.B Fish
+fish_add_path $HOME/.local/bin
+.TP
+.B Csh / Tcsh
+setenv PATH $HOME/.local/bin:$PATH
+.SH OPTIONS
+These options modify the behavior of commands.
+.TP
+.BR \-q ", " \-\-quiet
+Minimize logs output to stdout.
+.TP
+.BR \-f ", " \-\-force
+Force the package to be installed, even if it is already installed.
+.SH COMMANDS
+.TP
+.BR \-i ", " \-\-install " \fI<target>\fR"
+Install a package. Assuming the respective repository has been added,
+you can specify the package by name. The \fI<target>\fR argument supports
+several syntax variations:
+.RS
+.TP
+.B Basic install
+.B pkgit \-\-install
+.I pkg_name
+.TP
+.B Specific version
+.B pkgit \-\-install
+.IR pkg_name @ version
+.TP
+.B Specific target
+.B pkgit \-\-install
+.IR pkg_name , target
+(Target is based on configuration in
+.I bldit.lua
+or
+.IR init.lua ).
+.TP
+.B Combined target and version
+.B pkgit \-\-install
+.IR pkg_name , target @ version
+or
+.B pkgit \-\-install
+.IR pkg_name @ version , target
+(Order does not matter as long as the package name is first).
+.TP
+.B Repo install
+.B pkgit \-\-install
+.I url.git
+(Installs directly from a git URL. Works with target and version syntax).
+.TP
+.B Local install
+.B pkgit \-\-install " ."
+(Installs from the local code repository in the current directory,
+taking advantage of pkgit's build system autodetection).
+.RE
+.TP
+.BR \-b ", " \-\-build " \fI[/path/to/project]\fR"
+(Best for developers) Act as a meta-build-system to automatically compile
+any supported project. Can be run from the project's root directory
+without specifying the path.
+.TP
+.BR \-r ", " \-\-remove " \fI<pkg_name>\fR"
+Remove (uninstall) an installed package.
+.TP
+.BR \-u ", " \-\-update
+Update all installed packages.
+.TP
+.BR \-d ", " \-\-declare
+Use the configuration file as a package declaration file to declare
+and install all packages at once.
+.SH EXAMPLES
+.TP
+Install a package quietly, forcing the installation:
+.B pkgit \-qif
+.I mypackage
+.TP
+Install a specific version and target of a package:
+.B pkgit \-i
+.I mypackage,mytarget@1.0.0
+.TP
+Install a package directly from a git repository:
+.B pkgit \-\-install
+.I https://github.com/heather7283/pipemixer
+.TP
+Build the project in the current directory:
+.B pkgit \-\-build
+.SH SEE ALSO
+.BR git (1),
+.BR lua (1)
+.SH AUTHORS
+.B pkgit
+is developed and maintained by the contributors at
+.IR git.symlinx.net/pkgit .)'
diff --git a/include/add_repo.h b/include/add_repo.h
index 1f41e4b..5b32bd7 100644
--- a/include/add_repo.h
+++ b/include/add_repo.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef ADD_REPO_H
#define ADD_REPO_H
diff --git a/include/build.h b/include/build.h
index 18b92e2..18c08fd 100644
--- a/include/build.h
+++ b/include/build.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef BUILD_H
#define BUILD_H
diff --git a/include/cla_parse.h b/include/cla_parse.h
index 68f1c49..19ae172 100644
--- a/include/cla_parse.h
+++ b/include/cla_parse.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef CLA_PARSE_H
#define CLA_PARSE_H
diff --git a/include/cmd_out.h b/include/cmd_out.h
index ff4e882..1b5a35a 100644
--- a/include/cmd_out.h
+++ b/include/cmd_out.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef CMD_OUT_H
#define CMD_OUT_H
diff --git a/include/copy_install.h b/include/copy_install.h
index d0750b6..18ff679 100644
--- a/include/copy_install.h
+++ b/include/copy_install.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef COPY_INSTALL_H
#define COPY_INSTALL_H
diff --git a/include/create_pkg.h b/include/create_pkg.h
index ed6da14..0bad45d 100644
--- a/include/create_pkg.h
+++ b/include/create_pkg.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef CREATE_PKG_H
#define CREATE_PKG_H
diff --git a/include/declare.h b/include/declare.h
index daf2b5b..7b4b979 100644
--- a/include/declare.h
+++ b/include/declare.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef DECLARE
#define DECLARE
void declare();
diff --git a/include/fetch_git.h b/include/fetch_git.h
index 9b9af46..b27661e 100644
--- a/include/fetch_git.h
+++ b/include/fetch_git.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef FETCH_GIT_H
#define FETCH_GIT_H
diff --git a/include/fetch_pwd.h b/include/fetch_pwd.h
index 242d520..e64689b 100644
--- a/include/fetch_pwd.h
+++ b/include/fetch_pwd.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef FETCH_PWD_H
#define FETCH_PWD_H
diff --git a/include/fetch_src.h b/include/fetch_src.h
index 089776c..fd647d5 100644
--- a/include/fetch_src.h
+++ b/include/fetch_src.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef FETCH_SRC_H
#define FETCH_SRC_H
diff --git a/include/files.h b/include/files.h
index fac3a1e..cc72ace 100644
--- a/include/files.h
+++ b/include/files.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef FILES
#define FILES
const char *get_filename_ext(const char *filename);
diff --git a/include/help.h b/include/help.h
index dc2c7a3..c194be4 100644
--- a/include/help.h
+++ b/include/help.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef HELP_H
#define HELP_H
diff --git a/include/install_pkg.h b/include/install_pkg.h
index 52ce9c0..c35d8e3 100644
--- a/include/install_pkg.h
+++ b/include/install_pkg.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef INSTALL_PKG_H
#define INSTALL_PKG_H
diff --git a/include/is_updated.h b/include/is_updated.h
index a5ba31f..05cea76 100644
--- a/include/is_updated.h
+++ b/include/is_updated.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef IS_UPDATED_H
#define IS_UPDATED_H
diff --git a/include/link_install.h b/include/link_install.h
index a9528bb..084559b 100644
--- a/include/link_install.h
+++ b/include/link_install.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef LINK_INSTALL_H
#define LINK_INSTALL_H
diff --git a/include/list_pkgs.h b/include/list_pkgs.h
index 6a00ad6..3ae6900 100644
--- a/include/list_pkgs.h
+++ b/include/list_pkgs.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef LIST_PKGS_H
#define LIST_PKGS_H
diff --git a/include/lua_build.h b/include/lua_build.h
index 401a591..70c2e8b 100644
--- a/include/lua_build.h
+++ b/include/lua_build.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef LUA_BUILD_H
#define LUA_BUILD_H
diff --git a/include/lua_state.h b/include/lua_state.h
index f8564b9..e026ec4 100644
--- a/include/lua_state.h
+++ b/include/lua_state.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef LUA_STATE_H
#define LUA_STATE_H
diff --git a/include/name_from_url.h b/include/name_from_url.h
index fc80b45..ab2761b 100644
--- a/include/name_from_url.h
+++ b/include/name_from_url.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef NAME_FROM_URL_H
#define NAME_FROM_URL_H
diff --git a/include/remove_pkg.h b/include/remove_pkg.h
index 66ee5aa..4ac5ca0 100644
--- a/include/remove_pkg.h
+++ b/include/remove_pkg.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef REMOVE_PKG_H
#define REMOVE_PKG_H
diff --git a/include/resolve_deps.h b/include/resolve_deps.h
index 3874932..1e0b8ee 100644
--- a/include/resolve_deps.h
+++ b/include/resolve_deps.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef RESOLVE_DEPS_H
#define RESOLVE_DEPS_H
void resolve_deps(void);
diff --git a/include/search.h b/include/search.h
index 991a885..a316a71 100644
--- a/include/search.h
+++ b/include/search.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef FIND
#define FIND
void search(const char* arg);
diff --git a/include/set_install_directories.h b/include/set_install_directories.h
index b89330b..22886e1 100644
--- a/include/set_install_directories.h
+++ b/include/set_install_directories.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef SET_INSTALL_DIRECTORIES_H
#define SET_INSTALL_DIRECTORIES_H
diff --git a/include/setup_dirs.h b/include/setup_dirs.h
index 8d07748..4490948 100644
--- a/include/setup_dirs.h
+++ b/include/setup_dirs.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef SETUP_DIRS_H
#define SETUP_DIRS_H
diff --git a/include/setup_pkgit.h b/include/setup_pkgit.h
index 3c32fd1..9554969 100644
--- a/include/setup_pkgit.h
+++ b/include/setup_pkgit.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef SETUP_PKGIT_H
#define SETUP_PKGIT_H
diff --git a/include/update_all.h b/include/update_all.h
index 3d40e75..022c92b 100644
--- a/include/update_all.h
+++ b/include/update_all.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef UPDATE_ALL_H
#define UPDATE_ALL_H
diff --git a/include/update_pkg.h b/include/update_pkg.h
index 95d9aa8..8d3a993 100644
--- a/include/update_pkg.h
+++ b/include/update_pkg.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef UPDATE_PKG_H
#define UPDATE_PKG_H
diff --git a/include/vars.h b/include/vars.h
index 58cf634..53a5203 100644
--- a/include/vars.h
+++ b/include/vars.h
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#ifndef VARS_H
#define VARS_H
diff --git a/src/add_repo.c b/src/add_repo.c
index 71c3dda..11752b6 100644
--- a/src/add_repo.c
+++ b/src/add_repo.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
diff --git a/src/build.c b/src/build.c
index 5e96f52..66b9484 100644
--- a/src/build.c
+++ b/src/build.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/cla_parse.c b/src/cla_parse.c
index 3ca79ca..f2e7b2e 100644
--- a/src/cla_parse.c
+++ b/src/cla_parse.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <string.h>
diff --git a/src/cmd_out.c b/src/cmd_out.c
index b800149..269d6f2 100644
--- a/src/cmd_out.c
+++ b/src/cmd_out.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/create_pkg.c b/src/create_pkg.c
index cb35ad0..6aae657 100644
--- a/src/create_pkg.c
+++ b/src/create_pkg.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/declare.c b/src/declare.c
index d01468a..07bf68d 100644
--- a/src/declare.c
+++ b/src/declare.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/fetch_git.c b/src/fetch_git.c
index f47b881..7116e9e 100644
--- a/src/fetch_git.c
+++ b/src/fetch_git.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
diff --git a/src/fetch_pwd.c b/src/fetch_pwd.c
index 7e2f2e4..e04bb31 100644
--- a/src/fetch_pwd.c
+++ b/src/fetch_pwd.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/src/fetch_src.c b/src/fetch_src.c
index 8646b1d..d3698db 100644
--- a/src/fetch_src.c
+++ b/src/fetch_src.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <ftw.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/files.c b/src/files.c
index 38e87be..0cd301d 100644
--- a/src/files.c
+++ b/src/files.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/src/help.c b/src/help.c
index 659caad..d7e01a0 100644
--- a/src/help.c
+++ b/src/help.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include "help.h"
diff --git a/src/install_pkg.c b/src/install_pkg.c
index 32a84cd..80c6fd9 100644
--- a/src/install_pkg.c
+++ b/src/install_pkg.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/is_updated.c b/src/is_updated.c
index 124677a..3e1dd43 100644
--- a/src/is_updated.c
+++ b/src/is_updated.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -24,6 +44,7 @@ bool is_updated(const char *src) {
bool is_bldit_usable() {
char* bldit_version = bldit_getver();
+ if (!bldit_version) return false;
if (strcmp(bldit_version, version) == 0) return true;
bool prev_pass = false;
for (size_t i = 0; i < strlen(bldit_version); i++) {
diff --git a/src/list_pkgs.c b/src/list_pkgs.c
index 6d4ba3f..ccc0e8a 100644
--- a/src/list_pkgs.c
+++ b/src/list_pkgs.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <dirent.h>
#include <stdio.h>
#include <string.h>
diff --git a/src/lua_build.c b/src/lua_build.c
index 7a289fd..520117c 100644
--- a/src/lua_build.c
+++ b/src/lua_build.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <stdbool.h>
diff --git a/src/lua_state.c b/src/lua_state.c
index ed3f1cc..39dd089 100644
--- a/src/lua_state.c
+++ b/src/lua_state.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
@@ -17,754 +37,747 @@ static lua_State *B = NULL;
static bool bldit_loaded = false;
void push_lua_path(lua_State *L, const char *new_path) {
- lua_getglobal(L, "package");
- lua_getfield(L, -1, "path");
- const char *current_path = lua_tostring(L, -1);
- if (!current_path)
- current_path = "";
- lua_pop(L, 1);
- lua_pushfstring(L, "%s;%s", current_path, new_path);
- lua_setfield(L, -2, "path");
- lua_pop(L, 1);
+ lua_getglobal(L, "package");
+ lua_getfield(L, -1, "path");
+ const char *current_path = lua_tostring(L, -1);
+ if (!current_path) current_path = "";
+ lua_pop(L, 1);
+ lua_pushfstring(L, "%s;%s", current_path, new_path);
+ lua_setfield(L, -2, "path");
+ lua_pop(L, 1);
}
void init_lua_state() {
- if (L != NULL)
- return;
- L = luaL_newstate();
- luaL_openlibs(L);
- char lua_path[MAX_PATH_LEN + 20];
- snprintf(lua_path, sizeof(lua_path), "%s/?.lua", config_dir);
- push_lua_path(L, lua_path);
- if (luaL_loadfile(L, config_file) || lua_pcall(L, 0, 0, 0)) {
- printf(
- "%s cannot run configuration script: %s\n",
- print_error, lua_tostring(L, -1)
- );
- printf("%s to generate a configuration file, head into the", print_pkgit);
- printf(" root directory of the pkgit source and run `make defconfig`\n");
- exit(EXIT_FAILURE);
- }
- if (file_exists(repo_file)) {
- if (luaL_loadfile(L, repo_file) || lua_pcall(L, 0, 0, 0)) {
- printf(
- "%s cannot load repository file: %s\n",
- print_error, lua_tostring(L, -1)
- );
- lua_pop(L, 1);
- }
- }
- config_loaded = true;
+ if (L != NULL) return;
+ L = luaL_newstate();
+ luaL_openlibs(L);
+ char lua_path[MAX_PATH_LEN + 20];
+ snprintf(lua_path, sizeof(lua_path), "%s/?.lua", config_dir);
+ push_lua_path(L, lua_path);
+ if (luaL_loadfile(L, config_file) || lua_pcall(L, 0, 0, 0)) {
+ printf(
+ "%s cannot run configuration script: %s\n",
+ print_error, lua_tostring(L, -1)
+ );
+ printf(
+ "%s to generate a configuration file, head into the",
+ print_pkgit
+ );
+ printf(
+ " root directory of the pkgit source and run `make defconfig`\n"
+ );
+ exit(EXIT_FAILURE);
+ }
+ if (file_exists(repo_file)) {
+ if (luaL_loadfile(L, repo_file) || lua_pcall(L, 0, 0, 0)) {
+ printf(
+ "%s cannot load repository file: %s\n",
+ print_error, lua_tostring(L, -1)
+ );
+ lua_pop(L, 1);
+ }
+ }
+ config_loaded = true;
}
void init_bldit() {
- if (B != NULL)
- return;
- B = luaL_newstate();
- luaL_openlibs(B);
- if (luaL_loadfile(B, "bldit.lua") || lua_pcall(B, 0, 0, 0)) {
- if (is_verbose) printf(
- "%s cannot run bldit script: %s\n",
- print_warning, lua_tostring(B, -1)
- );
- return;
- }
- bldit_loaded = true;
+ if (B != NULL) return;
+ B = luaL_newstate();
+ luaL_openlibs(B);
+ if (luaL_loadfile(B, "bldit.lua") || lua_pcall(B, 0, 0, 0)) {
+ if (is_verbose) printf(
+ "%s cannot run bldit script: %s\n",
+ print_warning, lua_tostring(B, -1)
+ );
+ return;
+ }
+ bldit_loaded = true;
}
void free_lua_state() {
- if (L != NULL) {
- lua_close(L);
- L = NULL;
- }
- config_loaded = false;
+ if (L != NULL) {
+ lua_close(L);
+ L = NULL;
+ }
+ config_loaded = false;
}
lua_State *get_lua_state() { return L; }
void cache_prefix_directory() {
- lua_getglobal(L, "prefix");
- if (!lua_isstring(L, -1)) {
- printf(
- "%s init.lua: 'prefix' is not a string.\n",
- print_error
- );
- return;
- }
- snprintf(prefix_dir, MAX_PATH_LEN, "%s", lua_tostring(L, -1));
- lua_pop(L, 1);
+ lua_getglobal(L, "prefix");
+ if (!lua_isstring(L, -1)) {
+ printf(
+ "%s init.lua: 'prefix' is not a string.\n",
+ print_error
+ );
+ return;
+ }
+ snprintf(prefix_dir, MAX_PATH_LEN, "%s", lua_tostring(L, -1));
+ lua_pop(L, 1);
}
void cache_install_directories() {
- if (!config_loaded || !lua_istable(L, -1)) {
- lua_getglobal(L, "install_directories");
- }
- if (!lua_istable(L, -1)) {
- printf(
- "%s init.lua: 'install_directories' is not a table.\n",
- print_error
- );
- return;
- }
- lua_pushnil(L);
- while (lua_next(L, -2) != 0) {
- const char *key = lua_tostring(L, -2);
- const char *value = lua_tostring(L, -1);
- if (key && value) {
- map_put(&cached_install_directories, strdup(key), strdup(value));
- }
- lua_pop(L, 1);
- }
- lua_pop(L, 1);
+ if (!config_loaded || !lua_istable(L, -1)) {
+ lua_getglobal(L, "install_directories");
+ }
+ if (!lua_istable(L, -1)) {
+ printf(
+ "%s init.lua: 'install_directories' is not a table.\n",
+ print_error
+ );
+ return;
+ }
+ lua_pushnil(L);
+ while (lua_next(L, -2) != 0) {
+ const char *key = lua_tostring(L, -2);
+ const char *value = lua_tostring(L, -1);
+ if (key && value) {
+ map_put(&cached_install_directories, strdup(key), strdup(value));
+ }
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
}
void install_dependencies(lua_State *L) {
- while (lua_next(L, -2) != 0) {
- const char *depname = lua_tostring(L, -2);
- if (depname && lua_istable(L, -1)) {
- lua_getfield(L, -1, "url");
- const char *dep_url = lua_tostring(L, -1);
- lua_pop(L, 1);
- lua_getfield(L, -1, "version");
- const char *dep_version = lua_tostring(L, -1);
- lua_pop(L, 1);
- Pkg pkg = create_pkg(dep_url);
- pkg.ver = strdup(dep_version);
- const int top = lua_gettop(L);
- char cwd[PATH_MAX];
- if (getcwd(cwd, sizeof(cwd)) != NULL) {
- install_pkg(pkg);
- chdir(cwd);
- }
- lua_settop(L, top);
- }
- lua_pop(L, 1);
- }
+ while (lua_next(L, -2) != 0) {
+ const char *depname = lua_tostring(L, -2);
+ if (depname && lua_istable(L, -1)) {
+ lua_getfield(L, -1, "url");
+ const char *dep_url = lua_tostring(L, -1);
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "version");
+ const char *dep_version = lua_tostring(L, -1);
+ lua_pop(L, 1);
+ Pkg pkg = create_pkg(dep_url);
+ pkg.ver = strdup(dep_version);
+ const int top = lua_gettop(L);
+ char cwd[PATH_MAX];
+ if (getcwd(cwd, sizeof(cwd)) != NULL) {
+ install_pkg(pkg);
+ chdir(cwd);
+ }
+ lua_settop(L, top);
+ }
+ lua_pop(L, 1);
+ }
}
bool target_loop_build(
- lua_State *L, const char* lua_file, const char *target
+ lua_State *L, const char* lua_file, const char *target
) {
- lua_getfield(L, -1, target);
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s' is not a table.\n",
- print_warning, lua_file, target
- );
- lua_pop(L, 1);
- return false;
- }
- lua_getfield(L, -1, "dependencies");
- if (lua_istable(L, -1)) {
- lua_pushnil(L);
- install_dependencies(L);
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "build");
- if (!lua_isfunction(L, -1)) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s.build' is not a function.\n",
- print_warning, lua_file, target
- );
- lua_pop(L, 3);
- return false;
- }
- if (lua_pcall(L, 0, 1, 0) != LUA_OK) {
- printf(
- "%s %s: 'targets.%s.build' function borked: %s\n",
- print_error, lua_file, target, lua_tostring(L, -1)
- );
- lua_pop(L, 3);
- return false;
- }
- if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
- printf(
- "%s %s: 'targets.%s.build' failed: %s\n",
- print_error, lua_file, target, lua_tostring(L, -1)
- );
- lua_pop(L, 3);
- return false;
- }
- lua_pop(L, 3);
- return true;
+ lua_getfield(L, -1, target);
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s' is not a table.\n",
+ print_warning, lua_file, target
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ lua_getfield(L, -1, "dependencies");
+ if (lua_istable(L, -1)) {
+ lua_pushnil(L);
+ install_dependencies(L);
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "build");
+ if (!lua_isfunction(L, -1)) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s.build' is not a function.\n",
+ print_warning, lua_file, target
+ );
+ lua_pop(L, 3);
+ return false;
+ }
+ if (lua_pcall(L, 0, 1, 0) != LUA_OK) {
+ printf(
+ "%s %s: 'targets.%s.build' function borked: %s\n",
+ print_error, lua_file, target, lua_tostring(L, -1)
+ );
+ lua_pop(L, 3);
+ return false;
+ }
+ if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
+ printf(
+ "%s %s: 'targets.%s.build' failed: %s\n",
+ print_error, lua_file, target, lua_tostring(L, -1)
+ );
+ lua_pop(L, 3);
+ return false;
+ }
+ lua_pop(L, 3);
+ return true;
}
-bool target_loop_install(lua_State *L, const char* lua_file, const char *target) {
- lua_getfield(L, -1, target);
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s' is not a table.\n",
- print_warning, lua_file, target
- );
- lua_pop(L, 1);
- return false;
- }
- lua_getfield(L, -1, "pre_install");
- if (!lua_isfunction(L, -1)) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s.pre_install' is not a function.\n",
- print_warning, lua_file, target
- );
- } else if (lua_pcall(L, 0, 1, 0) != LUA_OK) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s.pre_install' function borked: %s\n",
- print_warning, lua_file, target, lua_tostring(L, -1)
- );
- if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
- printf(
- "%s %s: 'targets.%s.pre_install' failed: %d\n",
- print_error, lua_file, target, (int)lua_tonumber(L, -1)
- );
- return false;
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "install");
- if (!lua_isfunction(L, -1)) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s.install' is not a function.\n",
- print_warning, lua_file, target
- );
- lua_pop(L, 1);
- return false;
- }
- if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s.install' function borked: %s\n",
- print_warning, lua_file, target, lua_tostring(L, -1)
- );
- lua_pop(L, 1);
- return false;
- }
- if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
- printf(
- "%s %s: 'targets.%s.install' failed: %d\n",
- print_error, lua_file, target, (int)lua_tonumber(L, -1)
- );
- lua_pop(L, 1);
- return false;
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "post_install");
- if (!lua_isfunction(L, -1)) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s.post_install' is not a function.\n",
- print_warning, lua_file, target
- );
- } else if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s.post_install' function borked: %s\n",
- print_warning, lua_file, target, lua_tostring(L, -1)
- );
- if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
- printf(
- "%s %s: 'targets.%s.post_install' failed: %s\n",
- print_error, lua_file, target, lua_tostring(L, -1)
- );
- }
- }
- lua_pop(L, 1);
- return true;
+bool target_loop_install(
+ lua_State *L, const char* lua_file,
+ const char *target
+) {
+ lua_getfield(L, -1, target);
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s' is not a table.\n",
+ print_warning, lua_file, target
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ lua_getfield(L, -1, "pre_install");
+ if (!lua_isfunction(L, -1)) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s.pre_install' is not a function.\n",
+ print_warning, lua_file, target
+ );
+ } else if (lua_pcall(L, 0, 1, 0) != LUA_OK) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s.pre_install' function borked: %s\n",
+ print_warning, lua_file, target, lua_tostring(L, -1)
+ );
+ if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
+ printf(
+ "%s %s: 'targets.%s.pre_install' failed: %d\n",
+ print_error, lua_file, target, (int)lua_tonumber(L, -1)
+ );
+ return false;
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "install");
+ if (!lua_isfunction(L, -1)) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s.install' is not a function.\n",
+ print_warning, lua_file, target
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s.install' function borked: %s\n",
+ print_warning, lua_file, target, lua_tostring(L, -1)
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
+ printf(
+ "%s %s: 'targets.%s.install' failed: %d\n",
+ print_error, lua_file, target, (int)lua_tonumber(L, -1)
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "post_install");
+ if (!lua_isfunction(L, -1)) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s.post_install' is not a function.\n",
+ print_warning, lua_file, target
+ );
+ } else if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s.post_install' function borked: %s\n",
+ print_warning, lua_file, target, lua_tostring(L, -1)
+ );
+ if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
+ printf(
+ "%s %s: 'targets.%s.post_install' failed: %s\n",
+ print_error, lua_file, target, lua_tostring(L, -1)
+ );
+ }
+ }
+ lua_pop(L, 1);
+ return true;
}
bool target_loop_uninstall(lua_State *L, const char *lua_file, const char *target) {
- lua_getfield(L, -1, target);
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s' is not a table.\n",
- print_warning, lua_file, target
- );
- lua_pop(L, 1);
- return false;
- }
- lua_getfield(L, -1, "uninstall");
- if (!lua_isfunction(L, -1)) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s.uninstall' is not a function.\n",
- print_warning, lua_file, target
- );
- lua_pop(L, 1);
- return false;
- }
- if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
- if (is_verbose) printf(
- "%s %s: 'targets.%s.uninstall' function borked: %s\n",
- print_warning, lua_file, target, lua_tostring(L, -1)
- );
- lua_pop(L, 1);
- return false;
- }
- if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
- printf(
- "%s %s: 'targets.%s.uninstall' failed: %s\n",
- print_error, lua_file, target, lua_tostring(L, -1)
- );
- lua_pop(L, 1);
- return false;
- }
- lua_pop(L, 1);
- return true;
+ lua_getfield(L, -1, target);
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s' is not a table.\n",
+ print_warning, lua_file, target
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ lua_getfield(L, -1, "uninstall");
+ if (!lua_isfunction(L, -1)) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s.uninstall' is not a function.\n",
+ print_warning, lua_file, target
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
+ if (is_verbose) printf(
+ "%s %s: 'targets.%s.uninstall' function borked: %s\n",
+ print_warning, lua_file, target, lua_tostring(L, -1)
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) {
+ printf(
+ "%s %s: 'targets.%s.uninstall' failed: %s\n",
+ print_error, lua_file, target, lua_tostring(L, -1)
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ lua_pop(L, 1);
+ return true;
}
bool repo_build(const char *repository, const char *target) {
- lua_getglobal(L, "repositories");
- if (!config_loaded || !lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories' is not a table.\n",
- print_warning
- );
- lua_pop(L, 1);
- return false;
- }
- lua_getfield(L, -1, repository);
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories.%s' is not a table.\n",
- print_warning, repository
- );
- lua_pop(L, 2);
- return false;
- }
-
- lua_getfield(L, -1, "dependencies");
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories.%s.dependencies' is not a table.\n",
- print_warning, repository
- );
- } else {
- lua_pushnil(L);
- install_dependencies(L);
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "targets");
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories.%s.targets' is not a table.\n",
- print_warning, repository
- );
- return false;
- }
- bool target_loop_success = target_loop_build(L, "init.lua", target);
- lua_pop(L, 3);
- return target_loop_success;
+ lua_getglobal(L, "repositories");
+ if (!config_loaded || !lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories' is not a table.\n",
+ print_warning
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ lua_getfield(L, -1, repository);
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories.%s' is not a table.\n",
+ print_warning, repository
+ );
+ lua_pop(L, 2);
+ return false;
+ }
+
+ lua_getfield(L, -1, "dependencies");
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories.%s.dependencies' is not a table.\n",
+ print_warning, repository
+ );
+ } else {
+ lua_pushnil(L);
+ install_dependencies(L);
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "targets");
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories.%s.targets' is not a table.\n",
+ print_warning, repository
+ );
+ return false;
+ }
+ bool target_loop_success = target_loop_build(L, "init.lua", target);
+ lua_pop(L, 3);
+ return target_loop_success;
}
bool repo_install(const char *repository, const char* target) {
- lua_getglobal(L, "repositories");
- if (!config_loaded || !lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories' is not a table.\n",
- print_warning
- );
- lua_pop(L, 1);
- return false;
- }
- lua_getfield(L, -1, repository);
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories.%s' is not a table.\n",
- print_warning, repository
- );
- lua_pop(L, 2);
- return false;
- }
-
- lua_getfield(L, -1, "targets");
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories.%s.targets' is not a table.\n",
- print_warning, repository
- );
- return false;
- }
- bool target_loop_success = target_loop_install(L, "init.lua", target);
- lua_pop(L, 3);
- return target_loop_success;
+ lua_getglobal(L, "repositories");
+ if (!config_loaded || !lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories' is not a table.\n",
+ print_warning
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ lua_getfield(L, -1, repository);
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories.%s' is not a table.\n",
+ print_warning, repository
+ );
+ lua_pop(L, 2);
+ return false;
+ }
+ lua_getfield(L, -1, "targets");
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories.%s.targets' is not a table.\n",
+ print_warning, repository
+ );
+ return false;
+ }
+ bool target_loop_success = target_loop_install(L, "init.lua", target);
+ lua_pop(L, 3);
+ return target_loop_success;
}
bool repo_uninstall(const char *repository, const char *target) {
- lua_getglobal(L, "repositories");
- if (!config_loaded || !lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories' is not a table.\n",
- print_warning
- );
- lua_pop(L, 1);
- return false;
- }
- lua_getfield(L, -1, repository);
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories.%s' is not a table.\n",
- print_warning, repository
- );
- lua_pop(L, 2);
- return false;
- }
-
- lua_getfield(L, -1, "targets");
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'repositories.%s.targets' is not a table.\n",
- print_warning, repository
- );
- return false;
- }
- bool target_loop_success = target_loop_uninstall(L, "init.lua", target);
- lua_pop(L, 2);
- return target_loop_success;
+ lua_getglobal(L, "repositories");
+ if (!config_loaded || !lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories' is not a table.\n",
+ print_warning
+ );
+ lua_pop(L, 1);
+ return false;
+ }
+ lua_getfield(L, -1, repository);
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories.%s' is not a table.\n",
+ print_warning, repository
+ );
+ lua_pop(L, 2);
+ return false;
+ }
+ lua_getfield(L, -1, "targets");
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'repositories.%s.targets' is not a table.\n",
+ print_warning, repository
+ );
+ return false;
+ }
+ bool target_loop_success = target_loop_uninstall(L, "init.lua", target);
+ lua_pop(L, 2);
+ return target_loop_success;
}
char* bldit_getver() {
- init_bldit();
- lua_getglobal(B, "bldit_version");
- if (!lua_isstring(B, -1)) {
- if (is_verbose)
- printf("%s bldit.lua: 'bldit_version' is not a string.\n", print_warning);
- return NULL;
- }
- const char* bldit_version = lua_tostring(B, -1);
- return strdup(bldit_version);
+ init_bldit();
+ lua_getglobal(B, "bldit_version");
+ if (!lua_isstring(B, -1)) {
+ if (is_verbose) printf(
+ "%s bldit.lua: 'bldit_version' is not a string.\n",
+ print_warning
+ );
+ lua_pop(B, 1);
+ return NULL;
+ }
+ const char* bldit_version = lua_tostring(B, -1);
+ lua_pop(B, 1);
+ return strdup(bldit_version);
}
char* bldit_pkg_getver() {
- init_bldit();
- lua_getglobal(B, "package_version");
- if (!lua_isstring(B, -1)) {
- if (is_verbose)
- printf("%s bldit.lua: 'package_version' is not a string.\n", print_warning);
- return NULL;
- }
- const char* package_version = lua_tostring(B, -1);
- return strdup(package_version);
+ init_bldit();
+ lua_getglobal(B, "package_version");
+ if (!lua_isstring(B, -1)) {
+ if (is_verbose) printf(
+ "%s bldit.lua: 'package_version' is not a string.\n",
+ print_warning
+ );
+ lua_pop(B, 1);
+ return NULL;
+ }
+ const char* package_version = lua_tostring(B, -1);
+ lua_pop(B, 1);
+ return strdup(package_version);
}
bool bldit(const char *target) {
- lua_State *B = luaL_newstate();
- luaL_openlibs(B);
-
- if (luaL_loadfile(B, "bldit.lua") || lua_pcall(B, 0, 0, 0)) {
- if (is_verbose) printf(
- "%s cannot run bldit script: %s\n",
- print_warning, lua_tostring(B, -1)
- );
- lua_close(B);
- return false;
- }
-
- if (!is_bldit_usable()) {
- printf(
- "%s bldit version is newer than the installed pkgit version\n",
- print_error
- );
- printf(
- "%s consider updating pkgit\n",
- print_pkgit
- );
- if (!is_forced) return false;
- }
-
- lua_pushfstring(B, "%s", prefix_dir);
- lua_setglobal(B, "prefix");
- lua_pop(B, 1);
-
- lua_getglobal(B, "dependencies");
- if (!lua_istable(B, -1)) {
- if (is_verbose) printf("%s bldit.lua: 'dependencies' is not a table.\n", print_warning);
- } else {
- lua_pushnil(B);
- install_dependencies(B);
- }
- lua_pop(B, 1);
-
- lua_getglobal(B, "targets");
- if (!lua_istable(B, -1)) {
- if (is_verbose) printf("%s bldit.lua: 'targets' is not a table.\n", print_warning);
- lua_close(B);
- return false;
- }
-
- bool target_loop_success = target_loop_build(B, "bldit.lua", target);
- lua_pop(B, 2);
- lua_close(B);
- return target_loop_success;
+ lua_State *B = luaL_newstate();
+ luaL_openlibs(B);
+ if (luaL_loadfile(B, "bldit.lua") || lua_pcall(B, 0, 0, 0)) {
+ if (is_verbose) printf(
+ "%s cannot run bldit script: %s\n",
+ print_warning, lua_tostring(B, -1)
+ );
+ lua_close(B);
+ return false;
+ }
+ if (!is_bldit_usable()) {
+ printf(
+ "%s bldit version is newer than the installed pkgit version\n",
+ print_error
+ );
+ printf(
+ "%s consider updating pkgit\n",
+ print_pkgit
+ );
+ if (!is_forced) return false;
+ }
+ lua_pushfstring(B, "%s", prefix_dir);
+ lua_setglobal(B, "prefix");
+ lua_pop(B, 1);
+ lua_getglobal(B, "dependencies");
+ if (!lua_istable(B, -1)) {
+ if (is_verbose) printf(
+ "%s bldit.lua: 'dependencies' is not a table.\n", print_warning
+ );
+ } else {
+ lua_pushnil(B);
+ install_dependencies(B);
+ }
+ lua_pop(B, 1);
+ lua_getglobal(B, "targets");
+ if (!lua_istable(B, -1)) {
+ if (is_verbose) printf(
+ "%s bldit.lua: 'targets' is not a table.\n", print_warning
+ );
+ lua_close(B);
+ return false;
+ }
+ bool target_loop_success = target_loop_build(B, "bldit.lua", target);
+ lua_pop(B, 2);
+ lua_close(B);
+ return target_loop_success;
}
bool bldit_install(const char *target) {
- lua_State *B = luaL_newstate();
- luaL_openlibs(B);
-
- if (luaL_loadfile(B, "bldit.lua") || lua_pcall(B, 0, 0, 0)) {
- if (is_verbose) printf(
- "%s cannot run bldit script: %s\n",
- print_warning, lua_tostring(B, -1)
- );
- lua_close(B);
- return false;
- }
-
- if (!is_bldit_usable()) {
- printf(
- "%s bldit version is newer than the installed pkgit version\n",
- print_error
- );
- printf(
- "%s consider updating pkgit\n",
- print_pkgit
- );
- if (!is_forced) return false;
- }
-
- lua_pushfstring(B, "%s", prefix_dir);
- lua_setglobal(B, "prefix");
- lua_pop(B, 1);
-
- lua_getglobal(B, "targets");
- if (!lua_istable(B, -1)) {
- if (is_verbose) printf(
- "%s bldit.lua: 'targets' is not a table.\n",
- print_warning
- );
- lua_pop(B, 1);
- lua_close(B);
- return false;
- }
-
- bool target_loop_success = target_loop_install(B, "bldit.lua", target);
- lua_pop(B, 1);
- lua_close(B);
- return target_loop_success;
+ lua_State *B = luaL_newstate();
+ luaL_openlibs(B);
+ if (luaL_loadfile(B, "bldit.lua") || lua_pcall(B, 0, 0, 0)) {
+ if (is_verbose) printf(
+ "%s cannot run bldit script: %s\n",
+ print_warning, lua_tostring(B, -1)
+ );
+ lua_close(B);
+ return false;
+ }
+ if (!is_bldit_usable()) {
+ printf(
+ "%s bldit version is newer than the installed pkgit version\n",
+ print_error
+ );
+ printf(
+ "%s consider updating pkgit\n",
+ print_pkgit
+ );
+ if (!is_forced) return false;
+ }
+ lua_pushfstring(B, "%s", prefix_dir);
+ lua_setglobal(B, "prefix");
+ lua_pop(B, 1);
+ lua_getglobal(B, "targets");
+ if (!lua_istable(B, -1)) {
+ if (is_verbose) printf(
+ "%s bldit.lua: 'targets' is not a table.\n",
+ print_warning
+ );
+ lua_pop(B, 1);
+ lua_close(B);
+ return false;
+ }
+ bool target_loop_success = target_loop_install(B, "bldit.lua", target);
+ lua_pop(B, 1);
+ lua_close(B);
+ return target_loop_success;
}
bool bldit_uninstall(const char *target) {
- lua_State *B = luaL_newstate();
- luaL_openlibs(B);
-
- if (luaL_loadfile(B, "bldit.lua") || lua_pcall(B, 0, 0, 0)) {
- if (is_verbose) printf(
- "%s cannot run bldit script: %s\n",
- print_warning, lua_tostring(B, -1)
- );
- lua_close(B);
- return false;
- }
-
- if (!is_bldit_usable()) {
- printf(
- "%s bldit version is newer than the installed pkgit version\n",
- print_error
- );
- printf(
- "%s consider updating pkgit\n",
- print_pkgit
- );
- if (!is_forced) return false;
- }
-
- lua_pushfstring(B, "%s", prefix_dir);
- lua_setglobal(B, "prefix");
- lua_pop(B, 1);
-
- lua_getglobal(B, "targets");
- if (!lua_istable(B, -1)) {
- if (is_verbose) printf(
- "%s bldit.lua: 'targets' is not a table.\n",
- print_warning
- );
- lua_close(B);
- return false;
- }
-
- lua_getfield(B, -1, target);
- if (!lua_istable(B, -1)) {
- if (is_verbose) printf(
- "%s bldit.lua: 'targets.%s' is not a table.\n",
- print_warning, target
- );
- lua_pop(B, 2);
- lua_close(B);
- return false;
- }
-
- lua_getglobal(B, "targets");
- if (!lua_istable(B, -1)) {
- if (is_verbose) printf("%s bldit.lua: 'targets' is not a table.\n", print_warning);
- lua_close(B);
- return false;
- }
- bool target_loop_success = target_loop_uninstall(B, "bldit.lua", target);
- lua_pop(B, 1);
- lua_close(B);
- return target_loop_success;
+ lua_State *B = luaL_newstate();
+ luaL_openlibs(B);
+ if (luaL_loadfile(B, "bldit.lua") || lua_pcall(B, 0, 0, 0)) {
+ if (is_verbose) printf(
+ "%s cannot run bldit script: %s\n",
+ print_warning, lua_tostring(B, -1)
+ );
+ lua_close(B);
+ return false;
+ }
+ if (!is_bldit_usable()) {
+ printf(
+ "%s bldit version is newer than the installed pkgit version\n",
+ print_error
+ );
+ printf(
+ "%s consider updating pkgit\n",
+ print_pkgit
+ );
+ if (!is_forced) return false;
+ }
+ lua_pushfstring(B, "%s", prefix_dir);
+ lua_setglobal(B, "prefix");
+ lua_pop(B, 1);
+ lua_getglobal(B, "targets");
+ if (!lua_istable(B, -1)) {
+ if (is_verbose) printf(
+ "%s bldit.lua: 'targets' is not a table.\n",
+ print_warning
+ );
+ lua_close(B);
+ return false;
+ }
+ lua_getfield(B, -1, target);
+ if (!lua_istable(B, -1)) {
+ if (is_verbose) printf(
+ "%s bldit.lua: 'targets.%s' is not a table.\n",
+ print_warning, target
+ );
+ lua_pop(B, 2);
+ lua_close(B);
+ return false;
+ }
+ lua_getglobal(B, "targets");
+ if (!lua_istable(B, -1)) {
+ if (is_verbose) printf("%s bldit.lua: 'targets' is not a table.\n", print_warning);
+ lua_close(B);
+ return false;
+ }
+ bool target_loop_success = target_loop_uninstall(B, "bldit.lua", target);
+ lua_pop(B, 1);
+ lua_close(B);
+ return target_loop_success;
}
void cache_repos() {
- cached_repos_count = 0;
- lua_getglobal(L, "repositories");
- if (!config_loaded || !lua_istable(L, -1)) {
- printf(
- "%s init.lua: 'repositories' is not a table.\n",
- print_error
- );
- lua_pop(L, 1);
- return;
- }
- lua_pushnil(L);
- while (lua_next(L, -2) != 0) {
- const char *repo_name = lua_tostring(L, -2);
- if (!repo_name || !lua_istable(L, -1)) {
- printf("%s init.lua: 'repositories.%s' is not a table\n", print_error, repo_name);
- lua_pop(L, 1);
- continue;
- }
- Repo *repo = &cached_repos[cached_repos_count];
- repo->source_key = strdup(repo_name);
- lua_getfield(L, -1, "url");
- const char *url = lua_tostring(L, -1);
- repo->source_value = url ? strdup(url) : strdup("");
- lua_pop(L, 1);
- lua_getfield(L, -1, "version");
- const char *version = lua_tostring(L, -1);
- repo->version = version ? strdup(version) : strdup("HEAD");
- lua_pop(L, 1);
- lua_pop(L, 1);
- cached_repos_count++;
- }
- lua_pop(L, 1);
+ cached_repos_count = 0;
+ lua_getglobal(L, "repositories");
+ if (!config_loaded || !lua_istable(L, -1)) {
+ printf(
+ "%s init.lua: 'repositories' is not a table.\n",
+ print_error
+ );
+ lua_pop(L, 1);
+ return;
+ }
+ lua_pushnil(L);
+ while (lua_next(L, -2) != 0) {
+ const char *repo_name = lua_tostring(L, -2);
+ if (!repo_name || !lua_istable(L, -1)) {
+ printf("%s init.lua: 'repositories.%s' is not a table\n", print_error, repo_name);
+ lua_pop(L, 1);
+ continue;
+ }
+ Repo *repo = &cached_repos[cached_repos_count];
+ repo->source_key = strdup(repo_name);
+ lua_getfield(L, -1, "url");
+ const char *url = lua_tostring(L, -1);
+ repo->source_value = url ? strdup(url) : strdup("");
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "version");
+ const char *version = lua_tostring(L, -1);
+ repo->version = version ? strdup(version) : strdup("HEAD");
+ lua_pop(L, 1);
+ lua_pop(L, 1);
+ cached_repos_count++;
+ }
+ lua_pop(L, 1);
}
void cache_build_systems() {
- if (!config_loaded) {
- lua_getglobal(L, "build_systems");
- } else if (!lua_istable(L, -1)) {
- lua_getglobal(L, "build_systems");
- }
-
- if (!lua_istable(L, -1)) {
- printf("%s init.lua: 'build_systems' is not a table.\n", print_error);
- return;
- }
-
- lua_pushnil(L);
- while (lua_next(L, -2) != 0) {
- const char *key = lua_tostring(L, -2);
- if (lua_isfunction(L, -1) == 0) {
- printf("%s init.lua: 'build_systems.%s' is not a function\n", print_error, key);
- lua_pop(L, 1);
- continue;
- }
-
- map_put(&cached_build_systems, strdup(key), "");
- lua_pop(L, 1);
- }
- lua_pop(L, 1);
+ if (!config_loaded) {
+ lua_getglobal(L, "build_systems");
+ } else if (!lua_istable(L, -1)) {
+ lua_getglobal(L, "build_systems");
+ }
+ if (!lua_istable(L, -1)) {
+ printf("%s init.lua: 'build_systems' is not a table.\n", print_error);
+ return;
+ }
+ lua_pushnil(L);
+ while (lua_next(L, -2) != 0) {
+ const char *key = lua_tostring(L, -2);
+ if (lua_isfunction(L, -1) == 0) {
+ printf("%s init.lua: 'build_systems.%s' is not a function\n", print_error, key);
+ lua_pop(L, 1);
+ continue;
+ }
+ map_put(&cached_build_systems, strdup(key), "");
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
}
bool config_build(const char *path, const char *target) {
- lua_getglobal(L, "build_systems");
- if (!config_loaded || !lua_istable(L, -1)) {
- lua_pop(L, 1);
- return false;
- }
- bool target_loop_success = false;
- lua_pushnil(L);
- while (lua_next(L, -2) != 0) {
- const char *key = lua_tostring(L, -2);
- if (!lua_istable(L, -1)) {
- lua_pop(L, 1);
- continue;
- }
- char file_path[MAX_PATH_LEN];
- snprintf(file_path, sizeof(file_path), "%s/%s", path, key);
- if (access(file_path, F_OK) != 0) {
- lua_pop(L, 1);
- continue;
- }
- lua_getfield(L, -1, "targets");
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf("%s init.lua: 'targets' is not a table.\n", print_warning);
- lua_pop(L, 1);
- continue;
- }
- target_loop_success = target_loop_build(L, "init.lua", target);
- lua_pop(L, 1);
- }
- lua_pop(L, 1);
- return target_loop_success;
+ lua_getglobal(L, "build_systems");
+ if (!config_loaded || !lua_istable(L, -1)) {
+ lua_pop(L, 1);
+ return false;
+ }
+ bool target_loop_success = false;
+ lua_pushnil(L);
+ while (lua_next(L, -2) != 0) {
+ const char *key = lua_tostring(L, -2);
+ if (!lua_istable(L, -1)) {
+ lua_pop(L, 1);
+ continue;
+ }
+ char file_path[MAX_PATH_LEN];
+ snprintf(file_path, sizeof(file_path), "%s/%s", path, key);
+ if (access(file_path, F_OK) != 0) {
+ lua_pop(L, 1);
+ continue;
+ }
+ lua_getfield(L, -1, "targets");
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf("%s init.lua: 'targets' is not a table.\n", print_warning);
+ lua_pop(L, 1);
+ continue;
+ }
+ target_loop_success = target_loop_build(L, "init.lua", target);
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
+ return target_loop_success;
}
bool config_install(const char *path, const char *target) {
- lua_getglobal(L, "build_systems");
- if (!config_loaded || !lua_istable(L, -1)) {
- lua_pop(L, 1);
- return false;
- }
- lua_pushnil(L);
- bool target_loop_success = false;
- while (lua_next(L, -2) != 0) {
- const char *key = lua_tostring(L, -2);
- if (!lua_istable(L, -1)) {
- lua_pop(L, 1);
- continue;
- }
- char file_path[MAX_PATH_LEN];
- snprintf(file_path, sizeof(file_path), "%s/%s", path, key);
- if (access(file_path, F_OK) != 0) {
- lua_pop(L, 1);
- continue;
- }
-
- lua_getfield(L, -1, "targets");
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'build_systems.%s.targets' is not a table.\n",
- print_warning, key
- );
- lua_close(L);
- return false;
- }
- target_loop_success = target_loop_install(L, "init.lua", target);
- lua_pop(L, 2);
- }
- lua_pop(L, 1);
- return target_loop_success;
+ lua_getglobal(L, "build_systems");
+ if (!config_loaded || !lua_istable(L, -1)) {
+ lua_pop(L, 1);
+ return false;
+ }
+ lua_pushnil(L);
+ bool target_loop_success = false;
+ while (lua_next(L, -2) != 0) {
+ const char *key = lua_tostring(L, -2);
+ if (!lua_istable(L, -1)) {
+ lua_pop(L, 1);
+ continue;
+ }
+ char file_path[MAX_PATH_LEN];
+ snprintf(file_path, sizeof(file_path), "%s/%s", path, key);
+ if (access(file_path, F_OK) != 0) {
+ lua_pop(L, 1);
+ continue;
+ }
+ lua_getfield(L, -1, "targets");
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'build_systems.%s.targets' is not a table.\n",
+ print_warning, key
+ );
+ lua_close(L);
+ return false;
+ }
+ target_loop_success = target_loop_install(L, "init.lua", target);
+ lua_pop(L, 2);
+ }
+ lua_pop(L, 1);
+ return target_loop_success;
}
bool config_uninstall(const char *path, const char *target) {
- lua_getglobal(L, "build_systems");
- if (!config_loaded || !lua_istable(L, -1)) {
- lua_pop(L, 1);
- return false;
- }
- bool target_loop_success = false;
- lua_pushnil(L);
- while (lua_next(L, -2) != 0) {
- const char *key = lua_tostring(L, -2);
- if (!lua_istable(L, -1)) {
- lua_pop(L, 1);
- continue;
- }
- char file_path[MAX_PATH_LEN];
- snprintf(file_path, sizeof(file_path), "%s/%s", path, key);
- if (access(file_path, F_OK) != 0) {
- lua_pop(L, 1);
- continue;
- }
-
- lua_getfield(L, -1, "targets");
- if (!lua_istable(L, -1)) {
- if (is_verbose) printf(
- "%s init.lua: 'build_systems.%s.targets' is not a table.\n",
- print_warning, key
- );
- lua_close(L);
- return false;
- }
- target_loop_success = target_loop_uninstall(L, "init.lua", target);
- lua_pop(L, 2);
- }
- lua_pop(L, 1);
- return target_loop_success;
+ lua_getglobal(L, "build_systems");
+ if (!config_loaded || !lua_istable(L, -1)) {
+ lua_pop(L, 1);
+ return false;
+ }
+ bool target_loop_success = false;
+ lua_pushnil(L);
+ while (lua_next(L, -2) != 0) {
+ const char *key = lua_tostring(L, -2);
+ if (!lua_istable(L, -1)) {
+ lua_pop(L, 1);
+ continue;
+ }
+ char file_path[MAX_PATH_LEN];
+ snprintf(file_path, sizeof(file_path), "%s/%s", path, key);
+ if (access(file_path, F_OK) != 0) {
+ lua_pop(L, 1);
+ continue;
+ }
+ lua_getfield(L, -1, "targets");
+ if (!lua_istable(L, -1)) {
+ if (is_verbose) printf(
+ "%s init.lua: 'build_systems.%s.targets' is not a table.\n",
+ print_warning, key
+ );
+ lua_close(L);
+ return false;
+ }
+ target_loop_success = target_loop_uninstall(L, "init.lua", target);
+ lua_pop(L, 2);
+ }
+ lua_pop(L, 1);
+ return target_loop_success;
}
diff --git a/src/main.c b/src/main.c
index 9010d3e..6265db1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,22 @@
-#include <stdio.h>
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
#include "cla_parse.h"
#include "lua_state.h"
@@ -6,11 +24,11 @@
#include "vars.h"
int main(int argc, char *argv[]) {
- init_vars();
- init_lua_state();
- setup_pkgit();
- cache_repos();
- cla_parse(argc, argv);
- free_lua_state();
- return 0;
+ init_vars();
+ init_lua_state();
+ setup_pkgit();
+ cache_repos();
+ cla_parse(argc, argv);
+ free_lua_state();
+ return 0;
} \ No newline at end of file
diff --git a/src/name_from_url.c b/src/name_from_url.c
index 0140e1a..d7d892e 100644
--- a/src/name_from_url.c
+++ b/src/name_from_url.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -5,19 +25,14 @@
#include "name_from_url.h"
char* name_from_url(const char *url) {
- size_t len = strlen(url);
- char* after_git = strdup(url);
- const char *end = after_git + len;
- while (end > after_git && *(end-1) == '/') {
- end--;
- }
- const char *last_slash = end;
- while (last_slash > after_git && *(last_slash-1) != '/') {
- last_slash--;
- }
- if (last_slash < end) {
- return strndup(last_slash, end - last_slash);
- } else {
- return strndup(after_git, end - after_git);
- }
+ size_t len = strlen(url);
+ char* after_git = strdup(url);
+ const char *end = after_git + len;
+ while (end > after_git && *(end-1) == '/')
+ end--;
+ const char *last_slash = end;
+ while (last_slash > after_git && *(last_slash-1) != '/')
+ last_slash--;
+ if (last_slash < end) return strndup(last_slash, end - last_slash);
+ else return strndup(after_git, end - after_git);
}
diff --git a/src/remove_pkg.c b/src/remove_pkg.c
index ac723b3..71d2f2f 100644
--- a/src/remove_pkg.c
+++ b/src/remove_pkg.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <ftw.h>
#include <stdio.h>
#include <stdlib.h>
@@ -10,85 +30,89 @@
#include "vars.h"
static int remove_installed(
- const char *src_path, const struct stat *sb,
- int typeflag, struct FTW *ftwbuf
+ const char *src_path, const struct stat *sb,
+ int typeflag, struct FTW *ftwbuf
) {
- (void)sb;
- (void)ftwbuf;
+ (void)sb;
+ (void)ftwbuf;
- if (typeflag == FTW_F) {
- const char *filename = src_path + ftwbuf->base;
- const char *ext = strrchr(filename, '.');
- if (!ext)
- ext = "";
+ if (typeflag == FTW_F) {
+ const char *filename = src_path + ftwbuf->base;
+ const char *ext = strrchr(filename, '.');
+ if (!ext)
+ ext = "";
- if (strncmp(ext, ".so", 3) == 0) {
- char dest[MAX_PATH_LEN];
- snprintf(dest, sizeof(dest), "%s/%s", get_install_dir("lib"), filename);
- if (file_exists(dest))
- remove(dest);
- } else if (access(src_path, X_OK) == 0) {
- if (strcmp(ext, ".sample") != 0 && strcmp(filename, "bldit") != 0 &&
- strcmp(filename, "build.sh") != 0 &&
- strcmp(filename, "compile.sh") != 0) {
- char dest[MAX_PATH_LEN];
- snprintf(dest, sizeof(dest), "%s/%s", get_install_dir("bin"), filename);
- if (file_exists(dest))
- remove(dest);
- }
- } else if (strcmp(ext, ".h") == 0) {
- char dest[MAX_PATH_LEN];
- snprintf(dest, sizeof(dest), "%s/%s", get_install_dir("include"),
- filename);
- if (file_exists(dest))
- remove(dest);
- }
- }
-
- return 0;
+ if (strncmp(ext, ".so", 3) == 0) {
+ char dest[MAX_PATH_LEN];
+ snprintf(dest, sizeof(dest), "%s/%s", get_install_dir("lib"), filename);
+ if (file_exists(dest))
+ remove(dest);
+ } else if (access(src_path, X_OK) == 0) {
+ if (
+ strcmp(ext, ".sample") != 0 &&
+ strcmp(filename, "bldit") != 0 &&
+ strcmp(filename, "build.sh") != 0 &&
+ strcmp(filename, "compile.sh") != 0
+ ) {
+ char dest[MAX_PATH_LEN];
+ snprintf(dest, sizeof(dest), "%s/%s", get_install_dir("bin"), filename);
+ if (file_exists(dest))
+ remove(dest);
+ }
+ } else if (strcmp(ext, ".h") == 0) {
+ char dest[MAX_PATH_LEN];
+ snprintf(dest, sizeof(dest), "%s/%s", get_install_dir("include"),
+ filename);
+ if (file_exists(dest))
+ remove(dest);
+ }
+ }
+ return 0;
}
-static int remove_tree(const char *fpath, const struct stat *sb, int typeflag,
- struct FTW *ftwbuf) {
- (void)sb;
- (void)ftwbuf;
- if (typeflag == FTW_F || typeflag == FTW_SL) {
- unlink(fpath);
- } else if (typeflag == FTW_DP) {
- rmdir(fpath);
- }
- return 0;
+static int remove_tree(
+ const char *fpath, const struct stat *sb,
+ int typeflag, struct FTW *ftwbuf
+) {
+ (void)sb;
+ (void)ftwbuf;
+ if (typeflag == FTW_F || typeflag == FTW_SL) {
+ unlink(fpath);
+ } else if (typeflag == FTW_DP) {
+ rmdir(fpath);
+ }
+ return 0;
}
void remove_pkg(Pkg pkg) {
- if (!is_directory(pkg.src)) {
- printf("%s %s is not installed!\n", print_pkgit, pkg.name);
- return;
- }
- chdir(pkg.src);
+ if (!is_directory(pkg.src)) {
+ printf("%s %s is not installed!\n", print_pkgit, pkg.name);
+ return;
+ }
+ chdir(pkg.src);
- bool uninstall_available = false;
- if (!uninstall_available) if (repo_uninstall(pkg.name, pkg.target))
- uninstall_available = true;
- if (!uninstall_available) if (bldit_uninstall(pkg.target))
- uninstall_available = true;
- if (!uninstall_available) if (config_uninstall(pkg.src, pkg.target))
- uninstall_available = true;
+ bool uninstall_available = false;
+ if (!uninstall_available) if (repo_uninstall(pkg.name, pkg.target))
+ uninstall_available = true;
+ if (!uninstall_available) if (bldit_uninstall(pkg.target))
+ uninstall_available = true;
+ if (!uninstall_available) if (config_uninstall(pkg.src, pkg.target))
+ uninstall_available = true;
- if (!uninstall_available) printf(
- "%s no uninstall function availible for package: %s\n",
- print_error, pkg.name
- );
+ if (!uninstall_available) printf(
+ "%s no uninstall function availible for package: %s\n",
+ print_error, pkg.name
+ );
- nftw(pkg.src, remove_installed, 64, FTW_PHYS);
- const char *last_slash = strrchr(pkg.src, '/');
- char target[MAX_PATH_LEN];
- if (last_slash && last_slash != pkg.src) {
- size_t parent_len = last_slash - pkg.src;
- snprintf(target, sizeof(target), "%.*s", (int)parent_len, pkg.src);
- } else {
- snprintf(target, sizeof(target), "%s", pkg.src);
- }
- nftw(pkg.src, remove_tree, 64, FTW_DEPTH | FTW_PHYS);
- printf("%s removed %s\n", print_success, pkg.name);
+ nftw(pkg.src, remove_installed, 64, FTW_PHYS);
+ const char *last_slash = strrchr(pkg.src, '/');
+ char target[MAX_PATH_LEN];
+ if (last_slash && last_slash != pkg.src) {
+ size_t parent_len = last_slash - pkg.src;
+ snprintf(target, sizeof(target), "%.*s", (int)parent_len, pkg.src);
+ } else {
+ snprintf(target, sizeof(target), "%s", pkg.src);
+ }
+ nftw(pkg.src, remove_tree, 64, FTW_DEPTH | FTW_PHYS);
+ printf("%s removed %s\n", print_success, pkg.name);
} \ No newline at end of file
diff --git a/src/resolve_deps.c b/src/resolve_deps.c
index ed728d4..32118f0 100644
--- a/src/resolve_deps.c
+++ b/src/resolve_deps.c
@@ -1,28 +1,44 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <unistd.h>
#include "resolve_deps.h"
void resolve_deps(void) {
- const char *frame_top = " (c _c)";
- const char *frame1_bot = "_/ \\-";
- const char *frame2_bot = "-/ \\_";
-
- printf("\033[2J\033[H");
- printf("Unfortunately due to budget issues, we could not afford a progress bar. Enjoy this instead:\n\n");
-
- for (int i = 0; i < 16; i++) {
- printf("%s\n%s\n", frame_top, i % 2 == 0 ? frame1_bot : frame2_bot);
- for (int j = 0; j <= i; j++) {
- printf(".");
- }
- printf("\n");
- fflush(stdout);
- sleep(1);
- if (i < 15) {
- printf("\033[3A");
- }
- }
- printf("\n");
- printf("Dependencies resolved! (this does nothing)\n");
+ const char *frame_top = " (c _c)";
+ const char *frame1_bot = "_/ \\-";
+ const char *frame2_bot = "-/ \\_";
+
+ printf("\033[2J\033[H");
+ printf("Unfortunately due to budget issues, we could not afford a progress bar. Enjoy this instead:\n\n");
+
+ for (int i = 0; i < 16; i++) {
+ printf("%s\n%s\n", frame_top, i % 2 == 0 ? frame1_bot : frame2_bot);
+ for (int j = 0; j <= i; j++) printf(".");
+ printf("\n");
+ fflush(stdout);
+ sleep(1);
+ if (i < 15) printf("\033[3A");
+ }
+ printf("\n");
+ printf("Dependencies resolved! (this does nothing)\n");
}
diff --git a/src/search.c b/src/search.c
index 72fe350..19f9963 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <string.h>
@@ -5,14 +25,13 @@
#include "search.h"
void search(const char* arg) {
- if (!arg) {
- for (size_t i = 0; i < cached_repos_count; i++) {
- printf("%s\n", cached_repos[i].source_key);
- }
- return;
- }
- for (size_t i = 0; i < cached_repos_count; i++) {
- if (!strstr(cached_repos[i].source_key, arg)) continue;
- printf("%s\n", cached_repos[i].source_key);
- }
+ if (!arg) {
+ for (size_t i = 0; i < cached_repos_count; i++)
+ printf("%s\n", cached_repos[i].source_key);
+ return;
+ }
+ for (size_t i = 0; i < cached_repos_count; i++) {
+ if (!strstr(cached_repos[i].source_key, arg)) continue;
+ printf("%s\n", cached_repos[i].source_key);
+ }
}
diff --git a/src/set_install_directories.c b/src/set_install_directories.c
index b99e227..7a4b59e 100644
--- a/src/set_install_directories.c
+++ b/src/set_install_directories.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -7,62 +27,57 @@
#include "vars.h"
void set_install_directories() {
- lua_State *L = get_lua_state();
- cache_prefix_directory();
- lua_getglobal(L, "install_directories");
- if (!lua_istable(L, -1)) {
- printf(
- "%slua variable 'install_directories' is not a table.\n",
- print_error
- );
- }
-
- lua_pushnil(L);
- while (lua_next(L, -2) != 0) {
- const char *key = lua_tostring(L, -2);
- const char *value = lua_tostring(L, -1);
- if (key && value) {
- map_put(&cached_install_directories, strdup(key), strdup(value));
- }
- lua_pop(L, 1);
- }
+ lua_State *L = get_lua_state();
+ cache_prefix_directory();
+ lua_getglobal(L, "install_directories");
+ if (!lua_istable(L, -1)) {
+ printf(
+ "%slua variable 'install_directories' is not a table.\n",
+ print_error
+ );
+ }
+ lua_pushnil(L);
+ while (lua_next(L, -2) != 0) {
+ const char *key = lua_tostring(L, -2);
+ const char *value = lua_tostring(L, -1);
+ if (key && value) {
+ map_put(&cached_install_directories, strdup(key), strdup(value));
+ }
+ lua_pop(L, 1);
+ }
}
void map_init(Map *map) {
- map->items = NULL;
- map->size = 0;
- map->capacity = 0;
+ map->items = NULL;
+ map->size = 0;
+ map->capacity = 0;
}
void map_put(Map *map, char *key, char *value) {
- for (size_t i = 0; i < map->size; i++) {
- if (strcmp(map->items[i].key, key) == 0) {
- free(map->items[i].value);
- map->items[i].value = value;
- free(key);
- return;
- }
- }
-
- if (map->size >= map->capacity) {
- size_t new_capacity = map->capacity == 0 ? 8 : map->capacity * 2;
- MapItem *new_items = realloc(map->items, new_capacity * sizeof(MapItem));
- if (!new_items)
- return;
- map->items = new_items;
- map->capacity = new_capacity;
- }
-
- map->items[map->size].key = key;
- map->items[map->size].value = value;
- map->size++;
+ for (size_t i = 0; i < map->size; i++) {
+ if (strcmp(map->items[i].key, key) == 0) {
+ free(map->items[i].value);
+ map->items[i].value = value;
+ free(key);
+ return;
+ }
+ }
+ if (map->size >= map->capacity) {
+ size_t new_capacity = map->capacity == 0 ? 8 : map->capacity * 2;
+ MapItem *new_items = realloc(map->items, new_capacity * sizeof(MapItem));
+ if (!new_items) return;
+ map->items = new_items;
+ map->capacity = new_capacity;
+ }
+ map->items[map->size].key = key;
+ map->items[map->size].value = value;
+ map->size++;
}
char *map_get(Map *map, const char *key) {
- for (size_t i = 0; i < map->size; i++) {
- if (strcmp(map->items[i].key, key) == 0) {
- return map->items[i].value;
- }
- }
- return NULL;
+ for (size_t i = 0; i < map->size; i++) {
+ if (strcmp(map->items[i].key, key) != 0) continue;
+ return map->items[i].value;
+ }
+ return NULL;
} \ No newline at end of file
diff --git a/src/setup_dirs.c b/src/setup_dirs.c
index ee2196d..02442c3 100644
--- a/src/setup_dirs.c
+++ b/src/setup_dirs.c
@@ -1,4 +1,23 @@
-#include <stdio.h>
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <string.h>
#include <sys/stat.h>
@@ -6,12 +25,10 @@
#include "vars.h"
void setup_dirs() {
- mkdir_p(config_dir);
- for (int i = 0; i < 5; i++) {
- if (install_directories[i] && strlen(install_directories[i]) > 0) {
- if (!file_exists(install_directories[i])) {
- mkdir_p(install_directories[i]);
- }
- }
- }
+ mkdir_p(config_dir);
+ for (int i = 0; i < 5; i++) {
+ if (install_directories[i] && strlen(install_directories[i]) <= 0) continue;
+ if (file_exists(install_directories[i])) continue;
+ mkdir_p(install_directories[i]);
+ }
} \ No newline at end of file
diff --git a/src/setup_pkgit.c b/src/setup_pkgit.c
index fdcdb56..31e3fd2 100644
--- a/src/setup_pkgit.c
+++ b/src/setup_pkgit.c
@@ -1,10 +1,29 @@
-#include <stdio.h>
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <unistd.h>
#include "set_install_directories.h"
#include "setup_dirs.h"
void setup_pkgit() {
- set_install_directories();
- setup_dirs();
+ set_install_directories();
+ setup_dirs();
} \ No newline at end of file
diff --git a/src/update_all.c b/src/update_all.c
index 8a7d57f..79b653c 100644
--- a/src/update_all.c
+++ b/src/update_all.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
@@ -13,20 +33,26 @@
#include "vars.h"
void update_all() {
- init_lua_state();
- cache_repos();
- struct dirent* dirent_ptr;
- DIR* dir_ptr;
- if ((dir_ptr = opendir(get_install_dir("src"))) == NULL) {
- fprintf(stderr, "%s could not open %s\n", print_pkgit, get_install_dir("src"));
- }
- while ((dirent_ptr = readdir(dir_ptr)) != NULL) {
- if (strcmp(dirent_ptr->d_name, "..") == 0 || strcmp(dirent_ptr->d_name, ".") == 0) continue;
- for (size_t i = 0; i < cached_repos_count; i++) {
- if (strcmp(dirent_ptr->d_name, cached_repos[i].source_key) != 0) continue;
- Pkg pkg = create_pkg(cached_repos[i].source_value);
- update_pkg(pkg);
- }
- }
- closedir(dir_ptr);
+ init_lua_state();
+ cache_repos();
+ struct dirent* dirent_ptr;
+ DIR* dir_ptr;
+ if ((dir_ptr = opendir(get_install_dir("src"))) == NULL) {
+ fprintf(
+ stderr, "%s could not open %s\n",
+ print_pkgit, get_install_dir("src")
+ );
+ }
+ while ((dirent_ptr = readdir(dir_ptr)) != NULL) {
+ if (
+ strcmp(dirent_ptr->d_name, "..") == 0 ||
+ strcmp(dirent_ptr->d_name, ".") == 0
+ ) continue;
+ for (size_t i = 0; i < cached_repos_count; i++) {
+ if (strcmp(dirent_ptr->d_name, cached_repos[i].source_key) != 0) continue;
+ Pkg pkg = create_pkg(cached_repos[i].source_value);
+ update_pkg(pkg);
+ }
+ }
+ closedir(dir_ptr);
} \ No newline at end of file
diff --git a/src/update_pkg.c b/src/update_pkg.c
index 52c4c9e..ea6a20d 100644
--- a/src/update_pkg.c
+++ b/src/update_pkg.c
@@ -1,17 +1,43 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <stdio.h>
#include <string.h>
#include "update_pkg.h"
-#include "is_updated.h"
#include "install_pkg.h"
+#include "is_updated.h"
#include "lua_state.h"
void update_pkg(Pkg pkg) {
- if (is_updated(pkg.src)) {
- printf("%s %s%s%s is already up to date.\n", print_skipped, green, pkg.name, color_reset);
- return;
- }
- printf("%s Updating package: %s%s%s\n", print_pkgit, green, pkg.name, color_reset);
- install_pkg(pkg);
+ if (is_updated(pkg.src)) {
+ printf(
+ "%s %s%s%s is already up to date.\n",
+ print_skipped, green, pkg.name, color_reset
+ );
+ return;
+ }
+ printf(
+ "%s Updating package: %s%s%s\n",
+ print_pkgit, green, pkg.name, color_reset
+ );
+ install_pkg(pkg);
} \ No newline at end of file
diff --git a/src/vars.c b/src/vars.c
index 2691777..ba83559 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -1,3 +1,23 @@
+/*
+
+ 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 <https://www.gnu.org/licenses/>.
+
+*/
+
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
@@ -37,21 +57,24 @@ Map cached_build_systems = {0};
char home_config_buf[MAX_PATH_LEN] = {0};
char *home_config() {
- snprintf(home_config_buf, MAX_PATH_LEN, "%s/.config/pkgit/init.lua",
- home_dir);
- return home_config_buf;
+ snprintf(
+ home_config_buf, MAX_PATH_LEN,
+ "%s/.config/pkgit/init.lua",
+ home_dir
+ );
+ return home_config_buf;
}
const char *get_install_dir(const char *key) {
- for (size_t i = 0; i < cached_install_directories.size; i++) {
- if (strcmp(cached_install_directories.items[i].key, key) == 0) {
- return cached_install_directories.items[i].value;
- }
- }
- return "";
+ for (size_t i = 0; i < cached_install_directories.size; i++) {
+ if (strcmp(cached_install_directories.items[i].key, key) == 0) {
+ return cached_install_directories.items[i].value;
+ }
+ }
+ return "";
}
-const char *version = "1.0.0";
+const char *version = "1.1.3";
const char *red = "\e[0;31m";
const char *green = "\e[0;32m";
@@ -92,100 +115,106 @@ const char *print_warning;
const char *print_error;
int mkdir_p(const char *path) {
- char tmp[MAX_PATH_LEN];
- char *p = NULL;
- size_t len;
-
- snprintf(tmp, sizeof(tmp), "%s", path);
- len = strlen(tmp);
- if (tmp[len - 1] == '/') {
- tmp[len - 1] = 0;
- }
-
- for (p = tmp + 1; *p; p++) {
- if (*p == '/') {
- *p = 0;
- if (mkdir(tmp, 0755) != 0 && errno != EEXIST) {
- return -1;
- }
- *p = '/';
- }
- }
-
- if (mkdir(tmp, 0755) != 0 && errno != EEXIST) {
- return -1;
- }
-
- return 0;
+ char tmp[MAX_PATH_LEN];
+ char *p = NULL;
+ size_t len;
+ snprintf(tmp, sizeof(tmp), "%s", path);
+ len = strlen(tmp);
+ if (tmp[len - 1] == '/') {
+ tmp[len - 1] = 0;
+ }
+ for (p = tmp + 1; *p; p++) {
+ if (*p == '/') {
+ *p = 0;
+ if (mkdir(tmp, 0755) != 0 && errno != EEXIST) {
+ return -1;
+ }
+ *p = '/';
+ }
+ }
+ if (mkdir(tmp, 0755) != 0 && errno != EEXIST) {
+ return -1;
+ }
+ return 0;
}
bool file_exists(const char *path) {
- struct stat buffer;
- return (stat(path, &buffer) == 0);
+ struct stat buffer;
+ return (stat(path, &buffer) == 0);
}
bool is_directory(const char *path) {
- struct stat statbuf;
- if (stat(path, &statbuf) != 0) {
- return false;
- }
- return S_ISDIR(statbuf.st_mode);
+ struct stat statbuf;
+ if (stat(path, &statbuf) != 0) {
+ return false;
+ }
+ return S_ISDIR(statbuf.st_mode);
}
void init_vars() {
- char *home = getenv("HOME");
- if (home) {
- snprintf(home_dir, MAX_PATH_LEN, "%s", home);
- } else {
- snprintf(home_dir, MAX_PATH_LEN, "/root");
- }
-
- is_root_config = file_exists(root_config);
-
- if (is_root_config) {
- snprintf(config_dir, MAX_PATH_LEN, "/etc/pkgit");
- } else {
- snprintf(config_dir, MAX_PATH_LEN, "%s/.config/pkgit", home_dir);
- }
-
- snprintf(config_file, MAX_PATH_LEN, "%s/init.lua", config_dir);
- snprintf(repo_file, MAX_PATH_LEN, "%s/repos.lua", config_dir);
-
- config_exists = file_exists(root_config) || file_exists(home_config());
-
- snprintf(bin, MAX_PATH_LEN, "%s/.local/bin", home_dir);
- snprintf(lib, MAX_PATH_LEN, "%s/.local/lib", home_dir);
- snprintf(inc, MAX_PATH_LEN, "%s/.local/include", home_dir);
- snprintf(src, MAX_PATH_LEN, "%s/.local/share/pkgit", home_dir);
-
- install_directories[0] = config_dir;
- install_directories[1] = strdup(get_install_dir("bin"));
- install_directories[2] = strdup(get_install_dir("lib"));
- install_directories[3] = strdup(get_install_dir("inc"));
- install_directories[4] = strdup(get_install_dir("src"));
-
- static char print_pkgit_buf[256];
- snprintf(print_pkgit_buf, sizeof(print_pkgit_buf), "%s[%s%s%s]%s",
- bold_yellow, bold_magenta, "pkgit", bold_yellow, color_reset);
- print_pkgit = print_pkgit_buf;
-
- static char print_success_buf[256];
- snprintf(print_success_buf, sizeof(print_success_buf), "%s%s [SUCCESS]%s",
- print_pkgit, green, color_reset);
- print_success = print_success_buf;
-
- static char print_skipped_buf[256];
- snprintf(print_skipped_buf, sizeof(print_skipped_buf), "%s%s [SKIP]%s",
- print_pkgit, blue, color_reset);
- print_skipped = print_skipped_buf;
-
- static char print_warning_buf[256];
- snprintf(print_warning_buf, sizeof(print_warning_buf), "%s%s [WARN]%s",
- print_pkgit, yellow, color_reset);
- print_warning = print_warning_buf;
-
- static char print_error_buf[256];
- snprintf(print_error_buf, sizeof(print_error_buf), "%s%s [ERROR]%s",
- print_pkgit, red, color_reset);
- print_error = print_error_buf;
+ char *home = getenv("HOME");
+ if (home) snprintf(home_dir, MAX_PATH_LEN, "%s", home);
+ else snprintf(home_dir, MAX_PATH_LEN, "/root");
+
+ is_root_config = file_exists(root_config);
+
+ if (is_root_config) snprintf(config_dir, MAX_PATH_LEN, "/etc/pkgit");
+ else snprintf(config_dir, MAX_PATH_LEN, "%s/.config/pkgit", home_dir);
+
+ snprintf(config_file, MAX_PATH_LEN, "%s/init.lua", config_dir);
+ snprintf(repo_file, MAX_PATH_LEN, "%s/repos.lua", config_dir);
+
+ config_exists = file_exists(root_config) || file_exists(home_config());
+
+ snprintf(bin, MAX_PATH_LEN, "%s/.local/bin", home_dir);
+ snprintf(lib, MAX_PATH_LEN, "%s/.local/lib", home_dir);
+ snprintf(inc, MAX_PATH_LEN, "%s/.local/include", home_dir);
+ snprintf(src, MAX_PATH_LEN, "%s/.local/share/pkgit", home_dir);
+
+ install_directories[0] = config_dir;
+ install_directories[1] = strdup(get_install_dir("bin"));
+ install_directories[2] = strdup(get_install_dir("lib"));
+ install_directories[3] = strdup(get_install_dir("inc"));
+ install_directories[4] = strdup(get_install_dir("src"));
+
+ static char print_pkgit_buf[256];
+ snprintf(
+ print_pkgit_buf, sizeof(print_pkgit_buf),
+ "%s[%s%s%s]%s",
+ bold_yellow, bold_magenta, "pkgit",
+ bold_yellow, color_reset
+ );
+ print_pkgit = print_pkgit_buf;
+
+ static char print_success_buf[256];
+ snprintf(
+ print_success_buf, sizeof(print_success_buf),
+ "%s%s [SUCCESS]%s",
+ print_pkgit, green, color_reset
+ );
+ print_success = print_success_buf;
+
+ static char print_skipped_buf[256];
+ snprintf(
+ print_skipped_buf, sizeof(print_skipped_buf),
+ "%s%s [SKIP]%s",
+ print_pkgit, blue, color_reset
+ );
+ print_skipped = print_skipped_buf;
+
+ static char print_warning_buf[256];
+ snprintf(
+ print_warning_buf, sizeof(print_warning_buf),
+ "%s%s [WARN]%s",
+ print_pkgit, yellow, color_reset
+ );
+ print_warning = print_warning_buf;
+
+ static char print_error_buf[256];
+ snprintf(
+ print_error_buf, sizeof(print_error_buf),
+ "%s%s [ERROR]%s",
+ print_pkgit, red, color_reset
+ );
+ print_error = print_error_buf;
}