command "expr" (from coreutils) under LE ?

  • I need to do calculation in an shell script under LE, e.g. this:

    #!/bin/sh

    SPACE_NEEDED=$(expr 220 \* 3 \* 1024 );

    but "expr" is unavailable under LE.

    Idea's ?

  • thanks, but it wouldn't fullfill my needs.

    I want to share the script to LE users, so I need a LE-buildin-solution what will work on all LE boxes

  • write your script without using that calculation.

    You can get current disk space usage in KB or MB. So *1024 part is redundant.

    Assumption that compressed package needs three times more to install is as inaccurate as hardcoding space requirement in a script. Try compressing bmp files and see how much they can expand.

    Nothing stops you from having several size checks and then setting required space accordingly.

  • thanks HiassofT

    and sooo easy, Mrrppphh :cry:

    Assumption that compressed package needs three times more to install is as inaccurate ...

    Indeed it is inaccurate: cause it seems to be more then "3".

    *I* assumed the de-compressed file is 1.5 up to max. 2x of the initial compressed image.

    so my initial disk space calc was as following:

    1x image size for downloading the nightly image in ~/.update plus

    1x image size for the second copy of the nightly image in ~/backup plus

    0.5 up to 1x image size when decompressing the image

    ===

    2.5 up to 3x (the max) of the initial downloaded nightly image size as diskspace would be needed, so calculating with the 3 (the max.) I felt more on the safer side, until I proofed it:

    instead of assuming decompression ratio would be 2 only, it is real ~2.6x !

    :huh:

    Code
    ls -lh
    total 760M
    -rw-r--r--. 1 ron ron 549M 12. Jun 11:02 LibreELEC-Generic.x86_64-11.0-nightly-20220612-363112b.img
    -rw-r--r--. 1 ron ron 211M 13. Jun 09:42 LibreELEC-Generic.x86_64-11.0-nightly-20220612-363112b.img.gz
  • Disk/image size is constant (read: changes in calculation are very rare): https://github.com/LibreELEC/Libr…pts/mkimage#L25

    sorry can't get what you mean.

    my assumptions are

    1. if a nightly is stored under ~/.update and the box gets rebooted then the update installer decompresses the nightly (*.img.gz => *.img)

    what blows the nightly up to the un-compressed size of (compressed-nightly-size * 2.6)

    2. further I need to have this so calculated size of disk space to be able to install the update at all without errors (caused by lack of disk space)

    is my assumption wrong ?

  • The unpacked image is always 549MiB. Use this for your calculation.

    The compressed size differs from platform to platform, e.g. ~211MiB for Generic or ~123MiB for RPI4.

  • The compressed size differs from platform to platform, e.g. ~211MiB for Generic or ~123MiB for RPI4.

    sure, in my scripts I dynamically fetch the compressed image size for the diff. platforms already from the download server