--- /dev/null
+Packages are sqlite databases
+
+get application id and userver
+
+Primitive operations:
+
+add blob to repo
+add path to repo
+associate path with package
+associate blob with path?
+extract blob to a path
+compare blob to filesystem path
+create package with info
+
+Extra primitives:
+
+record elf information about blob
+compress blob
+uncompress blob
+sign a package? What are we verifying?
+
+Signatures
+----------
+
+things:
+
+files, just a table of file contents, hash to content,
+avoids redundancy. possibly type? size? internal compression?
+blobs might make more sense as a name.
+
+package files: table of pathnames in a package, with metadata
+file hash, type (directory, file, symlink, etc), permissions,
+owner, group, acls?, config file, and package name...
+
+create table paths (
+ path text,
+ mode integer, -- perms, use text for octal rep?
+ hash text, -- what should go here, null for dir
+ mtime integer -- seconds since epoch, but allow finer?
+);
+
+create table packagefiles (
+ package text,
+ subpackage text, -- libs, dev, client, server, whatever
+ path text,
+ filetype text -- e.g. config, etc?
+);
+
+-- TODO just elf information?
+create table libraries (
+ package text,
+ subpackage text,
+ path text,
+ soname text
+);
+
+create table librarydeps (
+ package text,
+ subpackage text,
+ path text,
+ soname text -- soname of dependency
+);
+
+-- package scripts: table of package, stage, file
+create table scripts (
+ package text,
+ subpackage text,
+ hash text
+);
+
+-- package dependencies: table of package, dependency, dep type (package, soname)
+create table packagedeps (
+ package text,
+ subpackage text,
+ requires text, -- package name
+ subreq text, -- if requires only a sub package, probably most common for libs
+ minversion text,
+ maxversion text
+);
+
+-- capability labels
+create table provides (
+ package text,
+ subpackage text,
+ label text -- a capability label
+);
+
+create table requires (
+ package text,
+ subpackage text,
+ label text -- a capability label
+);
+
+create table packages (
+ package text,
+ version text, -- the upstream version string
+ release integer, -- the local release number
+ description text,
+ architecture text,
+ url text,
+ licenses text, -- hash of actual license? need table for more than one?
+ packager text,
+ build_date integer,
+ install_date integer
+);
+
+create table packagegroups (
+ package text,
+ group text
+);
+
+packages: table of package info
+name, version, release,
+tied package? i.e. another package/version/release this one goes with.
+
+Actual Package Install DB:
+--------------------------
+
+packages table:
+package, name, version, release, install ts, uninstall/upgrade ts
+
+contents table:
+from package files table in package, plus install info
+
+Installing a Package
+--------------------
+
+insert into DB.packages the package info from the .zpkg file, leave install date null
+extract the pre-install script and run it. abort if exit failure
+insert into the contents table info from the ZP.packagefiles table
+for each file in the new contents, extract the file to a temporary location
+in the same directory, rename into place, update as installed
+for each file in the old contents, remove the file if it's not in the new contents
+delete the row from the contents table
+update the uninstall and install ts as a single transaction
+extract and run post-install script
+
+pre/post install scripts get arguments:
+package name, new version, new release, old version, old release
+old version/release only if upgrade.