diff --git a/osc/commandline.py b/osc/commandline.py index 82df3375..bb0528a9 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -7518,8 +7518,10 @@ Please submit there instead, or use --nodevelproject to force direct submission. if package is None: + package_specified = False package = meta_get_packagelist(apiurl, project, deleted=0) else: + package_specified = True if opts.multibuild_package: packages = [] for subpackage in opts.multibuild_package: @@ -7546,12 +7548,6 @@ Please submit there instead, or use --nodevelproject to force direct submission. for i in binaries: if binary != None and binary != i.name: continue - # skip metadata (unless explicitly specified as the `FILE` (== `binary`) argument) - if not binary and i.name.startswith("_"): - continue - # skip logs (unless explicitly specified as the `FILE` (== `binary`) argument) - if not binary and i.name.endswith(".log"): - continue # skip source rpms if not opts.sources and (i.name.endswith('src.rpm') or i.name.endswith('sdeb')): continue @@ -7560,7 +7556,18 @@ Please submit there instead, or use --nodevelproject to force direct submission. continue if i.name.find('-debugsource-') >= 0: continue - fname = '%s/%s' % (target_dir, i.name) + + if package_specified: + # if package is specified, download everything into the target dir + fname = '%s/%s' % (target_dir, i.name) + elif i.name.startswith("_") or i.name.endswith(".log"): + # download logs and metadata into subdirs + # to avoid overwriting them with files with indentical names + fname = '%s/%s/%s' % (target_dir, pac, i.name) + else: + # always download packages into the target dir + fname = '%s/%s' % (target_dir, i.name) + if os.path.exists(fname): st = os.stat(fname) if st.st_mtime == i.mtime and st.st_size == i.size: diff --git a/osc/core.py b/osc/core.py index 5ef2aa64..89931e6f 100644 --- a/osc/core.py +++ b/osc/core.py @@ -4747,6 +4747,15 @@ def get_binary_file(apiurl, prj, repo, arch, target_filename = target_filename or filename + # create target directory if it doesn't exist + target_dir = os.path.dirname(target_filename) + if target_dir: + try: + os.makedirs(target_dir, 0o755) + except OSError as e: + if e.errno != errno.EEXIST: + raise + where = package or '_repository' u = makeurl(apiurl, ['build', prj, repo, arch, where, filename]) download(u, target_filename, progress_obj, target_mtime)