Bug 14179

Summary: Need to validate user isn't building in a PSEUDO_IGNORE_PATHS
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Richard Purdie <richard.purdie>
Component: coreAssignee: Dorinda <dorindabassey>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: dorindabassey, meta.mr.watcher, meta.watcher, randy.macleod, yf3yu
Version: 3.3   
Target Milestone: 3.3 M3   
Hardware: x86   
OS: Multiple   
Whiteboard: NEWCOMER
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Richard Purdie 2021-01-09 09:27:29 UTC
If a user builds in a path in PSEUDO_IGNORE_PATHS we need to error from a sanity test in sanity.bbclass rather than give them random failures.

A recent example was an openbmi user building in /usr/local.
Comment 1 Dorinda 2021-01-17 21:25:19 UTC
Hi, Would adding this check in the function in sanity.bbclass suffice?

def check_sanity_everybuild(status, d):

    # Check that user isn't building in PSEUDO_IGNORE_PATHS
    pseudoignorepaths = d.getVar('PSEUDO_IGNORE_PATHS').split(",")
    workdir = d.getVar('WORKDIR')
    for i in pseudoignorepaths:
        if(i in workdir):
            status.addresult("you are building in a path under PSEUDO_IGNORE_PATHS, please remove this" + str(i) + "directory in \nParsed WORKDIR: " + str(workdir) + "\n")
Comment 2 Richard Purdie 2021-01-19 15:54:02 UTC
I think rather than "i in workdir", you might want to use:

if workdir.startswith(i):

but otherwise it looks good to me.
Comment 3 Richard Purdie 2021-01-19 15:54:41 UTC
Oh, also, do we need to run this test everybuild? I think we already test when tmpdir changes so we probably don't need to.
Comment 4 Yi Fan Yu 2021-01-19 16:01:15 UTC
looks like Dorinda did the work for me.
I'll new to the project so I'll try to come up with my own solution.

Dorinda,
Feel free to send your patch in though, I can also run some tests
Comment 5 Dorinda 2021-01-19 17:48:11 UTC
Ok i get Thanks, so since workdir path already begins with tmpdir, then it might be better to add this under the conditional statement that checks when tmpdir changes:

                # Also Check that user isn't building in PSEUDO_IGNORE_PATHS
                pseudoignorepaths = d.getVar('PSEUDO_IGNORE_PATHS').split(",")
                for i in pseudoignorepaths:
                    if tmpdir.startswith(i):
                        status.addresult("your tmpdir also contains a PSEUDO_IGNORE_PATHS, please remove this" + str(i) + "directory in \nParsed TMPDIR: " + str(tmpdir) + "\n")
Comment 6 Dorinda 2021-01-19 17:55:36 UTC
oh Alright Yi Fan Yu, i will send a patch in due time thanks.
Comment 7 Randy MacLeod 2021-01-19 17:58:55 UTC
Let's make this official since Dorinda is working on this bug.  Thanks Dorinda.
Comment 8 Yi Fan Yu 2021-01-19 18:43:45 UTC
Since I won't be working on this anymore,

Here might be something to keep in mind with PSEUDO_IGNORE_PATH
-variables are included in the PSEUDO_IGNORE_PATH  
`${BUILDHISTORY_DIR}` and  `${CCACHE_DIR}`
Comment 9 Yi Fan Yu 2021-01-19 18:59:52 UTC
More things...

-just doing `i in list` can cause issues such as if i am building in
   `home/NAME/usr/b/` the sanity check might trigger since it found `/usr`

-I think it makes sense just inserting it in `check_sanity_version_change(..)` 
    so it runs basically once.

    only issue I see is that a person might move everything to a suspicious directory after a build. -_-
Comment 10 Dorinda 2021-01-20 10:41:09 UTC
Okay i see, thank you Yi Fan Yu, took note of your points hence am adding this in 
check_sanity_version_change(status, d):

    # Check that user isn't building in PSEUDO_IGNORE_PATHS
    pseudoignorepaths = d.getVar('PSEUDO_IGNORE_PATHS', expand=True).split(",")
    workdir = d.getVar('WORKDIR', expand=True)
    for i in pseudoignorepaths:
        if workdir.startswith(i):
            status.addresult("you are building in a path under PSEUDO_IGNORE_PATHS, please remove this" + str(i) + "directory in \nParsed WORKDIR: " + str(workdir) + "\n")

i should submit a patch soon.
Comment 12 Randy MacLeod 2021-01-29 14:59:02 UTC
Thanks Dorinda.
Next time please provide a link to the commit since not all submissions to the emails list are merged. This one is on master:
http://cgit.openembedded.org/openembedded-core/commit/?id=7a681525e904914e938de25df5cc64209097d15d