Skip to content

Commit 11e02c0

Browse files
committed
lineageos: support LineageOS 20
1 parent aa0df00 commit 11e02c0

13 files changed

+341
-18
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ changes occur which require user intervention / configuration changes. These
88
are highlights since the last update, and are not meant to be an exhaustive
99
listing of changes. See the git commit log for additional details.
1010

11+
# 2023-09-14
12+
- Support LineageOS version 20.0 (`androidVersion=13`)
13+
1114
# 2022-02-10
1215
- Added LineageOS version 19.0. Use by setting `androidVersion=12` (thanks @Kranzes)
1316
- Updated vanilla flavor to 2022021005

default.nix

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ let
4242
./modules/10
4343
./modules/11
4444
./modules/12
45+
./modules/13
4546
./modules/9
4647
./modules/apps/auditor.nix
4748
./modules/apps/chromium.nix
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 0ba0ae56b5b7a4196f30b7c9cc899785797552bb Mon Sep 17 00:00:00 2001
2+
From: Daniel Fullmer <[email protected]>
3+
Date: Thu, 7 May 2020 17:52:03 -0400
4+
Subject: [PATCH] Remove LineageOS keys
5+
6+
Signing target files would fail:
7+
extra recovery-only key(s): vendor/lineage/build/target/product/security/lineage.x509.pem
8+
However, that key is not available in our build environment. We don't
9+
want to include them anyway.
10+
---
11+
config/common.mk | 4 ----
12+
1 file changed, 4 deletions(-)
13+
14+
diff --git a/config/common.mk b/config/common.mk
15+
index 7048c9cb..25f4b197 100644
16+
--- a/config/common.mk
17+
+++ b/config/common.mk
18+
@@ -207,12 +207,8 @@ PRODUCT_PACKAGES += \
19+
PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS += vendor/crowdin/overlay
20+
PRODUCT_PACKAGE_OVERLAYS += vendor/crowdin/overlay
21+
22+
-PRODUCT_EXTRA_RECOVERY_KEYS += \
23+
- vendor/lineage/build/target/product/security/lineage
24+
25+
include vendor/lineage/config/version.mk
26+
27+
--include vendor/lineage-priv/keys/keys.mk
28+
-
29+
-include $(WORKSPACE)/build_env/image-auto-bits.mk
30+
-include vendor/lineage/config/partner_gms.mk
31+
--
32+
2.39.2
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From a0de58b8fdba9fd3725eb604dec0cdc92ccfb4a2 Mon Sep 17 00:00:00 2001
2+
From: Daniel Fullmer <[email protected]>
3+
Date: Sun, 10 May 2020 18:50:33 -0400
4+
Subject: [PATCH] kernel: Set constant kernel timestamp
5+
6+
---
7+
build/tasks/kernel.mk | 5 ++++-
8+
1 file changed, 4 insertions(+), 1 deletion(-)
9+
10+
diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk
11+
index 9189864d..0c98a91d 100644
12+
--- a/build/tasks/kernel.mk
13+
+++ b/build/tasks/kernel.mk
14+
@@ -262,11 +262,14 @@ ifneq ($(TARGET_KERNEL_ADDITIONAL_FLAGS),)
15+
KERNEL_MAKE_FLAGS += $(TARGET_KERNEL_ADDITIONAL_FLAGS)
16+
endif
17+
18+
+# Use a constant timestamp
19+
+KERNEL_TIMESTAMP := KBUILD_BUILD_TIMESTAMP="$(shell date -u -d @1)"
20+
+
21+
# Internal implementation of make-kernel-target
22+
# $(1): output path (The value passed to O=)
23+
# $(2): target to build (eg. defconfig, modules, dtbo.img)
24+
define internal-make-kernel-target
25+
-$(PATH_OVERRIDE) $(KERNEL_MAKE_CMD) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_BUILD_OUT_PREFIX)$(1) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(2)
26+
+$(PATH_OVERRIDE) $(KERNEL_MAKE_CMD) $(KERNEL_MAKE_FLAGS) $(KERNEL_TIMESTAMP) -C $(KERNEL_SRC) O=$(KERNEL_BUILD_OUT_PREFIX)$(1) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(2)
27+
endef
28+
29+
# Make an external module target
30+
--
31+
2.39.2
32+

flavors/lineageos/default.nix

+29-16
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
let
66
inherit (lib)
77
optional optionals optionalString optionalAttrs
8-
elem mapAttrs mapAttrs' nameValuePair filterAttrs
8+
elem filter
9+
mapAttrs mapAttrs' nameValuePair filterAttrs
910
attrNames getAttrs flatten remove
1011
mkIf mkMerge mkDefault mkForce
11-
importJSON toLower hasPrefix removePrefix;
12+
importJSON toLower hasPrefix removePrefix hasSuffix replaceStrings;
1213

1314
androidVersionToLineageBranch = {
1415
"10" = "lineage-17.1";
1516
"11" = "lineage-18.1";
1617
"12" = "lineage-19.1";
18+
"13" = "lineage-20.0";
1719
};
1820
lineageBranchToAndroidVersion = mapAttrs' (name: value: nameValuePair value name) androidVersionToLineageBranch;
1921

@@ -92,15 +94,19 @@ in mkIf (config.flavor == "lineageos")
9294

9395
{
9496
"vendor/lineage".patches = [
95-
(if lib.versionAtLeast (toString config.androidVersion) "12"
96-
then ./0001-Remove-LineageOS-keys-12.patch
97-
else ./0001-Remove-LineageOS-keys.patch)
97+
(if lib.versionAtLeast (toString config.androidVersion) "13"
98+
then ./0001-Remove-LineageOS-keys-20.patch
99+
else ./0001-Remove-LineageOS-keys-19.patch)
98100

99101
(pkgs.substituteAll {
100102
src = ./0002-bootanimation-Reproducibility-fix.patch;
101103
inherit (pkgs) imagemagick;
102104
})
103-
./0003-kernel-Set-constant-kernel-timestamp.patch
105+
106+
(if lib.versionAtLeast (toString config.androidVersion) "13"
107+
then ./0003-kernel-Set-constant-kernel-timestamp-20.patch
108+
else ./0003-kernel-Set-constant-kernel-timestamp-19.patch)
109+
104110
];
105111
"system/extras".patches = [
106112
# pkgutil.get_data() not working, probably because we don't use their compiled python
@@ -115,19 +121,26 @@ in mkIf (config.flavor == "lineageos")
115121
# So we'll just build chromium webview ourselves.
116122
"external/chromium-webview".enable = false;
117123
}
118-
] ++ optionals (deviceMetadata ? "${config.device}") [
124+
] ++ optionals (deviceMetadata ? "${config.device}") (let
119125
# Device-specific source dirs
120-
(let
121-
vendor = toLower deviceMetadata.${config.device}.vendor;
122-
relpathWithDependencies = relpath: [ relpath ] ++ (flatten (map (p: relpathWithDependencies p) deviceDirs.${relpath}.deps));
123-
relpaths = relpathWithDependencies "device/${vendor}/${config.device}";
124-
filteredRelpaths = remove (attrNames repoDirs) relpaths; # Remove any repos that we're already including from repo json
125-
in filterDirsAttrs (getAttrs filteredRelpaths deviceDirs))
126-
126+
vendor = toLower deviceMetadata.${config.device}.vendor;
127+
relpathWithDependencies = relpath: [ relpath ] ++ (flatten (map (p: relpathWithDependencies p) deviceDirs.${relpath}.deps));
128+
relpaths = relpathWithDependencies "device/${vendor}/${config.device}";
129+
filteredRelpaths = remove (attrNames repoDirs) relpaths; # Remove any repos that we're already including from repo json
130+
131+
# Device-specific common vendor dirs
132+
deviceDirsCommon = filter (path: hasPrefix "device/" path && hasSuffix "-common" path && !hasSuffix "xiaomi/sm8350-common" path) relpaths;
133+
vendorDeviceDirs = map (replaceStrings [ "device/" ] [ "vendor/" ]) deviceDirsCommon;
134+
in [
135+
(filterDirsAttrs (getAttrs filteredRelpaths deviceDirs))
136+
(filterDirsAttrs (getAttrs vendorDeviceDirs vendorDirs))
137+
]) ++ [
127138
# Vendor-specific source dirs
128139
(let
129-
_vendor = toLower deviceMetadata.${config.device}.vendor;
130-
vendor = if config.device == "shamu" then "motorola" else _vendor;
140+
vendor = if config.androidVersion >= 13 then
141+
deviceMetadata.${config.device}.vendor_dir_new
142+
else
143+
deviceMetadata.${config.device}.vendor_dir;
131144
relpath = "vendor/${vendor}";
132145
in filterDirsAttrs (getAttrs [relpath] vendorDirs))
133146
] ++ optional (config.device == "bacon")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/config/Android.mk b/config/Android.mk
2+
--- a/config/Android.mk
3+
+++ b/config/Android.mk
4+
@@ -28,6 +28,6 @@
5+
6+
$(_build-manifest_xml):
7+
mkdir -p $(dir $@)
8+
- python3 .repo/repo/repo manifest -o - -r | grep -Ev "proprietary_$(MANIFEST_EXCLUDES)" > $@
9+
+ echo 'stubbed' > $@
10+
11+
include $(BUILD_SYSTEM)/base_rules.mk
12+
\ No newline at end of file
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
From 8792b0028fe89540c95a5e66adc5557054a3e393 Mon Sep 17 00:00:00 2001
2+
From: Daniel Fullmer <[email protected]>
3+
Date: Sun, 17 May 2020 00:42:48 -0400
4+
Subject: [PATCH] Readonly source fix
5+
6+
Have CopyFile just always set u+w on copied files. Fixes a bunch of
7+
issues that would be too difficult to track down otherwise. HACK
8+
9+
Change-Id: Ic905ab7c3c41f013fc70c92b375f5dc41d5cf586
10+
---
11+
core/Makefile | 3 +++
12+
core/definitions.mk | 4 ++++
13+
tools/libhost/CopyFile.c | 4 ++--
14+
3 files changed, 9 insertions(+), 2 deletions(-)
15+
16+
diff --git a/core/Makefile b/core/Makefile
17+
index c4d5530aa6..c96367a163 100644
18+
--- a/core/Makefile
19+
+++ b/core/Makefile
20+
@@ -1222,6 +1222,7 @@ INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
21+
ifeq ($(BOARD_AVB_ENABLE),true)
22+
$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
23+
cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
24+
+ chmod u+w $@
25+
$(AVBTOOL) add_hash_footer \
26+
--image $@ \
27+
$(call get-partition-size-argument,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) \
28+
@@ -4007,6 +4008,7 @@ INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
29+
ifeq ($(BOARD_AVB_ENABLE),true)
30+
$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
31+
cp $(BOARD_PREBUILT_DTBOIMAGE) $@
32+
+ chmod u+w $@
33+
$(AVBTOOL) add_hash_footer \
34+
--image $@ \
35+
$(call get-partition-size-argument,$(BOARD_DTBOIMG_PARTITION_SIZE)) \
36+
@@ -4020,6 +4022,7 @@ UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DTBOIMAGE_TARGET)
37+
else
38+
$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
39+
cp $(BOARD_PREBUILT_DTBOIMAGE) $@
40+
+ chmod u+w $@
41+
endif
42+
43+
endif # BOARD_PREBUILT_DTBOIMAGE
44+
diff --git a/core/definitions.mk b/core/definitions.mk
45+
index ce1248e2e9..4c5c3d51f3 100644
46+
--- a/core/definitions.mk
47+
+++ b/core/definitions.mk
48+
@@ -3262,6 +3262,7 @@ define copy-file-to-target
49+
@mkdir -p $(dir $@)
50+
$(hide) rm -f $@
51+
$(hide) cp "$<" "$@"
52+
+$(hide) chmod u+w "$@"
53+
endef
54+
55+
# Same as copy-file-to-target, but assume file is a licenes metadata file,
56+
@@ -3281,6 +3282,7 @@ define copy-file-to-target-with-cp
57+
@mkdir -p $(dir $@)
58+
$(hide) rm -f $@
59+
$(hide) cp -p "$<" "$@"
60+
+$(hide) chmod u+w "$@"
61+
endef
62+
63+
# The same as copy-file-to-target, but strip out "# comment"-style
64+
@@ -3297,6 +3299,7 @@ define copy-file-to-new-target
65+
@mkdir -p $(dir $@)
66+
$(hide) rm -f $@
67+
$(hide) cp $< $@
68+
+$(hide) chmod u+w "$@"
69+
endef
70+
71+
# The same as copy-file-to-new-target, but use the local
72+
@@ -3305,6 +3308,7 @@ define copy-file-to-new-target-with-cp
73+
@mkdir -p $(dir $@)
74+
$(hide) rm -f $@
75+
$(hide) cp $< $@
76+
+$(hide) chmod u+w "$@"
77+
endef
78+
79+
# The same as copy-file-to-new-target, but preserve symlinks. Symlinks are
80+
diff --git a/tools/libhost/CopyFile.c b/tools/libhost/CopyFile.c
81+
index f9bda86fd1..44b36e4bdf 100644
82+
--- a/tools/libhost/CopyFile.c
83+
+++ b/tools/libhost/CopyFile.c
84+
@@ -180,9 +180,9 @@ static int setPermissions(const char* dst, const struct stat* pSrcStat, unsigned
85+
/*
86+
* Set the permissions.
87+
*/
88+
- if (chmod(dst, pSrcStat->st_mode & ~(S_IFMT)) != 0) {
89+
+ if (chmod(dst, (pSrcStat->st_mode | S_IWUSR) & ~(S_IFMT)) != 0) {
90+
DBUG(("--- unable to set perms on '%s' to 0%o: %s\n",
91+
- dst, pSrcStat->st_mode & ~(S_IFMT), strerror(errno)));
92+
+ dst, (pSrcStat->st_mode | S_IWUSR) & ~(S_IFMT), strerror(errno)));
93+
}
94+
#ifndef _WIN32
95+
/*
96+
--
97+
2.39.2
98+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
From 105e08518e96424d9a8deaead77290baea906f42 Mon Sep 17 00:00:00 2001
2+
From: Zhaofeng Li <[email protected]>
3+
Date: Sat, 6 Nov 2021 12:48:25 -0700
4+
Subject: [PATCH] Add option to include prebuilt images when signing target
5+
files.
6+
7+
Adapted from original CL from Greg Ross <[email protected]>:
8+
https://review.lineageos.org/c/LineageOS/android_build/+/277134
9+
10+
When producing a signed build using sign_target_files_apks.py and a prebuilt
11+
vendor.img (or other prebuilt images that are to be included in the final zip)
12+
sign_target_files_apks.py must be told to include the prebuilt images or they
13+
will not be included in the final file.
14+
15+
The build process uses the make configuration statements
16+
BOARD_PREBUILT_VENDORIMAGE and AB_OTA_PARTITIONS to inform the build process
17+
to add the image files, however since sign_target_files_apks.py is not part
18+
of the make system, it does not know about these configuration settings.
19+
20+
This patch therefore adds a new command line option to the
21+
sign_target_files_apks.py script to allow the user to add one or more images
22+
to the signed-target_files.zip that is produced.
23+
24+
The command line option has the following format:
25+
26+
--prebuilt_image <path to prebuilt image>
27+
Specify a path to a prebuilt image file, to be added to the
28+
signed_target-files.zip. This option may be repeated to add multiple
29+
images.
30+
31+
Change-Id: Id906b2e32797f95b0ee47859036ba31ea7975b64
32+
---
33+
tools/releasetools/sign_target_files_apks.py | 30 ++++++++++++++++++++
34+
1 file changed, 30 insertions(+)
35+
36+
diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py
37+
index 0842af9018..b160a21c67 100755
38+
--- a/tools/releasetools/sign_target_files_apks.py
39+
+++ b/tools/releasetools/sign_target_files_apks.py
40+
@@ -136,6 +136,11 @@ Usage: sign_target_files_apks [flags] input_target_files output_target_files
41+
42+
--android_jar_path <path>
43+
Path to the android.jar to repack the apex file.
44+
+
45+
+ --prebuilt_image <path to prebuilt image>
46+
+ Specify a path to a prebuilt image file, to be added to the
47+
+ signed_target-files.zip. This option may be repeated to add multiple
48+
+ images.
49+
"""
50+
51+
from __future__ import print_function
52+
@@ -173,6 +178,7 @@ OPTIONS = common.OPTIONS
53+
54+
OPTIONS.extra_apks = {}
55+
OPTIONS.extra_apex_payload_keys = {}
56+
+OPTIONS.prebuilt_images = []
57+
OPTIONS.skip_apks_with_path_prefix = set()
58+
OPTIONS.key_map = {}
59+
OPTIONS.rebuild_recovery = False
60+
@@ -1190,6 +1196,8 @@ def main(argv):
61+
names = names.split(",")
62+
for n in names:
63+
OPTIONS.extra_apks[n] = key
64+
+ elif o == "--prebuilt_image":
65+
+ OPTIONS.prebuilt_images.append(a)
66+
elif o == "--extra_apex_payload_key":
67+
apex_name, key = a.split("=")
68+
OPTIONS.extra_apex_payload_keys[apex_name] = key
69+
@@ -1339,6 +1347,7 @@ def main(argv):
70+
"gki_signing_key=",
71+
"gki_signing_algorithm=",
72+
"gki_signing_extra_args=",
73+
+ "prebuilt_image=",
74+
],
75+
extra_option_handler=option_handler)
76+
77+
@@ -1381,6 +1390,23 @@ def main(argv):
78+
platform_api_level, codename_to_api_level_map,
79+
compressed_extension)
80+
81+
+ if OPTIONS.prebuilt_images:
82+
+ # Ugly Nix-specific HACK: The source file may be read-only
83+
+ # ZipWrite really, really wants to chmod the file :(
84+
+ # Delete all lines containing HACK
85+
+ tempdir = tempfile.mkdtemp() # HACK
86+
+
87+
+ for prebuilt_image in OPTIONS.prebuilt_images:
88+
+ image_name = os.path.basename(prebuilt_image)
89+
+
90+
+ temp = os.path.join(tempdir, image_name) # HACK
91+
+ shutil.copy(prebuilt_image, temp) # HACK
92+
+ prebuilt_image = temp # HACK
93+
+
94+
+ common.ZipWrite(output_zip, prebuilt_image, os.path.join("IMAGES/", image_name))
95+
+
96+
+ shutil.rmtree(tempdir) # HACK
97+
+
98+
common.ZipClose(input_zip)
99+
common.ZipClose(output_zip)
100+
101+
@@ -1390,6 +1416,10 @@ def main(argv):
102+
# recovery patch is guaranteed to be regenerated there.
103+
if OPTIONS.rebuild_recovery:
104+
new_args.append("--rebuild_recovery")
105+
+
106+
+ if OPTIONS.prebuilt_images:
107+
+ new_args.append("--add_missing")
108+
+
109+
new_args.append(args[1])
110+
add_img_to_target_files.main(new_args)
111+
112+
--
113+
2.33.0
114+

0 commit comments

Comments
 (0)