Initial commit: Android ROM building with Buildkite
- Added Buildkite pipeline configuration - Added Docker setup for Android build environment - Added build scripts for ROM compilation - Added comprehensive documentation - Added setup script for easy initialization
This commit is contained in:
65
scripts/build-rom.sh
Executable file
65
scripts/build-rom.sh
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "🔨 Starting Android ROM build..."
|
||||
|
||||
cd /home/buildbot/android/source
|
||||
|
||||
# Configuration - modify these for your target device
|
||||
TARGET_DEVICE="${TARGET_DEVICE:-generic}"
|
||||
BUILD_TYPE="${BUILD_TYPE:-userdebug}"
|
||||
BUILD_VARIANT="${BUILD_VARIANT:-lineage}"
|
||||
|
||||
echo "🎯 Build configuration:"
|
||||
echo " Device: $TARGET_DEVICE"
|
||||
echo " Type: $BUILD_TYPE"
|
||||
echo " Variant: $BUILD_VARIANT"
|
||||
|
||||
# Set up build environment
|
||||
echo "⚙️ Setting up build environment..."
|
||||
source build/envsetup.sh
|
||||
|
||||
# Setup ccache
|
||||
if [ "${USE_CCACHE:-1}" = "1" ]; then
|
||||
echo "🚀 Configuring ccache..."
|
||||
export USE_CCACHE=1
|
||||
export CCACHE_DIR=/home/buildbot/android/ccache
|
||||
ccache -M 50G
|
||||
ccache -s
|
||||
fi
|
||||
|
||||
# Clean previous builds if requested
|
||||
if [ "${CLEAN_BUILD:-0}" = "1" ]; then
|
||||
echo "🧹 Cleaning previous build..."
|
||||
make clean
|
||||
fi
|
||||
|
||||
# Select build target
|
||||
echo "🎯 Selecting build target..."
|
||||
lunch "${BUILD_VARIANT}_${TARGET_DEVICE}-${BUILD_TYPE}"
|
||||
|
||||
# Start build
|
||||
echo "🔨 Starting compilation..."
|
||||
START_TIME=$(date +%s)
|
||||
|
||||
# Build with appropriate number of parallel jobs
|
||||
JOBS=${BUILD_JOBS:-$(nproc)}
|
||||
echo "🚀 Building with $JOBS parallel jobs..."
|
||||
|
||||
if [ "$BUILD_VARIANT" = "lineage" ]; then
|
||||
# LineageOS specific build command
|
||||
brunch "$TARGET_DEVICE"
|
||||
else
|
||||
# Generic AOSP build
|
||||
make -j"$JOBS" otapackage
|
||||
fi
|
||||
|
||||
END_TIME=$(date +%s)
|
||||
BUILD_TIME=$((END_TIME - START_TIME))
|
||||
|
||||
echo "✅ Build completed successfully!"
|
||||
echo "⏱️ Build time: $(date -u -d @$BUILD_TIME +%H:%M:%S)"
|
||||
|
||||
# Display build artifacts
|
||||
echo "📦 Build artifacts:"
|
||||
find /home/buildbot/android/out/target/product/"$TARGET_DEVICE"/ -name "*.zip" -o -name "*.img" | head -10
|
||||
32
scripts/init-source.sh
Executable file
32
scripts/init-source.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "🚀 Initializing Android source repository..."
|
||||
|
||||
cd /home/buildbot/android/source
|
||||
|
||||
# Configuration - you can modify these
|
||||
MANIFEST_URL="https://github.com/LineageOS/android.git"
|
||||
MANIFEST_BRANCH="lineage-21.0"
|
||||
MANIFEST_NAME="default.xml"
|
||||
|
||||
# Check if source is already initialized
|
||||
if [ ! -d ".repo" ]; then
|
||||
echo "📁 Initializing repo with manifest: $MANIFEST_URL"
|
||||
echo "📋 Branch: $MANIFEST_BRANCH"
|
||||
|
||||
repo init \
|
||||
-u "$MANIFEST_URL" \
|
||||
-b "$MANIFEST_BRANCH" \
|
||||
-m "$MANIFEST_NAME" \
|
||||
--depth=1 \
|
||||
--no-clone-bundle
|
||||
|
||||
echo "✅ Repository initialized successfully!"
|
||||
else
|
||||
echo "📁 Repository already initialized, skipping..."
|
||||
fi
|
||||
|
||||
# Display repo info
|
||||
echo "📊 Repository information:"
|
||||
repo info | head -10
|
||||
68
scripts/package-rom.sh
Executable file
68
scripts/package-rom.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "📦 Packaging ROM artifacts..."
|
||||
|
||||
TARGET_DEVICE="${TARGET_DEVICE:-generic}"
|
||||
OUT_DIR="/home/buildbot/android/out/target/product/$TARGET_DEVICE"
|
||||
ARTIFACTS_DIR="/home/buildbot/artifacts"
|
||||
|
||||
# Create artifacts directory
|
||||
mkdir -p "$ARTIFACTS_DIR"
|
||||
|
||||
echo "📁 Copying build artifacts..."
|
||||
|
||||
# Copy main ROM files
|
||||
if [ -f "$OUT_DIR"/*.zip ]; then
|
||||
echo "📱 Copying ROM zip files..."
|
||||
cp "$OUT_DIR"/*.zip "$ARTIFACTS_DIR/" || true
|
||||
fi
|
||||
|
||||
# Copy recovery image
|
||||
if [ -f "$OUT_DIR/recovery.img" ]; then
|
||||
echo "🔧 Copying recovery image..."
|
||||
cp "$OUT_DIR/recovery.img" "$ARTIFACTS_DIR/" || true
|
||||
fi
|
||||
|
||||
# Copy boot image
|
||||
if [ -f "$OUT_DIR/boot.img" ]; then
|
||||
echo "🥾 Copying boot image..."
|
||||
cp "$OUT_DIR/boot.img" "$ARTIFACTS_DIR/" || true
|
||||
fi
|
||||
|
||||
# Copy system image
|
||||
if [ -f "$OUT_DIR/system.img" ]; then
|
||||
echo "💿 Copying system image..."
|
||||
cp "$OUT_DIR/system.img" "$ARTIFACTS_DIR/" || true
|
||||
fi
|
||||
|
||||
# Copy vendor image
|
||||
if [ -f "$OUT_DIR/vendor.img" ]; then
|
||||
echo "🏪 Copying vendor image..."
|
||||
cp "$OUT_DIR/vendor.img" "$ARTIFACTS_DIR/" || true
|
||||
fi
|
||||
|
||||
# Create build info JSON
|
||||
echo "📋 Creating build information..."
|
||||
cat > "$ARTIFACTS_DIR/build-info.json" << EOF
|
||||
{
|
||||
"build_number": "${BUILDKITE_BUILD_NUMBER:-unknown}",
|
||||
"commit": "${BUILDKITE_COMMIT:-unknown}",
|
||||
"branch": "${BUILDKITE_BRANCH:-unknown}",
|
||||
"device": "$TARGET_DEVICE",
|
||||
"build_date": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
||||
"build_type": "${BUILD_TYPE:-userdebug}",
|
||||
"variant": "${BUILD_VARIANT:-lineage}"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Create checksums
|
||||
echo "🔐 Generating checksums..."
|
||||
cd "$ARTIFACTS_DIR"
|
||||
find . -name "*.zip" -o -name "*.img" | xargs -I {} sh -c 'md5sum "{}" > "{}.md5"'
|
||||
find . -name "*.zip" -o -name "*.img" | xargs -I {} sh -c 'sha256sum "{}" > "{}.sha256"'
|
||||
|
||||
echo "📊 Artifact summary:"
|
||||
ls -lh "$ARTIFACTS_DIR"
|
||||
|
||||
echo "✅ Packaging completed successfully!"
|
||||
39
scripts/sync-source.sh
Executable file
39
scripts/sync-source.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "🔄 Syncing Android source code..."
|
||||
|
||||
cd /home/buildbot/android/source
|
||||
|
||||
# Check if repo is initialized
|
||||
if [ ! -d ".repo" ]; then
|
||||
echo "❌ Repository not initialized! Run init-source.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Sync with multiple jobs for faster download
|
||||
echo "⬇️ Starting source sync..."
|
||||
repo sync \
|
||||
-c \
|
||||
-j$(nproc) \
|
||||
--force-sync \
|
||||
--no-clone-bundle \
|
||||
--no-tags \
|
||||
--optimized-fetch \
|
||||
--prune
|
||||
|
||||
echo "✅ Source sync completed successfully!"
|
||||
|
||||
# Display sync statistics
|
||||
echo "📊 Sync statistics:"
|
||||
echo "Total repositories: $(find .repo/projects -name "*.git" | wc -l)"
|
||||
echo "Disk usage: $(du -sh . | cut -f1)"
|
||||
|
||||
# Check for any missing projects
|
||||
echo "🔍 Checking for missing projects..."
|
||||
if repo status | grep -q "project.*dirty\|project.*not up-to-date"; then
|
||||
echo "⚠️ Some projects may need attention:"
|
||||
repo status | grep -E "project.*dirty|project.*not up-to-date" || true
|
||||
else
|
||||
echo "✅ All projects are clean and up-to-date"
|
||||
fi
|
||||
Reference in New Issue
Block a user