Changeset a083b52 in rtems-source-builder


Ignore:
Timestamp:
07/29/14 06:35:43 (8 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, 4.9, 5, master
Children:
09cdaa3
Parents:
c49e500
Message:

Add checksum support for downloaded files.

File download by http, ftp, pw support checksum. The %hash
directive provides a means of setting a hash used to
checksum the file.

Files on disk or just downloaded are checked.

Files:
28 edited

Legend:

Unmodified
Added
Removed
  • bare/config/devel/expat-2.1.0-1.cfg

    rc49e500 ra083b52  
    1111%define expat_version 2.1.0
    1212
     13%hash md5 expat-%{expat_version}.tar.gz dd7dab7a5fea97d2a6a43f511449b7cd
     14
    1315#
    1416# The Expat build instructions. We use 2.xx Release 1.
  • rtems/config/4.11/rtems-arm.bset

    rc49e500 ra083b52  
    2121#
    2222%patch add gcc pw://patchwork.ozlabs.org/patch/372178/raw/v2-RTEMS-Add-multilibs-for-ARM.patch
     23%hash  md5 v2-RTEMS-Add-multilibs-for-ARM.patch 2f3b5cf8db2a4c19f77752851ca10f6e
    2324
    2425#
  • rtems/config/4.11/rtems-lm32.bset

    rc49e500 ra083b52  
    1616#
    1717%patch add gdb %{rtems_gdb_patches}/lm32/gdb-sim-lm32uart.diff
     18%hash  md5 gdb-sim-lm32uart.diff 77d070878112783292461bd6e7db17fb
    1819
    1920#
     
    2324devel/expat-2.1.0-1
    2425tools/rtems-binutils-2.24-1
    25 tools/rtems-gcc-4.9.0-newlib-cvs-1
     26tools/rtems-gcc-4.9.1-newlib-cvs-1
    2627tools/rtems-gdb-7.7-1
    2728tools/rtems-kernel-4.11
  • rtems/config/4.11/rtems-microblaze.bset

    rc49e500 ra083b52  
    1616#
    1717%patch add gcc %{rtems_gcc_patches}/microblaze/gcc-4.7.2-microblaze-ldscript-2.diff
     18%hash  md5 gcc-4.7.2-microblaze-ldscript-2.diff a34f87dfa792193ade7f95e0b084a262
    1819
    1920#
     
    2122#
    2223%patch add gcc %{rtems_gcc_patches}/microblaze/rtems-gcc-microblaze-libgcc-20131017.diff
     24%hash  md5 rtems-gcc-microblaze-libgcc-20131017.diff 097186bb4c2c9a1970fe502aec30530f
    2325
    2426#
  • rtems/config/4.11/rtems-nios2.bset

    rc49e500 ra083b52  
    1818#
    1919%patch add gcc pw://patchwork.ozlabs.org/patch/364504/raw/RTEMS-Add-Nios-2-support.patch
     20%hash  md5 RTEMS-Add-Nios-2-support.patch fd9bbc8482e69623214e2a4289e38d8f
    2021
    2122#
  • rtems/config/4.11/rtems-sparc.bset

    rc49e500 ra083b52  
    1616#
    1717%patch add gdb %{rtems_gdb_patches}/sparc/gdb-7.7-sis-output-nouartrx.diff
     18%hash  md5 gdb-7.7-sis-output-nouartrx.diff bc35b15de1325f3c4461ac3cda027bea
    1819
    1920#
  • rtems/config/net-mgmt/net-snmp-5.7.2.1-1.cfg

    rc49e500 ra083b52  
    1414%define net_snmp_version 5.7.2.1
    1515
     16%hash md5 net-snmp-%{net_snmp_version}.tar.gz 7db683faba037249837b226f64d566d4
     17
    1618#
    1719# We need some special flags to build this version.
     
    2325#
    2426%patch add net-snmp %{rtems_git_tools}/net-snmp/rtems-net-snmp-5.7.2.1-20140623.patch
     27%hash  md5 rtems-net-snmp-5.7.2.1-20140623.patch 9a22fb4366a113f5df71ed2acd672b2b
    2528
    2629#
  • rtems/config/net/ntp-4.2.6p5-1.cfg

    rc49e500 ra083b52  
    1414%define ntp_version 4.2.6p5
    1515
     16%hash md5 ntp-%{ntp_version}.tar.gz 00df80a84ec9528fcfb09498075525bc
     17
    1618#
    1719# Patch for RTEMS support.
    1820#
    1921%patch add ntp %{rtems_git_tools}/ntp/rtems-ntp-4.2.6p5.diff
     22%hash  md5 rtems-ntp-4.2.6p5.diff 6fce685a73873f924a48b19d6b1700fc
    2023
    2124#
  • rtems/config/tools/rtems-autoconf-2.69-1.cfg

    rc49e500 ra083b52  
    99%define rtems_autoconf_version 2.69
    1010
     11%hash md5 autoconf-%{rtems_autoconf_version}.tar.gz 82d05e03b93e45f5a39b828dc9c6c29b
     12
    1113#
    1214# Check the version of autoconf in the path.
  • rtems/config/tools/rtems-automake-1.12.6-1.cfg

    rc49e500 ra083b52  
    99%define rtems_automake_version 1.12.6
    1010
     11%hash md5 automake-%{rtems_automake_version}.tar.gz 199d39ece2e6070d64ac20d45ac86026
     12
    1113#
    1214# Check the version of automake in the path.
  • rtems/config/tools/rtems-binutils-2.24-1.cfg

    rc49e500 ra083b52  
    77
    88%define binutils_version 2.24
     9
     10%hash md5 binutils-%{binutils_version}.tar.bz2 e0f71a7b2ddab0f8612336ac81d9636b
    911
    1012#
  • rtems/config/tools/rtems-gcc-4.8-newlib-cvs-1.cfg

    rc49e500 ra083b52  
    2727
    2828#
     29# Hash checksums of the libraries used in GCC.
     30#
     31%hash md5 mpfr-%{mpfr_version}.tar.bz2 bfbecb2eacb6d48432ead5cfc3f7390a
     32%hash md5 mpc-%{mpc_version}.tar.gz    e98267ebd5648a39f881d66797122fb6
     33%hash md5 gmp-%{gmp_version}.tar.bz2   041487d25e9c230b0c42b106361055fe
     34
     35#
    2936# Newlib is from CVS.
    3037#
     
    3542#
    3643%patch add newlib -p0 %{rtems_newlib_patches}/newlib-sys-signal-20130532.diff
     44%hash  md5 newlib-sys-signal-20130532.diff 34af05f28a4921e47c053528f5a8b9fb
    3745
    3846#
  • rtems/config/tools/rtems-gcc-4.8.2-newlib-2.1.0-1.cfg

    rc49e500 ra083b52  
    2121
    2222#
     23# Hash checksums.
     24#
     25%hash md5 mpfr-%{mpfr_version}.tar.bz2    bfbecb2eacb6d48432ead5cfc3f7390a
     26%hash md5 mpc-%{mpc_version}.tar.gz       e98267ebd5648a39f881d66797122fb6
     27%hash md5 gmp-%{gmp_version}.tar.bz2      041487d25e9c230b0c42b106361055fe
     28%hash md5 gcc-%{gcc_version}.tar.bz2      a3d7d63b9cb6b6ea049469a0c4a43c9d
     29%hash md5 newlib-%{newlib_version}.tar.gz c6559d83ecce4728a52f0ce7ec80de97
     30
     31#
    2332# Joel's stack_t patch.
    2433#
    2534%patch add newlib -p0 %{rtems_newlib_patches}/newlib-sys-signal-20130532.diff
     35%hash  md5 newlib-sys-signal-20130532.diff 34af05f28a4921e47c053528f5a8b9fb
    2636
    2737# The gcc/newlib build instructions. We use 4.8 Release 1.
  • rtems/config/tools/rtems-gcc-4.8.2-newlib-cvs-1.cfg

    rc49e500 ra083b52  
    66%define newlib_version 12-Jul-2014
    77
     8%hash md5 gcc-%{gcc_version}.tar.bz2 a3d7d63b9cb6b6ea049469a0c4a43c9d
     9
    810#
    911# The gcc/newlib build instructions.
  • rtems/config/tools/rtems-gcc-4.8.3-newlib-cvs-1.cfg

    rc49e500 ra083b52  
    66%define newlib_version 26-Jul-2014
    77
     8%hash md5 gcc-%{gcc_version}.tar.bz2 7c60f24fab389f77af203d2516ee110f
     9
    810#
    911# The gcc/newlib build instructions.
  • rtems/config/tools/rtems-gcc-4.9-newlib-cvs-1.cfg

    rc49e500 ra083b52  
    2727
    2828#
    29 # Newlib is from CVS.
     29# Hash checksums of the libraries used in GCC.
     30#
     31%hash md5 mpfr-%{mpfr_version}.tar.bz2 bfbecb2eacb6d48432ead5cfc3f7390a
     32%hash md5 mpc-%{mpc_version}.tar.gz    e98267ebd5648a39f881d66797122fb6
     33%hash md5 gmp-%{gmp_version}.tar.bz2   041487d25e9c230b0c42b106361055fe
     34
     35#
     36# Newlib is from CVS. No hash on CVS.
    3037#
    3138%source set newlib cvs://pserver:anoncvs@sourceware.org/cvs/src?module=newlib?src-prefix=src?date=%{newlib_version}?reset
     
    3542#
    3643%patch add newlib -p0 %{rtems_newlib_patches}/newlib-sys-signal-20130532.diff
     44%hash  md5 newlib-sys-signal-20130532.diff 34af05f28a4921e47c053528f5a8b9fb
    3745
    3846#
  • rtems/config/tools/rtems-gcc-4.9.0-newlib-2.1.0-1.cfg

    rc49e500 ra083b52  
    2121
    2222#
     23# Hash checksums.
     24#
     25%hash md5 mpfr-%{mpfr_version}.tar.bz2    bfbecb2eacb6d48432ead5cfc3f7390a
     26%hash md5 mpc-%{mpc_version}.tar.gz       e98267ebd5648a39f881d66797122fb6
     27%hash md5 gmp-%{gmp_version}.tar.bz2      041487d25e9c230b0c42b106361055fe
     28%hash md5 gcc-%{gcc_version}.tar.bz2      9709b49ae0e904cbb0a6a1b62853b556
     29%hash md5 newlib-%{newlib_version}.tar.gz c6559d83ecce4728a52f0ce7ec80de97
     30
     31#
    2332# Joel's stack_t patch.
    2433#
    2534%patch add newlib -p0 %{rtems_newlib_patches}/newlib-sys-signal-20130532.diff
     35%hash  md5 newlib-sys-signal-20130532.diff 34af05f28a4921e47c053528f5a8b9fb
    2636
    2737#
  • rtems/config/tools/rtems-gcc-4.9.1-newlib-cvs-1.cfg

    rc49e500 ra083b52  
    66%define newlib_version 26-Jul-2014
    77
     8%hash md5 gcc-%{gcc_version}.tar.bz2 fddf71348546af523353bd43d34919c1
     9
    810#
    911# The gcc/newlib build instructions.
  • rtems/config/tools/rtems-gdb-7.7-1.cfg

    rc49e500 ra083b52  
    88%define gdb_version 7.7
    99
     10%hash md5 gdb-%{gdb_version}.tar.bz2 271a18f41858a7e98b28ae4eb91287c9
     11
    1012#
    1113# Clean up the sim-arange inline code so it builds.
    1214#
    1315%patch add gdb %{rtems_gdb_patches}/gdb-sim-arange-inline.diff
     16%hash  md5 gdb-sim-arange-inline.diff 11bb2936ea29afeaa023077191fd4705
    1417%patch add gdb %{rtems_gdb_patches}/gdb-sim-cgen-inline.diff
     18%hash  md5 gdb-sim-cgen-inline.diff e6f7d6d7295cdba99f51aab514ea9778
    1519
    1620%if %{_build_os} == freebsd
    1721 %patch add gdb -p0 %{rtems_gdb_patches}/patch-gdb-python-python-config.py
     22 %hash  md5 patch-gdb-python-python-config.py c0260fcca4c1a5509635049c0094eee3
    1823%endif
    1924
  • rtems/config/tools/rtems-gdb-7.7.1-1.cfg

    rc49e500 ra083b52  
    1212#
    1313%patch add gdb %{rtems_gdb_patches}/gdb-sim-arange-inline.diff
     14%hash  md5 gdb-sim-arange-inline.diff 11bb2936ea29afeaa023077191fd4705
    1415%patch add gdb %{rtems_gdb_patches}/gdb-sim-cgen-inline.diff
     16%hash  md5 gdb-sim-cgen-inline.diff e6f7d6d7295cdba99f51aab514ea9778
    1517
    1618%if %{_build_os} == freebsd
    1719 %patch add gdb -p0 %{rtems_gdb_patches}/patch-gdb-python-python-config.py
     20 %hash  md5 patch-gdb-python-python-config.py c0260fcca4c1a5509635049c0094eee3
    1821%endif
    1922
  • rtems/config/tools/rtems-nios2-binutils-2.20-1.cfg

    rc49e500 ra083b52  
    1717#
    1818%source set binutils http://ftp.rtems.org/ftp/pub/rtems/people/chrisj/nios/nios2-binutils-2.20.tar.bz2
     19%hash   md5 nios2-binutils-2.20.tar.bz2 42ce11b421a1d35fc7b17ee051ccf92a
    1920%patch  add binutils %{rtems_binutils_patches}/nios2/nios2-binutils-2.20-rtems-20110703.diff
     21%hash   md5 nios2-binutils-2.20-rtems-20110703.diff edaa78cdf7b87866c976232ccb1704ac
    2022
    2123#
  • rtems/config/tools/rtems-nios2-gcc-4.1-newlib-1.19.0-1.cfg

    rc49e500 ra083b52  
    4343#
    4444%source set gcc http://ftp.rtems.org/ftp/pub/rtems/people/chrisj/nios/nios2-gcc-4.1.tar.bz2
     45%hash   md5 nios2-gcc-4.1.tar.bz2 717e5a25fda68d96d09353bcfa149cff
    4546
    4647#
     
    4849#
    4950%source set newlib ftp://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
     51%hash   md5 newlib-%{newlib_version}.tar.gz 0966e19f03217db9e9076894b47e6601
    5052
    5153#
  • source-builder/sb/build.py

    rc49e500 ra083b52  
    309309                args = l.split()
    310310                if len(args):
     311                    def err(msg):
     312                        raise error.general('%s: %s' % (package, msg))
    311313                    if args[0] == '%setup':
    312314                        if len(args) == 1:
     
    316318                        elif args[1] == 'patch':
    317319                            self.patch_setup(package, args[1:])
    318                     elif args[0].startswith('%patch'):
    319                         self.patch(package, args)
     320                    elif args[0] in ['%patch', '%source']:
     321                        sources.process(args[0][1:], args[1:], self.macros, err)
     322                    elif args[0] == '%hash':
     323                        sources.hash(args[1:], self.macros, err)
     324                        self.hash(package, args)
    320325                    else:
    321326                        self.script.append(' '.join(args))
  • source-builder/sb/config.py

    rc49e500 ra083b52  
    230230    _ignore = [ re.compile('%setup'),
    231231                re.compile('%configure'),
    232                 re.compile('%source[0-9]*'),
    233                 re.compile('%patch[0-9]*'),
     232                re.compile('%source'),
     233                re.compile('%patch'),
     234                re.compile('%hash'),
    234235                re.compile('%select'),
    235236                re.compile('%disable') ]
     
    671672    def _sources(self, ls):
    672673        return sources.process(ls[0][1:], ls[1:], self.macros, self._error)
     674
     675    def _hash(self, ls):
     676        return sources.hash(ls[1:], self.macros, self._error)
    673677
    674678    def _define(self, config, ls):
     
    891895                    if isvalid:
    892896                        d = self._sources(ls)
     897                        if d is not None:
     898                            return ('data', d)
     899                elif ls[0] == '%hash':
     900                    if isvalid:
     901                        d = self._hash(ls)
    893902                        if d is not None:
    894903                            return ('data', d)
  • source-builder/sb/download.py

    rc49e500 ra083b52  
    2323#
    2424
     25import hashlib
    2526import os
    2627import stat
     
    5051            break
    5152    return '%.*f%s' % (precision, float(bytes) / factor, suffix)
     53
     54def _hash_check(file_, absfile, macros, remove = True):
     55    failed = False
     56    if file_.lower() in macros.map_keys('hashes'):
     57        m1, m2, hash = macros.get(file_.lower(), globals = False, maps = 'hashes')
     58        hash = hash.split()
     59        if len(hash) != 2:
     60            raise error.internal('invalid hash format: %s' % (file_))
     61        if hash[0] not in hashlib.algorithms:
     62            raise error.general('invalid hash algorithm for %s: %s' % (file_, hash[0]))
     63        hasher = None
     64        _in = None
     65        try:
     66            hasher = hashlib.new(hash[0])
     67            _in = open(absfile, 'rb')
     68            hasher.update(_in.read())
     69        except IOError, err:
     70            log.notice('hash: %s: read error: %s' % (file_, str(err)))
     71            failed = True
     72        except:
     73            msg = 'hash: %s: error' % (file_)
     74            log.stderr(msg)
     75            log.notice(msg)
     76            if _in is not None:
     77                _in.close()
     78            raise
     79        if _in is not None:
     80            _in.close()
     81        log.output('checksums: %s: %s => %s' % (file_, hasher.hexdigest(), hash[1]))
     82        if hasher.hexdigest() != hash[1]:
     83            log.warning('checksum error: %s' % (file_))
     84            failed = True
     85        if failed and remove:
     86            log.warning('removing: %s' % (file_))
     87            if path.exists(absfile):
     88                os.remove(path.host(absfile))
     89        if hasher is not None:
     90            del hasher
     91    else:
     92        log.warning('%s: no hash found' % (file_))
     93    return not failed
    5294
    5395def _http_parser(source, config, opts):
     
    174216            source['local_prefix'] = path.abspath(p)
    175217            source['local'] = local
     218            _hash_check(source['file'], local, config.macros)
    176219            break
    177220    source['script'] = ''
     
    258301            if not path.isfile(local):
    259302                raise error.general('source is not a file: %s' % (path.host(local)))
     303            if not _hash_check(path.basename(local), local, config.macros, False):
     304                raise error.general('checksum failure file: %s' % (dst))
    260305    return not failed
    261306
  • source-builder/sb/log.py

    rc49e500 ra083b52  
    8383def warning(text = os.linesep, log = None):
    8484    for l in text.replace(chr(13), '').splitlines():
    85         _output('warning: %s' % (l), log)
     85        notice('warning: %s' % (l), log)
    8686
    8787def flush(log = None):
  • source-builder/sb/setbuilder.py

    rc49e500 ra083b52  
    237237                    self.macros['package'] = self.bset_pkg
    238238                elif ls[0][0] == '%':
     239                    def err(msg):
     240                        raise error.general('%s:%d: %s' % (self.bset, lc, msg))
    239241                    if ls[0] == '%define':
    240242                        if len(ls) > 2:
     
    250252                    elif ls[0] == '%include':
    251253                        configs += self.parse(ls[1].strip())
    252                     elif ls[0] == '%patch' or ls[0] == '%source':
    253                         def err(msg):
    254                             raise error.general('%s:%d: %s' % (self.bset, lc, msg))
     254                    elif ls[0] in ['%patch', '%source']:
    255255                        sources.process(ls[0][1:], ls[1:], self.macros, err)
     256                    elif ls[0] == '%hash':
     257                        sources.hash(ls[1:], self.macros, err)
    256258                else:
    257259                    l = l.strip()
  • source-builder/sb/sources.py

    rc49e500 ra083b52  
    7373        return setup(label, args[1:], macros, error)
    7474    error('invalid %%%s command: %s' % (label, args[0]))
     75
     76def hash(args, macros, error):
     77    args = _args(args)
     78    if len(args) != 3:
     79        error('invalid number of hash args')
     80    _map = 'hashes'
     81    _file = macros.expand(args[1])
     82    if _file in macros.map_keys(_map):
     83        error('hash already set: %s' % (args[1]))
     84    macros.create_map(_map)
     85    macros.set_write_map(_map)
     86    macros.define(_file, '%s %s' % (args[0], args[2]))
     87    macros.unset_write_map()
     88    return None
Note: See TracChangeset for help on using the changeset viewer.