Skip to content
Snippets Groups Projects
Commit 73c8df5d authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

do not initiate empty db

parent c969977d
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <oblibs/obgetopt.h>
#include <oblibs/string.h>
......@@ -41,7 +42,7 @@
#include <66/ssexec.h>
#include <66/rc.h>
#include <stdio.h>
int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec_t *info)
{
......@@ -51,7 +52,7 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec
genalloc gares = GENALLOC_ZERO ; //ss_resolve_t type
stralloc ressrc = STRALLOC_ZERO ;
stralloc resdst = STRALLOC_ZERO ;
stralloc src = STRALLOC_ZERO ;
stralloc sares = STRALLOC_ZERO ;
ss_resolve_t res = RESOLVE_ZERO ;
classic = db = earlier = 0 ;
......@@ -73,7 +74,7 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec
if (r != 1) earlier = 1 ;
r = scan_mode(info->livetree.s,S_IFDIR) ;
if (r < 0) strerr_dief2x(111,info->livetree.s," conflicting format") ;
if (r < 0) strerr_dief2x(111,info->livetree.s," conflicted format") ;
if (!r)
{
VERBO2 strerr_warni2x("create directory: ",info->livetree.s) ;
......@@ -91,23 +92,23 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec
svdir[svdirlen + SS_SVC_LEN] = 0 ;
/** resolve live dir*/
if (!ss_resolve_pointo(&src,info,SS_NOTYPE,SS_RESOLVE_SRC)) strerr_diefu1sys(111,"set revolve pointer to source") ;
if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) strerr_diefu1sys(111,"set revolve pointer to source") ;
if (!stralloc_copy(&ressrc,&src)) retstralloc(111,"main") ;
if (!stralloc_copy(&ressrc,&sares)) retstralloc(111,"main") ;
ressrc.len--;
if (!stralloc_cats(&ressrc,SS_RESOLVE)) retstralloc(111,"main") ;
if (!stralloc_0(&ressrc)) retstralloc(111,"main") ;
if (!ss_resolve_pointo(&src,info,SS_NOTYPE,SS_RESOLVE_LIVE)) strerr_diefu1sys(111,"set revolve pointer to source") ;
r = scan_mode(src.s,S_IFDIR) ;
if (r < 0) strerr_dief2x(111,src.s," conflicting format") ;
if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_LIVE)) strerr_diefu1sys(111,"set revolve pointer to source") ;
r = scan_mode(sares.s,S_IFDIR) ;
if (r < 0) strerr_dief2x(111,sares.s," conflicting format") ;
if (!r)
{
VERBO2 strerr_warni3x("create directory: ",src.s,SS_RESOLVE) ;
r = dir_create_under(src.s,SS_RESOLVE+1,0700) ;
if (!r) strerr_diefu3sys(111,"create directory: ",src.s,SS_RESOLVE) ;
VERBO2 strerr_warni3x("create directory: ",sares.s,SS_RESOLVE) ;
r = dir_create_under(sares.s,SS_RESOLVE+1,0700) ;
if (!r) strerr_diefu3sys(111,"create directory: ",sares.s,SS_RESOLVE) ;
}
if (!stralloc_copy(&resdst,&src)) retstralloc(111,"main") ;
if (!stralloc_copy(&resdst,&sares)) retstralloc(111,"main") ;
resdst.len--;
if (!stralloc_cats(&resdst,SS_RESOLVE)) retstralloc(111,"main") ;
if (!stralloc_0(&resdst)) retstralloc(111,"main") ;
......@@ -124,7 +125,9 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec
if (!dir_cmp(svdir,info->scandir.s,"",&gasvc)) strerr_diefu4x(111,"compare ",svdir," to ",info->scandir.s) ;
if (!genalloc_len(stralist,&gasvc))
{
VERBO1 strerr_warni3x("svc service of tree: ",info->treename.s," already initiated") ;
VERBO1 strerr_warni2x("Initialization aborted -- no classic services into tree: ",info->treename.s) ;
genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ;
genalloc_deepfree(stralist,&gasvc,stra_free) ;
goto follow ;
}
......@@ -133,9 +136,9 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec
char *name = gaistr(&gasvc,i) ;
ss_resolve_t tmp = RESOLVE_ZERO ;
if (!ss_resolve_check(info,name,SS_RESOLVE_LIVE)) strerr_dief2sys(110,"unknow service: ",name) ;
if (!ss_resolve_read(&tmp,src.s,name)) strerr_diefu2sys(111,"read resolve file of: ",name) ;
if (!genalloc_append(ss_resolve_t,&gares,&tmp)) strerr_diefu3x(111,"add: ",name," on genalloc") ;
if (!ss_resolve_read(&tmp,sares.s,name)) strerr_diefu2sys(111,"read resolve file of: ",name) ;
if (!ss_resolve_add_deps(&gares,&tmp,info)) strerr_diefu2sys(111,"resolve dependencies of: ",name) ;
ss_resolve_free(&tmp) ;
}
/** reverse to start first the logger */
genalloc_reverse(ss_resolve_t,&gares) ;
......@@ -164,7 +167,7 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec
follow:
stralloc_free(&src) ;
stralloc_free(&sares) ;
ss_resolve_free(&res) ;
genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ;
genalloc_deepfree(stralist,&gasvc,stra_free) ;
......@@ -182,31 +185,38 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec
}else strerr_dief3x(110,"scandir: ",info->scandir.s," is not running") ;
}else goto end ;
if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC))
VERBO1 strerr_diefu1x(111,"set revolve pointer to source") ;
if (!ss_resolve_check(info,SS_MASTER +1,SS_RESOLVE_SRC)) strerr_diefu1x(111,"find inner bundle -- please make a bug report") ;
if (!ss_resolve_read(&res,sares.s,SS_MASTER + 1)) strerr_diefu1sys(111,"read resolve file of inner bundle") ;
if (!res.ndeps)
{
if (!ss_resolve_pointo(&src,info,SS_NOTYPE,SS_RESOLVE_SRC))
VERBO1 strerr_diefu1x(111,"set revolve pointer to source") ;
if (!ss_resolve_check(info,SS_MASTER +1,SS_RESOLVE_SRC)) strerr_diefu1x(111,"find inner bundle -- please make a bug report") ;
if (!ss_resolve_read(&res,src.s,SS_MASTER + 1)) strerr_diefu1sys(111,"read resolve file of inner bundle") ;
if (!clean_val(&gasvc,res.sa.s + res.deps)) strerr_diefu1sys(111,"clean dependencies of inner bundle") ;
for (unsigned int i = 0 ; i < genalloc_len(stralist,&gasvc) ; i++)
{
char *name = gaistr(&gasvc,i) ;
ss_resolve_t tmp = RESOLVE_ZERO ;
if (!ss_resolve_check(info,name,SS_RESOLVE_SRC)) strerr_dief2sys(110,"unknow service: ",name) ;
if (!ss_resolve_read(&tmp,src.s,name)) strerr_diefu2sys(111,"read resolve file of: ",name) ;
if (!genalloc_append(ss_resolve_t,&gares,&tmp)) strerr_diefu3x(111,"add: ",name," on genalloc") ;
if (!ss_resolve_add_deps(&gares,&tmp,info)) strerr_diefu2sys(111,"resolve dependencies of: ",name) ;
}
if (!rc_init(info,&gares,envp)) strerr_diefu2sys(111,"initiate db of tree: ",info->treename.s) ;
genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ;
genalloc_deepfree(stralist,&gasvc,stra_free) ;
VERBO1 strerr_warni2x("Initialization aborted -- no atomic services into tree: ",info->treename.s) ;
stralloc_free(&sares) ;
ss_resolve_free(&res) ;
stralloc_free(&src) ;
goto end ;
}
if (!clean_val(&gasvc,res.sa.s + res.deps)) strerr_diefu1sys(111,"clean dependencies of inner bundle") ;
for (unsigned int i = 0 ; i < genalloc_len(stralist,&gasvc) ; i++)
{
char *name = gaistr(&gasvc,i) ;
ss_resolve_t tmp = RESOLVE_ZERO ;
if (!ss_resolve_check(info,name,SS_RESOLVE_SRC)) strerr_dief2sys(110,"unknow service: ",name) ;
if (!ss_resolve_read(&tmp,sares.s,name)) strerr_diefu2sys(111,"read resolve file of: ",name) ;
if (!ss_resolve_add_deps(&gares,&tmp,info)) strerr_diefu2sys(111,"resolve dependencies of: ",name) ;
ss_resolve_free(&tmp) ;
}
if (!rc_init(info,&gares,envp)) strerr_diefu2sys(111,"initiate db of tree: ",info->treename.s) ;
genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ;
genalloc_deepfree(stralist,&gasvc,stra_free) ;
ss_resolve_free(&res) ;
stralloc_free(&sares) ;
end:
return 0 ;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment