socsvn commit: r254232 - soc2013/mattbw/backend/actions

mattbw at FreeBSD.org mattbw at FreeBSD.org
Sat Jul 6 09:35:57 UTC 2013


Author: mattbw
Date: Sat Jul  6 09:35:57 2013
New Revision: 254232
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254232

Log:
  install-packages seems to work enough to install packages now

Modified:
  soc2013/mattbw/backend/actions/install-packages.c

Modified: soc2013/mattbw/backend/actions/install-packages.c
==============================================================================
--- soc2013/mattbw/backend/actions/install-packages.c	Sat Jul  6 09:22:42 2013	(r254231)
+++ soc2013/mattbw/backend/actions/install-packages.c	Sat Jul  6 09:35:57 2013	(r254232)
@@ -32,6 +32,8 @@
 static gboolean	body(struct query *q);
 static gboolean	sim_body(struct query *q);
 static void	do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate);
+static void	do_install_solved_job(struct pkg_jobs *jobs, PkBackend *backend, gboolean simulate);
+static void	do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend);
 static void	emit(struct pkg *pkg, const gchar *id, struct query *q);
 static void	job (struct pkg_jobs *jobs, struct query *q);
 static void	sim_emit(struct pkg *pkg, const gchar *id, struct query *q);
@@ -81,17 +83,18 @@
 	return query_emit_match(q, sim_emit);
 }
 
+/*
+ * Installs (or pretends to install) an unsolved installation job.
+ */
 static void
 do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate)
 {
-	int		err;
 	PkBackend      *backend;
 
 	backend = query_backend(q);
 
 	pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE);
-	err = pkg_jobs_solve(jobs);
-	if (err != EPKG_OK)
+	if (pkg_jobs_solve(jobs) != EPKG_OK)
 		pk_backend_error_code(backend,
 				      PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,
 				      "could not solve the job");
@@ -99,20 +102,42 @@
 		pk_backend_error_code(backend,
 				      PK_ERROR_ENUM_INTERNAL_ERROR,
 				      "job contains no packages");
-	else {
-		struct pkg     *pkg;
+	else
+		do_install_solved_job(jobs, backend, simulate);
+}
+
+/*
+ * Installs (or pretends to install) a fully solved installation job.
+ */
+static void
+do_install_solved_job(struct pkg_jobs *jobs,
+		      PkBackend *backend,
+		      gboolean simulate)
+{
+	struct pkg     *pkg;
 
-		pkg = NULL;
-		while (pkg_jobs(jobs, &pkg) == EPKG_OK)
-			pkgutils_emit(pkg,
-				      backend,
-				      pkgutils_pkg_install_state(pkg));
-
-		if (simulate == FALSE)
-			pk_backend_error_code(backend,
-					      PK_ERROR_ENUM_NOT_SUPPORTED,
-					      "not implemented yet");
-	}
+	pkg = NULL;
+	while (pkg_jobs(jobs, &pkg) == EPKG_OK)
+		pkgutils_emit(pkg,
+			      backend,
+			      pkgutils_pkg_install_state(pkg));
+
+	if (simulate == FALSE)
+		do_install_solved_job_real(jobs, backend);
+}
+
+/*
+ * Actually installs a fully solved installation job.
+ */
+static void
+do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend)
+{
+	
+	pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL);
+	if (pkg_jobs_apply(jobs) != EPKG_OK)
+		pk_backend_error_code(backend,
+				      PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL,
+				      "job failed");
 }
 
 /*


More information about the svn-soc-all mailing list