Spkg
I don't plan to talk about/support archives explicitly (yet). There is more to spkg than that, such as removals and facilitating searching through metadata. Data will be read/written to a generic intermediate buffer then we can plugin archivers afterwards. Mnemoc will appreciating avoiding stdio anyway. (:
Proposed base structures
struct spkg_dep; struct spkg_file; struct spkg_md5; struct spkg; struct spkg_db;
struct spkg_db
The db just contains the packages installed on the system, and a table with all the “owned” files (with the file name as key and its owner).
struct spkg_db { struct tree pkgs; struct htable fltbl; };
struct spkg
The 'spkg' package structure contains the package name and its dependencies. It also contains a list of files the package owns (symlist, flist, dirlist). These are the three major types of file. They classified as such because the removal priorities differ– you don't remove a directory then the file in it.
struct spkg { /* independant of archive etc */ struct node self; /* node in spkg_db */ char name[PKG_NAME_MAX]; struct list deps; /* list of this packages dependencies */ struct list flist; /* list of files with sum (node = struct spkg_file_sum) */ struct list symlist; /* list of symlinks (node = struct spkg_file) */ struct list dirlist; /* list of directories (node = struct spkg_file) */ /* * metadata */ char *title; /* I tag */ char *text; /* T tag */ char *version; /*V tag */ char *url; /* U tag */ char *author; /* A tag */ char *maintainer; /* M tag */ char *category; /* C tag */ char *license; /* L tag */ char *stability; /*S tag */ size_t files; /* number of files the pkg owns. */ size_t kbytes; /* file size in kb */ };
struct spkg_file
A file contains the filename and and the owner. A file is in an entry in the spkg db (spkg_db→fltbl). In this context the filename is a key used to provide “which package owns this file?” functionality.
It is also used within a package itself as nodes in list of symlinks (spkg→symlist) and list of directories (spkg→dirlist).
struct spkg_file { struct node self; /* node in spkg_db->fltbl */ struct node selfL; /* node in spkg->{f,dir,sum}list */ char *fname; /* name of file */ struct spkg *owner; };
struct spkg_file_md5
This inherits the node structure of spkg_file but includes an extra field “md5” used to check if the the file has been modified. It is a node in spkg→flist.
struct spkg_file_md5 { struct spkg_file self; uint32_t md5[4]; }
struct spkg_dep
This is just a node in spkg→deps which contains the name of a package its owner depends upon. Currently we don't support depedencies particularily well. In the future, this may have an additional field to identify the type of dependency … and be used to generate dependancy graphs when more worthwhile.
struct spkg_dep { struct node self; /* node in spkg->deps */ char *depname; /* name of package that owner depends upon */ };