nkiss

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/nkiss
Log | Files | Refs

commit df6050eddd126f55dc9f3c3567cc12f7763daec8
parent 7e500069483c5587c6753fb072faf25eaaaea9f4
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Thu, 18 Feb 2021 20:29:27 -0600

pkg.*: update source_t

rename url to loc
add member to source_t to indicate whether a package is local

Diffstat:
Mpkg.c | 16++++++++++------
Mpkg.h | 3++-
2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/pkg.c b/pkg.c @@ -28,10 +28,10 @@ pkg_download(char *repo, char *name) strcat(destpath, name); strcat(destpath, "/"); mkdirs(destpath); - strcat(destpath, basename(sources[i].url)); + strcat(destpath, basename(sources[i].loc)); if (access(destpath, F_OK)) - http_fetch(sources[i].url, destpath); + http_fetch(sources[i].loc, destpath); } } @@ -61,8 +61,8 @@ pkg_sources(char *repo, char *name, struct source_t *sources) /* we are given an extraction path */ if ((end = strchr(p, ' '))) { - strncpy(sources[i].url, p, end - p); - sources[i].url[end - p] = '\0'; + strncpy(sources[i].loc, p, end - p); + sources[i].loc[end - p] = '\0'; /* no NULL check needed, as we know its in the string */ p = strrchr(p, ' ') + 1; @@ -71,10 +71,14 @@ pkg_sources(char *repo, char *name, struct source_t *sources) sources[i].path[end - p] = '\0'; } else { end = strchr(p, '\n'); - strncpy(sources[i].url, p, end-p); - sources[i].url[end-p] = '\0'; + strncpy(sources[i].loc, p, end-p); + sources[i].loc[end-p] = '\0'; } + /* local source */ + if (strstr(sources[i].loc, "://") == NULL) + sources[i].local = 1; + if (++i > PKG_SOURCES_MAX) { fclose(sfile); die("%s: too many sources for %s", __func__, name); diff --git a/pkg.h b/pkg.h @@ -8,7 +8,8 @@ struct source_t { char git; - char url[URL_LEN]; + char local; + char loc[URL_LEN]; char path[PATH_LEN]; };