Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
libcapsule
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Vivek Das Mohapatra
libcapsule
Commits
da0adc03
Commit
da0adc03
authored
Sep 18, 2019
by
Simon McVittie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
capture-libs: Clarify by introducing more temporaries
Signed-off-by:
Simon McVittie
<
smcv@collabora.com
>
parent
1decbc12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
26 deletions
+29
-26
utils/capture-libs.c
utils/capture-libs.c
+29
-26
No files found.
utils/capture-libs.c
View file @
da0adc03
...
...
@@ -354,9 +354,11 @@ capture_one( const char *soname, capture_flags flags,
{
_capsule_autofree
char
*
target
=
NULL
;
struct
stat
statbuf
;
const
char
*
its_basename
;
const
char
*
needed_name
=
provider
.
needed
[
i
].
name
;
const
char
*
needed_path_in_provider
=
provider
.
needed
[
i
].
path
;
const
char
*
needed_basename
;
if
(
!
provider
.
needed
[
i
].
name
)
if
(
!
needed_
name
)
{
continue
;
}
...
...
@@ -364,7 +366,7 @@ capture_one( const char *soname, capture_flags flags,
if
(
i
==
0
&&
!
(
flags
&
CAPTURE_FLAG_LIBRARY_ITSELF
)
)
{
DEBUG
(
DEBUG_TOOL
,
"Not capturing
\"
%s
\"
itself as requested"
,
provider
.
needed
[
i
].
name
);
needed_
name
);
continue
;
}
...
...
@@ -372,11 +374,11 @@ capture_one( const char *soname, capture_flags flags,
{
DEBUG
(
DEBUG_TOOL
,
"Not capturing dependencies of
\"
%s
\"
as requested"
,
provider
.
needed
[
0
].
name
);
so
name
);
break
;
}
its_basename
=
my_basename
(
provider
.
needed
[
i
].
name
);
needed_basename
=
my_basename
(
needed_
name
);
if
(
!
option_glibc
)
{
...
...
@@ -391,11 +393,11 @@ capture_one( const char *soname, capture_flags flags,
assert
(
strstarts
(
libc_patterns
[
j
],
"soname:"
)
);
if
(
strcmp
(
libc_patterns
[
j
]
+
strlen
(
"soname:"
),
its
_basename
)
==
0
)
needed
_basename
)
==
0
)
{
DEBUG
(
DEBUG_TOOL
,
"Not capturing
\"
%s
\"
because it is part of glibc"
,
provider
.
needed
[
i
].
name
);
needed_
name
);
capture
=
false
;
break
;
}
...
...
@@ -405,14 +407,14 @@ capture_one( const char *soname, capture_flags flags,
continue
;
}
if
(
fstatat
(
dest_fd
,
its
_basename
,
&
statbuf
,
if
(
fstatat
(
dest_fd
,
needed
_basename
,
&
statbuf
,
AT_SYMLINK_NOFOLLOW
)
==
0
)
{
/* We already created a symlink for this library. No further
* action required (but keep going through its dependencies
* in case we need to symlink those into place) */
DEBUG
(
DEBUG_TOOL
,
"We already have a symlink for %s"
,
provider
.
needed
[
i
].
name
);
needed_
name
);
continue
;
}
...
...
@@ -424,22 +426,23 @@ capture_one( const char *soname, capture_flags flags,
DEBUG
(
DEBUG_TOOL
,
"Container unknown, cannot compare version with "
"
\"
%s
\"
: assuming provider version is newer"
,
provider
.
needed
[
i
].
path
);
needed_path_in_provider
);
}
else
if
(
i
==
0
&&
(
flags
&
CAPTURE_FLAG_EVEN_IF_OLDER
)
)
{
DEBUG
(
DEBUG_TOOL
,
"Explicitly requested %s from %s even if older:
\"
%s
\"
"
,
provider
.
needed
[
i
].
name
,
option_provider
,
provider
.
needed
[
i
].
path
);
needed_
name
,
option_provider
,
needed_path_in_provider
);
}
else
{
_capsule_cleanup
(
ld_libs_finish
)
ld_libs
container
=
{};
if
(
init_with_target
(
&
container
,
option_container
,
provider
.
needed
[
i
].
name
,
needed_
name
,
&
local_code
,
&
local_message
)
)
{
const
char
*
needed_path_in_container
=
container
.
needed
[
0
].
path
;
_capsule_autofree
char
*
p_realpath
=
NULL
;
_capsule_autofree
char
*
c_realpath
=
NULL
;
const
char
*
p_basename
;
...
...
@@ -447,15 +450,15 @@ capture_one( const char *soname, capture_flags flags,
// This might look redundant, but resolve_symlink_prefixed()
// doesn't chase symlinks if the prefix is '/' or empty.
p_realpath
=
realpath
(
provider
.
needed
[
i
].
path
,
NULL
);
c_realpath
=
realpath
(
container
.
needed
[
0
].
path
,
NULL
);
p_realpath
=
realpath
(
needed_path_in_provider
,
NULL
);
c_realpath
=
realpath
(
needed_path_in_container
,
NULL
);
p_basename
=
my_basename
(
p_realpath
);
c_basename
=
my_basename
(
c_realpath
);
DEBUG
(
DEBUG_TOOL
,
"Comparing %s
\"
%s
\"
from
\"
%s
\"
with "
"
\"
%s
\"
from
\"
%s
\"
"
,
provider
.
needed
[
i
].
name
,
p_basename
,
option_provider
,
needed_
name
,
p_basename
,
option_provider
,
c_basename
,
option_container
);
/* If equal, we prefer the provider over the container */
...
...
@@ -465,14 +468,14 @@ capture_one( const char *soname, capture_flags flags,
* symlink in the one from the provider */
DEBUG
(
DEBUG_TOOL
,
"%s is strictly newer in the container"
,
provider
.
needed
[
i
].
name
);
needed_
name
);
continue
;
}
else
{
DEBUG
(
DEBUG_TOOL
,
"%s is newer or equal in the provider"
,
provider
.
needed
[
i
].
name
);
needed_
name
);
}
}
else
if
(
local_code
==
ENOENT
)
...
...
@@ -480,7 +483,7 @@ capture_one( const char *soname, capture_flags flags,
/* else assume it's absent from the container, which is
* just like it being newer in the provider */
DEBUG
(
DEBUG_TOOL
,
"%s is not in the container"
,
provider
.
needed
[
i
].
name
);
needed_
name
);
_capsule_clear
(
&
local_message
);
}
else
...
...
@@ -496,7 +499,7 @@ capture_one( const char *soname, capture_flags flags,
if
(
option_link_target
==
NULL
)
{
target
=
xstrdup
(
provider
.
needed
[
i
].
path
);
target
=
xstrdup
(
needed_path_in_provider
);
}
else
{
...
...
@@ -509,7 +512,7 @@ capture_one( const char *soname, capture_flags flags,
// $libdir/libGL.so.1 -> /etc/alternatives/whatever -> ...
// within that prefix.
safe_strncpy
(
path
,
provider
.
needed
[
i
].
path
,
sizeof
(
path
)
);
safe_strncpy
(
path
,
needed_path_in_provider
,
sizeof
(
path
)
);
DEBUG
(
DEBUG_TOOL
,
"Link target initially:
\"
%s
\"
"
,
path
);
...
...
@@ -539,21 +542,21 @@ capture_one( const char *soname, capture_flags flags,
assert
(
target
!=
NULL
);
DEBUG
(
DEBUG_TOOL
,
"Creating symlink %s/%s -> %s"
,
option_dest
,
its
_basename
,
target
);
option_dest
,
needed
_basename
,
target
);
if
(
symlinkat
(
target
,
dest_fd
,
its
_basename
)
<
0
)
if
(
symlinkat
(
target
,
dest_fd
,
needed
_basename
)
<
0
)
{
warn
(
"warning: cannot create symlink %s/%s"
,
option_dest
,
its
_basename
);
option_dest
,
needed
_basename
);
}
if
(
strcmp
(
its
_basename
,
"libc.so.6"
)
==
0
)
if
(
strcmp
(
needed
_basename
,
"libc.so.6"
)
==
0
)
{
/* Having captured libc, we need to capture the rest of
* the related libraries from the same place */
DEBUG
(
DEBUG_TOOL
,
"Capturing the rest of glibc to go with %s"
,
provider
.
needed
[
i
].
name
);
needed_
name
);
if
(
!
capture_patterns
(
libc_patterns
,
(
flags
|
CAPTURE_FLAG_IF_EXISTS
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment