[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#771864: libdebian-installer - dependency resolver support excluding packages



Package: libdebian-installer
Severity: wishlist

Not tagging patch, as the patch is obviously not finished,
feel free to extend it, just did enough now so that I could
get cdebootstrap working with jessie. I don't think I will
have time to implement the plumbing for the full exclude
functionality, but the patch below is enough to prove that
excluding packages isn't that hard or intrusive to add.

IMHO jessie is effectively systemd only, when jessie sysvinit
images are only buildable with a custom libdebian-installer
package.


diff --git a/src/package_parser.c b/src/package_parser.c
index 6d6a5e7..990cd03 100644
--- a/src/package_parser.c
+++ b/src/package_parser.c
@@ -265,7 +265,7 @@ void di_package_parser_read_dependency (
   internal_di_package_parser_data *parser_data = user_data;
   di_package *p = *data, *q;
   char *cur = value->string, *end = value->string + value->size;
-  char *namebegin, *fieldend;
+  char *namebegin, *fieldend, *fieldpipe;
   size_t namelen;
   di_package_dependency *d, *d1;
 
@@ -278,6 +278,24 @@ void di_package_parser_read_dependency (
     namebegin = cur;
     namelen = strcspn (cur, " \t\n(,|");
 
+    /* XXX hardcoded to only and always exclude systemd-sysv
+     * TODO expose an exclude API that cdebootstrap can use */
+
+    /* check if package should be excluded */
+    if (namelen == sizeof("systemd-sysv") - 1
+        && memcmp(cur, "systemd-sysv", namelen) == 0) {
+      /* take next option */
+      fieldpipe = cur + strcspn(cur, "|");
+      fieldend = cur + strcspn (cur, "\n,");
+      if (fieldpipe < fieldend) {
+       printf("alternative exists\n");
+        /* only obey if an alternative exists */
+        while (isspace(*++fieldpipe));
+        cur = fieldpipe;
+        continue;
+      }
+    }
+
     d = di_package_dependency_alloc (parser_data->allocator);
 
     if (parser_data->packages)

-- 
Best regards
Asbjørn Sloth Tønnesen

Reply to: