Skip to content

Modify Waydroid

Modify Waydroid #3

Workflow file for this run

name: Modify Waydroid
on:
push:
paths-ignore:
- 'README.md'
pull_request:
paths-ignore:
- 'README.md'
workflow_dispatch:
inputs:
arch:
description: "Build arch"
required: true
default: "x64"
type: choice
options:
- x64
and_ver:
description: "Android Version"
required: true
default: "11"
type: choice
options:
- 11
magisk_apk:
description: "Magisk version"
required: true
default: "26.1"
type: choice
options:
- 24.1
- 24.2
- 24.3
- 25.2
- 26.1
- canary
- delta
gapps_variant:
description: "Variants of gapps"
required: true
default: "pico"
type: choice
options:
- none
- super
- stock
- full
- mini
- micro
- nano
- pico
- tvstock
- tvmini
root_sol:
description: "Root solution"
required: true
default: "magisk"
type: choice
options:
- magisk
- none
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Generate build matrix
id: set-matrix
uses: actions/github-script@v6
with:
script: |
let matrix = {};
let arch = "${{ github.event.inputs.arch }}"
switch ( arch ) {
case "x64":
matrix.arch = ["x64"];
break;
case "arm64":
matrix.arch = ["arm64"];
break;
default:
matrix.arch = ["x64"];
break;
}
let release_type = "${{ github.event.inputs.release_type }}"
switch ( release_type ) {
default:
matrix.release_type = ["WIS"];
break;
}
let magisk_apk = "${{ github.event.inputs.magisk_apk }}"
switch ( magisk_apk ) {
case "25.2":
matrix.magisk_apk = ["25.2"];
break;
case "canary":
matrix.magisk_apk = ["canary"];
break;
case "delta":
matrix.magisk_apk = ["delta"];
break;
default:
matrix.magisk_apk = ["25.2"];
break;
}
let gapps_variant = "${{ github.event.inputs.gapps_variant }}"
switch ( gapps_variant ) {
default:
matrix.gapps_variant = ["pico"];
break;
}
let root_sol = "${{ github.event.inputs.root_sol }}"
switch ( root_sol ) {
default:
matrix.root_sol = ["magisk"];
break;
}
core.setOutput("matrix",JSON.stringify(matrix));
build:
runs-on: ubuntu-20.04
needs: matrix
strategy:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- name: Dependencies
run: |
pip3 install beautifulsoup4 lxml
sudo apt-get update && sudo apt-get install setools lzip qemu-utils wine winetricks patchelf attr
wget -qO- "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/archive/$GITHUB_REF.tar.gz" | sudo tar --wildcards -zxvf- -C ~ --strip-component=2 '*/wine/*' '*/linker/*'
winetricks msxml6
- name: Download WSA
shell: python
run: |
import requests
from bs4 import BeautifulSoup
import re
import zipfile
import os
import urllib.request
arch = "${{ matrix.arch }}"
#release_type_map = {"retail": "Retail", "release preview": "RP", "insider slow": "WIS", "insider fast": "WIF"}
#release_type_map = "WIS"
#release_type = release_type_map["${{ matrix.release_type }}"] if "${{ matrix.release_type }}" != "" else "Retail"
release_type = "WIS"
res = requests.post("https://store.rg-adguard.net/api/GetFiles", f"type=CategoryId&url=858014f3-3934-4abe-8078-4aa193e74ca8&ring={release_type}&lang=en-US", headers={
"content-type": "application/x-www-form-urlencoded"
}, verify=False) # source site has expired cert
html = BeautifulSoup(res.content, "lxml")
a = html.find("a", string=re.compile(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx"))
link = a["href"]
print(f"downloading link: {link}", flush=True)
out_file = "xaml.appx"
if not os.path.isfile(out_file):
urllib.request.urlretrieve(link, out_file)
a = html.find("a", string=re.compile(f"Microsoft\.VCLibs\..*_{arch}_.*\.appx"))
link = a["href"]
print(f"downloading link: {link}", flush=True)
out_file = "vclibs.appx"
if not os.path.isfile(out_file):
urllib.request.urlretrieve(link, out_file)
a = html.find("a", string=re.compile("MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle"))
link = a["href"]
print(f"downloading link: {link}", flush=True)
out_file = "wsa.zip"
if not os.path.isfile(out_file):
urllib.request.urlretrieve(link, out_file)
zip_name = ""
with zipfile.ZipFile(out_file) as zip:
for f in zip.filelist:
if arch in f.filename.lower():
zip_name = f.filename
if not os.path.isfile(zip_name):
print(f"unzipping to {zip_name}", flush=True)
zip.extract(f)
ver_no = zip_name.split("_")
ver = ver_no[1]
with open(os.environ['GITHUB_ENV'], 'a') as g:
g.write(f'WSA_VER={ver}\n')
rel = ver_no[3].split(".")
rell = str(rel[0])
with open(os.environ['GITHUB_ENV'], 'a') as g:
g.write(f'WSA_REL={rell}\n')
if 'language' in f.filename.lower() or 'scale' in f.filename.lower():
name = f.filename.split("-", 1)[1].split(".")[0]
zip.extract(f)
with zipfile.ZipFile(f.filename) as l:
for g in l.filelist:
if g.filename == 'resources.pri':
g.filename = f'{name}.pri'
l.extract(g, 'pri')
print(f"extract resource pack {g.filename}")
elif g.filename == 'AppxManifest.xml':
g.filename = f'{name}.xml'
l.extract(g, 'xml')
with zipfile.ZipFile(zip_name) as zip:
if not os.path.isdir(arch):
print(f"unzipping from {zip_name}", flush=True)
zip.extractall(arch)
print("done", flush=True)
- name: Download Magisk
shell: python
run: |
import urllib.request
import zipfile
import os
import json
import requests
magisk_apk = """${{ github.event.inputs.magisk_apk }}"""
if not magisk_apk:
magisk_apk = "26.1"
if magisk_apk == "24.1":
magisk_apk = "https://github.com/topjohnwu/Magisk/releases/download/v24.1/Magisk-v24.1.apk"
if magisk_apk == "24.2":
magisk_apk = "https://github.com/topjohnwu/Magisk/releases/download/v24.2/Magisk-v24.2.apk"
if magisk_apk == "24.3":
magisk_apk = "https://github.com/topjohnwu/Magisk/releases/download/v24.3/Magisk-v24.3.apk"
if magisk_apk == "25.2":
magisk_apk = "https://github.com/topjohnwu/Magisk/releases/download/v25.2/Magisk-v25.2.apk"
if magisk_apk == "26.1":
magisk_apk = "https://github.com/topjohnwu/Magisk/releases/download/v26.1/Magisk-v26.1.apk"
if magisk_apk == "canary":
magisk_apk = "https://raw.githubusercontent.com/topjohnwu/magisk-files/canary/app-debug.apk"
if magisk_apk == "delta":
magisk_apk = "https://huskydg.github.io/magisk-files/app-release.apk"
if magisk_apk == "stable" or magisk_apk == "beta":
magisk_apk = json.loads(requests.get(f"https://github.com/topjohnwu/magisk-files/raw/master/{magisk_apk}.json").content)['magisk']['link']
out_file = "magisk.zip"
arch = "${{ matrix.arch }}"
abi_map={"x64" : ["x86_64", "x86"], "arm64" : ["arm64-v8a", "armeabi-v7a"]}
if not os.path.isfile(out_file):
urllib.request.urlretrieve(magisk_apk, out_file)
def extract_as(zip, name, as_name, dir):
info = zip.getinfo(name)
info.filename = as_name
zip.extract(info, dir)
# changes to standalone_policy since v24.3
# extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagiskinit.so", "magiskpolicy", "magisk")
# extract_as(zip, f"lib/{ abi_map['x64'][0] }/libmagiskinit.so", "magiskpolicy", ".")
with zipfile.ZipFile(out_file) as zip:
extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagisk64.so", "magisk64", "magisk")
extract_as(zip, f"lib/{ abi_map[arch][1] }/libmagisk32.so", "magisk32", "magisk")
standalone_policy = False
try:
zip.getinfo(f"lib/{ abi_map[arch][0] }/libmagiskpolicy.so")
standalone_policy = True
except:
pass
extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagiskinit.so", "magiskinit", "magisk")
if standalone_policy:
extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagiskpolicy.so", "magiskpolicy", "magisk")
else:
extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagiskinit.so", "magiskpolicy", "magisk")
extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagiskboot.so", "magiskboot", "magisk")
extract_as(zip, f"lib/{ abi_map[arch][0] }/libbusybox.so", "busybox", "magisk")
if standalone_policy:
extract_as(zip, f"lib/{ abi_map['x64'][0] }/libmagiskpolicy.so", "magiskpolicy", ".")
else:
extract_as(zip, f"lib/{ abi_map['x64'][0] }/libmagiskinit.so", "magiskpolicy", ".")
extract_as(zip, f"assets/boot_patch.sh", "boot_patch.sh", "magisk")
extract_as(zip, f"assets/util_functions.sh", "util_functions.sh", "magisk")
- name: Download OpenGApps
if: ${{ matrix.gapps_variant != 'none' && matrix.gapps_variant != '' }}
shell: python
run: |
import requests
import zipfile
import os
import urllib.request
import json
import re
arch = "${{ matrix.arch }}"
variant = "${{ matrix.gapps_variant }}"
abi_map = {"x64" : "x86_64", "arm64": "arm64"}
try:
res = requests.get(f"https://api.opengapps.org/list")
j = json.loads(res.content)
link = {i["name"]: i for i in j["archs"][abi_map[arch]]["apis"]["11.0"]["variants"]}[variant]["zip"]
except Exception:
print("Failed to fetch from opengapps api, fallbacking to sourceforge rss...")
res = requests.get(f'https://sourceforge.net/projects/opengapps/rss?path=/{abi_map[arch]}&limit=100')
link = re.search(f'https://.*{abi_map[arch]}/.*{variant}.*\.zip/download', res.text).group().replace('.zip/download', '.zip').replace('sourceforge.net/projects/opengapps/files', 'downloads.sourceforge.net/project/opengapps')
print(f"downloading link: {link}", flush=True)
out_file = "gapps.zip"
if not os.path.isfile(out_file):
urllib.request.urlretrieve(link, out_file)
print("done", flush=True)
- name: Replace system and vendor
run: |
rm -rf ${{ matrix.arch }}/{system,vendor}.img
#wget -q https://sourceforge.net/projects/blissos-dev/files/waydroid/lineage/lineage-18.1/Lineage-OS-18.1-waydroid_x86_64-202111291420-foss-sd-hd-ex_ax86-vaapi_gles-aep.zip/download -O los.zip
wget -q https://sourceforge.net/projects/waydroid/files/images/system/lineage/waydroid_x86_64/lineage-18.1-20230422-GAPPS-waydroid_x86_64-system.zip/download -O system.zip
wget -q https://sourceforge.net/projects/waydroid/files/images/vendor/waydroid_x86_64/lineage-18.1-20230422-MAINLINE-waydroid_x86_64-vendor.zip/download -O vendor.zip
7z x system.zip -o${{ matrix.arch }}/
7z x vendor.zip -o${{ matrix.arch }}/
- name: Extract GApps and expand images
if: ${{ matrix.gapps_variant != 'none' && matrix.gapps_variant != '' }}
run: |
mkdir gapps
unzip -p gapps.zip {Core,GApps}/'*.lz' | tar --lzip -C gapps -xvf - -i --strip-components=2 --exclude='setupwizardtablet-x86_64' --exclude='packageinstallergoogle-all' --exclude='speech-common' --exclude='markup-lib-arm' --exclude='markup-lib-arm64' --exclude='markup-all' --exclude='setupwizarddefault-x86_64' --exclude='pixellauncher-all' --exclude='pixellauncher-common'
e2fsck -yf ${{ matrix.arch }}/system.img
resize2fs ${{ matrix.arch }}/system.img $(( $(du -sB512 gapps | cut -f1) + $(du -sB512 ${{ matrix.arch }}/system.img | cut -f1) ))s
- name: Expand vendor
run: |
e2fsck -yf ${{ matrix.arch }}/vendor.img
resize2fs ${{ matrix.arch }}/vendor.img 512M
- name: Mount images
run: |
sudo mkdir system
sudo mkdir userdata
sudo mount -o loop ${{ matrix.arch }}/system.img system
sudo mount -o loop ${{ matrix.arch }}/vendor.img system/vendor
sudo mv system/product system/product_ln
sudo mkdir system/product
sudo mount --bind $(pwd)/system/system/product $(pwd)/system/product
ls system/product
sudo mv system/system_ext system/system_ext_ln
sudo mkdir system/system_ext
sudo mount --bind $(pwd)/system/system/system_ext $(pwd)/system/system_ext
ls system/system_ext
qemu-img convert -O raw ${{ matrix.arch }}/userdata.vhdx userdata.img
sudo mount -o loop userdata.img userdata
- name: Integrate Magisk
if: ${{ github.event.inputs.root_sol == 'magisk' || github.event.inputs.root_sol == '' }}
run: |
mkdir linker
mkdir linker/x86_64
wget -q https://raw.githubusercontent.com/pagkly/MagiskOnWaydroid/main/linker/x86_64/libc.so -O linker/x86_64/libc.so
wget -q https://raw.githubusercontent.com/pagkly/MagiskOnWaydroid/main/linker/x86_64/libdl.so -O linker/x86_64/libdl.so
wget -q https://raw.githubusercontent.com/pagkly/MagiskOnWaydroid/main/linker/x86_64/libm.so -O linker/x86_64/libm.so
wget -q https://raw.githubusercontent.com/pagkly/MagiskOnWaydroid/main/linker/x86_64/linker64 -O linker/x86_64/linker64
sudo chmod +x "linker/x86_64/linker64" || abort
sudo patchelf --set-interpreter "linker/x86_64/linker64" "magisk/magiskpolicy" || abort
chmod +x "magisk/magiskpolicy" || abort
sudo cp "magisk/magisk"* "system/debug_ramdisk/"
sudo cp magisk.zip "system/debug_ramdisk/stub.apk" || abort
sudo tee -a "system/debug_ramdisk/loadpolicy.sh" <<EOF >/dev/null || abort
#!/system/bin/sh
MAGISKTMP=/debug_ramdisk
export MAGISKTMP
mkdir -p /data/adb/magisk
cp \$MAGISKTMP/* /data/adb/magisk/
sync
chmod -R 755 /data/adb/magisk
restorecon -R /data/adb/magisk
MAKEDEV=1 \$MAGISKTMP/magisk --preinit-device 2>&1
RULESCMD=""
for r in \$MAGISKTMP/.magisk/preinit/*/sepolicy.rule; do
[ -f "\$r" ] || continue
RULESCMD="\$RULESCMD --apply \$r"
done
\$MAGISKTMP/magiskpolicy --live \$RULESCMD 2>&1
EOF
sudo find "system/debug_ramdisk" -type f -exec chmod 0711 {} \;
sudo find "system/debug_ramdisk" -type f -exec chown root:root {} \;
sudo find "system/debug_ramdisk" -type f -exec setfattr -n security.selinux -v "u:object_r:magisk_file:s0" {} \; || abort
echo "/debug_ramdisk(/.*)? u:object_r:magisk_file:s0" | sudo tee -a "system/vendor/etc/selinux/vendor_file_contexts"
echo '/data/adb/magisk(/.*)? u:object_r:magisk_file:s0' | sudo tee -a "system/vendor/etc/selinux/vendor_file_contexts"
#ls -R .
sudo LD_LIBRARY_PATH="linker/x86_64" "magisk/magiskpolicy" --load "system/vendor/etc/selinux/precompiled_sepolicy" --save "system/vendor/etc/selinux/precompiled_sepolicy" --magisk || abort
sudo tee -a "system/system/etc/init/hw/init.rc" <<EOF >/dev/null
on post-fs-data
mkdir /dev/debug_ramdisk_mirror
mount none /debug_ramdisk /dev/debug_ramdisk_mirror bind
mount none none /dev/debug_ramdisk_mirror private
mount tmpfs magisk /debug_ramdisk mode=0755
copy /dev/debug_ramdisk_mirror/magisk64 /debug_ramdisk/magisk64
chmod 0755 /debug_ramdisk/magisk64
symlink ./magisk64 /debug_ramdisk/magisk
symlink ./magisk64 /debug_ramdisk/su
symlink ./magisk64 /debug_ramdisk/resetprop
start adbd
copy /dev/debug_ramdisk_mirror/magisk32 /debug_ramdisk/magisk32
chmod 0755 /debug_ramdisk/magisk32
copy /dev/debug_ramdisk_mirror/magiskinit /debug_ramdisk/magiskinit
chmod 0750 /debug_ramdisk/magiskinit
copy /dev/debug_ramdisk_mirror/magiskpolicy /debug_ramdisk/magiskpolicy
chmod 0755 /debug_ramdisk/magiskpolicy
mkdir /debug_ramdisk/.magisk
mkdir /debug_ramdisk/.magisk/mirror 0
mkdir /debug_ramdisk/.magisk/block 0
mkdir /debug_ramdisk/.magisk/worker 0
copy /dev/debug_ramdisk_mirror/stub.apk /debug_ramdisk/stub.apk
chmod 0644 /debug_ramdisk/stub.apk
copy /dev/debug_ramdisk_mirror/loadpolicy.sh /debug_ramdisk/loadpolicy.sh
chmod 0755 /debug_ramdisk/loadpolicy.sh
umount /dev/debug_ramdisk_mirror
rmdir /dev/debug_ramdisk_mirror
exec u:r:magisk:s0 0 0 -- /system/bin/sh /debug_ramdisk/loadpolicy.sh
exec u:r:magisk:s0 0 0 -- /debug_ramdisk/magisk --post-fs-data
on property:vold.decrypt=trigger_restart_framework
exec u:r:magisk:s0 0 0 -- /debug_ramdisk/magisk --service
on nonencrypted
exec u:r:magisk:s0 0 0 -- /debug_ramdisk/magisk --service
on property:sys.boot_completed=1
exec u:r:magisk:s0 0 0 -- /debug_ramdisk/magisk --boot-complete
on property:init.svc.zygote=stopped
exec u:r:magisk:s0 0 0 -- /debug_ramdisk/magisk --zygote-restart
EOF
for i in "system/system/etc/init/hw"/*; do
if [[ "$i" =~ init.zygote.+\.rc ]]; then
echo "Inject zygote restart $i"
sudo awk -i inplace '{if($0 ~ /service zygote /){print $0;print " exec u:r:magisk:s0 0 0 -- /debug_ramdisk/magisk --zygote-restart";a="";next}} 1' "$i"
sudo setfattr -n security.selinux -v "u:object_r:system_file:s0" "$i" || abort
fi
done
echo -e "Integrate Magisk done\n"
- name: Remove FOSS Apps
run: |
sudo rm -rf system/system/app/com.google.android.gsf
sudo rm -rf system/system/app/com.aurora.adroid
sudo rm -rf system/system/app/com.aurora.store
sudo rm -rf system/system/app/com.etesync.syncadapter
sudo rm -rf system/system/app/is.xyz.mpv
sudo rm -rf system/system/app/me.jfenn.alarmio
sudo rm -rf system/system/app/org.microg.gms.droidguard
sudo rm -rf system/system/app/org.microg.nlp.backend.ichnaea
sudo rm -rf system/system/app/org.microg.nlp.backend.nominatim
sudo rm -rf system/system/app/org.schabi.newpipe
sudo rm -rf system/system/app/ws.xsoh.etar
sudo rm -rf system/system/priv-app/AuroraServices_v1.1.1
sudo rm -rf system/system/priv-app/com.google.android.gms
sudo rm -rf system/system/priv-app/com.android.vending
sudo rm -rf system/system/product/app/Etar
sudo rm -rf system/system/product/priv-app/Contacts
sudo rm -rf system/system/product/app/ExactCalculator
sudo rm -rf system/system/product/priv-app/Eleven
sudo rm -rf system/system/app/com.simplemobiletools.gallery.pro
sudo rm -rf system/system/app/NotePad
sudo rm -rf system/system/app/org.bromite.bromite
sudo rm -rf system/system/app/com.google.android.webview
sudo rm -rf system/system/app/com.android.webview
#sudo mv system/system/xbin/su system/system/xbin/suold
sudo ls system/system/xbin
wget -qO- "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/archive/$GITHUB_REF.tar.gz" | sudo tar --wildcards -zxvf- --strip-component=2 '*/${{ matrix.arch }}/system/*'
sudo find system/system/priv-app -type d -exec chmod 0755 {} \;
sudo find system/system/priv-app -type f -exec chmod 0644 {} \;
sudo find system/system/priv-app -exec chcon --reference=system/system/priv-app {} \;
- name: Fix GApps prop
if: ${{ matrix.gapps_variant != 'none' && matrix.gapps_variant != '' }}
shell: sudo python {0}
run: |
from __future__ import annotations
from io import TextIOWrapper
from os import system
from typing import OrderedDict
class Prop(OrderedDict):
def __init__(self, file: TextIOWrapper) -> None:
super().__init__()
for i, line in enumerate(file.read().splitlines(False)):
if '=' in line:
k, v = line.split('=', 2)
self[k] = v
else:
self[f".{i}"] = line
def __str__(self) -> str:
return '\n'.join([v if k.startswith('.') else f"{k}={v}" for k, v in self.items()])
def __iadd__(self, other: str) -> Prop:
self[f".{len(self)}"] = other
return self
new_props = {
("product", "brand"): "google",
("product", "manufacturer"): "Google",
("build", "product"): "redfin",
("product", "name"): "redfin",
("product", "device"): "redfin",
("product", "model"): "Pixel 5",
("build", "flavor"): "redfin-user"
}
def description(sec: str, p: Prop) -> str:
return f"{p[f'ro.{sec}.build.flavor']} {p[f'ro.{sec}.build.version.release_or_codename']} {p[f'ro.{sec}.build.id']} {p[f'ro.{sec}.build.version.incremental']} {p[f'ro.{sec}.build.tags']}"
def fingerprint(sec: str, p: Prop) -> str:
return f"""{p[f"ro.product.{sec}.brand"]}/{p[f"ro.product.{sec}.name"]}/{p[f"ro.product.{sec}.device"]}:{p[f"ro.{sec}.build.version.release"]}/{p[f"ro.{sec}.build.id"]}/{p[f"ro.{sec}.build.version.incremental"]}:{p[f"ro.{sec}.build.type"]}/{p[f"ro.{sec}.build.tags"]}"""
def fix_prop(sec, prop):
print(f"fixing {prop}", flush=True)
with open(prop, 'r') as f:
p = Prop(f)
p += "# extra prop added by MagiskOnWSA"
for k, v in new_props.items():
p[f"ro.{k[0]}.{k[1]}"] = v
if k[0] == "build":
p[f"ro.{sec}.{k[0]}.{k[1]}"] = v
elif k[0] == "product":
p[f"ro.{k[0]}.{sec}.{k[1]}"] = v
p["ro.build.description"] = description(sec, p)
p[f"ro.build.fingerprint"] = fingerprint(sec, p)
p[f"ro.{sec}.build.description"] = description(sec, p)
p[f"ro.{sec}.build.fingerprint"] = fingerprint(sec, p)
p[f"ro.bootimage.build.fingerprint"] = fingerprint(sec, p)
with open(prop, 'w') as f:
f.write(str(p))
for sec, prop in {"system": "system/system/build.prop", "product": "system/product/build.prop", "system_ext": "system/system_ext/build.prop", "vendor": "system/vendor/build.prop", "odm": "system/vendor/odm/etc/build.prop"}.items():
fix_prop(sec, prop)
- name: Umount images
run: |
sudo umount system/vendor
sudo umount -l system/product
sudo rm -rf system/product
sudo mv system/product_ln system/product
sudo umount -l system/system_ext
sudo rm -rf system/system_ext
sudo mv system/system_ext_ln system/system_ext
sudo umount system
sudo umount userdata
qemu-img convert -o subformat=dynamic -f raw -O vhdx userdata.img ${{ matrix.arch }}/userdata.vhdx
- name: Shrink images
run: |
e2fsck -yf ${{ matrix.arch }}/system.img
resize2fs -M ${{ matrix.arch }}/system.img
e2fsck -yf ${{ matrix.arch }}/vendor.img
resize2fs -M ${{ matrix.arch }}/vendor.img
- name: Remove signature and add scripts
run: |
rm -rf ${{ matrix.arch }}/product.img
rm -rf ${{ matrix.arch }}/system_ext.img
rm -rf ${{ matrix.arch }}/userdata.img
rm -rf WsaPackage_*_ARM64_Release-Nightly.msix
rm -rf WsaPackage_*_language*.msix
rm -rf ${{ matrix.arch }}/\[Content_Types\].xml ${{ matrix.arch }}/AppxBlockMap.xml ${{ matrix.arch }}/AppxSignature.p7x ${{ matrix.arch }}/AppxMetadata
cp vclibs.appx xaml.appx ${{ matrix.arch }}
tee ${{ matrix.arch }}/Install.ps1 <<EOF
# Automated Install script by Mioki
# http://github.com/okibcn
function Test-Administrator {
[OutputType([bool])]
param()
process {
[Security.Principal.WindowsPrincipal]\$user = [Security.Principal.WindowsIdentity]::GetCurrent();
return \$user.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator);
}
}
function Finish {
Clear-Host
Start-Process "wsa://com.topjohnwu.magisk"
Start-Process "wsa://com.android.vending"
}
if (-not (Test-Administrator)) {
\$proc = Start-Process -PassThru -WindowStyle Hidden -Verb RunAs powershell.exe -Args "-executionpolicy bypass -command Set-Location '\$PSScriptRoot'; &'\$PSCommandPath' EVAL"
\$proc.WaitForExit()
if (\$proc.ExitCode -ne 0) {
Clear-Host
Write-Warning "Failed to launch start as Administrator\`r\`nPress any key to exit"
\$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
}
exit
}
elseif ((\$args.Count -eq 1) -and (\$args[0] -eq "EVAL")) {
Start-Process powershell.exe -Args "-executionpolicy bypass -command Set-Location '\$PSScriptRoot'; &'\$PSCommandPath'"
exit
}
if (((Test-Path -Path $(ls -Q ./${{ matrix.arch }} | paste -sd "," -)) -eq \$false).Count) {
Write-Error "Some files are missing in the zip. Please try to download it again from the browser downloader, or try to run the workflow again. Press any key to exist"
\$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit 1
}
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
\$VMP = Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform'
if (\$VMP.State -ne "Enabled") {
Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'VirtualMachinePlatform'
Clear-Host
Write-Warning "Need restart to enable virtual machine platform\`r\`nPress y to restart or press any key to exit"
\$key = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
If ("y" -eq \$key.Character) {
Restart-Computer -Confirm
}
Else {
exit 1
}
}
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path vclibs.appx
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path xaml.appx
\$Installed = \$null
\$Installed = Get-AppxPackage -Name 'MicrosoftCorporationII.WindowsSubsystemForAndroid'
If ((\$null -ne \$Installed) -and (-not (\$Installed.IsDevelopmentMode))) {
Clear-Host
Write-Warning "There is already one installed WSA. Please uninstall it first.\`r\`nPress y to uninstall existing WSA or press any key to exit"
\$key = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
If ("y" -eq \$key.Character) {
Remove-AppxPackage -Package \$Installed.PackageFullName
}
Else {
exit 1
}
}
Clear-Host
Write-Host "Installing MagiskOnWSA..."
Stop-Process -Name "wsaclient" -ErrorAction "silentlycontinue"
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
if (\$?) {
Finish
}
Elseif (\$null -ne \$Installed) {
Clear-Host
Write-Host "Failed to update, try to uninstall existing installation while preserving userdata..."
Remove-AppxPackage -PreserveApplicationData -Package \$Installed.PackageFullName
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
if (\$?) {
Finish
}
}
Write-Host "All Done\`r\`nPress any key to exit"
\$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
EOF
shopt -s extglob
sudo rm -rf -- ${{ matrix.arch }}/!(system.img|vendor.img)
- name: Generate artifact name
run: |
variant="${{ matrix.gapps_variant }}"
root="${{ github.event.inputs.root_sol }}"
if [[ "$root" = "none" ]]; then
name1=""
elif [[ "$root" = "" ]]; then
name1="-magisk"
else
name1="-${root}"
fi
if [[ "$variant" = "none" || "$variant" = "" ]]; then
name2="-NoGApps"
else
name2="-${variant}"
fi
echo "artifact_name=WD${name1}${name2}_${{ matrix.arch }}" >> $GITHUB_ENV
- name: Upload Waydroid
uses: actions/upload-artifact@v2
with:
name: ${{ env.artifact_name }}
path: "./${{ matrix.arch }}/*"