tClean existing code and set goals - pm - barely a pack manager
HTML git clone git://z3bra.org/pm
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit fbd4d728ef17718ed7ee6ac2629ac3913111ff79
DIR parent b524aa9f8ac73b9a4c65824380ed5375f6fcef5c
HTML Author: z3bra <willyatmailoodotorg>
Date: Wed, 23 Dec 2015 10:36:08 +0100
Clean existing code and set goals
Diffstat:
A README | 30 ++++++++++++++++++++++++++++++
M pm.c | 68 ++++++++++++++++++++++++-------
2 files changed, 84 insertions(+), 14 deletions(-)
---
DIR diff --git a/README b/README
t@@ -0,0 +1,30 @@
+# pm
+
+A package manager.
+
+## features
+
+0. install
+ 0.0 resolve dependencies
+ 0.1 differenciate explicit install and deps
+ 0.2 recall installed files
+ 0.3 recall dependencies
+ 0.4 accept multiple repositories (order matter)
+ 0.5 NEVER overwrite an existing file
+1. update
+ 1.0 check versions from a local file
+ 1.1 update repo by downloading a newer version
+ 1.2 assume repo to have the latest version
+ 1.3 warn about dep/filesystem changes
+ 1.4 NEVER overwrite an existing file
+2. remove
+ 2.0 remove deps not needed by other packages
+ 2.1 remove directories left empty (two-pass removal)
+3. list
+ 2.0 list packages in repo
+ 2.1 list files in packages (cache needed for remote)
+ 2.2 list dependencies of a package (tree view)
+4. metadata
+ 4.0 store everything into a single directory
+ 4.1 $ROOT/pm.d/$pkg/{deps,files,version[,explicit]}
+ 4.2 cache packages locally
DIR diff --git a/pm.c b/pm.c
t@@ -9,24 +9,40 @@
#include "arg.h"
-#define PACKAGE_ROOT "."
+#define PACKAGE_ROOT_DIR "."
#define PACKAGE_BUFF_SIZE 8192
+/* possible actions */
+enum {
+ ACTION_INSTALL = 0,
+ ACTION_REMOVE = 1,
+ ACTION_UPDATE = 2,
+ ACTION_INSPECT = 3,
+ ACTION_LIST_FILES = 4,
+ ACTION_LIST_DEPS = 5,
+ ACTION_LIST_LOCAL = 6,
+ ACTION_LIST_REMOTE = 7,
+ ACTION_PACKAGE = 8,
+ ACTION_INVALID = 9
+};
+
+enum {
+ ERROR_INVALID_ACTION = 1,
+};
char *argv0;
void
usage(char *name)
{
- fprintf(stderr, "usage: %s -cel <archive> [files..]\n", name);
- exit(1);
+ fprintf(stderr, "usage: %s -aci <package> [files..]\n" , name);
}
/*
* output the content of an archive
*/
int
-inspect(char *filename)
+inspect(const char *filename)
{
struct archive *a;
struct archive_entry *e;
t@@ -168,24 +184,49 @@ unpack(char *root, const char *in)
int
main (int argc, char **argv)
{
- const char *fn;
+ const char *packname;
+ uint8_t action;
ARGBEGIN{
case 'c':
if (argc <3) /* what a cute variable */
usage(argv0);
- fn = ARGF();
- pack(fn, ++argv);
+ action = ACTION_PACKAGE;
+ packname = ARGF();
break;
- case 'e':
- unpack(PACKAGE_ROOT, EARGF(usage(argv0)));
+ case 'a':
+ action = ACTION_INSTALL;
+ packname = EARGF(usage(argv0));
break;
- case 'l':
- inspect(EARGF(usage(argv0)));
+ case 'i':
+ action = ACTION_INSPECT;
+ packname = EARGF(usage(argv0));
break;
- default:
+ case 'h':
usage(argv0);
+ return 0;
+ default:
+ action = ACTION_INVALID;
}ARGEND;
+ switch (action) {
+ case ACTION_INSTALL:
+ return unpack(PACKAGE_ROOT_DIR, packname);
+ case ACTION_INSPECT:
+ return inspect(packname);
+ case ACTION_PACKAGE:
+ return pack(packname, argv);
+ /* handle me, Octave */
+ case ACTION_REMOVE:
+ case ACTION_UPDATE:
+ case ACTION_LIST_FILES:
+ case ACTION_LIST_DEPS:
+ case ACTION_LIST_LOCAL:
+ case ACTION_LIST_REMOTE:
+ default:
+ usage(argv0);
+ exit(ERROR_INVALID_ACTION);
+ }
+
return 0;
-}
-\ No newline at end of file
+}