Initial commit of inapt, declarative DSL for apt
authorMichael Spang <mspang@csclub.uwaterloo.ca>
Sat, 7 Nov 2009 21:36:23 +0000 (16:36 -0500)
committerMichael Spang <mspang@csclub.uwaterloo.ca>
Tue, 22 Dec 2009 03:09:20 +0000 (22:09 -0500)
Signed-off-by: Michael Spang <mspang@csclub.uwaterloo.ca>
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
magic.cc [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..719b46d
--- /dev/null
@@ -0,0 +1,4 @@
+*.aux
+*.log
+*.pdf
+magic
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..f9fbc31
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,5 @@
+magic: magic.cc
+       g++ -o magic -g3 -Wall -Werror -lapt-pkg -lapt-inst magic.cc
+clean:
+       rm -f magic
+
diff --git a/magic.cc b/magic.cc
new file mode 100644 (file)
index 0000000..3e7d76b
--- /dev/null
+++ b/magic.cc
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cachefile.h>
+#include <apt-pkg/dpkgdb.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/init.h>
+#include <apt-pkg/error.h>
+
+int main(int argc, char *argv[]) {
+
+    pkgInitConfig(*_config);
+    pkgInitSystem(*_config, _system);
+
+    OpTextProgress prog;
+    pkgCacheFile cache;
+
+    if (cache.Open(prog) == false) {
+       _error->DumpErrors();
+        exit(1);
+    }
+
+    fprintf(stderr, "%lud\n", cache->BrokenCount());
+}