copr: be: hotfix for issue 1213

This commit is contained in:
Pavel Raiskup 2020-01-17 14:52:32 +01:00 committed by Pierre-Yves Chibon
parent 541a4f70f3
commit 46ec931235
2 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,45 @@
--- /usr/bin/copr-repo 2020-01-15 08:23:09.000000000 +0000
+++ /usr/bin/copr-repo 2020-01-17 01:07:57.791459957 +0000
@@ -148,6 +148,12 @@
def add_appdata(opts):
if opts.devel or opts.no_appstream_metadata:
+ opts.log.info("appstream-builder skipped, devel or "
+ "--no-appstream-metadata")
+ return
+
+ if os.path.exists(os.path.join(opts.projectdir, ".disable-appstream")):
+ opts.log.info("appstream-builder skipped, .disable-appstream file")
return
path = opts.directory
@@ -199,6 +205,9 @@
# To avoid race conditions, remove the directories _after_ we have
# successfully generated the new repodata.
for subdir in opts.delete:
+ if not subdir or '..' in subdir:
+ raise Exception("removal of \"%s\" subdir requested", subdir)
+
opts.log.info("removing %s subdirectory", subdir)
try:
shutil.rmtree(os.path.join(opts.directory, subdir))
@@ -244,6 +253,7 @@
def process_directory_path(opts):
helper_path = os.path.abspath(opts.directory)
helper_path, opts.chroot = os.path.split(helper_path)
+ opts.projectdir = helper_path
helper_path, opts.dirname = os.path.split(helper_path)
helper_path, opts.ownername = os.path.split(helper_path)
opts.projectname = opts.dirname.split(':')[0]
@@ -257,6 +267,11 @@
# try to setup logging based on copr-be.conf
process_backend_config(opts)
+ # argument parsing
+ if '' in opts.add or '' in opts.delete:
+ opts.log.error("'' dir addition/removal requested")
+ return 1
+
# resolve absolute path from opts.directory, and detect
# ownername, dirname, chroot, etc. from it
process_directory_path(opts)

View file

@ -33,6 +33,11 @@
# dest=/usr/bin/prunerepo
# tags: patches
- name: issue 1213
patch: src=patches/fixup-copr-repo-script.patch
dest=/usr/bin/copr-repo
tags: patches
- name: install openstackclient for image preparation
dnf: state=present name=python3-openstackclient
when: devel|bool