Calculate system size dynamically

This commit is contained in:
Peter Njeim 2022-05-21 00:50:19 -03:00
parent 8cbe7bf64c
commit 7b6cff2666

View File

@ -284,15 +284,25 @@ jobs:
mkdir gapps 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' 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
# TODO: calculate the size dynamically for better compatibility # TODO: calculate the size dynamically for better compatibility
e2fsck -yf ${{ matrix.arch }}/product.img e2fsck -yf ${{ matrix.arch }}/product.img
resize2fs ${{ matrix.arch }}/product.img 1024M resize2fs ${{ matrix.arch }}/product.img 1024M
e2fsck -yf ${{ matrix.arch }}/system_ext.img e2fsck -yf ${{ matrix.arch }}/system_ext.img
resize2fs ${{ matrix.arch }}/system_ext.img 200M resize2fs ${{ matrix.arch }}/system_ext.img 200M
- name: Expand vendor - name: Expand vendor and system
run: | run: |
e2fsck -yf ${{ matrix.arch }}/system.img
system_size=$(( $(du -sB512 ${{ matrix.arch }}/system.img | cut -f1) + 20000 ))
if [ -d gapps ]; then
system_size=$(( $system_size + $(du -sB512 gapps | cut -f1) ))
fi
if [ -d magisk ]; then
system_size=$(( $system_size +$(du -sB512 magisk | cut -f1) ))
fi
if [ -f magisk.zip ]; then
system_size=$(( $system_size +$(du -sB512 magisk.zip | cut -f1) ))
fi
resize2fs ${{ matrix.arch }}/system.img "$system_size"s
e2fsck -yf ${{ matrix.arch }}/vendor.img e2fsck -yf ${{ matrix.arch }}/vendor.img
resize2fs ${{ matrix.arch }}/vendor.img 400M resize2fs ${{ matrix.arch }}/vendor.img 400M
- name: Mount images - name: Mount images