LSPosed / MagiskOnWSALocal

Integrate Magisk root and Google Apps into WSA (Windows Subsystem for Android)
GNU Affero General Public License v3.0
9.49k stars 22.97k forks source link

[Feature Request] Reproducibly produce images. (product.img, system_ext.img, etc.) #347

Closed A2uria closed 1 year ago

A2uria commented 1 year ago

Is your feature request related to a problem?/你的请求是否与某个问题相关?

No.

Describe the solution you'd like/描述你想要的解决方案

Reproducibly produce patched raw ext2 images. (product.img, system_ext.img, etc.)

Additional context/其他信息

e2fsprogs provided environment variable E2FSPROGS_FAKE_TIME to produce reproducible ext2 images. Also, with environment variable E2FSCK_TIME, we can shrink the size of ext2 images while keep reproducibility.

Here is an example. I use debugfs to delete (inodes of) preinstalled amazon and shrink the fs. The hash of modified modified system_ext.img is always 6cfa7fb0805c69d6af2949eab4356ac9c06e8c36c0304e344a2ce420580ba85a. (original ebcc4c707ba97ea8855064231bbe045bcc6023a3f18aa9c024f6c334d0635ab2, from MicrosoftCorporationII.WindowsSubsystemForAndroid_2211.40000.11.0_neutral_~_8wekyb3d8bbwe.msixbundle)

Note that the major version should be greater than 2211, otherwise replace system_ext.img with product.img

export E2FSPROGS_FAKE_TIME=1230768000
debugfs -w -f system_ext.txt system_ext.img
export E2FSCK_TIME=1230768000
e2fsck -pf system_ext.img
resize2fs -M system_ext.img

Note that time_t 1230768000 is equivalent to timestamp 200901010000 (UTC).

Here's system_ext.txt.

rm /etc/permissions/privapp-permissions-venezia.xml
rm /framework/com.amazon.device.messaging.jar
rm /framework/oat/x86/com.amazon.device.messaging.odex
rm /framework/oat/x86/com.amazon.device.messaging.vdex
rm /framework/oat/x86_64/com.amazon.device.messaging.odex
rm /framework/oat/x86_64/com.amazon.device.messaging.vdex
rm /priv-app/amazon-adm-release/amazon-adm-release.apk
rm /priv-app/amazon-store-release/amazon-store-release.apk
rmdir /priv-app/amazon-adm-release
rmdir /priv-app/amazon-store-release

As far as I know, in MagiskOnWSALocal/scripts/build.sh#L739, you use find . -exec touch -hamt <timestamp> {} ';' to set every timestamp to 200901010000, but there are {a,c,m}time for each file, so just use -ht <timestamp> instead of -hamt <timestamp>.

Another important thing is that the timestamp is localized, so in China, timestamp 200901010000 would be shown as 200901010800, but when setting it to 200901010000, it would be shown as 200901010000, not 200901010800.

p.s. We may need e2fsprogs>=1.46.6-rc1 to do so. However, e2fsprogs=1.46.5 works fine for the example.

github-actions[bot] commented 1 year ago

@A2uria this issue was automatically closed because: