Update build tools

This commit is contained in:
2025-11-05 17:22:24 +00:00
parent e0a43d9e66
commit 5b82916a29
3 changed files with 81 additions and 92 deletions
+45 -92
View File
@@ -1,130 +1,83 @@
# PawletOS-Build
A comprehensive build system for PawletOS with advanced patch management and Android source synchronization capabilities.
## Overview
PawletOS-Build provides automated tools for setting up and managing the PawletOS build environment, featuring:
- **Intelligent Patch Management**: Advanced patch application with conflict detection and resolution
- **Source Synchronization**: Automated Android source sync using repo
- **Build Environment Setup**: Streamlined environment configuration for Raspberry Pi builds
- **Robust Error Handling**: Graceful fallback mechanisms and detailed error reporting
## Features
### 🔧 Build System (`build.py`)
The main build script provides comprehensive Android build environment setup with the following capabilities:
- **Source Code Synchronization**: Sync Android source code using `repo sync` with configurable parallel jobs
- **Advanced Patch Application**: Intelligent patch system with two modes:
- **Robust Handler**: Git-based patch application with conflict analysis and dependency detection
- **Legacy Handler**: Traditional patch command fallback for compatibility
- **Flexible Configuration**: Customizable source directories, patch levels, and build options
- **Batch Processing**: Apply multiple patches with selective filtering and ignore lists
### 🛠️ Patch Management (`scripts/better-patch.py`)
Advanced patch handling system featuring:
- **Conflict Analysis**: Pre-application analysis of potential patch conflicts
- **Dependency Detection**: Automatic detection of patch dependencies and ordering
- **Rollback Capability**: Automatic rollback on failure with cleanup
- **Git Integration**: Leverages Git's powerful merge capabilities for better conflict resolution
- **Detailed Reporting**: Comprehensive patch application reports and statistics
### 🍓 Raspberry Pi Setup (`rpivanilla-ensetup.sh`)
Environment setup script for Raspberry Pi vanilla builds:
- Sets up the RaspberryVanilla build environment
- Sources necessary build configuration files
- Provides template for build-specific exports
Scripts and helpers to build PawletOS.
## Usage
### Quick Start
### Setup Environment
1. **Basic patch application**:
```bash
python3 build.py --applyPatches
```
```bash
# Install dependencies
pip3 install -r requirements.txt
2. **Sync source and apply patches**:
```bash
python3 build.py --resync --applyPatches
```
# Setup and sync source code
python3 environ.py --applyPatches
3. **Force operations with verbose output**:
```bash
python3 build.py --forceResync --forceApplyPatches --verbosePatches
```
# Or with custom source directory
python3 environ.py --sourceDir my-source --applyPatches
```
### Configuration
Create `repo.yml`:
```yaml
repo:
url: "https://android.googlesource.com/platform/manifest"
branch: "android-14.0.0_r1"
options:
- "--depth=1"
- "--no-clone-bundle"
local_manifests:
device_manifest: "https://raw.githubusercontent.com/example/device-manifest/main/manifest.xml"
vendor_manifest: "https://raw.githubusercontent.com/example/vendor-manifest/main/manifest.xml"
```
### Command Line Options
| Option | Description |
|--------|-------------|
| `--resync` | Sync source code with repo sync |
| `--noSync` | Skip repo sync (sync is enabled by default) |
| `--forceResync` | Force sync source code with repo sync --force-sync |
| `--applyPatches` | Apply patches from patches directory |
| `--forceApplyPatches` | Force apply patches even if some fail |
| `--patchLevel <n>` | Patch level for -p option (default: 1) |
| `--sourceDir <path>` | Source directory (default: current directory) |
| `--patchDir <path>` | Patch directory (default: patches) |
| `--sourceDir <path>` | Source directory (default: AOSP-source) |
| `--patchDir <dirs>` | Patch directories (default: patches). Can specify multiple. |
| `--syncJobs <n>` | Number of parallel jobs for repo sync |
| `--ignorePatches <files>` | List of patches to ignore |
| `--useLegacyPatch` | Use legacy patch command instead of robust handler |
| `--verbosePatches` | Verbose output for patch application |
| `--config <file>` | Path to repo configuration file (default: repo.yml) |
| `--no-git-lfs` | Disable Git LFS setup (enabled by default) |
### Advanced Patch Management
The build system includes an intelligent patch handler that provides:
- **Pre-flight Analysis**: Analyzes patches before application to detect conflicts
- **Smart Conflict Resolution**: Uses Git's three-way merge for better conflict handling
- **Dependency Management**: Automatically orders patches based on file dependencies
- **Rollback Protection**: Automatic rollback on failure with repository cleanup
### Environment Setup
For Raspberry Pi builds, use the provided setup script:
### Raspberry Pi Setup
```bash
chmod +x rpivanilla-ensetup.sh
./rpivanilla-ensetup.sh
```
This script will:
- Navigate to the RaspberryVanilla directory
- Source the build environment setup
- Prepare the environment for lunch and build commands
## Files
## Directory Structure
```
PawletOS-Build/
├── build.py # Main build system script
├── rpivanilla-ensetup.sh # Raspberry Pi environment setup
├── scripts/
│ └── better-patch.py # Advanced patch management system
├── patches/ # Patch files directory (created as needed)
└── README.md # This file
```
- `environ.py` - Main setup script
- `rpivanilla-ensetup.sh` - Raspberry Pi environment setup
- `repo.yml` - Repository configuration
- `scripts/better-patch.py` - Patch management
- `patches/` - Patch files
## Requirements
- Python 3.6+
- Git (recommended for advanced patch features)
- Git LFS (optional, for large file support)
- Android build tools (repo, patch)
- Bash shell for setup scripts
- Python packages:
- `PyYAML` (for YAML configuration support)
- `requests` (for downloading local manifests)
## Contributing
### Installing Python Dependencies
When adding new patches or modifying the build system:
1. Test patches individually before batch application
2. Use `--verbosePatches` for debugging patch issues
3. Consider patch dependencies when organizing patch files
4. Update documentation for new features or options
## License
See the LICENSE file for licensing information.
```bash
pip3 install PyYAML requests
```
+34
View File
@@ -122,6 +122,31 @@ def download_local_manifests(source_dir, manifests):
except requests.exceptions.RequestException as e:
print(f"Failed to download {manifest_name}.xml: {e}")
def setup_git_lfs(source_dir):
"""Set up Git LFS in the repository."""
print("Setting up Git LFS...")
try:
# Check if git-lfs is installed
run_command(["git", "lfs", "version"], cwd=source_dir)
except (subprocess.CalledProcessError, FileNotFoundError):
print("Warning: git-lfs is not installed. Skipping Git LFS setup.")
return False
try:
# Initialize Git LFS in the repo
run_command(["git", "lfs", "install"], cwd=source_dir)
# Pull LFS objects for all projects
print("Pulling Git LFS objects...")
run_command_realtime(["repo", "forall", "-c", "git lfs pull"], cwd=source_dir)
print("Git LFS setup completed successfully!")
return True
except subprocess.CalledProcessError as e:
print(f"Warning: Git LFS setup failed: {e}")
return False
def find_patches(patch_dirs):
"""Find all patch files in the patch directories."""
patches = []
@@ -278,6 +303,8 @@ def parse_arguments():
help="Verbose output for patch application")
parser.add_argument("--config", type=str, default="repo.yml",
help="Path to repo configuration file (default: repo.yml)")
parser.add_argument("--no-git-lfs", action="store_true",
help="Disable Git LFS setup (enabled by default)")
return parser.parse_args()
@@ -299,6 +326,7 @@ def main():
print(f"Sync jobs: {sync_jobs}")
if ignore_patches:
print(f"Ignoring patches: {', '.join(ignore_patches)}")
print(f"Git LFS: {'Disabled' if args.no_git_lfs else 'Enabled'}")
# Get absolute path to prevent any relative path confusion
current_dir = os.path.abspath(".")
@@ -343,6 +371,12 @@ def main():
else:
print("Skipping repo sync as requested")
# Setup Git LFS after repo sync (enabled by default unless --no-git-lfs is specified)
if not args.no_git_lfs:
setup_git_lfs(working_dir)
else:
print("Skipping Git LFS setup as requested")
# Apply patches
if args.applyPatches or args.forceApplyPatches:
# Handle relative paths - if working_dir is not ".", prepend it to patch directories
+2
View File
@@ -0,0 +1,2 @@
PyYAML
requests