Skip to content

Android 11 and Debian 10 base image #31

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
4f26211
[scripts/manifest] Coding style fix
ypid Nov 13, 2020
22c02f5
[scripts/manifest] Project remove might fail. Print first for debugging.
ypid Nov 14, 2020
4e08008
[scripts/manifest] Print what caused a project to be removed
ypid Nov 14, 2020
92d74df
[scripts/manifest] _remove needs to loops if both remove a project
ypid Nov 14, 2020
694dd22
[scripts/manifest] Repo Manifest project groups can be space-separated
ypid Nov 14, 2020
cd3e3f0
[scripts/manifest] Use `{}.get(k, fallback)` to make code more readable
ypid Nov 14, 2020
5f02210
[scripts/manifest] Drop redundant fallback to default remote
ypid Nov 14, 2020
4602bf4
[scripts/manifest] Preserve already locked project revision/commit hash
ypid Nov 14, 2020
8acde60
[scripts/retry] The first try is technically not a "retry"
ypid Nov 14, 2020
2c4f228
[scripts/build] export in build/make was deprecated with Android 11
ypid Nov 15, 2020
3d702d7
[Makefile] Set Bash failsafe options for inline shell
ypid Nov 21, 2020
d641140
[Makefile] Disable more GNU Make "magic"
ypid Nov 21, 2020
940f400
[Makefile] Fix `patches` target: The `repo` ROOT_DIR is build/base
ypid Nov 21, 2020
dcbbcce
[Makefile] `docker run --privileged` is beneficial so that nsjail works
ypid Nov 21, 2020
8b917c6
[Makefile] Reorder make targets so that they match the order of usage
ypid Nov 21, 2020
545b39e
[Makefile] Remove config as dependency of manifest to allow review
ypid Nov 21, 2020
8b95eda
[config.yml] Sort remove_paths to make changes better diffable
ypid Nov 22, 2020
614c88b
make config (taimen and walleye have issues; Ignored by me)
ypid Nov 22, 2020
3ba66a2
[scripts/manifest] Add support for platform.manifest_url in config
ypid Jan 5, 2021
921367c
[scripts/manifest] Create repo per device to match fetch script
ypid Jan 5, 2021
891eaa5
[scripts/manifest] Enable more bash safety features
ypid Jan 5, 2021
10428c5
[scripts/*] Make `repo forall` output more debug friendly
ypid Jan 5, 2021
873bf7a
[scripts/*] Performance gain: Use `--jobs` with `repo forall`
ypid Jan 5, 2021
493862f
[scripts/*] Coding style TODO: Rebase this at the end and only one
ypid Jan 5, 2021
9641d4c
[scripts/manifest] Support to reuse upstream manifest hash lock
ypid Jan 5, 2021
56ad0d2
[scripts/config] Sort remove_paths and remove_groups
ypid Jan 5, 2021
262c6b6
Switch Docker base image from Ubuntu 18.10 to Debian 10
ypid Jan 5, 2021
bf82447
[.gitignore] `build` directory could be a symlink
ypid Jan 9, 2021
4b20cb7
[manifest] Verify git tags before using manifests
ypid Jan 9, 2021
bb174c2
[verify] Add verify script called from fetch
ypid Jan 10, 2021
ae9e601
[scripts/manifest] Harden XML parsing of manifest using defusedxml
ypid Jan 30, 2021
4e4268b
[scripts/config] Use Python logging module
ypid Jan 30, 2021
2e09add
[scripts/environment] Android 11 signapk.jar needs jre11 instead of jre8
ypid Jan 31, 2021
ec9da87
[scripts/keys] networkstack is needed to sign CellBroadcastApp.apk
ypid Jan 31, 2021
c36843b
Update package pins for container image
ypid Feb 6, 2021
59be2a5
Drop redundant information from README
ypid Feb 7, 2021
daf5afc
More flexible make file. keys are no longer available during build
ypid Feb 7, 2021
0901dc1
Ensure disk has enough free space before attempting to build
ypid Feb 7, 2021
382b9a7
Add script to review (GrapheneOS) patchset across rebases
ypid Feb 7, 2021
389f8ac
[scripts/fetch] Rework the script
ypid Feb 7, 2021
87c8e78
[scripts/fetch-tag] Ensure git tags are fetched
ypid Feb 7, 2021
dd5f4aa
[scripts/build] Skip the release step for userdebug build
ypid Feb 7, 2021
c821708
[scripts/build] Ensure up-to-date aapt2 version is build for releasing
ypid Feb 7, 2021
a0c2bbf
[scripts/build] Overwriting build_id.mk not needed with Android 11
ypid Feb 7, 2021
e3e47e5
Only call build-kernel from build script for more flexibility
ypid Feb 7, 2021
aee336b
[scripts/build] Stop deleting /vendor because it breaks repo manifest -r
ypid Feb 7, 2021
ed68d0d
[scripts/manifest] Ignore missing kernel_ref for GrapheneOS support
ypid Feb 9, 2021
0600e78
[scripts/build-vendor] Fix indention
ypid Feb 9, 2021
e5155f7
Add section about reviewing patchsets to README
ypid Feb 9, 2021
a67ad1f
No need to commit YAML files in manifest directory
ypid Feb 9, 2021
28b3e96
Disable PS4 debugging. This approach needs to be reevaluated
ypid Feb 9, 2021
013fb88
Fix empty BUILD_ID
ypid Feb 9, 2021
0b6b9ab
Ignore more unneeded projects for performance reasons
ypid Feb 9, 2021
59b4f45
make config
ypid Feb 9, 2021
55826d9
[scripts/build] Support Android 11 in build_platform func
ypid Feb 9, 2021
472ec32
make manifest
ypid Feb 9, 2021
a550c23
Rename from HashbangOS to HashbangMobile
ypid Feb 9, 2021
3cd1a51
Update generate-metadata to support Updater app after 2020-06-02
thestinger Feb 11, 2021
169bc62
OTA_CHANNEL env var does not make much sense with new metadata, drop
ypid Feb 11, 2021
18463e7
Changes needed to build android-10.0.0_r22 for crosshatch
mpoel Feb 14, 2021
396cfbd
Regenerate all manifest files
ypid Feb 14, 2021
f7eab24
Regenerate all manifest files
ypid Mar 2, 2021
baa4146
Document host software requirements
ypid Mar 8, 2021
96dcc90
Fix build after I removed access to keys from build target
ypid Mar 8, 2021
dc5ee97
Switch to snapshot.debian.org for reproducable building of the image
ypid Mar 8, 2021
addc92f
Regenerate all manifest files
ypid Apr 6, 2021
5f2f66d
Regenerate all manifest files
ypid May 4, 2021
c97e444
chore: Regenerate all manifest files
ypid Jun 10, 2021
a156a63
fix: Make verify-do accept grapheneos* remote as grapheneos
ypid Jul 8, 2021
0e61a09
chore: Regenerate all manifest files
ypid Jul 8, 2021
6ae3dab
chore: Update to buster-20210621
ypid Aug 7, 2021
0372c0f
chore: Update to android-11.0.0_r40
ypid Aug 7, 2021
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
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
build/*
config/keys/*
build
config/env/*
config/container/Dockerfile.*
config/container/Dockerfile-*
config/manifests/**/*.yml
release/*

# Old path, please manually move to new path.
config/keys

# New keys path.
keys

.*
134 changes: 97 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
SHELL = /bin/bash -o nounset -o pipefail -o errexit
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:

## Argument Variables ##

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

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

Expand All @@ -25,20 +29,24 @@ default: machine image fetch tools keys build release
## Primary Targets ##

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

.PHONY: keys
keys:
$(contain) keys
$(contain-keys) keys

.PHONY: review
review:
$(contain) review

.PHONY: build
build:
build: ensure-enough-free-disk-space
$(contain) build

.PHONY: release
release:
$(contain) release
$(contain-keys) release

.PHONY: publish
publish:
Expand All @@ -52,28 +60,41 @@ clean:
mrproper: storage-delete machine-delete
rm -rf build


## Secondary Targets ##

config/container/Dockerfile: config/container/Dockerfile.j2 config/container/render_template
./config/container/render_template "$<" "{\"tags\":[]}" > "$@"

## Support for different Docker image variants.
config/container/Dockerfile-golang:
config/container/Dockerfile-latest:
config/container/Dockerfile-%: config/container/Dockerfile.j2 config/container/render_template
./config/container/render_template "$<" "{\"tags\":[\"$*\"]}" > "$@"

.PHONY: image
image:
image: config/container/Dockerfile
$(docker) build \
--tag $(IMAGE) \
--file $(PWD)/config/container/Dockerfile \
--file "$(PWD)/$<" \
$(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
.PHONY: image-%
image-golang:
image-latest:
image-%: config/container/Dockerfile-%
$(docker) build \
--tag $(IMAGE) \
--file "$(PWD)/$<" \
$(IMAGE_OPTIONS) \
$(PWD)

## Note that the `image-latest` target should be used for pinning.
.PHONY: config/container/packages-pinned.list
config/container/packages-pinned.list:
$(contain-no-tty) pin-packages > "$@"


.PHONY: tools
tools:
mkdir -p config/keys build/base release build/external
Expand All @@ -97,14 +118,14 @@ kernel:
.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: manifest
manifest:
$(contain) bash -c "source <(environment) && manifest"

.PHONY: test-repro
test-repro:
$(contain) test-repro
Expand All @@ -114,18 +135,16 @@ test: test-repro

.PHONY: patches
patches:
@$(contain) bash -c "cd base; repo diff --absolute"
@$(contain) bash -c "cd build/base && repo diff --absolute"

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

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

.PHONY: install
install: tools
Expand Down Expand Up @@ -250,22 +269,63 @@ endif
userid = $(shell id -u)
groupid = $(shell id -g)
docker_machine = docker-machine --storage-path "${PWD}/build/machine"
contain := \

# Can be used mount aosp-build directory to /opt/aosp-build to allow fast
# development without the need to rebuild the container image all the time.
# See HashbangMobile for example.
contain-base-extend =

contain-base = \
$(docker) run \
--rm \
--tty \
--interactive \
--name "$(NAME)" \
--hostname "$(NAME)" \
--user $(userid):$(groupid) \
--env DEVICE=$(DEVICE) \
--privileged \
--security-opt seccomp=unconfined \
--volume $(PWD)/config:/home/build/config \
--volume $(PWD)/release:/home/build/release \
--volume $(PWD)/scripts:/home/build/scripts \
$(storage_flags) \
$(contain-base-extend) \
$(RUN_OPTIONS) \
--shm-size="1g" \
$(storage_flags)

contain-no-tty = \
$(contain-base) \
$(IMAGE)

contain-keys = \
$(contain-base) \
--tty \
--volume $(PWD)/keys:/home/build/keys \
$(IMAGE)

contain = \
$(contain-base) \
--tty \
$(IMAGE)

## Helpers ##

ensure-git-status-clean:
@if [ -z "$(shell git status --porcelain=v2)" ]; then \
echo "git status has no output. Working tree is clean."; \
else \
git status; \
echo "Working tree is not clean as required. Exiting."; \
exit 1; \
fi

ensure-enough-free-disk-space:
@free_space=$(shell df -k --output=avail "$$PWD" | tail -n1); \
needed_free_space=$$(( $(REQUIRED_FREE_SPACE_IN_GIB) * 1024 * 1024 )); \
if [[ $$free_space -lt $$needed_free_space ]]; then \
echo "Not enought free space. $(REQUIRED_FREE_SPACE_IN_GIB) GiB are required." 1>&2; \
exit 1; \
fi

## Required Binary Check ##

Expand Down
122 changes: 53 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ of the Makefile and config.yml from this repo, along with any desired patches.

## Support ##

Please join us on IRC: ircs://irc.hashbang.sh/#!os
Please join us on IRC: ircs://irc.hashbang.sh/#!mobile

## Features ##

Expand All @@ -42,72 +42,12 @@ Please join us on IRC: ircs://irc.hashbang.sh/#!os

## Install ##

### Requirements ###
Refer to [GrapheneOS CLI install].

* [Android Developer Tools][4]
[GrapheneOS CLI install]: https://grapheneos.org/install/cli

[4]: https://developer.android.com/studio/releases/platform-tools
### Notes

### Connect

1. Go to "Settings > About Phone"
2. Tap "Build number" 7 times.
3. Go to "Settings > System > Advanced > Developer options"
4. Enable "USB Debugging"
5. Connect to device to laptop via short USB C cable
6. Hit "OK" on "Allow USB Debugging?" prompt on device if present.
7. Verify ADB connectivity
```
adb devices
```
Note: Should return something like: "7CKY1QD3F device"

### Flash

1. Extract

```
unzip crosshatch-PQ1A.181205.006-factory-1947dcec.zip
cd crosshatch-PQ1A.181205.006
```

2. [Connect](#Connect)
3. Go to "Settings > System > Advanced > Developer options"
4. Enable "OEM Unlocking"
5. Unlock the bootloader via ADB

```
adb reboot bootloader
fastboot flashing unlock
```
Note: You must manually accept prompt on device.

6. Flash new factory images

```
./flash-all.sh
```

### Harden

1. [Connect](#Connect)
2. Lock the bootloader
```
adb reboot bootloader
fastboot flashing lock
```
3. Go to "Settings > About Phone"
4. Tap "Build number" 7 times.
5. Go to "Settings > System > Advanced > Developer options"
6. Disable "OEM unlocking"
7. Reboot
8. Verify boot message: "Your device is loading a different operating system"
9. Go to "Settings > System > Advanced > Developer options"
10. Verify "OEM unlocking" is still disabled

#### Notes

* Failure to run these hardening steps means -anyone- can flash your device.
* Past this point if signing keys are lost, all devices are bricked. Backup!

### Update ###
Expand All @@ -126,11 +66,27 @@ Please join us on IRC: ircs://irc.hashbang.sh/#!os

## Build ##

Most of the dependencies are "contained". Only minimal software requirements
exist for the controlling host that cannot be contained easily because of the
bootstrapping problem:

* GNU core utilities
* GNU Make
* Python 3 dependencies: jinja2

They should be packaged by your distribution under the following names (adjust
slight distro differences yourself):

```
coreutils make python3 python3-jinja2
```

### Backends ###

#### Local

##### Requirements

* Docker 10+
* x86_64 CPU
* 10GB+ available memory
Expand Down Expand Up @@ -250,13 +206,41 @@ make diff > patches/my-feature.patch
make install
```

#### Update ####
### Release ###

Build latest config from upstream sources:
1. Update references to latest upstream sources.

```
make DEVICE=crosshatch manifest
```
```
make config
```

1. Regenerate the git-repo XML manifest files.

```
make manifest
```

1. Build all targets impacted by given change

```
make DEVICE=crosshatch release
```

1. Commit changes to a PR

## Review ##

Patchsets that base on AOSP will carry their patchset forward using `git
rebase`. In case you use aosp-build you might be interested in an ongoing
review of this patchset across rebases. For this, checkout `make review`.

Refer to https://github.com/ypid/android-review for one public instance of such
a review.

### How it works? ###

We use the hash locked manifest that [aosp-build] produces from AOSP to
whatever you have checked out.

## Notes ##

Expand Down
Loading