Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Machine abstraction, Pixel 3a and Android 10 #40

Merged
merged 24 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6259b86
Support machine-abstraction
ypid Nov 10, 2019
1c46e68
Add Makefile from aosp-build
lrvick Nov 10, 2019
b8a2e76
Update to 2019-11-05 security patch level
ypid Nov 10, 2019
bb515fe
Update to 0.2.10 of F-DroidPrivilegedExtension for Android 10 support
ypid Nov 10, 2019
5017710
Add Pixel 3a and 3a XL to fix-devicenames.patch
ypid Nov 14, 2019
a7a881e
Port patch to Android 10 to ignore allowBackup="false" of apps
ypid Nov 14, 2019
c243191
Backup app is now called seedvault
ypid Nov 17, 2019
1afb1e4
Update kernel manifests. New commits are are almost only merge commits.
ypid Nov 17, 2019
72d87cc
[manifests] Manifest script uses the git tag hash instead of the commit
ypid Nov 17, 2019
c2cf707
temporarily use standalone WebView
thestinger Nov 18, 2019
8d3deb0
Disable Backup app for now until it can be build in tree
ypid Nov 18, 2019
fac2557
Disable F-Droid for now until it can be build in tree
ypid Nov 18, 2019
ecc5c8a
Temporarily use standalone WebView prebuilds provided by GrapheneOS
ypid Nov 18, 2019
b968199
Fix "Clock has stopped" message displayed when Alarm trigger
ypid Nov 21, 2019
a0057d4
Remove F-Droid priv ext patch as it is part of 0.2.10
ypid Nov 21, 2019
b26100b
Fix tmp-set-webview.patch. It must be based on a unpatched version.
ypid Nov 21, 2019
cfdd701
Update to F-Droid priv ext 0.2.11
ypid Nov 22, 2019
5250667
Update sargo (Pixel 3a) status to Tested: True :-)
ypid Nov 23, 2019
4239648
[docs] Yalp seems not to work anymore, recommend Aurora Store
ypid Dec 22, 2019
a09df67
[docs] Sync with README of aosp-build and avoid redundancy
ypid Dec 22, 2019
9481753
Fix malformed patch set-packages
ypid Jan 16, 2020
967a7c3
Update platform/set-packages.patch for 2020-03-05
ypid Mar 8, 2020
e0133b7
[WIP] Use updated app ID org.grapheneos.vanadium.webview
ypid Mar 9, 2020
57a6d3a
Update to 2020-03-05 security patch level
ypid Mar 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
build/*
keys/*
config/keys/*
config/env/*
config/container/Dockerfile.*
release/*
.*
338 changes: 266 additions & 72 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,84 +1,278 @@
CPUS := "$(shell nproc)"
image = "local/aosp-build:latest"
device = ${DEVICE}
OTA_CHANNEL ?= beta
## Argument Variables ##

CPUS := $(shell nproc)
MEMORY := 10000
DISK := 300000
DEVICE := crosshatch
BACKEND := local
CHANNEL := beta
BUILD := user
FLAVOR := aosp
IMAGE := hashbang/aosp-build:latest
IMAGE_OPTIONS :=
NAME := aosp-build-$(FLAVOR)-$(BACKEND)
SHELL := /bin/bash

-include $(PWD)/config/env/$(BACKEND).env

## Default Target ##

.DEFAULT_GOAL := default
.PHONY: default
default: machine image fetch tools keys build release

contain := \
mkdir -p keys build/base && \
mkdir -p keys build/release && \
mkdir -p keys build/external && \
docker run -it --rm -h "android" \
-v $(PWD)/build/base:/home/build/base \
-v $(PWD)/build/release:/home/build/release \
-v $(PWD)/build/external:/home/build/external \
-v $(PWD)/build/.rnd:/home/build/.rnd \
-v $(PWD)/keys:/home/build/keys \
-v $(PWD)/scripts:/home/build/scripts \
-v $(PWD)/config.yml:/home/build/config.yml \
-v $(PWD)/manifests:/home/build/manifests \
-v $(PWD)/patches:/home/build/patches \
-u $(shell id -u):$(shell id -g) \
-e DEVICE=$(device) \
-e OTA_CHANNEL=$(OTA_CHANNEL) \
--cpus $(CPUS) \
$(image)

default: build

manifest:
$(contain) manifest

config: manifest
$(contain) config

fetch: random
docker build -t local/aosp-build .
mkdir -p build
@$(contain) fetch

tools: fetch
@$(contain) tools

random:
test -f $(PWD)/build/.rnd || head -c 1G </dev/urandom > $(PWD)/build/.rnd

keys: tools
@$(contain) keys

build: fetch
@$(contain) build

kernel: tools
@$(contain) build-kernel

vendor: tools
@$(contain) build-vendor

chromium: tools
@$(contain) build-chromium

release: tools
mkdir -p build/release
@$(contain) release

test-repro:
@$(contain) test-repro
## Primary Targets ##

test:
@$(contain) test-repro
.PHONY: fetch
fetch: submodule-update machine image
$(contain) fetch

shell:
@$(contain) shell
.PHONY: keys
keys:
$(contain) keys

diff:
@$(contain) bash -c "cd base; repo diff -u"
.PHONY: build
build:
$(contain) build

.PHONY: release
release:
$(contain) release

.PHONY: publish
publish:
$(contain) publish

.PHONY: clean
clean:
@$(contain) clean
$(contain) clean

mrproper: clean
.PHONY: mrproper
mrproper: storage-delete machine-delete
rm -rf build

.PHONY: build shell diff install update flash clean tools default

## Secondary Targets ##

.PHONY: image
image:
$(docker) build \
--tag $(IMAGE) \
--file $(PWD)/config/container/Dockerfile \
$(IMAGE_OPTIONS) \
$(PWD)

config/container/Dockerfile.minimal: config/container/Dockerfile config/container/render_template
./config/container/render_template "$<" | grep -v '^#\s*$$' > "$@"

.PHONY: image-minimal
image-minimal: config/container/Dockerfile.minimal
$(docker) build \
--tag $(IMAGE) \
--file "$(PWD)/$<" \
$(IMAGE_OPTIONS) \
$(PWD)

.PHONY: tools
tools:
mkdir -p config/keys build/base release build/external
$(contain) tools

.PHONY: vendor
vendor:
$(contain) build-vendor

.PHONY: chromium
chromium:
$(contain) build-chromium

.PHONY: kernel
kernel:
$(contain) build-kernel


## Development ##

.PHONY: latest
latest: config submodule-latest fetch

.PHONY: manifest
manifest: config
$(contain) bash -c "source <(environment) && manifest"

.PHONY: config
config:
$(contain) bash -c "source <(environment) && config"

.PHONY: test-repro
test-repro:
$(contain) test-repro

.PHONY: test
test: test-repro

.PHONY: patches
patches:
@$(contain) bash -c "cd base; repo diff -u"

.PHONY: shell
shell:
$(docker) inspect "$(NAME)" \
&& $(docker) exec --interactive --tty "$(NAME)" shell \
|| $(contain) shell

.PHONY: monitor
monitor:
$(docker) inspect "$(NAME)" \
&& $(docker) exec --interactive --tty "$(NAME)" htop

.PHONY: install
install: tools
@scripts/flash


## Source Management ##

.PHONY: submodule-update
submodule-update:
git submodule update --init --recursive

.PHONY: submodule-latest
submodule-latest:
git submodule foreach 'git checkout master && git pull'

## Storage Bootstrapping ##

# TODO: detect if plugin is already installed or not
# TODO: Hash lock rexray with sha256 digest to prevent tag clobbering
.PHONY: storage-digitalocean
storage-digitalocean:
$(docker) volume ls | grep $(NAME) \
||( $(docker) plugin install \
--grant-all-permissions \
rexray/dobs:0.11.4 \
DOBS_REGION=$(DIGITALOCEAN_REGION) \
DOBS_TOKEN=$(DIGITALOCEAN_TOKEN) \
; $(docker) volume create \
--driver rexray/dobs:0.11.4 \
--opt=size=$$(( $(DISK) / 1000 )) \
--name=$(NAME) \
)

.PHONY: storage-local
storage-local:
$(docker) volume ls | grep $(NAME) \
|| $(docker) volume create \
--driver local \
--opt type=none \
--opt o=bind \
--opt device=$(PWD)/build \
$(NAME)

.PHONY: storage-delete
storage-delete:
$(docker) volume rm -f $(NAME) || :


## VM Management ##

.PHONY: machine-start
machine-start: machine-install machine-create machine-date
$(docker_machine) status $(NAME) \
|| $(docker_machine) start $(NAME)

.PHONY: machine-sync
machine-sync:
$(docker_machine) scp -r -d config/ $(NAME):$(PWD)/config/

.PHONY: machine-shell
machine-shell:
$(docker_machine) ssh $(NAME)

.PHONY: machine-stop
machine-stop:
$(docker_machine) stop $(NAME)

.PHONY: machine-delete
machine-delete:
$(docker_machine) rm -f -y $(NAME)

.PHONY: machine-date
machine-date:
$(docker_machine) ssh $(NAME) \
"sudo date -s @$(shell date +%s)"

.PHONY: machine-create
machine-create: machine-install
$(docker_machine) status $(NAME) \
||( $(docker_machine) create \
--driver $(BACKEND) \
$(docker_machine_create_flags) \
$(NAME) \
)

.PHONY: machine-install
machine-install:
# wget docker-machine & hash check here


## VM Bootstrapping ##

ifeq ($(BACKEND),local)

executables = docker
docker = docker
machine:
storage_flags = --volume $(PWD)/build/:/home/build/build/

else ifeq ($(BACKEND),virtualbox)

executables = docker-machine ssh virtualbox
docker = $(docker_machine) ssh $(NAME) -t docker
machine: machine-start storage-local
storage_flags = --volume $(NAME):/home/build/build/
docker_machine_create_flags = \
--virtualbox-share-folder="$(PWD):$(PWD)" \
--virtualbox-disk-size="$(DISK)" \
--virtualbox-memory="$(MEMORY)" \
--virtualbox-cpu-count="$(CPUS)"

else ifeq ($(BACKEND),digitalocean)

executables = docker-machine ssh
docker = $(docker_machine) ssh $(NAME) -t docker
machine: machine-start storage-digitalocean machine-sync
storage_flags = --volume $(NAME):/home/build/build/
docker_machine_create_flags = \
--digitalocean-access-token=$(DIGITALOCEAN_TOKEN) \
--digitalocean-region=$(DIGITALOCEAN_REGION) \
--digitalocean-image=$(DIGITALOCEAN_IMAGE) \
--digitalocean-size=$(DIGITALOCEAN_SIZE)

endif

userid = $(shell id -u)
groupid = $(shell id -g)
docker_machine = docker-machine --storage-path "${PWD}/build/machine"
contain := \
$(docker) run \
--rm \
--tty \
--interactive \
--name "$(NAME)" \
--hostname "$(NAME)" \
--user $(userid):$(groupid) \
--env DEVICE=$(DEVICE) \
--security-opt seccomp=unconfined \
--volume $(PWD)/config:/home/build/config \
--volume $(PWD)/release:/home/build/release \
--volume $(PWD)/scripts:/home/build/scripts \
$(storage_flags) \
$(IMAGE)


## Required Binary Check ##

check_executables := $(foreach exec,$(executables),\$(if \
$(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
Loading