Add comprehensive testing framework, performance monitoring, and plugin system
- Add complete pytest testing framework with conftest.py and test files - Add performance monitoring and benchmarking capabilities - Add plugin system with ccache plugin example - Add comprehensive documentation (API, deployment, testing, etc.) - Add Docker API wrapper for service deployment - Add advanced configuration examples - Remove old wget package file - Update core modules with enhanced functionality
This commit is contained in:
parent
4c0dcb2522
commit
c51819c836
30 changed files with 11141 additions and 105 deletions
106
examples/advanced-config.yaml
Normal file
106
examples/advanced-config.yaml
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
# Advanced deb-mock configuration example
|
||||
# Demonstrates parallel builds and advanced mount management
|
||||
|
||||
# Basic chroot configuration
|
||||
chroot_name: "debian-trixie-amd64-advanced"
|
||||
architecture: "amd64"
|
||||
suite: "trixie"
|
||||
output_dir: "./output"
|
||||
keep_chroot: false
|
||||
verbose: true
|
||||
debug: false
|
||||
|
||||
# Chroot paths
|
||||
basedir: "/var/lib/deb-mock"
|
||||
chroot_dir: "/var/lib/deb-mock/chroots"
|
||||
chroot_config_dir: "/etc/schroot/chroot.d"
|
||||
chroot_home: "/home/build"
|
||||
|
||||
# Parallel build configuration
|
||||
parallel_builds: 4 # Number of parallel chroots
|
||||
parallel_chroot_prefix: "parallel"
|
||||
parallel_build_timeout: 7200 # 2 hours
|
||||
parallel_build_cleanup: true
|
||||
|
||||
# Advanced mount management
|
||||
mount_proc: true
|
||||
mount_sys: true
|
||||
mount_dev: true
|
||||
mount_devpts: true
|
||||
mount_tmp: true
|
||||
mount_home: false
|
||||
|
||||
# Tmpfs configuration
|
||||
use_tmpfs: true
|
||||
tmpfs_size: "4G"
|
||||
|
||||
# Custom bind mounts
|
||||
bind_mounts:
|
||||
- host: "/usr/share/doc"
|
||||
chroot: "/usr/share/doc"
|
||||
options: "ro"
|
||||
- host: "/var/cache/apt/archives"
|
||||
chroot: "/var/cache/apt/archives"
|
||||
options: "ro"
|
||||
- host: "/tmp/deb-mock-sources"
|
||||
chroot: "/tmp/sources"
|
||||
options: ""
|
||||
|
||||
# Tmpfs mounts for performance
|
||||
tmpfs_mounts:
|
||||
- chroot: "/tmp/build"
|
||||
size: "2G"
|
||||
options: "noexec,nosuid"
|
||||
- chroot: "/var/cache/ccache"
|
||||
size: "1G"
|
||||
options: ""
|
||||
|
||||
# Overlay mounts (requires overlayfs support)
|
||||
overlay_mounts:
|
||||
- lower: "/var/lib/deb-mock/base-chroot"
|
||||
upper: "/var/lib/deb-mock/overlay-upper"
|
||||
work: "/var/lib/deb-mock/overlay-work"
|
||||
chroot: "/var/lib/deb-mock/overlay-chroot"
|
||||
|
||||
# Advanced chroot features
|
||||
use_namespaces: false
|
||||
uid_mapping: null
|
||||
gid_mapping: null
|
||||
capabilities: []
|
||||
seccomp_profile: null
|
||||
|
||||
# UID/GID management
|
||||
chroot_user: "build"
|
||||
chroot_group: "build"
|
||||
chroot_uid: 1000
|
||||
chroot_gid: 1000
|
||||
use_host_user: false
|
||||
copy_host_users: []
|
||||
preserve_uid_gid: true
|
||||
|
||||
# Build optimization
|
||||
use_root_cache: true
|
||||
root_cache_dir: "/var/cache/deb-mock/root-cache"
|
||||
root_cache_age: 7
|
||||
use_package_cache: true
|
||||
package_cache_dir: "/var/cache/deb-mock/package-cache"
|
||||
use_ccache: true
|
||||
ccache_dir: "/var/cache/deb-mock/ccache"
|
||||
|
||||
# Network configuration
|
||||
use_host_resolv: true
|
||||
enable_network: true
|
||||
http_proxy: null
|
||||
https_proxy: null
|
||||
no_proxy: null
|
||||
|
||||
# Mirror configuration
|
||||
mirror: "http://deb.debian.org/debian/"
|
||||
security_mirror: "http://security.debian.org/debian-security"
|
||||
backports_mirror: "http://deb.debian.org/debian/"
|
||||
|
||||
# Bootstrap chroot support
|
||||
use_bootstrap_chroot: false
|
||||
bootstrap_chroot_name: null
|
||||
bootstrap_arch: null
|
||||
bootstrap_suite: null
|
||||
101
examples/plugins/ccache_plugin.py
Normal file
101
examples/plugins/ccache_plugin.py
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Sample ccache plugin for deb-mock
|
||||
Demonstrates the plugin system capabilities
|
||||
"""
|
||||
|
||||
requires_api_version = "1.0"
|
||||
run_in_bootstrap = False
|
||||
|
||||
|
||||
def init(plugin_manager, conf, deb_mock):
|
||||
"""Plugin entry point"""
|
||||
CCachePlugin(plugin_manager, conf, deb_mock)
|
||||
|
||||
|
||||
class CCachePlugin:
|
||||
"""Enables ccache in deb-mock chroots"""
|
||||
|
||||
def __init__(self, plugin_manager, conf, deb_mock):
|
||||
self.plugin_manager = plugin_manager
|
||||
self.conf = conf
|
||||
self.deb_mock = deb_mock
|
||||
|
||||
# Plugin configuration with defaults
|
||||
self.ccache_dir = conf.get('dir', '/var/cache/deb-mock/ccache')
|
||||
self.max_cache_size = conf.get('max_cache_size', '2G')
|
||||
self.show_stats = conf.get('show_stats', True)
|
||||
self.compress = conf.get('compress', True)
|
||||
self.hashdir = conf.get('hashdir', True)
|
||||
self.debug = conf.get('debug', False)
|
||||
|
||||
# Register hooks
|
||||
self._register_hooks()
|
||||
|
||||
# Add ccache to build dependencies
|
||||
if hasattr(deb_mock.config, 'chroot_additional_packages'):
|
||||
if 'ccache' not in deb_mock.config.chroot_additional_packages:
|
||||
deb_mock.config.chroot_additional_packages.append('ccache')
|
||||
|
||||
print(f"CCache plugin initialized: cache_dir={self.ccache_dir}, max_size={self.max_cache_size}")
|
||||
|
||||
def _register_hooks(self):
|
||||
"""Register plugin hooks"""
|
||||
self.plugin_manager.add_hook("prebuild", self._ccache_prebuild)
|
||||
self.plugin_manager.add_hook("postbuild", self._ccache_postbuild)
|
||||
self.plugin_manager.add_hook("prechroot_init", self._ccache_prechroot_init)
|
||||
|
||||
def _ccache_prebuild(self, source_package, **kwargs):
|
||||
"""Setup ccache before build starts"""
|
||||
print(f"CCache: Setting up ccache for {source_package}")
|
||||
|
||||
# Set ccache environment variables
|
||||
if hasattr(self.deb_mock.config, 'build_env'):
|
||||
self.deb_mock.config.build_env.update({
|
||||
'CCACHE_DIR': '/var/tmp/ccache',
|
||||
'CCACHE_UMASK': '002',
|
||||
'CCACHE_COMPRESS': str(self.compress),
|
||||
'CCACHE_HASHDIR': '1' if self.hashdir else '0',
|
||||
'CCACHE_DEBUG': '1' if self.debug else '0'
|
||||
})
|
||||
|
||||
def _ccache_postbuild(self, build_result, source_package, **kwargs):
|
||||
"""Show ccache statistics after build"""
|
||||
if not self.show_stats:
|
||||
return
|
||||
|
||||
print("CCache: Build completed, showing statistics...")
|
||||
# In a real implementation, you would execute ccache --show-stats in the chroot
|
||||
|
||||
if build_result.get('success', False):
|
||||
print(f"CCache: Build successful for {source_package}")
|
||||
else:
|
||||
print(f"CCache: Build failed for {source_package}")
|
||||
|
||||
def _ccache_prechroot_init(self, chroot_name):
|
||||
"""Setup ccache in chroot before initialization"""
|
||||
print(f"CCache: Setting up ccache in chroot {chroot_name}")
|
||||
|
||||
# Create ccache directory in chroot
|
||||
chroot_ccache_dir = f"/var/tmp/ccache"
|
||||
|
||||
# In a real implementation, you would:
|
||||
# 1. Create the ccache directory in the chroot
|
||||
# 2. Set proper permissions
|
||||
# 3. Mount the host ccache directory if configured
|
||||
|
||||
print(f"CCache: Created {chroot_ccache_dir} in chroot {chroot_name}")
|
||||
|
||||
|
||||
# Example configuration for this plugin:
|
||||
# plugin_conf = {
|
||||
# 'ccache_enable': True,
|
||||
# 'ccache_opts': {
|
||||
# 'dir': '/var/cache/deb-mock/ccache',
|
||||
# 'max_cache_size': '4G',
|
||||
# 'show_stats': True,
|
||||
# 'compress': True,
|
||||
# 'hashdir': True,
|
||||
# 'debug': False
|
||||
# }
|
||||
# }
|
||||
Loading…
Add table
Add a link
Reference in a new issue