Skip to content

Commit 49511ef

Browse files
committed
Merge branch 'feature/android-11-and-debian-10-base-image'
2 parents a562660 + 0372c0f commit 49511ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6658
-5986
lines changed

.gitignore

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
build/*
2-
config/keys/*
1+
build
32
config/env/*
4-
config/container/Dockerfile.*
3+
config/container/Dockerfile-*
4+
config/manifests/**/*.yml
55
release/*
6+
7+
# Old path, please manually move to new path.
8+
config/keys
9+
10+
# New keys path.
11+
keys
12+
613
.*

Makefile

Lines changed: 97 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
SHELL = /bin/bash -o nounset -o pipefail -o errexit
2+
MAKEFLAGS += --no-builtin-rules
3+
.SUFFIXES:
4+
15
## Argument Variables ##
26

3-
CPUS := $(shell nproc)
4-
MEMORY := 10000
5-
DISK := 300000
6-
DEVICE :=
7-
BACKEND := local
8-
CHANNEL := beta
9-
BUILD := user
10-
FLAVOR := aosp
11-
IMAGE := hashbang/aosp-build:latest
12-
IMAGE_OPTIONS :=
13-
NAME := aosp-build-$(FLAVOR)-$(BACKEND)
14-
SHELL := /bin/bash
7+
CPUS = $(shell nproc)
8+
MEMORY = 10000
9+
DISK = 300000
10+
DEVICE =
11+
BACKEND = local
12+
CHANNEL = beta
13+
FLAVOR = aosp
14+
IMAGE = hashbang/aosp-build:latest
15+
IMAGE_OPTIONS =
16+
RUN_OPTIONS =
17+
NAME = aosp-build-$(FLAVOR)-$(BACKEND)
18+
REQUIRED_FREE_SPACE_IN_GIB = 120
1519

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

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

2731
.PHONY: fetch
28-
fetch: submodule-update machine image
32+
fetch:
2933
$(contain) fetch
3034

3135
.PHONY: keys
3236
keys:
33-
$(contain) keys
37+
$(contain-keys) keys
38+
39+
.PHONY: review
40+
review:
41+
$(contain) review
3442

3543
.PHONY: build
36-
build:
44+
build: ensure-enough-free-disk-space
3745
$(contain) build
3846

3947
.PHONY: release
4048
release:
41-
$(contain) release
49+
$(contain-keys) release
4250

4351
.PHONY: publish
4452
publish:
@@ -52,28 +60,41 @@ clean:
5260
mrproper: storage-delete machine-delete
5361
rm -rf build
5462

55-
5663
## Secondary Targets ##
5764

65+
config/container/Dockerfile: config/container/Dockerfile.j2 config/container/render_template
66+
./config/container/render_template "$<" "{\"tags\":[]}" > "$@"
67+
68+
## Support for different Docker image variants.
69+
config/container/Dockerfile-golang:
70+
config/container/Dockerfile-latest:
71+
config/container/Dockerfile-%: config/container/Dockerfile.j2 config/container/render_template
72+
./config/container/render_template "$<" "{\"tags\":[\"$*\"]}" > "$@"
73+
5874
.PHONY: image
59-
image:
75+
image: config/container/Dockerfile
6076
$(docker) build \
6177
--tag $(IMAGE) \
62-
--file $(PWD)/config/container/Dockerfile \
78+
--file "$(PWD)/$<" \
6379
$(IMAGE_OPTIONS) \
6480
$(PWD)
6581

66-
config/container/Dockerfile.minimal: config/container/Dockerfile config/container/render_template
67-
./config/container/render_template "$<" | grep -v '^#\s*$$' > "$@"
68-
69-
.PHONY: image-minimal
70-
image-minimal: config/container/Dockerfile.minimal
82+
.PHONY: image-%
83+
image-golang:
84+
image-latest:
85+
image-%: config/container/Dockerfile-%
7186
$(docker) build \
7287
--tag $(IMAGE) \
7388
--file "$(PWD)/$<" \
7489
$(IMAGE_OPTIONS) \
7590
$(PWD)
7691

92+
## Note that the `image-latest` target should be used for pinning.
93+
.PHONY: config/container/packages-pinned.list
94+
config/container/packages-pinned.list:
95+
$(contain-no-tty) pin-packages > "$@"
96+
97+
7798
.PHONY: tools
7899
tools:
79100
mkdir -p config/keys build/base release build/external
@@ -97,14 +118,14 @@ kernel:
97118
.PHONY: latest
98119
latest: config submodule-latest fetch
99120

100-
.PHONY: manifest
101-
manifest: config
102-
$(contain) bash -c "source <(environment) && manifest"
103-
104121
.PHONY: config
105122
config:
106123
$(contain) bash -c "source <(environment) && config"
107124

125+
.PHONY: manifest
126+
manifest:
127+
$(contain) bash -c "source <(environment) && manifest"
128+
108129
.PHONY: test-repro
109130
test-repro:
110131
$(contain) test-repro
@@ -114,18 +135,16 @@ test: test-repro
114135

115136
.PHONY: patches
116137
patches:
117-
@$(contain) bash -c "cd base; repo diff --absolute"
138+
@$(contain) bash -c "cd build/base && repo diff --absolute"
118139

119140
.PHONY: shell
120141
shell:
121-
$(docker) inspect "$(NAME)" \
122-
&& $(docker) exec --interactive --tty "$(NAME)" shell \
123-
|| $(contain) shell
142+
$(docker) exec --interactive --tty "$(NAME)" shell \
143+
|| $(contain) shell
124144

125145
.PHONY: monitor
126146
monitor:
127-
$(docker) inspect "$(NAME)" \
128-
&& $(docker) exec --interactive --tty "$(NAME)" htop
147+
$(docker) exec --interactive --tty "$(NAME)" htop
129148

130149
.PHONY: install
131150
install: tools
@@ -250,22 +269,63 @@ endif
250269
userid = $(shell id -u)
251270
groupid = $(shell id -g)
252271
docker_machine = docker-machine --storage-path "${PWD}/build/machine"
253-
contain := \
272+
273+
# Can be used mount aosp-build directory to /opt/aosp-build to allow fast
274+
# development without the need to rebuild the container image all the time.
275+
# See HashbangMobile for example.
276+
contain-base-extend =
277+
278+
contain-base = \
254279
$(docker) run \
255280
--rm \
256-
--tty \
257281
--interactive \
258282
--name "$(NAME)" \
259283
--hostname "$(NAME)" \
260284
--user $(userid):$(groupid) \
261285
--env DEVICE=$(DEVICE) \
286+
--privileged \
262287
--security-opt seccomp=unconfined \
263288
--volume $(PWD)/config:/home/build/config \
264289
--volume $(PWD)/release:/home/build/release \
265290
--volume $(PWD)/scripts:/home/build/scripts \
266-
$(storage_flags) \
291+
$(contain-base-extend) \
292+
$(RUN_OPTIONS) \
293+
--shm-size="1g" \
294+
$(storage_flags)
295+
296+
contain-no-tty = \
297+
$(contain-base) \
298+
$(IMAGE)
299+
300+
contain-keys = \
301+
$(contain-base) \
302+
--tty \
303+
--volume $(PWD)/keys:/home/build/keys \
304+
$(IMAGE)
305+
306+
contain = \
307+
$(contain-base) \
308+
--tty \
267309
$(IMAGE)
268310

311+
## Helpers ##
312+
313+
ensure-git-status-clean:
314+
@if [ -z "$(shell git status --porcelain=v2)" ]; then \
315+
echo "git status has no output. Working tree is clean."; \
316+
else \
317+
git status; \
318+
echo "Working tree is not clean as required. Exiting."; \
319+
exit 1; \
320+
fi
321+
322+
ensure-enough-free-disk-space:
323+
@free_space=$(shell df -k --output=avail "$$PWD" | tail -n1); \
324+
needed_free_space=$$(( $(REQUIRED_FREE_SPACE_IN_GIB) * 1024 * 1024 )); \
325+
if [[ $$free_space -lt $$needed_free_space ]]; then \
326+
echo "Not enought free space. $(REQUIRED_FREE_SPACE_IN_GIB) GiB are required." 1>&2; \
327+
exit 1; \
328+
fi
269329

270330
## Required Binary Check ##
271331

README.md

Lines changed: 53 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ of the Makefile and config.yml from this repo, along with any desired patches.
1515

1616
## Support ##
1717

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

2020
## Features ##
2121

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

4343
## Install ##
4444

45-
### Requirements ###
45+
Refer to [GrapheneOS CLI install].
4646

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

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

51-
### Connect
52-
53-
1. Go to "Settings > About Phone"
54-
2. Tap "Build number" 7 times.
55-
3. Go to "Settings > System > Advanced > Developer options"
56-
4. Enable "USB Debugging"
57-
5. Connect to device to laptop via short USB C cable
58-
6. Hit "OK" on "Allow USB Debugging?" prompt on device if present.
59-
7. Verify ADB connectivity
60-
```
61-
adb devices
62-
```
63-
Note: Should return something like: "7CKY1QD3F device"
64-
65-
### Flash
66-
67-
1. Extract
68-
69-
```
70-
unzip crosshatch-PQ1A.181205.006-factory-1947dcec.zip
71-
cd crosshatch-PQ1A.181205.006
72-
```
73-
74-
2. [Connect](#Connect)
75-
3. Go to "Settings > System > Advanced > Developer options"
76-
4. Enable "OEM Unlocking"
77-
5. Unlock the bootloader via ADB
78-
79-
```
80-
adb reboot bootloader
81-
fastboot flashing unlock
82-
```
83-
Note: You must manually accept prompt on device.
84-
85-
6. Flash new factory images
86-
87-
```
88-
./flash-all.sh
89-
```
90-
91-
### Harden
92-
93-
1. [Connect](#Connect)
94-
2. Lock the bootloader
95-
```
96-
adb reboot bootloader
97-
fastboot flashing lock
98-
```
99-
3. Go to "Settings > About Phone"
100-
4. Tap "Build number" 7 times.
101-
5. Go to "Settings > System > Advanced > Developer options"
102-
6. Disable "OEM unlocking"
103-
7. Reboot
104-
8. Verify boot message: "Your device is loading a different operating system"
105-
9. Go to "Settings > System > Advanced > Developer options"
106-
10. Verify "OEM unlocking" is still disabled
107-
108-
#### Notes
109-
110-
* Failure to run these hardening steps means -anyone- can flash your device.
11151
* Past this point if signing keys are lost, all devices are bricked. Backup!
11252

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

12767
## Build ##
12868

69+
Most of the dependencies are "contained". Only minimal software requirements
70+
exist for the controlling host that cannot be contained easily because of the
71+
bootstrapping problem:
72+
73+
* GNU core utilities
74+
* GNU Make
75+
* Python 3 dependencies: jinja2
76+
77+
They should be packaged by your distribution under the following names (adjust
78+
slight distro differences yourself):
79+
80+
```
81+
coreutils make python3 python3-jinja2
82+
```
83+
12984
### Backends ###
13085

13186
#### Local
13287

13388
##### Requirements
89+
13490
* Docker 10+
13591
* x86_64 CPU
13692
* 10GB+ available memory
@@ -250,13 +206,41 @@ make diff > patches/my-feature.patch
250206
make install
251207
```
252208

253-
#### Update ####
209+
### Release ###
254210

255-
Build latest config from upstream sources:
211+
1. Update references to latest upstream sources.
256212

257-
```
258-
make DEVICE=crosshatch manifest
259-
```
213+
```
214+
make config
215+
```
216+
217+
1. Regenerate the git-repo XML manifest files.
218+
219+
```
220+
make manifest
221+
```
222+
223+
1. Build all targets impacted by given change
224+
225+
```
226+
make DEVICE=crosshatch release
227+
```
228+
229+
1. Commit changes to a PR
230+
231+
## Review ##
232+
233+
Patchsets that base on AOSP will carry their patchset forward using `git
234+
rebase`. In case you use aosp-build you might be interested in an ongoing
235+
review of this patchset across rebases. For this, checkout `make review`.
236+
237+
Refer to https://github.com/ypid/android-review for one public instance of such
238+
a review.
239+
240+
### How it works? ###
241+
242+
We use the hash locked manifest that [aosp-build] produces from AOSP to
243+
whatever you have checked out.
260244

261245
## Notes ##
262246

0 commit comments

Comments
 (0)