Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1657c74b52 |
+25
-6
@@ -1102,18 +1102,37 @@ def build_package_buildah(
|
|||||||
'find', '/app/dist', '-type', 'f', '-name', '*.rpm'
|
'find', '/app/dist', '-type', 'f', '-name', '*.rpm'
|
||||||
]
|
]
|
||||||
result = subprocess.run(copy_out_args, capture_output=True, text=True)
|
result = subprocess.run(copy_out_args, capture_output=True, text=True)
|
||||||
|
logger.debug(f"Find RPMs result: {result.stdout}")
|
||||||
|
|
||||||
if result.returncode == 0 and result.stdout.strip():
|
if result.returncode == 0 and result.stdout.strip():
|
||||||
rpm_files = result.stdout.strip().split('\n')
|
rpm_files = result.stdout.strip().split('\n')
|
||||||
|
logger.info(f"Found {len(rpm_files)} RPM files to copy")
|
||||||
|
|
||||||
for rpm_file in rpm_files:
|
for rpm_file in rpm_files:
|
||||||
rpm_file = rpm_file.strip()
|
rpm_file = rpm_file.strip()
|
||||||
if rpm_file:
|
if rpm_file:
|
||||||
copy_args = [
|
# Use buildah mount to copy files out
|
||||||
'buildah', 'copy', '--from', container_name,
|
mount_args = ['buildah', 'mount', container_name]
|
||||||
rpm_file, str(package_dist_dir)
|
mount_result = subprocess.run(mount_args, capture_output=True, text=True)
|
||||||
]
|
|
||||||
logger.debug(f"Running: {' '.join(copy_args)}")
|
if mount_result.returncode == 0:
|
||||||
subprocess.run(copy_args, capture_output=True, text=True)
|
container_path = mount_result.stdout.strip()
|
||||||
|
source_file = Path(container_path) / rpm_file.lstrip('/')
|
||||||
|
|
||||||
|
if source_file.exists():
|
||||||
|
import shutil
|
||||||
|
dest_file = package_dist_dir / source_file.name
|
||||||
|
shutil.copy2(source_file, dest_file)
|
||||||
|
logger.debug(f"Copied {source_file} to {dest_file}")
|
||||||
|
else:
|
||||||
|
logger.error(f"Source file not found: {source_file}")
|
||||||
|
|
||||||
|
# Unmount
|
||||||
|
subprocess.run(['buildah', 'unmount', container_name], capture_output=True)
|
||||||
|
else:
|
||||||
|
logger.error(f"Failed to mount container: {mount_result.stderr}")
|
||||||
|
else:
|
||||||
|
logger.warning(f"No RPM files found or find command failed: {result.stderr}")
|
||||||
|
|
||||||
logger.info(f"Successfully built {package_name}-{package_version}-{package_release} using Buildah")
|
logger.info(f"Successfully built {package_name}-{package_version}-{package_release} using Buildah")
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user