aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-05-31 02:52:43 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-05-31 02:52:43 +0200
commit4ab4c1d0ba31d437e05792719fba664a94521819 (patch)
tree953bf2925e1c96f95be28132a5459b82bd5a51bf /src
parent56e07b6224fce7e213bfb9b4d00b93628a50aca7 (diff)
downloadblogc-4ab4c1d0ba31d437e05792719fba664a94521819.tar.gz
blogc-4ab4c1d0ba31d437e05792719fba664a94521819.tar.bz2
blogc-4ab4c1d0ba31d437e05792719fba664a94521819.zip
git-receiver: allow users to define builds dir
Diffstat (limited to 'src')
-rw-r--r--src/blogc-git-receiver/pre-receive.c9
-rw-r--r--src/blogc-git-receiver/settings.c19
-rw-r--r--src/blogc-git-receiver/settings.h3
-rw-r--r--src/blogc-git-receiver/shell.c2
4 files changed, 23 insertions, 10 deletions
diff --git a/src/blogc-git-receiver/pre-receive.c b/src/blogc-git-receiver/pre-receive.c
index 897e8f0..9611567 100644
--- a/src/blogc-git-receiver/pre-receive.c
+++ b/src/blogc-git-receiver/pre-receive.c
@@ -199,15 +199,16 @@ default_sym:
goto cleanup;
}
- const char *bd = bgr_settings_get_basedir();
- if (bd == NULL) {
- fprintf(stderr, "error: failed to find user base directory path\n");
+ char *buildsd = bgr_settings_get_builds_dir();
+ if (buildsd == NULL) {
+ fprintf(stderr, "error: failed to find builds directory path\n");
rv = 3;
goto cleanup;
}
unsigned long epoch = time(NULL);
- output_dir = bc_strdup_printf("%s/builds/%s-%lu", bd, master, epoch);
+ output_dir = bc_strdup_printf("%s/%s-%lu", buildsd, master, epoch);
+ free(buildsd);
if (0 == access(output_dir, F_OK)) {
char *tmp = output_dir;
diff --git a/src/blogc-git-receiver/settings.c b/src/blogc-git-receiver/settings.c
index 514fcdf..4cfcaf7 100644
--- a/src/blogc-git-receiver/settings.c
+++ b/src/blogc-git-receiver/settings.c
@@ -20,9 +20,9 @@
const char*
-bgr_settings_get_basedir(void)
+bgr_settings_get_base_dir(void)
{
- char *rv = getenv("BLOGC_GIT_RECEIVER_BASEDIR");
+ char *rv = getenv("BLOGC_GIT_RECEIVER_BASE_DIR");
if (rv != NULL) {
return rv;
}
@@ -31,9 +31,20 @@ bgr_settings_get_basedir(void)
char*
+bgr_settings_get_builds_dir(void)
+{
+ char *rv = getenv("BLOGC_GIT_RECEIVER_BUILDS_DIR");
+ if (rv != NULL) {
+ return bc_strdup(rv);
+ }
+ return bc_strdup_printf("%s/builds", bgr_settings_get_base_dir());
+}
+
+
+char*
bgr_settings_get_section(bc_config_t *config, const char *repo_path)
{
- const char *bd = bgr_settings_get_basedir();
+ const char *bd = bgr_settings_get_base_dir();
if (bd == NULL) {
return NULL;
}
@@ -62,7 +73,7 @@ bgr_settings_get_section(bc_config_t *config, const char *repo_path)
bc_config_t*
bgr_settings_parse(void)
{
- const char *bd = bgr_settings_get_basedir();
+ const char *bd = bgr_settings_get_base_dir();
if (bd == NULL) {
return NULL;
}
diff --git a/src/blogc-git-receiver/settings.h b/src/blogc-git-receiver/settings.h
index 1b89d0f..bb6649a 100644
--- a/src/blogc-git-receiver/settings.h
+++ b/src/blogc-git-receiver/settings.h
@@ -11,7 +11,8 @@
#include "../common/config-parser.h"
-const char* bgr_settings_get_basedir(void);
+const char* bgr_settings_get_base_dir(void);
+char* bgr_settings_get_builds_dir(void);
char* bgr_settings_get_section(bc_config_t *config, const char *repo_path);
bc_config_t* bgr_settings_parse(void);
diff --git a/src/blogc-git-receiver/shell.c b/src/blogc-git-receiver/shell.c
index f2eaf32..8c45b54 100644
--- a/src/blogc-git-receiver/shell.c
+++ b/src/blogc-git-receiver/shell.c
@@ -36,7 +36,7 @@ bgr_shell(int argc, char *argv[])
}
// get base dir path
- const char *bd = bgr_settings_get_basedir();
+ const char *bd = bgr_settings_get_base_dir();
if (bd == NULL) {
fprintf(stderr, "error: failed to find base directory path\n");
rv = 3;