Example #1
0
    def download(self, urldata, d):
        dldir = d.getVar('DL_DIR')

        m = __pattern__.match(urldata.url)
        path = m.group('path')
        host = m.group('host')
        port = m.group('port')
        user = m.group('user')
        password = m.group('pass')

        if port:
            portarg = '-P %s' % port
        else:
            portarg = ''

        if user:
            fr = user
            if password:
                fr += ':%s' % password
            fr += '@%s' % host
        else:
            fr = host

        if path[0] != '~':
            path = '/%s' % path
        path = path.replace("%3A", ":")

        fr += ':%s' % path

        cmd = 'scp -B -r %s %s %s/' % (portarg, fr, dldir)

        check_network_access(d, cmd, urldata.url)

        runfetchcmd(cmd, d)
Example #2
0
        def _npm_view():
            args = []
            args.append(("json", "true"))
            args.append(("registry", ud.registry))
            pkgver = shlex.quote(ud.package + "@" + ud.version)
            cmd = ud.basecmd + " view %s" % pkgver
            env = NpmEnvironment(d)
            check_network_access(d, cmd, ud.registry)
            view_string = env.run(cmd, args=args)

            if not view_string:
                raise FetchError("Unavailable package %s" % pkgver, ud.url)

            try:
                view = json.loads(view_string)

                error = view.get("error")
                if error is not None:
                    raise FetchError(error.get("summary"), ud.url)

                if ud.version == "latest":
                    bb.warn("The npm package %s is using the latest " \
                            "version available. This could lead to " \
                            "non-reproducible builds." % pkgver)
                elif ud.version != view.get("version"):
                    raise ParameterError("Invalid 'version' parameter", ud.url)

                return view

            except Exception as e:
                raise FetchError("Invalid view from npm: %s" % str(e), ud.url)
Example #3
0
    def checkstatus(self, fetch, urldata, d):
        """
        Check the status of the url
        """
        m = __pattern__.match(urldata.url)
        path = m.group('path')
        host = m.group('host')
        port = m.group('port')
        user = m.group('user')
        password = m.group('pass')

        if port:
            portarg = '-P %s' % port
        else:
            portarg = ''

        if user:
            fr = user
            if password:
                fr += ':%s' % password
            fr += '@%s' % host
        else:
            fr = host

        if path[0] != '~':
            path = '/%s' % path
        path = path.replace("%3A", ":")

        cmd = 'ssh -o BatchMode=true %s %s [ -f %s ]' % (portarg, fr, path)

        check_network_access(d, cmd, urldata.url)

        if runfetchcmd(cmd, d):
            return True

        return False