From 3ae746e5ac3f8feb80a8619127956fb93ba47ca0 Mon Sep 17 00:00:00 2001 From: Jack Jamison Date: Mon, 20 Jul 2026 12:08:18 -0400 Subject: start snag program and defining package format --- snag/getpkginfo.sh | 17 +++++++++++++++++ snag/main.c | 30 ++++++++++++++++++++++++++++++ snag/readme.txt | 31 +++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100755 snag/getpkginfo.sh create mode 100644 snag/readme.txt (limited to 'snag') diff --git a/snag/getpkginfo.sh b/snag/getpkginfo.sh new file mode 100755 index 0000000..0650740 --- /dev/null +++ b/snag/getpkginfo.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# reads a package description script and outputs the attributes in a format easy +# for the snag program to read + +if [ -z "$1" ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +# load the description script +. $1 + +# echo package properties +echo ID $pkg_id +echo NAME $pkg_name +echo DESC $pkg_desc diff --git a/snag/main.c b/snag/main.c index 8a3b3be..9eacf33 100644 --- a/snag/main.c +++ b/snag/main.c @@ -1,3 +1,33 @@ +#include +#include + +#define DESC_DIR "../snaggies" + +typedef struct { + char* id; + char* name; + char* desc; +} package_info_t; + +void subcmd_install(char* pkgs[], size_t count); +bool load_package_info(package_info_t* info, char* pkgid); + int main(int argc, char* argv[]) { + + // run install subcommand with each argument as a package + subcmd_install(argv+1, argc-1); + return 0; } + +void subcmd_install(char* pkgs[], size_t count) { + + // install each package listed + for (int i = 0; i < count; ++i) { + + char* package = pkgs[i]; + printf("Installing '%s'\n", package); + + // load package description + } +} diff --git a/snag/readme.txt b/snag/readme.txt new file mode 100644 index 0000000..ef15404 --- /dev/null +++ b/snag/readme.txt @@ -0,0 +1,31 @@ +# SNAG Package Manager + +## Useful Subcommands +`install`/`inst` - install the specified package(s) (default) +`remove` - uninstall the specified package(s) +`upgrade/'up` - upgrade the package database +`find`/`search` - list packages whose metadata matches specified search string +`info`/`desc` - describe the metadata of the specified package(s) + +`files` - list the installed files of the specified package(s) +`log` - open your pager to the build log of the specified package +`reason` - list why this package is installed (manually installed, as a dependency, from a group) + +## Terminology +"Package Database" - the directory containing package descriptions +"Install Database" - the directory containing information on installed package +"Package Description" - the directory and script containing build instructions for a package +"Package Info/Metadata" - the metadata encoded in the package description +"Package Attribute" - a single key value property of the package info + +## Package 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}` +> We're still deciding if we want the metadata to be split from the instruction in separate file(s). + +Packages have the following attributes: +`id` - the identifier name of the package. everything uses this +`name` - the display name of package +`desc` - the short description of the package -- cgit v1.2.3