Change package-exists to return section/description
[hcoop/domtool2.git] / src / main.sml
index 4b8123d..e2df22b 100644 (file)
@@ -795,10 +795,13 @@ fun requestAptExists {node, pkg} =
                         OS.Process.failure)
              | SOME m =>
                case m of
-                   MsgYes => (print "Package exists.\n";
-                              OS.Process.success)
+                   MsgAptQuery {section,description}  =>  (print "Package exists.\n";
+                                                           print ("Section: " ^ section ^ "\n");
+                                                           print ("Description: " ^ description ^ "\n");
+                                                           OS.Process.success)
                  | MsgNo => (print "Package does not exist.\n";
-                             OS.Process.failure)
+                             OS.Process.failure
+                            (* It might be the Wrong Thing (tm) to use MsgNo like this *))
                  | MsgError s => (print ("APT existence query failed: " ^ s ^ "\n");
                                   OS.Process.failure)
                  | _ => (print "Unexpected server reply.\n";
@@ -1213,7 +1216,9 @@ fun now () = Date.toString (Date.fromTimeUniv (Time.now ()))
 fun answerQuery q =
     case q of
        QApt pkg => if Apt.installed pkg then MsgYes else MsgNo
-      | QAptExists pkg => if Apt.exists pkg then MsgYes else MsgNo
+      | QAptExists pkg => (case Apt.info pkg of
+                             SOME {section, description} => MsgAptQuery {section = section, description = description}
+                           | NONE => MsgNo)
       | QCron user => if Cron.allowed user then MsgYes else MsgNo
       | QFtp user => if Ftp.allowed user then MsgYes else MsgNo
       | QTrustedPath user => if TrustedPath.query user then MsgYes else MsgNo