aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO6
-rwxr-xr-xsnag/get_pkg_attrs.sh (renamed from snag/snagpkginfo.sh)0
-rw-r--r--snag/main.c20
-rw-r--r--snag/readme.txt15
-rwxr-xr-xsnag/run_pkg_install.sh16
-rw-r--r--snaggies/swenu/swenu.sh6
6 files changed, 49 insertions, 14 deletions
diff --git a/TODO b/TODO
index 40fac4b..7cf102e 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,9 @@
+SNAG
+- [ ] make install subcommand actually run the install script
+- [ ] multiple subcommand handling and proper argument parsing
+- [ ] figure out how we handle make configuration, and tools for build scripts
+- [ ] dependencies
+
Things to come back to
- [ ] Optional package info attributes
- [ ] better memory allocation strategies for snag (temporary, arena) \ No newline at end of file
diff --git a/snag/snagpkginfo.sh b/snag/get_pkg_attrs.sh
index bb80418..bb80418 100755
--- a/snag/snagpkginfo.sh
+++ b/snag/get_pkg_attrs.sh
diff --git a/snag/main.c b/snag/main.c
index 10a5f86..c80ec65 100644
--- a/snag/main.c
+++ b/snag/main.c
@@ -5,7 +5,7 @@
#include <unistd.h>
#define PKG_DB "../snaggies"
-#define PKG_INFO_CMD "./snagpkginfo.sh"
+#define PKG_INFO_CMD "./get_pkg_attrs.sh"
typedef struct {
char* id;
@@ -40,6 +40,9 @@ void subcmd_install(char* pkgs[], size_t count) {
}
}
+// loads and allocates package attributes for the info struct. does not do
+// excessive validation, so this should be fine when loading package data in
+// bulk.
bool load_package_info(package_info_t* info, char* pkgid) {
// construct package description directory path and ensure it exists
@@ -63,13 +66,14 @@ bool load_package_info(package_info_t* info, char* pkgid) {
return false;
}
- // run getpkginfo script that outputs package attributes
+ // run get_pkg_attrs script that outputs package attributes
size_t cmd_len = strlen(PKG_INFO_CMD) + script_path_len + 3;
char* cmd = malloc(cmd_len + 1);
snprintf(cmd, cmd_len + 1, "%s '%s'", PKG_INFO_CMD, info->script_path);
FILE* getinfo_fp = popen(cmd, "r");
+ free(cmd);
if (getinfo_fp == NULL) {
- perror("failed to popen getpkginfo");
+ perror("failed to popen get_pkg_attrs");
exit(1); // fatal error
}
@@ -98,9 +102,13 @@ bool load_package_info(package_info_t* info, char* pkgid) {
}
free(line);
- // close the getpkginfo process
- if (pclose(getinfo_fp) != 0) {
- perror("failed to pclose getpkginfo");
+ // close the get_pkg_attrs process
+ int close_err = pclose(getinfo_fp);
+ if (close_err == -1) {
+ perror("failed to pclose get_pkg_attrs");
+ exit(1); // fatal error
+ } else if (close_err != 0) {
+ fprintf(stderr, "failed to execute get_pkg_attrs: %d\n", close_err);
exit(1); // fatal error
}
diff --git a/snag/readme.txt b/snag/readme.txt
index d93431d..6062924 100644
--- a/snag/readme.txt
+++ b/snag/readme.txt
@@ -11,6 +11,12 @@
`log` - open your pager to the build log of the specified package
`why` - list why this package is installed (manually installed, as a dependency, from a group)
+## Important Directories
+Package Database - /var/snag/pkgs/
+Install Database - /var/snag/install/
+Logs/In Progress Builds - /var/snag/logs/
+SNAG Configuration - /etc/snag/
+
## Terminology
"Package Database" - the directory containing package descriptions
"Install Database" - the directory containing information on installed package
@@ -23,16 +29,15 @@ 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).
+
+## 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
`desc` - the short description of the package
-## Interesting Features
-- switch between cli and tui mode mid run
-- build packages that aren't in the database
-
## Developer Subcommands
`validate` - check a package description and check for format errors or warnings
diff --git a/snag/run_pkg_install.sh b/snag/run_pkg_install.sh
new file mode 100755
index 0000000..d48d831
--- /dev/null
+++ b/snag/run_pkg_install.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# reads a package description script and runs the configure, build, and install
+# steps. intended only for use by snag program
+if [ -z "$1" ]; then
+ echo "Usage: $0 <description script>" >&2
+ exit 1
+fi
+
+# load the description script
+. $1
+
+# run all install steps for package
+configure
+build
+install
diff --git a/snaggies/swenu/swenu.sh b/snaggies/swenu/swenu.sh
index 9d4a58b..8fdf584 100644
--- a/snaggies/swenu/swenu.sh
+++ b/snaggies/swenu/swenu.sh
@@ -3,13 +3,13 @@ pkg_name="Swenu"
pkg_desc="Simple Wayland ENU"
configure() {
- echo "CONFIGURING..."
+ echo "configuring swenu..."
}
build() {
- echo "BUILDING..."
+ echo "building swenu..."
}
install() {
- echo "INSTALLING..."
+ echo "installing swenu..."
}