diff options
Diffstat (limited to 'snag')
| -rwxr-xr-x | snag/configure | 14 | ||||
| -rw-r--r-- | snag/readme.txt | 22 | ||||
| -rw-r--r-- | snag/src/download_db.c | 10 | ||||
| -rw-r--r-- | snag/src/package_db.c | 2 |
4 files changed, 36 insertions, 12 deletions
diff --git a/snag/configure b/snag/configure index d5493e1..9613843 100755 --- a/snag/configure +++ b/snag/configure @@ -1,27 +1,31 @@ #!/bin/sh +# temp for testing +mkdir -p ./var/snag/{downloads,installs,builds} +ln -s ../../../packages/ ./var/snag/packages + bin="snag" libs="libcurl libcrypto" builddir="build" -CFLAGS=${CFLAGS:-""} +CFLAGS="$CFLAGS $(pkg-config --cflags $libs)"${CFLAGS:-""} CFLAGS_RELEASE="$CFLAGS -O2" CFLAGS_DEBUG="$CFLAGS -Wall -g -DDEBUG=1" write() { echo "$@" >> build.ninja; } -echo "$CFLAGS_DEBUG $(pkg-config --cflags $libs)" | tr ' ' '\n' > compile_flags.txt +echo "$CFLAGS_DEBUG" | tr ' ' '\n' > compile_flags.txt rm -f build.ninja write "builddir = $builddir" -write "libs = $(pkg-config --libs $libs)" +write "linkflags = $(pkg-config --libs $libs)" write 'rule link' write ' description = LD $out' -write ' command = gcc $libs $in -o $out' +write ' command = gcc $linkflags $in -o $out' for target in $(echo "debug release"); do - eval write "cflags_$target = \$CFLAGS_$(echo $target | tr 'a-z' 'A-Z') $(pkg-config --cflags $libs)" + eval write "cflags_$target = \$CFLAGS_$(echo $target | tr 'a-z' 'A-Z')" write "rule cc-$target" write ' deps = gcc' diff --git a/snag/readme.txt b/snag/readme.txt index d42d19c..c64ced7 100644 --- a/snag/readme.txt +++ b/snag/readme.txt @@ -13,7 +13,7 @@ why - list why this package is installed (manually installed, as a depe ## Important Directories Package Database - /var/snag/pkgs/ -Install Database - /var/snag/state/ +Install Database - /var/snag/installs/ Download Database - /var/snag/downloads/ Logs/In Progress Builds - /var/snag/builds/ SNAG Configuration - /etc/snag/ @@ -31,7 +31,7 @@ Download Database - the directory where package downloads are stored and cac - switch between cli and tui mode mid run - build packages that aren't in the database -## Package Description Format +## Package Database and 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` @@ -48,11 +48,27 @@ version - software version, in whatever format is needed. commit hashes are allo ### Snag Shell API TBD -## Install Description Format +## Download Database +TBD + +## Build Database +Each build iteration gets its own directory in the build database, named "id-version-time". +A symlink named "id-latest" will point to the newest build for that package. +The build iteration directory contains: +- the package source trees (if applicable) +- a copy of the package description directory +- the build logs +- an executable script to rebuild + +## Install Database and Description Format TBD. Will contain at least: - date installed - flists - install reason +- link to the build iteration directory ## Developer Subcommands `validate` - check a package description and check for format errors or warnings + + +https://www.labri.fr/perso/nrougier/GTD/index.html#orgfb65d8f diff --git a/snag/src/download_db.c b/snag/src/download_db.c index 6261627..c1e2e1b 100644 --- a/snag/src/download_db.c +++ b/snag/src/download_db.c @@ -9,7 +9,7 @@ #include <errno.h> // note: fixed location of download database for now -const char download_db_path[] = "../downloads"; +const char download_db_path[] = "./var/snag/downloads"; // libcrpyto context EVP_MD_CTX *mdctx = NULL; @@ -18,7 +18,7 @@ const EVP_MD *md = NULL; // curl context CURL *curl = NULL; -static size_t curl_write_cb(char* ptr, size_t size, size_t nmemb, void* usrdata) +static size_t download_write_callback(char* ptr, size_t size, size_t nmemb, void* usrdata) { // write the curl data to the file in usr data size_t written = fwrite(ptr, size, nmemb, (FILE *)usrdata); @@ -56,6 +56,9 @@ bool download_package(package_info_t* pkg) { EVP_DigestInit_ex(mdctx, md, NULL); // open file for writing + // note(jqj): extension is fixed to tar gz until the switch out download + // attrs for the swenu api download command which will specify + // more information char* download_path = vastrcat(download_db_path, "/", pkg->attrs.id, "-", pkg->attrs.version, ".tar.gz"); FILE* download_file = fopen(download_path, "wb"); if (download_file == NULL) die("failed open download file for writing (%s): %s", download_path, strerror(errno)); @@ -64,10 +67,11 @@ bool download_package(package_info_t* pkg) { // callback writes to the file and feeds the hash curl_easy_setopt(curl, CURLOPT_URL, pkg->attrs.source_url); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_cb); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, download_write_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, download_file); CURLcode result = curl_easy_perform(curl); if(result != CURLE_OK) { + // todo(jqj): handle better, maybe try again print("failed to download package with curl: %s", curl_easy_strerror(result)); return false; } diff --git a/snag/src/package_db.c b/snag/src/package_db.c index 3974120..04705e4 100644 --- a/snag/src/package_db.c +++ b/snag/src/package_db.c @@ -12,7 +12,7 @@ #define PKG_INST_CMD "./scripts/run_pkg_install.sh" // note: fixed location of package database for now -const char pkg_db[] = "../packages"; +const char pkg_db[] = "./var/snag/packages"; const size_t pkg_db_len = sizeof(pkg_db) - 1; bool load_package_info(char* pkgid, package_info_t* info) { |
