Last active
April 11, 2022 14:49
-
-
Save xingrz/9525c0e2bc224bbb4d46448dca08e083 to your computer and use it in GitHub Desktop.
Extract a system-as-root update.zip
This file contains 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
SOURCE := $(TARGET).zip | |
MOUNT := $(TARGET)/.mount | |
BOOT := $(TARGET)/boot | |
ROOT := $(TARGET)/system | |
VENDOR := $(ROOT)/vendor | |
PAYLOAD_BIN := $(TARGET)/payload.bin | |
BOOT_IMG := $(TARGET)/boot.img | |
SYSTEM_IMG := $(TARGET)/system.img | |
VENDOR_IMG := $(TARGET)/vendor.img | |
UNPACK := ~/android/packing/unpack.sh | |
EXTRACT := python ~/android/extract_android_ota_payload/extract_android_ota_payload.py | |
ifeq (,$(shell which unpackbootimg)) | |
$(error `unpackbootimg` not found.) | |
endif | |
define extract-ext4-image | |
mkdir -p $(MOUNT) | |
ext4fuse $(1) $(MOUNT) | |
cp -Rvf $(MOUNT) $(2) | |
umount $(MOUNT) | |
chown -R XiNGRZ:staff $(2) | |
chmod -R +r $(2) | |
chmod +w $(2) | |
endef | |
.PHONY: unpack | |
unpack: $(BOOT) $(ROOT) $(VENDOR) | |
$(BOOT): $(BOOT_IMG) | |
pushd $(dir $@) && $(UNPACK) $(notdir $^) && popd | |
$(ROOT): $(SYSTEM_IMG) | |
$(call extract-ext4-image,$(SYSTEM_IMG),$@) | |
rm -f $(SYSTEM_IMG) | |
rm -rf $(VENDOR) | |
$(VENDOR): $(VENDOR_IMG) $(ROOT) | |
$(call extract-ext4-image,$(VENDOR_IMG),$@) | |
rm -f $(VENDOR_IMG) | |
$(SYSTEM_IMG): $(BOOT_IMG) | |
$(VENDOR_IMG): $(BOOT_IMG) | |
$(BOOT_IMG): $(PAYLOAD_BIN) | |
$(EXTRACT) $(PAYLOAD_BIN) $(dir $@) | |
$(PAYLOAD_BIN): $(TARGET) | |
$(TARGET): $(SOURCE) | |
mkdir -p $@ | |
unzip $(SOURCE) -d $@ | |
.PHONY: clean | |
clean: | |
rm -rf $(TARGET) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment