Skip to content

Commit f298262

Browse files
committed
add option for finding libgcc
Signed-off-by: Zen <[email protected]>
1 parent 05f7d99 commit f298262

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

src/ugrd/base/core.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '3.2.0'
2+
__version__ = '3.3.0'
33

44
from pathlib import Path
55
from typing import Union
@@ -140,6 +140,27 @@ def deploy_nodes(self) -> None:
140140
raise e
141141

142142

143+
@check_dict('find_libgcc', value=True, log_level=20, message="Skipping libgcc_s dependency resolution.")
144+
def find_libgcc(self) -> None:
145+
"""
146+
Finds libgcc.so, adds a 'dependencies' item for it.
147+
Adds the parent directory to 'library_paths'
148+
"""
149+
from pathlib import Path
150+
151+
try:
152+
ldconfig = self._run(['ldconfig', '-p']).stdout.decode().split("\n")
153+
except RuntimeError:
154+
return self.logger.critical("Unable to run ldconfig -p, if GCC is being used, this is fatal!")
155+
156+
libgcc = [lib for lib in ldconfig if 'libgcc_s' in lib and '(libc6,' in lib][0]
157+
source_path = Path(libgcc.partition('=> ')[-1])
158+
self.logger.info("Source path for libgcc_s: %s" % source_path)
159+
160+
self['dependencies'] = source_path
161+
self['library_paths'] = str(source_path.parent)
162+
163+
143164
def _process_paths_multi(self, path: Union[Path, str]) -> None:
144165
"""
145166
Converts the input to a Path if it is not one.
@@ -161,8 +182,7 @@ def _process_paths_multi(self, path: Union[Path, str]) -> None:
161182
def _process_binaries_multi(self, binary: str) -> None:
162183
""" Processes binaries into the binaries list, adding dependencies along the way. """
163184
if binary in self['binaries']:
164-
self.logger.debug("Binary already in binaries list, skipping: %s" % binary)
165-
return
185+
return self.logger.debug("Binary already in binaries list, skipping: %s" % binary)
166186

167187
# Check if there is an import function that collides with the name of the binary
168188
if funcs := self['imports'].get('functions'):

src/ugrd/base/core.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ build_dir = "/tmp/initramfs"
33
_build_log_level = 10
44
out_dir = "/tmp/initramfs_out"
55
clean = true
6+
find_libgcc = true
67
hostonly = true
78
validate = true
89
library_paths = [ "/lib64" ]
@@ -32,7 +33,7 @@ minor = 1
3233
]
3334

3435
[imports.build_pre]
35-
"ugrd.base.core" = [ "clean_build_dir" ]
36+
"ugrd.base.core" = [ "clean_build_dir", "find_libgcc" ]
3637

3738
[imports.build_tasks]
3839
"ugrd.base.core" = [ "generate_structure", "deploy_dependencies", "deploy_gz_dependencies", "deploy_copies", "deploy_nodes", "deploy_symlinks" ]
@@ -53,6 +54,7 @@ dependencies = "NoDupFlatList" # Dependencies, used to define the dependencies
5354
opt_dependencies = "NoDupFlatList" # Optional dependencies, which will be included if they are found
5455
gz_dependencies = "NoDupFlatList" # GZipped dependencies property, used to define the gzipped dependencies (will be extracted)
5556
library_paths = "NoDupFlatList" # library_paths property, used to define the library paths to add to LD_LIBRARY_PATH
57+
find_libgcc = "bool" # If true, the initramfs will search for libgcc_s.so.1 and add it to the initramfs
5658
binaries = "NoDupFlatList" # Binaries which should be included in the intiramfs, dependencies resolved with lddtree
5759
copies = "dict" # Copies dict, defines the files to be copied to the initramfs
5860
nodes = "dict" # Nodes dict, defines the device nodes to be created

src/ugrd/crypto/cryptsetup.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '2.2.1'
2+
__version__ = '2.2.2'
33

44
from zenlib.util import check_dict
55

@@ -272,18 +272,3 @@ def crypt_init(self) -> list[str]:
272272
'fi']
273273
return out
274274

275-
276-
def find_libgcc(self) -> None:
277-
"""
278-
Finds libgcc.so, adds a 'dependencies' item for it.
279-
Adds the parent directory to 'library_paths'
280-
"""
281-
from pathlib import Path
282-
283-
ldconfig = self._run(['ldconfig', '-p']).stdout.decode().split("\n")
284-
libgcc = [lib for lib in ldconfig if 'libgcc_s' in lib and '(libc6,' in lib][0]
285-
source_path = Path(libgcc.partition('=> ')[-1])
286-
self.logger.info("Source path for libgcc_s: %s" % source_path)
287-
288-
self['dependencies'] = source_path
289-
self['library_paths'] = str(source_path.parent)

src/ugrd/crypto/cryptsetup.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ cryptsetup_autoretry = true
1212
[imports.config_processing]
1313
"ugrd.crypto.cryptsetup" = [ "_process_cryptsetup_multi", "_process_cryptsetup_key_types_multi" ]
1414

15-
[imports.build_pre]
16-
"ugrd.crypto.cryptsetup" = [ "find_libgcc" ]
17-
1815
[imports.init_early]
1916
"ugrd.crypto.cryptsetup" = [ "get_crypt_sources" ]
2017

0 commit comments

Comments
 (0)