Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install both copr-backend and copr-dist-git #3007

Closed
Bob131 opened this issue Nov 20, 2023 · 3 comments
Closed

Cannot install both copr-backend and copr-dist-git #3007

Bob131 opened this issue Nov 20, 2023 · 3 comments

Comments

@Bob131
Copy link
Contributor

Bob131 commented Nov 20, 2023

I'm experimenting with a very small deployment of Copr where it's convenient to just set up all the services on a single machine, but copr-backend and copr-dist-git can't be installed together due to both containing a script at /usr/bin/copr-run-dispatcher. It would be nice if this restriction could be lifted.

On the off chance it helps, I have a patch for unifying the two scripts. I've just attached it rather than opening a PR since I was having trouble figuring out how to contribute with the current setup in this repo. The patch applies to adfc60b.

diff --git a/backend/run/copr-run-dispatcher b/backend/run/copr-run-dispatcher
deleted file mode 100755
index 7bfec897..00000000
--- a/backend/run/copr-run-dispatcher
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/python3
-
-"""
-Simple wrapper around our Dispatcher classed that is used to start the
-dispatchers from our systemd unit files.
-"""
-
-import sys
-
-from copr_backend.daemons.action_dispatcher import ActionDispatcher
-from copr_backend.daemons.build_dispatcher import BuildDispatcher
-from copr_backend.helpers import get_backend_opts
-
-
-def _main():
-    dispatcher = None
-    request = sys.argv[1]
-    if request == "actions":
-        dispatcher = ActionDispatcher
-    elif request == "builds":
-        dispatcher = BuildDispatcher
-    else:
-        raise NotImplementedError(
-            "Not implemented '{}' dispatcher".format(request))
-
-    dispatcher(backend_opts=get_backend_opts()).run()
-
-
-if __name__ == "__main__":
-    _main()
diff --git a/common/python-copr-common.spec b/common/python-copr-common.spec
index e48e61e7..d93b88f6 100644
--- a/common/python-copr-common.spec
+++ b/common/python-copr-common.spec
@@ -108,6 +108,7 @@ version=%version %py2_install
 %files -n python3-%{srcname}
 %license LICENSE
 %{python3_sitelib}/*
+%{_bindir}/*
 %endif
 
 
@@ -115,6 +116,7 @@ version=%version %py2_install
 %files -n python2-%{srcname}
 %license LICENSE
 %{python2_sitelib}/*
+%{_bindir}/*
 %endif
 
 
diff --git a/common/run/copr-run-dispatcher b/common/run/copr-run-dispatcher
new file mode 100644
index 00000000..4fb31a6f
--- /dev/null
+++ b/common/run/copr-run-dispatcher
@@ -0,0 +1,38 @@
+#! /usr/bin/python3
+
+"""
+Simple wrapper around our Dispatcher classed that is used to start the
+dispatchers from our systemd unit files.
+"""
+
+import sys
+
+
+def _main():
+    request = sys.argv[1]
+    if request == "actions" or request == "builds":
+        from copr_backend.daemons.action_dispatcher import ActionDispatcher
+        from copr_backend.daemons.build_dispatcher import BuildDispatcher
+        from copr_backend.helpers import get_backend_opts
+
+        dispatcher = None
+        if request == "actions":
+            dispatcher = ActionDispatcher
+        elif request == "builds":
+            dispatcher = BuildDispatcher
+
+        dispatcher(backend_opts=get_backend_opts()).run()
+    elif request == "imports":
+        from copr_dist_git.helpers import get_distgit_opts
+        from copr_dist_git.import_dispatcher import ImportDispatcher
+
+        config = "/etc/copr/copr-dist-git.conf"
+        opts = get_distgit_opts(config)
+        ImportDispatcher(opts).run()
+    else:
+        raise NotImplementedError(
+            "Not implemented '{}' dispatcher".format(request))
+
+
+if __name__ == "__main__":
+    _main()
diff --git a/common/setup.py b/common/setup.py
index 083393aa..33e5aa38 100644
--- a/common/setup.py
+++ b/common/setup.py
@@ -31,6 +31,7 @@ setup(
         "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
     ],
     packages=['copr_common'],
+    scripts=[os.path.join("run", p) for p in os.listdir("run")],
     include_package_data=True,
     zip_safe=False
     )
diff --git a/dist-git/run/copr-run-dispatcher b/dist-git/run/copr-run-dispatcher
deleted file mode 100755
index 73501ea2..00000000
--- a/dist-git/run/copr-run-dispatcher
+++ /dev/null
@@ -1,28 +0,0 @@
-#! /usr/bin/python3
-
-"""
-Simple wrapper around our Dispatcher classed that is used to start the
-dispatchers from our systemd unit files.
-"""
-
-import sys
-from copr_dist_git.helpers import get_distgit_opts
-from copr_dist_git.import_dispatcher import ImportDispatcher
-
-
-def _main():
-    dispatcher = None
-    request = sys.argv[1]
-    if request == "imports":
-        dispatcher = ImportDispatcher
-    else:
-        raise NotImplementedError(
-            "Not implemented '{}' dispatcher".format(request))
-
-    config = "/etc/copr/copr-dist-git.conf"
-    opts = get_distgit_opts(config)
-    dispatcher(opts).run()
-
-
-if __name__ == "__main__":
-    _main()
@praiskup
Copy link
Member

It would be nice if this restriction could be lifted.

Thank you for the report and patch. I agree. Would you mind providing a proper pull-request? That would help us a lot.

@praiskup
Copy link
Member

One issue after a quick patch review: please don't move the script from dist-git to common.

@Bob131
Copy link
Contributor Author

Bob131 commented Nov 20, 2023

Would you mind providing a proper pull-request? That would help us a lot.

Sure.

One issue after a quick patch review: please don't move the script from dist-git to common.

I'm not really sure what you mean, but this discussion may as well happen on the PR.

Bob131 added a commit to Bob131/copr that referenced this issue Nov 20, 2023
A hurdle when trying to stand-up a simple single-machine Copr
deployment is that both the copr-backend and copr-dist-git packages
install a script to /usr/bin/copr-run-dispatcher, preventing the user
from asking that both be installed on the same system with dnf.

This commit unifies the two scripts into a single script and has it
shipped as part of python-copr-common instead.

Fixes fedora-copr#3007.
@nikromen nikromen moved this from Needs triage to Someday in future in CPT Kanban Nov 22, 2023
Bob131 added a commit to Bob131/copr that referenced this issue Dec 5, 2023
A hurdle when trying to stand-up a simple single-machine Copr
deployment is that both the copr-backend and copr-dist-git packages
install a script to /usr/bin/copr-run-dispatcher, preventing the user
from asking that both be installed on the same system with dnf.

This commit renames the script from backend and dist-git to
copr-run-dispatcher-backend and copr-run-dispatcher-dist-git
respectively.

Fixes fedora-copr#3007.
@praiskup praiskup moved this from Someday in future to Done in CPT Kanban Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants