Message ID | 20230802072436.1020900-1-alex@linutronix.de |
---|---|
State | Accepted, archived |
Commit | b25e922b271794906b22450c7e6cc18fcab51ff8 |
Headers | show |
Series | [1/2] devtool/upgrade: raise an error if extracting source produces more than one directory | expand |
On Wed, Aug 2, 2023 at 12:24 AM Alexander Kanavin <alex.kanavin@gmail.com> wrote: > This can happen if running unpack task produces unrelated files and > directories > (e.g. if recipe_qa or other tasks run); in this case it's better to stop, > rather > than allow devtool to continue and error out much later with a message > that has > nothing to do with where the problem originated. > > The idea here was to handle tarballs that don't contain a top level > directory and thus > the source tree is one level up; this basically never happens, and if it > does we > should find a less brittle way to handle such tarballs. > > Signed-off-by: Alexander Kanavin <alex@linutronix.de> Tested-by: Tim Orling <tim.orling@konsulko.com> > > --- > scripts/lib/devtool/upgrade.py | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/scripts/lib/devtool/upgrade.py > b/scripts/lib/devtool/upgrade.py > index 6c4a62b5584..e015a85982c 100644 > --- a/scripts/lib/devtool/upgrade.py > +++ b/scripts/lib/devtool/upgrade.py > @@ -35,6 +35,8 @@ def _get_srctree(tmpdir): > dirs = scriptutils.filter_src_subdirs(tmpdir) > if len(dirs) == 1: > srctree = os.path.join(tmpdir, dirs[0]) > + else: > + raise DevtoolError("Cannot determine where the source tree is > after unpacking in {}: {}".format(tmpdir,dirs)) > return srctree > > def _copy_source_code(orig, dest): > -- > 2.30.2 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#185378): > https://lists.openembedded.org/g/openembedded-core/message/185378 > Mute This Topic: https://lists.openembedded.org/mt/100500737/924729 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ > ticotimo@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > >
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py index 6c4a62b5584..e015a85982c 100644 --- a/scripts/lib/devtool/upgrade.py +++ b/scripts/lib/devtool/upgrade.py @@ -35,6 +35,8 @@ def _get_srctree(tmpdir): dirs = scriptutils.filter_src_subdirs(tmpdir) if len(dirs) == 1: srctree = os.path.join(tmpdir, dirs[0]) + else: + raise DevtoolError("Cannot determine where the source tree is after unpacking in {}: {}".format(tmpdir,dirs)) return srctree def _copy_source_code(orig, dest):
This can happen if running unpack task produces unrelated files and directories (e.g. if recipe_qa or other tasks run); in this case it's better to stop, rather than allow devtool to continue and error out much later with a message that has nothing to do with where the problem originated. The idea here was to handle tarballs that don't contain a top level directory and thus the source tree is one level up; this basically never happens, and if it does we should find a less brittle way to handle such tarballs. Signed-off-by: Alexander Kanavin <alex@linutronix.de> --- scripts/lib/devtool/upgrade.py | 2 ++ 1 file changed, 2 insertions(+)