Initial commit

Este commit está contenido en:
Lucas Verney 2020-12-10 22:59:25 +01:00
commit bb27dc8dc1
Se han modificado 7 ficheros con 284 adiciones y 0 borrados

2
.gitignore vendido Archivo normal
Ver fichero

@ -0,0 +1,2 @@
__pycache__
ovh_orchestrator/config.py

6
README.md Archivo normal
Ver fichero

@ -0,0 +1,6 @@
Building Android (Lineage 17.1 / `/e/`) for LG G6 (h870)
========================================================
Lots of RAM (12GB is short!) / good CPU required!

115
build_android.sh Archivo ejecutable
Ver fichero

@ -0,0 +1,115 @@
#!/bin/bash
# Ubuntu 20.04 base
set -e
set -x
# Install dependencies
apt-get update
apt-get upgrade -y
apt-get install -y bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev
apt-get install -y default-jdk
apt-get install -y python2
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 # Android git repo hooks are python2-only
# Install repo
mkdir ~/bin
cat >> ~/.profile <<EOF
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
EOF
source ~/.profile
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
# Git config
git config --global user.email "phyks@phyks.me"
git config --global user.name "Phyks (Lucas Verney)"
# Use ccache
cat >> ~/.bashrc <<EOF
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
EOF
source ~/.bashrc
ccache -M 50G
ccache -o compression=true
# Clone Lineage 17.1 or /e/ codebase (takes roughly 1h!)
mkdir -p ~/android/lineage
cd ~/android/lineage
if [[ "${BUILD_FLAVOR}" == "lineage" ]]; then
repo init -u https://github.com/LineageOS/android.git -b lineage-17.1
elif [[ "$BUILD_FLAVOR" == "e" ]]; then
repo init -u https://gitlab.e.foundation/e/os/android.git -b v1-q
else
echo "Unknown build flavor! Exiting."
exit 1
fi
repo sync
source build/envsetup.sh
# Get h870-specific repos
mkdir -p ~/android/lineage/.repo/local_manifests/
cat > ~/android/lineage/.repo/local_manifests/roomservice.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="LG-G6-DEV/android_device_lge_h870" path="device/lge/h870" remote="github" revision="lineage-17.0" />
<project name="LG-G6-DEV/android_device_lge_msm8996-common" path="device/lge/msm8996-common" remote="github" revision="stagingAU" />
<project name="LG-G6-DEV/android_kernel_lge_msm8996" path="kernel/lge/msm8996" remote="github" revision="Optimizing" />
<project name="LG-G6-DEV/proprietary_vendor_lge" path="vendor/lge" remote="github" revision="new_audio" />
</manifest>
EOF
repo sync
# Some h870 cherry picks
croot
cd frameworks/base/
git remote add fixes https://github.com/BernardoBas/android_frameworks_base.git
git fetch fixes
# Phantom camera fixes
git cherry-pick a904a84ad485d8768c7a523ec380696d573c9a9e 5a02ae0abfb2a341055aecbb46fb6ce3b24070cf
# Sunrise/Sunset hardoded if location is not available
git cherry-pick 2c9baf509fef40586cc07a8b3aed91bb3cc741b3
croot
cd device/lge/msm8996-common/
git remote add brightness https://github.com/BernardoBas/android_device_lge_msm8996-common.git
git fetch brightness
# MIC LEVEL -- TODO
git cherry-pick 9123565f56262e73dc6d613a0efc4bfb5867f5e6
# ROUNDED CORNERS -- TODO
git cherry-pick 5c490db56b5d2431bc21a35f865511a3ea86ca4a
# If you want micro-g on Lineage, uncomment this part
# Note: micro-g is already built-in with /e/
# if [[ "${BUILD_FLAVOR}" == "lineage" ]]; then
# croot
# cd frameworks/base
# curl https://raw.githubusercontent.com/lineageos4microg/docker-lineage-cicd/master/src/signature_spoofing_patches/android_frameworks_base-Q.patch > android_frameworks_base-Q.patch
# patch -p1 -i android_frameworks_base-Q.patch
# fi
if [[ "${BUILD_FLAVOR}" == "e" ]]; then
# Remove some apps built with /e/, comment if you want to keep them
croot
# Remove MagicEarth (non-free)
rm -r prebuilts/prebuiltapks/MagicEarth
# Remove DemoApp
rm -r prebuilts/prebuiltapks/DemoApp
# Remove DroidGuard
rm -r prebuilts/prebuiltapks/DroidGuard
# Remove eDrive
rm -r prebuilts/prebuiltapks/eDrive
# Remove ESmsSync
rm -r prebuilts/prebuiltapks/ESmsSync
# Remove ESmsSync
rm -r prebuilts/prebuiltapks/ESmsSync
fi
# Build Lineage or /e/ (takes 2 to 3 hours!)
croot
make clean
date | tee build.log; brunch h870 | tee build.log; date | tee build.log
touch ~/BUILD_DONE

110
ovh_orchestrator/__init__.py Archivo normal
Ver fichero

@ -0,0 +1,110 @@
import uuid
import sys
import time
import ovh
from . import config
if __name__ == '__main__':
client = ovh.Client(
endpoint=config.ovh_endpoint,
application_key=config.ovh_application_key,
application_secret=config.ovh_application_secret,
consumer_key=config.ovh_consumer_key,
)
if len(sys.argv) < 2:
sys.exit(1)
# Create VM
if sys.argv[1] == 'init':
# Get image id
result = client.get(
'/cloud/project/' + config.ovh_public_cloud_project + '/image',
flavorType='s1-2',
osType='linux',
region=config.ovh_public_cloud_region,
)
image_id = next(
x['id']
for x in result
if x['name'] == config.ovh_public_cloud_image
)
# Get SSH key id
result = client.get(
'/cloud/project/' + config.ovh_public_cloud_project + '/sshkey',
region=config.ovh_public_cloud_region,
)
ssh_key_id = next(
x['id']
for x in result
if x['name'] == config.ovh_public_cloud_sshkey_name
)
# Get flavor id
result = client.get(
'/cloud/project/' + config.ovh_public_cloud_project + '/flavor',
region=config.ovh_public_cloud_region,
)
flavor_id = next(
x['id']
for x in result
if x['name'] == 's1-2'
)
# Create instance
name = str(uuid.uuid4())
result = client.post(
'/cloud/project/' + config.ovh_public_cloud_project + '/instance',
flavorId=flavor_id,
imageId=image_id,
monthlyBilling=False,
name=name,
region=config.ovh_public_cloud_region,
sshKeyId=ssh_key_id
)
if 'id' not in result:
sys.exit(1)
# Wait for IP address
while True:
result = client.get(
'/cloud/project/' + config.ovh_public_cloud_project + '/instance',
region=config.ovh_public_cloud_region,
)
ipAddresses = next(
x['ipAddresses']
for x in result
if x['name'] == name
)
if ipAddresses:
print(ipAddresses[0])
sys.exit(0)
time.sleep(30)
# Clear VM
elif sys.argv[1] == 'purge':
if len(sys.argv) < 3:
sys.exit(1)
# Get instance id from its IP address
result = client.get(
'/cloud/project/' + config.ovh_public_cloud_project + '/instance',
region=config.ovh_public_cloud_region,
)
instance_id = next(
x['id']
for x in result
if sys.argv[2] in x['ipAddresses']
)
# Delete instance
client.delete(
'/cloud/project/' + config.ovh_public_cloud_project +
'/instance/' + instance_id
)
else:
sys.exit(1)

Ver fichero

@ -0,0 +1,18 @@
# Create API credentials at https://eu.api.ovh.com/createToken/
# See https://docs.ovh.com/fr/api/api-premiers-pas/#prerequis
ovh_endpoint = 'ovh-eu'
ovh_application_key = 'xxxxxxx'
ovh_application_secret = 'xxxxxxx'
ovh_consumer_key = 'xxxxxxx'
# Fill with ID of your public cloud project, found in the manager URI
ovh_public_cloud_project = 'xxxxxxx'
ovh_public_cloud_region = 'SBG5'
# Fill with the name of your SSH key
ovh_public_cloud_sshkey_name = 'xxx'
# These are tailored for Android builds at reasonable speed / cost
ovh_public_cloud_image = 'Ubuntu 20.04'
ovh_public_cloud_flavor = 'b2-30'

1
requirements.txt Archivo normal
Ver fichero

@ -0,0 +1 @@
ovh

32
run.sh Archivo ejecutable
Ver fichero

@ -0,0 +1,32 @@
#!/bin/bash
set -e
# Install OVH orchestrator dependencies
python3 -m venv .venv
./.venv/bin/pip install -r requirements.txt
# Set up an OVH instance to run the build
printf "%s" "Waiting for OVH instance ..."
IP_ADDRESS=$(./.venv/bin/python3 -m ovh_orchestrator init)
while ! timeout 0.2 ping -c 1 -n ${IP_ADDRESS} &> /dev/null
do
printf "%c" "."
done
# Run the build on the OVH instance
scp ./build_android.sh ubuntu@${IP_ADDRESS}:~
ssh -f ubuntu@${IP_ADDRESS} 'screen -S build -dm bash ./build_android.sh'
# Wait for build to complete
set +e
printf "%s" "Building ..."
until ssh ubuntu@${IP_ADDRESS} 'ls ~/BUILD_DONE'; do
printf "%c" "."
done
set -e
# Fetch back the built images
rsync -azr --progress ubuntu@${IP_ADDRESS}:~/android/lineage/out/target/product/h870/\*.{zip,md5sum,img} .
# Purge the OVH instance
./.venv/bin/python3 -m ovh_orchestrator purge ${IP_ADDRESS}