Review required to use custom script

Submitted by Michael Wood on Nov. 2, 2016, 4:12 p.m. | Patch ID: 133524

Details

Message ID 52a9bcfe-9444-b117-97e8-38da03b7c1bf@intel.com
State New
Headers show

Commit Message

Michael Wood Nov. 2, 2016, 4:12 p.m.
Couple of comments below:


 From b874cbeae00a4e0d34336d3857731c1233ac73d0 Mon Sep 17 00:00:00 2001
From: Sujith H <sujith.h@gmail.com>
Date: Fri, 28 Oct 2016 07:40:22 +0000
Subject: toaster: accept custom init script for build

When passed variable CUSTOM_BUILD_INIT_SCRIPT to toaster
setting, it would be nice to use it. Else toaster
can use oe-init script. This gives an oppurtunity to
use customized build init scritps.

Signed-off-by: Sujith H <sujith.h@gmail.com>

+        if "# line added by toaster build control\n" in conflines:
+            conflines.pop()



This is something that needs to be a in separate patch as it's a different issue.




  with open(bblconfpath, 'w') as bblayers:
              for line in conflines:
                  if line.startswith("# line added by toaster"):
-                    skip = True
                      continue
-                if skip:
-                    skip = False
                  else:
                      bblayers.write(line)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
index a64e89b..33717cd 100644
--- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -27,7 +27,7 @@  import shutil
  from django.db import transaction
  from django.db.models import Q
  from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget, BRBitbake
-from orm.models import CustomImageRecipe, Layer, Layer_Version, ProjectLayer
+from orm.models import CustomImageRecipe, Layer, Layer_Version, ProjectLayer, ToasterSetting
  import subprocess
  
  from toastermain import settings
@@ -277,20 +277,23 @@  class LocalhostBEController(BuildEnvironmentController):
          builddir = '%s-toaster-%d' % (self.be.builddir, bitbake.req.project.id)
          oe_init = os.path.join(self.pokydirname, 'oe-init-build-env')
          # init build environment
-        self._shellcmd("bash -c 'source %s %s'" % (oe_init, builddir),
+        try:
+            custom_script = ToasterSetting.objects.get(name="CUSTOM_BUILD_INIT_SCRIPT").value
+            custom_script = custom_script.replace("%BUILDDIR%" ,builddir)
+            self._shellcmd("bash -c 'source %s'" % (custom_script))
+        except:



Please add the exception type in here. It'll be something like ToaserSettings.DoesNotExist see
https://docs.djangoproject.com/en/1.8/ref/models/instances/#django.db.models.Model.DoesNotExist




  +            self._shellcmd("bash -c 'source %s %s'" % (oe_init, builddir),
                         self.be.sourcedir)
  
          # update bblayers.conf
          bblconfpath = os.path.join(builddir, "conf/bblayers.conf")
          conflines = open(bblconfpath, "r").readlines()
-        skip = False

Comments

Sujith H Nov. 4, 2016, 6:20 a.m.
Hi,

I have updated the patch:
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=sujith/toaster-use-custom-build-scripts&id=e0cdebe26298c014db68f61955586e66d7f2ea83

Added except ToasterSetting.DoesNotExist: instead of just except:

Let me know if this looks ok. Else I can rework on the same.

Thanks,
Sujith H

On Wed, Nov 2, 2016 at 9:42 PM, Michael Wood <michael.g.wood@intel.com>
wrote:

> Couple of comments below:
>
>
> From b874cbeae00a4e0d34336d3857731c1233ac73d0 Mon Sep 17 00:00:00 2001
> From: Sujith H <sujith.h@gmail.com>
> Date: Fri, 28 Oct 2016 07:40:22 +0000
> Subject: toaster: accept custom init script for build
>
> When passed variable CUSTOM_BUILD_INIT_SCRIPT to toaster
> setting, it would be nice to use it. Else toaster
> can use oe-init script. This gives an oppurtunity to
> use customized build init scritps.
>
> Signed-off-by: Sujith H <sujith.h@gmail.com>
>
> diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
> b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
> index a64e89b..33717cd 100644
> --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
> +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
> @@ -27,7 +27,7 @@ import shutil
>  from django.db import transaction
>  from django.db.models import Q
>  from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable,
> BRTarget, BRBitbake
> -from orm.models import CustomImageRecipe, Layer, Layer_Version,
> ProjectLayer
> +from orm.models import CustomImageRecipe, Layer, Layer_Version,
> ProjectLayer, ToasterSetting
>  import subprocess
>   from toastermain import settings
> @@ -277,20 +277,23 @@ class LocalhostBEController(BuildEnv
> ironmentController):
>          builddir = '%s-toaster-%d' % (self.be.builddir,
> bitbake.req.project.id)
>          oe_init = os.path.join(self.pokydirname, 'oe-init-build-env')
>          # init build environment
> -        self._shellcmd("bash -c 'source %s %s'" % (oe_init, builddir),
> +        try:
> +            custom_script = ToasterSetting.objects.get(nam
> e="CUSTOM_BUILD_INIT_SCRIPT").value
> +            custom_script = custom_script.replace("%BUILDDIR%" ,builddir)
> +            self._shellcmd("bash -c 'source %s'" % (custom_script))
> +        except:
>
>
>
> Please add the exception type in here. It'll be something like
> ToaserSettings.DoesNotExist see
> https://docs.djangoproject.com/en/1.8/ref/models/instances/#
> django.db.models.Model.DoesNotExist
>
>
>
>
>  +            self._shellcmd("bash -c 'source %s %s'" % (oe_init,
> builddir),
>                         self.be.sourcedir)
>           # update bblayers.conf
>          bblconfpath = os.path.join(builddir, "conf/bblayers.conf")
>          conflines = open(bblconfpath, "r").readlines()
> -        skip = False
> +        if "# line added by toaster build control\n" in conflines:
> +            conflines.pop()
>
>
>
> This is something that needs to be a in separate patch as it's a different
> issue.
>
>
>
>
>  with open(bblconfpath, 'w') as bblayers:
>              for line in conflines:
>                  if line.startswith("# line added by toaster"):
> -                    skip = True
>                      continue
> -                if skip:
> -                    skip = False
>                  else:
>                      bblayers.write(line)
>
>
> --
> cgit v0.10.2
>
> Thanks,
>
> Michael
>
>
> On 02/11/16 05:03, sujith h wrote:
>
>> Hi,
>>
>> I have created a patch: http://git.yoctoproject.org/cg
>> it/cgit.cgi/poky-contrib/commit/?h=sujith/toaster-use-custom
>> -build-scripts&id=b874cbeae00a4e0d34336d3857731c1233ac73d0 to review the
>> usage of custom init or setup script. This will help users to use their own
>> script instead of poky's oe-init, if they wish. If CUSTOM_BUILD_INIT_SCRIPT
>> variable is not available it will fall back to poky's oe-init. Kindly let
>> me know if the patch is ok or not ( basically feedback ), I can do the
>> needful to get it better.
>>
>> Thanks,
>> Sujith H
>>
>> --
>> സുജിത് ഹരിദാസന്
>> Bangalore
>> <Project>Contributor to KDE project
>> <Project>Contributor to Yocto project
>> http://fci.wikia.com/wiki/Anti-DRM-Campaign
>> <Blog> http://sujithh.info
>> C-x C-c
>>
>>
>>
> --
> _______________________________________________
> toaster mailing list
> toaster@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>
Sujith H Nov. 9, 2016, 11:17 a.m.
Hi,

I have split my patches into 2. And the top two patches need review. Below
is the link to the branch:
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=sujith/toaster-use-custom-build-scriptsV2

Thanks,
Sujith H

On Fri, Nov 4, 2016 at 11:50 AM, sujith h <sujith.h@gmail.com> wrote:

> Hi,
>
> I have updated the patch: http://git.yoctoproject.org/
> cgit/cgit.cgi/poky-contrib/commit/?h=sujith/toaster-use-
> custom-build-scripts&id=e0cdebe26298c014db68f61955586e66d7f2ea83
>
> Added except ToasterSetting.DoesNotExist: instead of just except:
>
> Let me know if this looks ok. Else I can rework on the same.
>
> Thanks,
> Sujith H
>
> On Wed, Nov 2, 2016 at 9:42 PM, Michael Wood <michael.g.wood@intel.com>
> wrote:
>
>> Couple of comments below:
>>
>>
>> From b874cbeae00a4e0d34336d3857731c1233ac73d0 Mon Sep 17 00:00:00 2001
>> From: Sujith H <sujith.h@gmail.com>
>> Date: Fri, 28 Oct 2016 07:40:22 +0000
>> Subject: toaster: accept custom init script for build
>>
>> When passed variable CUSTOM_BUILD_INIT_SCRIPT to toaster
>> setting, it would be nice to use it. Else toaster
>> can use oe-init script. This gives an oppurtunity to
>> use customized build init scritps.
>>
>> Signed-off-by: Sujith H <sujith.h@gmail.com>
>>
>> diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
>> b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
>> index a64e89b..33717cd 100644
>> --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
>> +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
>> @@ -27,7 +27,7 @@ import shutil
>>  from django.db import transaction
>>  from django.db.models import Q
>>  from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable,
>> BRTarget, BRBitbake
>> -from orm.models import CustomImageRecipe, Layer, Layer_Version,
>> ProjectLayer
>> +from orm.models import CustomImageRecipe, Layer, Layer_Version,
>> ProjectLayer, ToasterSetting
>>  import subprocess
>>   from toastermain import settings
>> @@ -277,20 +277,23 @@ class LocalhostBEController(BuildEnv
>> ironmentController):
>>          builddir = '%s-toaster-%d' % (self.be.builddir,
>> bitbake.req.project.id)
>>          oe_init = os.path.join(self.pokydirname, 'oe-init-build-env')
>>          # init build environment
>> -        self._shellcmd("bash -c 'source %s %s'" % (oe_init, builddir),
>> +        try:
>> +            custom_script = ToasterSetting.objects.get(nam
>> e="CUSTOM_BUILD_INIT_SCRIPT").value
>> +            custom_script = custom_script.replace("%BUILDDIR%"
>> ,builddir)
>> +            self._shellcmd("bash -c 'source %s'" % (custom_script))
>> +        except:
>>
>>
>>
>> Please add the exception type in here. It'll be something like
>> ToaserSettings.DoesNotExist see
>> https://docs.djangoproject.com/en/1.8/ref/models/instances/#
>> django.db.models.Model.DoesNotExist
>>
>>
>>
>>
>>  +            self._shellcmd("bash -c 'source %s %s'" % (oe_init,
>> builddir),
>>                         self.be.sourcedir)
>>           # update bblayers.conf
>>          bblconfpath = os.path.join(builddir, "conf/bblayers.conf")
>>          conflines = open(bblconfpath, "r").readlines()
>> -        skip = False
>> +        if "# line added by toaster build control\n" in conflines:
>> +            conflines.pop()
>>
>>
>>
>> This is something that needs to be a in separate patch as it's a
>> different issue.
>>
>>
>>
>>
>>  with open(bblconfpath, 'w') as bblayers:
>>              for line in conflines:
>>                  if line.startswith("# line added by toaster"):
>> -                    skip = True
>>                      continue
>> -                if skip:
>> -                    skip = False
>>                  else:
>>                      bblayers.write(line)
>>
>>
>> --
>> cgit v0.10.2
>>
>> Thanks,
>>
>> Michael
>>
>>
>> On 02/11/16 05:03, sujith h wrote:
>>
>>> Hi,
>>>
>>> I have created a patch: http://git.yoctoproject.org/cg
>>> it/cgit.cgi/poky-contrib/commit/?h=sujith/toaster-use-custom
>>> -build-scripts&id=b874cbeae00a4e0d34336d3857731c1233ac73d0 to review
>>> the usage of custom init or setup script. This will help users to use their
>>> own script instead of poky's oe-init, if they wish. If
>>> CUSTOM_BUILD_INIT_SCRIPT variable is not available it will fall back to
>>> poky's oe-init. Kindly let me know if the patch is ok or not ( basically
>>> feedback ), I can do the needful to get it better.
>>>
>>> Thanks,
>>> Sujith H
>>>
>>> --
>>> സുജിത് ഹരിദാസന്
>>> Bangalore
>>> <Project>Contributor to KDE project
>>> <Project>Contributor to Yocto project
>>> http://fci.wikia.com/wiki/Anti-DRM-Campaign
>>> <Blog> http://sujithh.info
>>> C-x C-c
>>>
>>>
>>>
>> --
>> _______________________________________________
>> toaster mailing list
>> toaster@yoctoproject.org
>> https://lists.yoctoproject.org/listinfo/toaster
>>
>
>
>
> --
> സുജിത് ഹരിദാസന്
> Bangalore
> <Project>Contributor to KDE project
> <Project>Contributor to Yocto project
> http://fci.wikia.com/wiki/Anti-DRM-Campaign
> <Blog> http://sujithh.info
> C-x C-c
>