[elbe-devel] [PATCH v3 08/52] prjrepo: add support for .changes files to "elbe prjrepo upload_pkg"

dion at linutronix.de dion at linutronix.de
Thu Jun 27 14:44:22 CEST 2019


From: Torben Hohn <torben.hohn at linutronix.de>

.changes files are pretty similar to .dsc files
Collect the files referenced in them, and upload them into the prjdir.
Then call "reprepro include" to add the changes.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
Reviewed-by: Kurt Kanzenbach <kurt at linutronix.de>
---
 docs/elbe-prjrepo.txt      |  8 +++++---
 elbepack/projectmanager.py |  9 ++++++---
 elbepack/soapclient.py     | 10 +++++++---
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/docs/elbe-prjrepo.txt b/docs/elbe-prjrepo.txt
index db37034c..17d66783 100644
--- a/docs/elbe-prjrepo.txt
+++ b/docs/elbe-prjrepo.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'elbe prjrepo download' <project_dir>
-'elbe prjrepo upload_pkg' <project_dir> [<debfile> | <dscfile>]
+'elbe prjrepo upload_pkg' <project_dir> [<debfile> | <dscfile> | <changesfile>]
 'elbe prjrepo list_packages' <project_dir>
 
 DESCRIPTION
@@ -44,13 +44,15 @@ Downloads the Debian repository of the project located in <project_dir> to the
 host machine.
 
 
-'upload_pkg' <project_dir> [<debfile> | <dscfile>]::
+'upload_pkg' <project_dir> [<debfile> | <dscfile> | <changesfile>]::
 
 Loads a Debian package into the Debian repository of an existing Elbe project in
 the initvm. Both binary and source packages are supported. In order to upload a
 source package you need to specify the dsc-file in the command as shown above.
 The actual source files which are required for the source package need to be
-located in the same directory as the dsc-file.
+located in the same directory as the dsc-file. The same is true for a changes
+file.  The actual files defined in the changes file need to reside in the same
+directory.
 
 
 'list_packages' <project_dir>::
diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
index 0e22fb7e..49cc2945 100644
--- a/elbepack/projectmanager.py
+++ b/elbepack/projectmanager.py
@@ -498,15 +498,18 @@ class ProjectManager(object):
     def add_deb_package(self, userid, filename):
         ep = self._get_current_project(userid)
 
-        t = filename[-3:]  # filetype of uploaded file
+        t = os.path.splitext(filename)[1]  # filetype of uploaded file
         pkg_name = filename.split('_')[0]
 
-        if t == 'dsc':
+        if t == '.dsc':
             ep.repo.includedsc(os.path.join(ep.builddir, filename),
                                force=True)
-        elif t == 'deb':
+        elif t == '.deb':
             ep.repo.includedeb(os.path.join(ep.builddir, filename),
                                pkgname=pkg_name, force=True)
+        elif t == '.changes':
+            ep.repo.include(os.path.join(ep.builddir, filename),
+                            force=True)
 
         ep.repo.finalize()
 
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index 2a857f94..43b8f6e2 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -928,7 +928,7 @@ class UploadPackageAction(RepoAction):
     def execute(self, client, _opt, args):
         if len(args) != 2:
             print(
-                "usage: elbe prjrepo upload_pkg <project_dir> <deb/dsc file>",
+                "usage: elbe prjrepo upload_pkg <project_dir> <deb/dsc/changes file>",
                 file=sys.stderr)
             sys.exit(20)
 
@@ -943,8 +943,8 @@ class UploadPackageAction(RepoAction):
         filetype = os.path.splitext(filename)[1]
 
         # Check filetype
-        if filetype not in ['.dsc', '.deb']:
-            print("Error: Only .dsc and .deb files allowed to upload.")
+        if filetype not in ['.dsc', '.deb', '.changes']:
+            print("Error: Only .dsc, .deb or .changes files allowed to upload.")
             sys.exit(20)
 
         files = [filename]  # list of all files which will be uploaded
@@ -954,6 +954,10 @@ class UploadPackageAction(RepoAction):
             for f in deb822.Dsc(file(filename))['Files']:
                 files.append(f['name'])
 
+        if filetype == '.changes':
+            for f in deb822.Changes(file(filename))['Files']:
+                files.append(f['name'])
+
         # Check whether all files are available
         abort = False
         for f in files:
-- 
2.11.0




More information about the elbe-devel mailing list