Bug 10333

Summary: Install scripts fail when installing to SanDisk HDD/SSD
Product: [Runtime] Installation Reporter: Scott Lawson <scott.lawson.linux>
Component: InstallationAssignee: Saul Wold <sgw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: kevin.tian, sgw
Version: unspecified   
Target Milestone: 2.0.3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Scott Lawson 2016-09-26 22:06:43 UTC
Preconditions/Environment
-------------------------
Using image built with Yocto 2.1.1 (jethro branch)
Build target is intel-corei7-64 from meta-intel
Installing image on Sony Vaio with SanDisk 256GB SSD

Triggering Action/Cause
-----------------------
Run install.sh

Expectation
-----------
The image is installed

Actual Result
-------------
Install script fails with "./install.sh: line 131: arithmetic syntax error". This is the line referenced:

    swap_size=$((disk_size*swap_ratio/100))

Adding printouts of $disk_size and $swap_ratio shows that $swap_ratio is set correctly, but $disk_size is set to this:

    SanDisk 256061

$disk_size is set several lines prior by this line:

    disk_size=$(parted ${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")

On this test system, "parted /dev/sda unit mb print" returns the following:

    Model: ATA SanDisk SD6SN1M2 (scsi)
    Disk /dev/sda: 256061MB
    ...snip...

It looks like "Disk" being in the model specification line is causing the manufacturer name to be captured by "grep Disk" when this was not intended. Executing the entire command that is supposed to be setting $disk_size$ confirms this:

    $ parted /dev/sda unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//"
    SanDisk
    256061
    < blank line >


The end result is that the $disk_size variable contains a string with alphabetic characters, rather than just numbers, resulting in the arithmetic syntax error when it is used in a calculation.

Reproducibility
---------------
5/5, assuming SanDisk HDD/SSD is used.

Other Notes
---------------
The same command is used in multiple scripts to set $disk_size, so this issue likely affects all of them. install.sh was just used as an example.
Comment 1 Saul Wold 2016-09-26 22:46:18 UTC
There appears to be a fix for this issue in master and krogoth, I will propose this as a backport for jethro.  You can see the patch here: http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=3ce7d8cdc8537fef07efc2d3f6b540faab1819e4


If you are working from a GIT branch for jethro, you might try to cherry pick:
git cherry-pick 3ce7d8cd
Comment 2 Scott Lawson 2016-09-28 18:50:25 UTC
Thanks for the info. Given that the fix is present in a newer release than we're using, I would be fine with this being closed. It sounds like just completing our Krogoth upgrade will resolve it.