-
Notifications
You must be signed in to change notification settings - Fork 82
twrp: Initial basic support for TWRP builds #99
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
Draft
samueldr
wants to merge
6
commits into
nix-community:master
Choose a base branch
from
samueldr:feature/twrp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0294b7f
twrp: Init TWRP integration
samueldr 86d6c9f
twrp: Prepare for multiple branches
samueldr 2b993d3
twrp: Add support for the android-10 based branch
samueldr f5a4975
[DONTMERGE] surfna example configuration
samueldr d9f9781
[DONTMERGE] sofiar example configuration
samueldr 7a21c7f
source: Don't dereference links when linking
samueldr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# SPDX-FileCopyrightText: 2021 Samuel Dionne-Riel | ||
# SPDX-FileCopyrightText: 2021 Daniel Fullmer and robotnix contributors | ||
# SPDX-License-Identifier: MIT | ||
|
||
{ config, pkgs, lib, ... }: | ||
let | ||
inherit (lib) | ||
mkDefault | ||
mkIf | ||
mkMerge | ||
; | ||
androidVersionToTWRPBranch = { | ||
"9" = "twrp-9.0"; | ||
"10" = "twrp-10.0-deprecated"; | ||
}; | ||
TWRPBranch = androidVersionToTWRPBranch.${toString config.androidVersion}; | ||
repoDirs = lib.importJSON (./. + "/${TWRPBranch}/repo.json"); | ||
in mkIf (config.flavor == "twrp") | ||
(mkMerge [ | ||
{ | ||
# Defaults elsewhere makes it default to `12` if unset. | ||
androidVersion = mkDefault (builtins.throw "androidVersion needs to be set according to your device tree."); | ||
|
||
# product names start with "omni_" | ||
# → lunch omni_sailfish-eng | ||
productNamePrefix = "omni_"; | ||
|
||
buildDateTime = mkDefault 1616627550; | ||
|
||
# TWRP uses this by default. If your device supports it, I recommend using variant = "user" | ||
variant = mkDefault "eng"; | ||
|
||
source.dirs = mkMerge ([ | ||
repoDirs | ||
]); | ||
|
||
source.manifest.url = mkDefault "https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git"; | ||
source.manifest.rev = mkDefault "refs/heads/${TWRPBranch}"; | ||
envVars.RELEASE_TYPE = mkDefault "EXPERIMENTAL"; # Other options are RELEASE NIGHTLY SNAPSHOT EXPERIMENTAL | ||
|
||
build = { | ||
twrp = config.build.mkAndroid { | ||
name = "robotnix-${config.productName}-${config.buildNumber}"; | ||
makeTargets = [ "recoveryimage" ]; | ||
# Note that $ANDROID_PRODUCT_OUT is set by choosecombo above | ||
installPhase = '' | ||
mkdir -p $out | ||
cp --reflink=auto $ANDROID_PRODUCT_OUT/recovery.img $out/ | ||
''; | ||
}; | ||
Comment on lines
+42
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How should we handle the need to provide either Would adding an option be correct? |
||
}; | ||
} | ||
(mkIf (config.androidVersion == 9) { | ||
source.dirs = mkMerge ([ | ||
repoDirs | ||
{ | ||
"bootable/recovery" = { | ||
patches = [ | ||
./patches/android_bootable_recovery/0001-gui-Don-t-preserve-mode-owner-when-copying-files.patch | ||
]; | ||
}; | ||
"build/make" = { | ||
patches = [ | ||
./patches/android_build/0001-Work-around-source-files-being-read-only.patch | ||
]; | ||
}; | ||
} | ||
]); | ||
}) | ||
(mkIf (config.androidVersion == 10) { | ||
# It seems to want a lot of packages normally present in androidVersion == 9... | ||
envPackages = with pkgs; [ | ||
openssl.dev | ||
bison | ||
flex | ||
perl | ||
which | ||
]; | ||
|
||
# Ugh, something really wants `ccache` in these repos. | ||
# :/ | ||
ccache.enable = lib.mkForce true; | ||
envVars = { | ||
CCACHE_DIR = lib.mkForce "/tmp"; # Make configurable? | ||
}; | ||
}) | ||
]) |
29 changes: 29 additions & 0 deletions
29
...hes/android_bootable_recovery/0001-gui-Don-t-preserve-mode-owner-when-copying-files.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
From 36960782d92c384db2d74795d458a3cfb5f6013d Mon Sep 17 00:00:00 2001 | ||
From: Samuel Dionne-Riel <[email protected]> | ||
Date: Sat, 24 Apr 2021 18:46:05 -0400 | ||
Subject: [PATCH] gui: Don't preserve mode,owner when copying files | ||
|
||
When building under some strict build environments, like robotnix, it | ||
fails since the source files are in directories without +w. | ||
--- | ||
gui/Android.mk | 4 ++-- | ||
1 file changed, 2 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/gui/Android.mk b/gui/Android.mk | ||
index 32c0d5b1..4ccdf386 100755 | ||
--- a/gui/Android.mk | ||
+++ b/gui/Android.mk | ||
@@ -216,8 +216,8 @@ TWRP_RES += $(TW_ADDITIONAL_RES) | ||
TWRP_RES_GEN := $(intermediates)/twrp | ||
$(TWRP_RES_GEN): | ||
mkdir -p $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH) | ||
- cp -fr $(TWRP_RES) $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH) | ||
- cp -fr $(TWRP_THEME_LOC)/* $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH) | ||
+ cp --no-preserve=owner,mode -fr $(TWRP_RES) $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH) | ||
+ cp --no-preserve=owner,mode -fr $(TWRP_THEME_LOC)/* $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH) | ||
|
||
LOCAL_GENERATED_SOURCES := $(TWRP_RES_GEN) | ||
LOCAL_SRC_FILES := twrp $(TWRP_RES_GEN) | ||
-- | ||
2.29.2 | ||
|
103 changes: 103 additions & 0 deletions
103
flavors/twrp/patches/android_build/0001-Work-around-source-files-being-read-only.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
From 12382e7d66d993d89e52e840e7965009de2f81e5 Mon Sep 17 00:00:00 2001 | ||
From: Samuel Dionne-Riel <[email protected]> | ||
Date: Sat, 24 Apr 2021 21:05:00 -0400 | ||
Subject: [PATCH] Work around source files being read-only | ||
|
||
--- | ||
core/Makefile | 33 +++++++++++++++++---------------- | ||
1 file changed, 17 insertions(+), 16 deletions(-) | ||
|
||
diff --git a/core/Makefile b/core/Makefile | ||
index 2f7219daa..43017a35b 100644 | ||
--- a/core/Makefile | ||
+++ b/core/Makefile | ||
@@ -84,7 +84,7 @@ gen := $(OUT_DOCS)/index.html | ||
ALL_DOCS += $(gen) | ||
$(gen): frameworks/base/docs/docs-redirect-index.html | ||
@mkdir -p $(dir $@) | ||
- @cp -f $< $@ | ||
+ @cp --no-preserve=owner,mode -f $< $@ | ||
endif | ||
|
||
ndk_doxygen_out := $(OUT_NDK_DOCS) | ||
@@ -1052,7 +1052,7 @@ $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem: $(addsuffix .x509.pe | ||
|
||
ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem | ||
$(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem: $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem | ||
- $(hide) cp -f $< $@ | ||
+ $(hide) cp --no-preserve=owner,mode -f $< $@ | ||
endif | ||
endif | ||
|
||
@@ -1413,27 +1413,28 @@ define build-recoveryramdisk | ||
# Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac. | ||
$(hide) rsync -a --exclude=etc --exclude=sdcard --exclude=vendor $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) | ||
# Copy adbd from system/bin to recovery/root/sbin | ||
- $(hide) cp -f $(TARGET_OUT_EXECUTABLES)/adbd $(TARGET_RECOVERY_ROOT_OUT)/sbin/adbd | ||
+ $(hide) cp --no-preserve=owner,mode -f $(TARGET_OUT_EXECUTABLES)/adbd $(TARGET_RECOVERY_ROOT_OUT)/sbin/adbd | ||
# Modifying ramdisk contents... | ||
$(if $(BOARD_RECOVERY_KERNEL_MODULES), \ | ||
$(call build-image-kernel-modules,$(BOARD_RECOVERY_KERNEL_MODULES),$(TARGET_RECOVERY_ROOT_OUT),,$(call intermediates-dir-for,PACKAGING,depmod_recovery))) | ||
# Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc. | ||
$(hide) find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f | ||
- $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/ | ||
- $(hide) cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ || true # Ignore error when the src file doesn't exist. | ||
+ $(hide) cp --no-preserve=owner,mode -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/ | ||
+ chmod -R +w $(TARGET_RECOVERY_ROOT_OUT) | ||
+ $(hide) cp --no-preserve=owner,mode $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ || true # Ignore error when the src file doesn't exist. | ||
$(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res | ||
$(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/* | ||
- $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res | ||
- $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png | ||
+ $(hide) cp --no-preserve=owner,mode -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res | ||
+ $(hide) cp --no-preserve=owner,mode -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png | ||
$(hide) $(foreach item,$(recovery_root_private), \ | ||
- cp -rf $(item) $(TARGET_RECOVERY_OUT)/;) | ||
+ cp --no-preserve=owner,mode -rf $(item) $(TARGET_RECOVERY_OUT)/;) | ||
$(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \ | ||
- cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline)) | ||
+ cp --no-preserve=owner,mode -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline)) | ||
$(hide) $(foreach item,$(recovery_fstab), \ | ||
- cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab) | ||
+ cp --no-preserve=owner,mode -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab) | ||
$(if $(strip $(recovery_wipe)), \ | ||
- $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.wipe) | ||
- $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys | ||
+ $(hide) cp --no-preserve=mode -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.wipe) | ||
+ $(hide) cp --no-preserve=owner,mode $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys | ||
$(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) \ | ||
> $(TARGET_RECOVERY_ROOT_OUT)/prop.default | ||
$(if $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET), \ | ||
@@ -1514,7 +1515,7 @@ $(recovery_uncompressed_ramdisk): $(MKBOOTFS) $(ADBD) \ | ||
$(BOARD_RECOVERY_KERNEL_MODULES) \ | ||
$(DEPMOD) | ||
$(call build-recoveryramdisk) | ||
- @echo ----- Making uncompressed recovery ramdisk ------ | ||
+ @echo ----- Making uncompressed recovery ramdisk YAY ------ | ||
$(hide) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) > $@ | ||
|
||
$(recovery_ramdisk): $(MINIGZIP) \ | ||
@@ -1857,7 +1858,7 @@ endif | ||
define build-boottarball-target | ||
$(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)" | ||
$(hide) mkdir -p $(PRODUCT_OUT)/boot | ||
- $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/. | ||
+ $(hide) cp --no-preserve=owner,mode -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/. | ||
$(hide) echo $(INTERNAL_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline | ||
$(hide) $(MKTARBALL) $(FS_GET_STATS) \ | ||
$(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \ | ||
@@ -3398,9 +3399,9 @@ $(INTERNAL_SDK_TARGET): $(deps) | ||
-v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \ | ||
-v "FONT_OUT=$(SDK_FONT_TEMP)" \ | ||
-o $(PRIVATE_DIR) && \ | ||
- cp -f $(target_notice_file_txt) \ | ||
+ cp --no-preserve=owner,mode -f $(target_notice_file_txt) \ | ||
$(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \ | ||
- cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \ | ||
+ cp --no-preserve=owner,mode -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \ | ||
HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \ | ||
development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \ | ||
chmod -R ug+rwX $(PRIVATE_DIR) && \ | ||
-- | ||
2.29.2 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.