This repository contains a containerized build system for VoltageOS GSI (Generic System Image) images using container technology. It automates the entire build process from source preparation to final image compression.
- Podman or Docker
- At least 200GB of free disk space
- At least 16GB of RAM (32GB recommended)
- A fast internet connection
The build system uses a single comprehensive Makefile to orchestrate the build process. The Makefile contains all configuration, variables, and build targets in one file for simplicity.
The build system is organized in a clear, sequential manner:
- Configuration variables and resource limits at the top
- Common container parameters and phony target definitions
- Convenience targets for different build combinations
- Individual build steps in sequential order with clear headers
This consolidated structure makes it easier to:
- Understand the entire build process at a glance
- Follow the build flow from start to finish
- See all dependencies and relationships between targets
The build system supports running individual steps independently, similar to GitHub Actions workflow:
build-container: Build the container imageclean: Clean build directoriescreate-folders: Create necessary build directories
clone-rom-manifest: Clone the ROM manifest repositorycopy-manifest-config: Copy manifest configuration filessync-sources: Sync all source code (with auto-retry)apply-patches: Apply trebledroid and personal patches (includes debug patches if APPLY_DEBUG_PATCHES=true)stash-gapps-variants: Setup temporary directory and stash GApps variantsgenerate-signing-keys: Generate signing keys for the buildbuild-treble-app: Build the Treble appvndk-test-sepolicy: Run VNDK sepolicy tests
build-vanilla-arm64: Build vanilla arm64 imagebuild-microg-arm64: Build microG arm64 imagebuild-gapps-arm64: Build GApps arm64 imagebuild-vanilla-a64: Build vanilla arm32_binder64 imagebuild-microg-a64: Build microG arm32_binder64 imagebuild-gapps-a64: Build GApps arm32_binder64 image
rename-images: Rename all image files to final namescompress-images: Compress all images with xzupload-to-github: Upload compressed images to GitHub releases (requires GitHub CLI)
build-vanilla: Build all vanilla variantsbuild-microg: Build all microG variantsbuild-gapps: Build all GApps variantsbuild-arm64: Build all arm64 variantsbuild-a64: Build all arm32_binder64 variantsall-images: Build all images without source preparationbuild-prerequisites: Run all build prerequisites (container, folders, clone, sync, patches, etc.)post-build: Run all post-build steps (testing, renaming, compression)full-build: Run the complete build process (default target)
You can customize the build process with the following variables:
# Example of using multiple configuration variables
make ROM_VERSION=4.3 ROM_TAG=16-qpr1 ANDROID_VERSION_TAG=ap4b APPLY_DEBUG_PATCHES=true VERIFY_SEPOLICY=true MAX_CPU_PERCENT=50 CONTAINER_RUNTIME=docker
# Example with GitHub upload enabled
make ROM_VERSION=4.3 MAINTAINER="your-github-username" REPO_NAME="VoltageOS-GSI" UPLOAD_TO_GITHUB=trueAvailable variables:
ROM_VERSION: Version of the ROM (default: 4.3)ROM_TAG: Git tag/branch to use for ROM source (default: 15-qpr2)ANDROID_VERSION_TAG: Android version tag for the build (default: ap4a)APPLY_DEBUG_PATCHES: Whether to apply debug patches (default: false)VERIFY_SEPOLICY: Whether to verify SELinux policy during build (default: true)MAX_CPU_PERCENT: Maximum CPU usage in percent (default: 100)MAX_MEM_PERCENT: Maximum memory usage in percent (default: 100)CONTAINER_RUNTIME: Container runtime to use (default: podman, can be set to docker)MAINTAINER: GitHub username for uploading releases (required for GitHub uploads)REPO_NAME: GitHub repository name for uploading releases (default: VoltageOS-GSI)UPLOAD_TO_GITHUB: Whether to automatically upload to GitHub after build (default: false)
The ANDROID_VERSION_TAG variable specifies the Android version tag used for the build. This affects how the ROM is built and which Android version features are included.
make ANDROID_VERSION_TAG=ap4bThe default value is ap4a which corresponds to Android 15.
You can limit CPU and memory usage with:
make MAX_CPU_PERCENT=50 MAX_MEM_PERCENT=75This will use 50% of available CPU cores and 75% of available memory.
By default, the build system uses Podman. To use Docker instead:
make CONTAINER_RUNTIME=dockerYou can also set this for specific targets:
make CONTAINER_RUNTIME=docker build-vanilla-arm64The build system can automatically upload the built images to GitHub releases. This requires:
- The GitHub CLI (
gh) to be installed in the container (automatically included) - Setting your GitHub username and repository name
- Being authenticated with GitHub (you'll be prompted to login if needed)
To upload images to GitHub after building:
make MAINTAINER="your-github-username" UPLOAD_TO_GITHUB=trueYou can also run the upload step separately after building:
make MAINTAINER="your-github-username" upload-to-githubThe upload process:
- Creates a Git repository in the output directory
- Sets up the remote to your GitHub repository
- Creates a draft release with the version and build date
- Uploads all .img.xz files to the release
- Cleans up the temporary Git repository
The release title will be in the format: VoltageOS 4.2-20250603
One of the key features of this build system is the ability to run individual build steps independently, similar to GitHub Actions workflow. This allows you to:
- Run specific parts of the build process
- Resume a build from a specific step if it fails
- Test individual components without running the entire build
To run the complete build process:
make full-buildTo build only the vanilla arm64 variant:
make build-vanilla-arm64To build all microG variants:
make build-microgTo run the VNDK sepolicy tests (which can be controlled with the VERIFY_SEPOLICY variable):
make VERIFY_SEPOLICY=true vndk-test-sepolicyTo apply patches and then build the Treble app:
make apply-patches apply-debug-patches build-treble-appIf a build fails at a specific step, you can resume from that step. For example, if the build fails during the source sync:
# First, ensure the container and folders are ready
make build-container create-folders
# Then resume from the sync step
make sync-sources apply-patches stash-gapps-variants generate-signing-keys build-treble-app
# ... continue with the remaining stepsAlternatively, you can use the convenience targets:
# If you need to resume after the prerequisites
make build-prerequisites all-images post-build
# Or if you just need to rebuild the images
make all-images post-buildThe typical build process follows these steps:
-
Container preparation
build-containercreate-folders
-
Source code preparation
clone-rom-manifestcopy-manifest-configsync-sourcesapply-patches(includes debug patches if APPLY_DEBUG_PATCHES=true)
-
Build preparation
stash-gapps-variantsgenerate-signing-keysbuild-treble-app
-
Building images
build-vanilla-arm64(and other variants)- Or use
all-imagesto build all variants
-
Post-build processing
vndk-test-sepolicyrename-imagescompress-imagesupload-to-github(optional, when UPLOAD_TO_GITHUB=true)- Or use
post-buildto run all post-build steps
For convenience, you can use:
build-prerequisites: Run all steps from container preparation through build preparationfull-build: Run the complete build process (default target)compress-images
The built images are initially created in the tmp directory and then copied to the out directory after compression.
The built images are initially created in the tmp directory during the build process. After compression with xz, the final image files (with .img.xz extension) are copied to the out directory.
The final image filenames follow this format:
VoltageOS-[variant]-[architecture]-ab-[version]-[build_date]-UNOFFICIAL.img.xz
Where:
[variant]is one of: vanilla, microg, or gapps[architecture]is one of: arm64 or arm32_binder64[version]is the ROM version (e.g., 4.2)[build_date]is the date of the build in YYYYMMDD format
For example:
VoltageOS-vanilla-arm64-ab-4.2-20250603-UNOFFICIAL.img.xz
The build system applies several sets of patches to the VoltageOS source code:
These patches come from the TrebleDroid project and provide essential fixes and improvements for GSI compatibility across various devices. They address issues with hardware support, SELinux policies, and vendor compatibility.
These are custom patches that enhance the ROM with additional features and fixes specific to this build system. They include:
- UI/UX improvements
- Performance optimizations
- Additional device support
- Feature enhancements
When enabled with APPLY_DEBUG_PATCHES=true, these patches add debugging capabilities that can help troubleshoot issues on specific devices.
- VoltageOS Team
- Phhusson
- AndyYan
- Ponces
- TrebleDroid Project
- And all other contributors to the project