On Wed, Apr 1, 2020 at 3:02 PM Tim Orling <[email protected]> wrote:
> On Wed, Apr 1, 2020 at 2:32 PM Tim Orling via lists.openembedded.org 
> <[email protected]> wrote:
>> On Wed, Apr 1, 2020 at 1:09 PM Andre McCurdy <[email protected]> wrote:
>>>
>>> On Mon, Mar 30, 2020 at 12:43 PM Tim Orling
>>> <[email protected]> wrote:
>>> >
>>> > * Install directory defaults to scripts/../buildtools
>>> >   e.g. --directory is set by default
>>> >   This avoids the user having to type in their sudo password
>>> >   to install in /opt/poky/<installer-version>
>>> >
>>> > * Use "." rather than "source" for sourcing the environment script
>>> >   as not all distros (e.g. Debian) have "source" by default.
>>> >
>>> > * Add buildtools/ to .gitignore
>>> >
>>> > * Fix typos in example usage (--install-version -> --installer-version)
>>> >
>>> > [YOCTO #13832]
>>> >
>>> > Signed-off-by: Tim Orling <[email protected]>
>>> > ---
>>> >  .gitignore                 |  1 +
>>> >  scripts/install-buildtools | 13 +++++++++----
>>> >  2 files changed, 10 insertions(+), 4 deletions(-)
>>> >
>>> > diff --git a/.gitignore b/.gitignore
>>> > index d0e6b2fb89..b66d371aac 100644
>>> > --- a/.gitignore
>>> > +++ b/.gitignore
>>> > @@ -9,6 +9,7 @@ pstage/
>>> >  scripts/oe-git-proxy-socks
>>> >  sources/
>>> >  meta-*/
>>> > +buildtools/
>>> >  !meta-skeleton
>>> >  !meta-selftest
>>> >  hob-image-*.bb
>>> > diff --git a/scripts/install-buildtools b/scripts/install-buildtools
>>> > index 0947e9c4d6..49cab1345a 100755
>>> > --- a/scripts/install-buildtools
>>> > +++ b/scripts/install-buildtools
>>> > @@ -17,7 +17,7 @@
>>> >  #        $ install-buildtools \
>>> >  #          --base-url http://downloads.yoctoproject.org/releases/yocto \
>>> >  #          --release yocto-3.1_M2 \
>>> > -#          --install-version 3.0+snapshot
>>> > +#          --installer-version 3.0+snapshot
>>> >  #          --build-date 202000122
>>> >  #
>>> >  #  Example usage (standard buildtools from release):
>>> > @@ -29,7 +29,7 @@
>>> >  #        $ install-buildtools --without-extended-buildtools \
>>> >  #          --base-url http://downloads.yoctoproject.org/releases/yocto \
>>> >  #          --release yocto-3.0.2 \
>>> > -#          --install-version 3.0.2
>>> > +#          --installer-version 3.0.2
>>> >  #
>>> >
>>> >  import argparse
>>> > @@ -59,6 +59,7 @@ if not bitbakepath:
>>> >  PROGNAME = 'install-buildtools'
>>> >  logger = scriptutils.logger_create(PROGNAME, stream=sys.stdout)
>>> >
>>> > +DEFAULT_INSTALL_DIR: str = 
>>> > os.path.join(os.path.split(scripts_path)[0],'buildtools')
>>>
>>> It looks like there are some assumptions about the minimum version of
>>> python3 on the host in order to even be able to run
>>> install-buildtools. Should that be checked explicitly?
>>
>>
>> To be honest, everything was written on CentOS-7, where ‘python3’ is now 
>> python36.
>>
>> The remaining supported holdout for 3.4 is Debian-8 (Jessie). Which also 
>> happens to have tar 1.27. At least it has git 2.1.4, so it’s not a complete 
>> mess.
>>
>> Python 3.4 is already EOL. We should not support it for the complete build 
>> system, but I can see that the install-buildtools script should ideally 
>> still run on python34. The whole point is to make it easier to install the 
>> pre-built buildtools.
>
> Python 3.5 is now required in bitbake/lib/bb/__init__.py
> Which is needed for bb.utils.md5sum_file and sha256_file to check the 
> checksum of the download. I’d rather not have to rewrite those functions.

Looks like copy and pasting ~30 lines? Maybe not even much of a net
increase in code size if you can remove the existing code to check
that bitbake libs are available...

def _hasher(method, filename):
    import mmap

    with open(filename, "rb") as f:
        try:
            with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as mm:
                for chunk in iter(lambda: mm.read(8192), b''):
                    method.update(chunk)
        except ValueError:
            # You can't mmap() an empty file so silence this exception
            pass
    return method.hexdigest()

def md5_file(filename):
    """
    Return the hex string representation of the MD5 checksum of filename.
    """
    import hashlib
    return _hasher(hashlib.md5(), filename)

def sha256_file(filename):
    """
    Return the hex string representation of the 256-bit SHA checksum of
    filename.
    """
    import hashlib
    return _hasher(hashlib.sha256(), filename)


>> Debian-8 is EOL in June 2020.
>>
>>>
>>> >  DEFAULT_BASE_URL: str = 
>>> > 'http://downloads.yoctoproject.org/releases/yocto'
>>> >  DEFAULT_RELEASE: str = 'yocto-3.1_M2'
>>> >  DEFAULT_INSTALLER_VERSION: str = '3.0+snapshot'
>>> > @@ -66,6 +67,7 @@ DEFAULT_BUILDDATE: str = "20200122"
>>> >
>>> >
>>> >  def main():
>>> > +    global DEFAULT_INSTALL_DIR
>>> >      global DEFAULT_BASE_URL
>>> >      global DEFAULT_RELEASE
>>> >      global DEFAULT_INSTALLER_VERSION
>>> > @@ -73,6 +75,7 @@ def main():
>>> >      filename: str = ""
>>> >      release: str = ""
>>> >      buildtools_url: str = ""
>>> > +    install_dir: str = ""
>>> >
>>> >      parser = argparse.ArgumentParser(
>>> >          description="Buildtools installation helper",
>>> > @@ -87,6 +90,7 @@ def main():
>>> >                               '(optional)\nRequires --url',
>>> >                          action='store')
>>> >      parser.add_argument('-d', '--directory',
>>> > +                        default=DEFAULT_INSTALL_DIR,
>>> >                          help='directory where buildtools SDK will be 
>>> > installed (optional)',
>>> >                          action='store')
>>> >      parser.add_argument('-r', '--release',
>>> > @@ -216,12 +220,12 @@ def main():
>>> >          st = os.stat(tmpbuildtools)
>>> >          os.chmod(tmpbuildtools, st.st_mode | stat.S_IEXEC)
>>> >          logger.debug(os.stat(tmpbuildtools))
>>> > -        install_dir = "/opt/poky/%s" % args.installer_version
>>> >          if args.directory:
>>> >              install_dir = args.directory
>>> >              ret = subprocess.call("%s -d %s -y" %
>>> >                                    (tmpbuildtools, install_dir), 
>>> > shell=True)
>>> >          else:
>>> > +            install_dir = "/opt/poky/%s" % args.installer_version
>>> >              ret = subprocess.call("%s -y" % tmpbuildtools, shell=True)
>>> >          if ret != 0:
>>> >              logger.error("Could not run buildtools installer")
>>> > @@ -238,7 +242,8 @@ def main():
>>> >              tool = 'gcc'
>>> >          else:
>>> >              tool = 'tar'
>>> > -        proc = subprocess.run("source 
>>> > %s/environment-setup-x86_64-pokysdk-linux && which %s" %
>>> > +        logger.debug("install_dir: %s" % install_dir)
>>> > +        proc = subprocess.run(". 
>>> > %s/environment-setup-x86_64-pokysdk-linux && which %s" %
>>> >                                (install_dir, tool),
>>> >                                shell=True, stdout=subprocess.PIPE)
>>> >          which_tool = proc.stdout.decode("utf-8")
>>> > --
>>> > 2.24.0
>>> >
>>> >
>>>
>> 
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#136941): 
https://lists.openembedded.org/g/openembedded-core/message/136941
Mute This Topic: https://lists.openembedded.org/mt/72661727/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to