Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
88f8f7bc
Commit
88f8f7bc
authored
4 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
add env_find_current(). Fix 66-env import options
parent
2e82711b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/include/66/environ.h
+1
-0
1 addition, 0 deletions
src/include/66/environ.h
src/lib66/ss_environ.c
+11
-1
11 additions, 1 deletion
src/lib66/ss_environ.c
src/lib66/ssexec_env.c
+21
-17
21 additions, 17 deletions
src/lib66/ssexec_env.c
with
33 additions
and
18 deletions
src/include/66/environ.h
+
1
−
0
View file @
88f8f7bc
...
...
@@ -25,5 +25,6 @@ extern int env_resolve_conf(stralloc *env,char const *svname,uid_t owner) ;
extern
int
env_merge_conf
(
stralloc
*
result
,
stralloc
*
srclist
,
stralloc
*
modifs
,
uint8_t
conf
)
;
extern
int
env_clean_with_comment
(
stralloc
*
sa
)
;
extern
int
env_compute
(
stralloc
*
result
,
sv_alltype
*
sv
,
uint8_t
conf
)
;
extern
int
env_find_current_version
(
stralloc
*
sa
,
char
const
*
svconf
)
;
#endif
This diff is collapsed.
Click to expand it.
src/lib66/ss_environ.c
+
11
−
1
View file @
88f8f7bc
...
...
@@ -23,8 +23,8 @@
#include
<oblibs/string.h>
#include
<oblibs/types.h>
#include
<oblibs/directory.h>
#include
<skalibs/unix-transactional.h>
//atomic_symlink
#include
<skalibs/unix-transactional.h>
//atomic_symlink
#include
<skalibs/stralloc.h>
#include
<skalibs/djbunix.h>
//rm_rf
...
...
@@ -433,3 +433,13 @@ int env_clean_with_comment(stralloc *sa)
return
1
;
}
int
env_find_current_version
(
stralloc
*
sa
,
char
const
*
svconf
)
{
size_t
svconflen
=
strlen
(
svconf
)
;
char
tmp
[
svconflen
+
SS_SYM_VERSION_LEN
+
1
]
;
auto_strings
(
tmp
,
svconf
,
SS_SYM_VERSION
)
;
if
(
sareadlink
(
sa
,
tmp
)
==
-
1
)
log_warnusys_return
(
LOG_EXIT_ZERO
,
"readlink: "
,
tmp
)
;
if
(
!
stralloc_0
(
sa
))
log_warnusys_return
(
LOG_EXIT_ZERO
,
"stralloc"
)
;
return
1
;
}
This diff is collapsed.
Click to expand it.
src/lib66/ssexec_env.c
+
21
−
17
View file @
88f8f7bc
...
...
@@ -56,7 +56,7 @@ static void check_version(stralloc *sa, char const *version)
int
r
;
r
=
version_scan
(
sa
,
version
,
SS_CONFIG_VERSION_NDOT
)
;
if
(
r
==
-
1
)
log_die_nomem
(
"stralloc"
)
;
if
(
!
r
)
log_die
(
LOG_EXIT_USER
,
"invalid version format
"
)
;
if
(
!
r
)
log_die
(
LOG_EXIT_USER
,
"invalid version format
: "
,
version
)
;
}
static
void
append_version
(
stralloc
*
saversion
,
char
const
*
svconf
,
char
const
*
version
)
...
...
@@ -79,13 +79,9 @@ static void append_version(stralloc *saversion, char const *svconf, char const *
static
uint8_t
check_current_version
(
char
const
*
svconf
,
char
const
*
version
)
{
stralloc
sa
=
STRALLOC_ZERO
;
size_t
svconflen
=
strlen
(
svconf
)
;
char
tmp
[
svconflen
+
SS_SYM_VERSION_LEN
+
1
]
;
auto_strings
(
tmp
,
svconf
,
SS_SYM_VERSION
)
;
if
(
sareadlink
(
&
sa
,
tmp
)
==
-
1
)
log_dieusys
(
LOG_EXIT_SYS
,
"readlink: "
,
sa
.
s
)
;
if
(
!
stralloc_0
(
&
sa
))
log_die_nomem
(
"stralloc"
)
;
if
(
!
env_find_current_version
(
&
sa
,
svconf
))
log_dieu
(
LOG_EXIT_SYS
,
"find current version"
)
;
char
bname
[
sa
.
len
+
1
]
;
if
(
!
ob_basename
(
bname
,
sa
.
s
))
log_dieu
(
LOG_EXIT_SYS
,
"get
current version"
)
;
if
(
!
ob_basename
(
bname
,
sa
.
s
))
log_dieu
(
LOG_EXIT_SYS
,
"get
basename of: "
,
sa
.
s
)
;
stralloc_free
(
&
sa
)
;
return
!
version_cmp
(
bname
,
version
,
SS_CONFIG_VERSION_NDOT
)
?
1
:
0
;
}
...
...
@@ -108,7 +104,8 @@ static void do_import(char const *svname, char const *svconf, char const *versio
size_t
pos
=
0
;
stralloc
salist
=
STRALLOC_ZERO
;
stralloc
sasrc
=
STRALLOC_ZERO
;
stralloc
sadst
=
STRALLOC_ZERO
;
stralloc
src_ver
=
STRALLOC_ZERO
;
stralloc
dst_ver
=
STRALLOC_ZERO
;
char
*
src_version
=
0
;
char
*
dst_version
=
0
;
...
...
@@ -124,22 +121,28 @@ static void do_import(char const *svname, char const *svconf, char const *versio
else
dst_version
=
sasrc
.
s
+
pos
;
}
append_version
(
&
sasrc
,
svconf
,
src_version
)
;
append_version
(
&
sadst
,
svconf
,
dst_version
)
;
if
(
!
version_cmp
(
src_version
,
dst_version
,
SS_CONFIG_VERSION_NDOT
))
{
log_1_warn
(
"import asked on same version -- nothing to do"
)
;
return
;
}
append_version
(
&
src_ver
,
svconf
,
src_version
)
;
append_version
(
&
dst_ver
,
svconf
,
dst_version
)
;
if
(
!
sastr_dir_get
(
&
salist
,
s
as
rc
.
s
,
svname
,
S_IFREG
))
log_dieu
(
LOG_EXIT_SYS
,
"get configuration file from directory: "
,
s
as
rc
.
s
)
;
if
(
!
sastr_dir_get
(
&
salist
,
src
_ver
.
s
,
svname
,
S_IFREG
))
log_dieu
(
LOG_EXIT_SYS
,
"get configuration file from directory: "
,
src
_ver
.
s
)
;
for
(
pos
=
0
;
pos
<
salist
.
len
;
pos
+=
strlen
(
salist
.
s
+
pos
)
+
1
)
{
char
*
name
=
salist
.
s
+
pos
;
size_t
namelen
=
strlen
(
name
)
;
char
s
[
s
as
rc
.
len
+
1
+
namelen
+
1
]
;
auto_strings
(
s
,
s
as
rc
.
s
,
"/"
,
name
)
;
char
s
[
src
_ver
.
len
+
1
+
namelen
+
1
]
;
auto_strings
(
s
,
src
_ver
.
s
,
"/"
,
name
)
;
char
d
[
sa
dst
.
len
+
1
+
namelen
+
1
]
;
auto_strings
(
d
,
sa
dst
.
s
,
"/"
,
name
)
;
char
d
[
dst
_ver
.
len
+
1
+
namelen
+
1
]
;
auto_strings
(
d
,
dst
_ver
.
s
,
"/"
,
name
)
;
if
(
lstat
(
s
,
&
st
)
<
0
)
log_dieusys
(
LOG_EXIT_SYS
,
"stat: "
,
s
)
;
log_info
(
"copy: "
,
s
,
" to: "
,
d
)
;
...
...
@@ -147,7 +150,8 @@ static void do_import(char const *svname, char const *svconf, char const *versio
}
stralloc_free
(
&
sasrc
)
;
stralloc_free
(
&
sadst
)
;
stralloc_free
(
&
src_ver
)
;
stralloc_free
(
&
dst_ver
)
;
stralloc_free
(
&
salist
)
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment