aboutsummaryrefslogtreecommitdiff
path: root/snag
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2026-07-22 11:14:54 -0400
committerJack Jamison <jackqjamison@gmail.com>2026-07-22 11:14:54 -0400
commitc293d3cc413991e4fb18b963427a6e55afd2b5c0 (patch)
tree0adc4aba00d9f6497e09c4b77b6017d2cd3bb54a /snag
parent5365f8fa8d6ebfbf3ba92816abe55a99feff6f25 (diff)
organization and url stuff
Diffstat (limited to 'snag')
-rwxr-xr-xsnag/configure1
-rw-r--r--snag/ideas.txt5
-rw-r--r--snag/readme.txt11
-rwxr-xr-xsnag/scripts/get_pkg_attrs.sh2
-rw-r--r--snag/src/main.c7
-rw-r--r--snag/src/package.h16
-rw-r--r--snag/src/package_db.c (renamed from snag/src/pkg_db.c)8
-rw-r--r--snag/src/package_db.h (renamed from snag/src/pkg_db.h)17
-rw-r--r--snag/src/util.h2
9 files changed, 42 insertions, 27 deletions
diff --git a/snag/configure b/snag/configure
index 9b73f97..757df3a 100755
--- a/snag/configure
+++ b/snag/configure
@@ -37,7 +37,6 @@ for target in $(echo "debug release"); do
write ' description = CC $out'
write " command = gcc -MD -MF \$out.d \$cflags_$target -c \$in -o \$out"
-
files="$(find . -name '*.c')"
sedstr=$(printf 's,^\./\(.*\)\.c$,%s\/%s\/\\1.o,g' ${builddir} ${target})
ofiles=$(echo "$files" | sed ${sedstr})
diff --git a/snag/ideas.txt b/snag/ideas.txt
index 5bfe899..2044da6 100644
--- a/snag/ideas.txt
+++ b/snag/ideas.txt
@@ -1,4 +1,7 @@
- system that allows multiple different downloads for a package, each with a hash and location. it could also handle submodules somehow
- sepration of (program/lib package, app package, admin package)
- developer tools for creating and updating packages
-- snag shell api
+- selectively choose static and dynamic linking for certain libraries.
+- allow a package/bin to be recompiled to be totally portable
+
+- easy bootstrapping and cross compilation
diff --git a/snag/readme.txt b/snag/readme.txt
index 33938d6..53df374 100644
--- a/snag/readme.txt
+++ b/snag/readme.txt
@@ -27,16 +27,16 @@ Install Database - the directory containing information on installed packag
Install Description - the data stored about a package in the install database
Download Database - the directory where package downloads are stored and cached
+## Interesting Features
+- switch between cli and tui mode mid run
+- build packages that aren't in the database
+
## Package Description Format
Each package has a directory in the package database, named by its `id`.
Inside each package directory is the description script named `{id}.sh`
The description script should have functions for `configure`, `build`, and `install`
The description script should define variables for attributes with the name `pkg_{attr}`
-## Interesting Features
-- switch between cli and tui mode mid run
-- build packages that aren't in the database
-
Packages have the following attributes:
id - the identifier name of the package. everything uses this
name - the display name of package
@@ -45,6 +45,9 @@ webpage - url to home website
license - spdx identifer for package license (https://spdx.org/licenses/)
version - software version, in whatever format is needed. commit hashes are allowed
+### Snag Shell API
+TBD
+
## Install Description Format
TBD. Will contain at least:
- date installed
diff --git a/snag/scripts/get_pkg_attrs.sh b/snag/scripts/get_pkg_attrs.sh
index 25f9177..932c79c 100755
--- a/snag/scripts/get_pkg_attrs.sh
+++ b/snag/scripts/get_pkg_attrs.sh
@@ -20,3 +20,5 @@ echoatt d "$pkg_desc"
echoatt w "$pkg_webpage"
echoatt l "$pkg_license"
echoatt v "$pkg_version"
+echoatt u "$pkg_source_url"
+echoatt h "$pkg_source_hash"
diff --git a/snag/src/main.c b/snag/src/main.c
index 0429fda..7d5ea58 100644
--- a/snag/src/main.c
+++ b/snag/src/main.c
@@ -2,7 +2,7 @@
#include "util.h"
#include "libargs/args.h"
-#include "pkg_db.h"
+#include "package_db.h"
int cmd_install(char* cmd_name, ArgParser* parser);
@@ -37,13 +37,14 @@ int cmd_install(char* cmd_name, ArgParser* parser) {
// install each package specified
for (int i = 0; i < ap_count_args(parser); i++) {
- if (i != 0) printf("\n");
+ if (i != 0) print("\n");
// load package description
char* pkgid = ap_get_arg_at_index(parser, i);
package_info_t info;
if (load_package_info(pkgid, &info)) {
- printf("Installing %s - %s\n", info.attrs.name, info.attrs.desc);
+ print("Installing %s - %s\n", info.attrs.name, info.attrs.desc);
+ print("Downloading '%s'\n", info.attrs.source_url);
run_package_install(&info);
}
}
diff --git a/snag/src/package.h b/snag/src/package.h
new file mode 100644
index 0000000..3ff58b6
--- /dev/null
+++ b/snag/src/package.h
@@ -0,0 +1,16 @@
+typedef struct {
+ char* id;
+ char* name;
+ char* desc;
+ char* webpage;
+ char* license;
+ char* version;
+ char* source_url;
+ char* source_hash;
+ char buffer[4069];
+} package_attrs_t;
+
+typedef struct {
+ char* script_path;
+ package_attrs_t attrs;
+} package_info_t;
diff --git a/snag/src/pkg_db.c b/snag/src/package_db.c
index c35e47b..0bae257 100644
--- a/snag/src/pkg_db.c
+++ b/snag/src/package_db.c
@@ -1,12 +1,12 @@
-#include "pkg_db.h"
+#include "package_db.h"
#include "util.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <errno.h>
#include <sys/wait.h>
+#include <errno.h>
#define PKG_INFO_CMD "./scripts/get_pkg_attrs.sh"
#define PKG_INST_CMD "./scripts/run_pkg_install.sh"
@@ -106,6 +106,10 @@ bool load_package_info(char* pkgid, package_info_t* info) {
info->attrs.license = &info->attrs.buffer[i]; break;
case 'v':
info->attrs.version = &info->attrs.buffer[i]; break;
+ case 'u':
+ info->attrs.source_url = &info->attrs.buffer[i]; break;
+ case 'h':
+ info->attrs.source_hash = &info->attrs.buffer[i]; break;
}
for(;info->attrs.buffer[i] && i < bytes_read; i++);
i++;
diff --git a/snag/src/pkg_db.h b/snag/src/package_db.h
index 0d34a61..bae1cdd 100644
--- a/snag/src/pkg_db.h
+++ b/snag/src/package_db.h
@@ -3,24 +3,11 @@
#include <stdbool.h>
+#include "package.h"
+
// loads and allocates package attributes for the info struct. does not do
// excessive validation, so this should be fine when loading lots of package
// data
-typedef struct {
- char* id;
- char* name;
- char* desc;
- char* webpage;
- char* license;
- char* version;
- char buffer[4069];
-} package_attrs_t;
-
-typedef struct {
- char* script_path;
- package_attrs_t attrs;
-} package_info_t;
-
bool load_package_info(char* pkgid, package_info_t* info);
void run_package_install(const package_info_t* info);
diff --git a/snag/src/util.h b/snag/src/util.h
index 3813903..eca4e4d 100644
--- a/snag/src/util.h
+++ b/snag/src/util.h
@@ -25,7 +25,7 @@
#define print(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
// string functions
-char* vastrcat_(int dummy, ...);
#define vastrcat(...) vastrcat_(0, __VA_ARGS__, NULL)
+char* vastrcat_(int dummy, ...);
#endif