Commit 3b6108db authored by Steven Arnow's avatar Steven Arnow

Switched dependency checking to libdbpmgr in dbp-run

parent b0226691
VALAC = valac
VALAPKG = --pkg=gio-2.0 --target-glib 2.32 --pkg glib-2.0 --pkg=gtk+-3.0 --pkg=posix --pkg=dbp
VALAFLAGS = --vapidir=./common -X -I../libdbpbase -X -I../build/include --thread -X -DGETTEXT_PACKAGE=\"dbp-run\" -X -L../build/lib
DEPCHECKSRC = dep-check/dep-check.vala
LIBS = -X -larchive -X -ldbpmgr -X -ldbpbase
BINPATH = ../build/bin
all:
@echo " [VALA] dbp-run.vala"
@$(VALAC) -o $(BINPATH)/dbp-run $(VALAPKG) $(VALAFLAGS) dbp-run.vala common/*.vala -X common/*.c $(DEPCHECKSRC) $(VALASTATICLIBS) $(LIBS)
@$(VALAC) -o $(BINPATH)/dbp-run $(VALAPKG) $(VALAFLAGS) dbp-run.vala common/*.vala $(VALASTATICLIBS) $(LIBS)
@echo " [VALA] dbp-run-path.vala"
@$(VALAC) -o $(BINPATH)/dbp-run-path $(VALAPKG) $(VALAFLAGS) dbp-run-path.vala common/*.vala -X common/*.c $(DEPCHECKSRC) $(VALASTATICLIBS) $(LIBS)
@$(VALAC) -o $(BINPATH)/dbp-run-path $(VALAPKG) $(VALAFLAGS) dbp-run-path.vala common/*.vala $(VALASTATICLIBS) $(LIBS)
@echo "Done."
clean:
......
......@@ -142,6 +142,25 @@ namespace DBP {
namespace Depend {
[CCode (cname = "dbpmgr_depend_debian_check")]
bool debian_check(string? package_string);
[CCode (cname = "struct DBPDependList", has_type_id = false, destroy_function = "", default_value = "{}")]
public struct ListEntry {
[CCode (array_length_cname = "depends", array_length_type = "int")]
string?[] depend;
}
[CCode (cname = "struct DBPDependListList", free_function = "dbpmgr_depend_delete_list_ptr")]
[Compact]
public class List {
[CCode (cname = "dbpmgr_depend_check")]
public List(DBP.Desktop df);
public ListEntry sysonly;
public ListEntry dbponly;
public ListEntry syspref;
public ListEntry dbppref;
public ListEntry whatevs;
}
}
[CCode (cheader_filename = "dbpmgr/dbpmgr.h", cprefix = "dbpmgr_server_")]
......
#include <stdio.h>
FILE *dbp_error_log;
\ No newline at end of file
......@@ -36,11 +36,10 @@ namespace Run {
}
bool dependency_ok(string pkg_id, DBP.Meta.Package pkg, bool gui_errors) throws IOError {
string[] sysdeps, dbpdeps, sysmissing, dbpmissing;
string sysdep, dbpdep, pkgarch;
string[] sysmissing = {}, dbpmissing = {};
string pkgarch;
DBP.Depend.List deplist = new DBP.Depend.List(pkg.desktop_file);
sysdep = pkg.desktop_file.lookup("SysDependency", "", "Package Entry");
dbpdep = pkg.desktop_file.lookup("PkgDependency", "", "Package Entry");
pkgarch = pkg.desktop_file.lookup("Arch", "", "Package Entry");
if (pkgarch == null || pkgarch == "")
pkgarch = "any";
......@@ -53,17 +52,17 @@ namespace Run {
throw new IOError.FAILED(_("This package is not supported on your system architecture") + "\n" + _("Package is for") + " " + pkgarch);
}
if (sysdep != null) {
sysdeps = sysdep.split(";");
sysmissing = DepCheck.check_sys_dep(sysdeps, pkgarch);
} else
sysmissing = {};
if (dbpdep != null) {
dbpdeps = dbpdep.split(";");
dbpmissing = DepCheck.check_dbp_dep(dbpdeps);
} else
dbpmissing = {};
foreach (string s in deplist.sysonly.depend)
sysmissing += s;
foreach (string s in deplist.syspref.depend)
sysmissing += s;
foreach (string s in deplist.dbponly.depend)
dbpmissing += s;
foreach (string s in deplist.dbppref.depend)
dbpmissing += s;
foreach (string s in deplist.whatevs.depend)
dbpmissing += s;
if (dbpmissing.length > 0 || sysmissing.length > 0) {
string err;
......
namespace DepCheck {
string[] check_dbp_dep(string[] dep) throws IOError {
string[] missing = { };
foreach (string s in dep) {
/* check if the package is present */
string path;
int err = DBP.ServerAPI.path_from_id(s, out path);
if (err < 0)
missing += s;
}
return missing;
}
string[] check_sys_dep(string[] deps, string pkgarch) {
// DBP.DebDepCheck.do_init();
string[] missing = { };
foreach (string s in deps) {
if (!DBP.Depend.debian_check(s))
missing += s;
}
// DBP.DebDepCheck.do_free();
return missing;
}
}
......@@ -519,7 +519,7 @@ static void addto_list(struct DBPDependList *list, const char *str) {
}
void dbpmgr_depend_delete_list(struct DBPDependList *list) {
static void dbpmgr_depend_delete_list(struct DBPDependList *list) {
int i;
for (i = 0; i < list->depends; i++)
......@@ -528,15 +528,25 @@ void dbpmgr_depend_delete_list(struct DBPDependList *list) {
}
void dbpmgr_depend_delete_list_ptr(struct DBPDependListList *list) {
dbpmgr_depend_delete_list(&list->sysonly);
dbpmgr_depend_delete_list(&list->syspref);
dbpmgr_depend_delete_list(&list->dbponly);
dbpmgr_depend_delete_list(&list->dbppref);
dbpmgr_depend_delete_list(&list->whatevs);
free(list);
}
void dbpmgr_depend_cleanup() {
free_node(debian_root), debian_root = NULL;
free_node(dbp_root), dbp_root = NULL;
}
struct DBPDependListList dbpmgr_depend_check(struct DBPDesktopFile *meta) {
struct DBPDependListList *dbpmgr_depend_check(struct DBPDesktopFile *meta) {
char *sysonly, *dbponly, *prefsys, *prefdbp, *whatevs;
struct DBPDependListList list, missing;
struct DBPDependListList list, missing, *missing_ptr;
int i;
sysonly = dbp_desktop_lookup(meta, "Dependency", "deb", "Package Entry");
......@@ -571,9 +581,16 @@ struct DBPDependListList dbpmgr_depend_check(struct DBPDesktopFile *meta) {
if (!dbpmgr_depend_dbp_check(list.whatevs.depend[i]))
if (!dbpmgr_depend_debian_check(list.whatevs.depend[i]))
addto_list(&missing.whatevs, list.whatevs.depend[i]);
dbpmgr_depend_delete_list(&list.sysonly), dbpmgr_depend_delete_list(&list.syspref);
dbpmgr_depend_delete_list(&list.dbponly), dbpmgr_depend_delete_list(&list.dbppref);
dbpmgr_depend_delete_list(&list.whatevs);
dbpmgr_depend_cleanup();
return list;
missing_ptr = malloc(sizeof(*missing_ptr));
*missing_ptr = missing;
return missing_ptr;
}
......
......@@ -33,12 +33,12 @@ bool dbpmgr_depend_debian_check(const char *package_string);
struct DBPDepend *dbpmgr_depend_parse(const char *package_string);
void dbpmgr_depend_free(struct DBPDepend *dep);
void dbpmgr_depend_version_result_compare(int result, enum DBPMgrDependVersionCheck check);
struct DBPDependListList dbpmgr_depend_check(struct DBPDesktopFile *meta);
struct DBPDependListList *dbpmgr_depend_check(struct DBPDesktopFile *meta);
/* After doing package dependency checking, run free to unload databases */
void dbpmgr_depend_cleanup();
struct DBPDependDPackage *dbpmgr_depend_debian_next(const char *pkg_name, struct DBPDependDPackage *prev);
void dbpmgr_depend_delete_list(struct DBPDependList *list);
void dbpmgr_depend_delete_list_ptr(struct DBPDependListList *list);
#endif
CFLAGS += -DVERSION=\"0.6.10\"
CFLAGS += -DVERSION=\"0.6.11-volatile\"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment