'Gets the urls for the scratch packages specified in pkg
:type pkg: KojiScratchPkgSpec
:param pkg: a scratch package specification
:type arch: string
:param arch: packages built for this architecture, but also including
architecture independent (noarch) packages'

def get_scratch_pkg_urls(self, pkg, arch=None):

    rpm_urls = []
    if (arch is None):
        arch = utils.get_arch()
    arches = [arch, 'noarch']
    index_url = ('%s/%s/task_%s' % (self.get_scratch_base_url(), pkg.user, pkg.task))
    index_parser = KojiDirIndexParser()
    index_parser.feed(urllib.urlopen(index_url).read())
    if pkg.subpackages:
        for p in pkg.subpackages:
            for pfn in index_parser.package_file_names:
                r = RPMFileNameInfo(pfn)
                info = r.get_nvr_info()
                if ((p == info['name']) and (r.get_arch() in arches)):
                    rpm_urls.append(('%s/%s' % (index_url, pfn)))
    else:
        for pfn in index_parser.package_file_names:
            if (RPMFileNameInfo(pfn).get_arch() in arches):
                rpm_urls.append(('%s/%s' % (index_url, pfn)))
    return rpm_urls
