3 PRAGMA application_id = 0x5a504442;
4 PRAGMA user_version = 1;
6 -- should be faster with rowid due to the blob content
7 -- these are really just blobs of data
8 -- TODO copyright and license information should probably
11 hash text primary key, -- sha256 of content
12 size integer, -- bigint? certainly need > 2GB
13 compression text, -- always xz?
18 -- information about packages
19 -- a package is identified by a package,version,release triple
20 create table packages (
21 -- primary key columns
23 version text, -- the upstream version string
24 release integer, -- the local release number
25 pkgid text, -- the three above joined with '-'
32 licenses text, -- hash of actual license? need table for more than one?
34 build_time integer default (strftime('%s', 'now')),
36 checksum text, -- checksum of package contents. null for incompleted packages
37 primary key (package,version,release),
38 check (typeof(release) = 'integer'),
40 -- TODO enforce name and release conventions
45 -- handle package status history with a logging trigger.
46 create trigger logpkgstatus after update of status on packages
47 begin insert into zpmlog (action,target,info)
48 values (printf('status change %s %s', OLD.status, NEW.status),
49 printf('%s-%s-%s', NEW.package, NEW.version, NEW.release),
52 create table packagetags (
58 set_time integer default (strftime('%s', 'now')),
59 primary key (package,version,release,tag),
60 foreign key (package,version,release) references packages (package,version,release) on delete cascade
63 -- packagefile hash is columns as text, joined with null bytes, then
65 -- package checksum is package columns as text, joined with null bytes,
66 -- other than the checksum and install_time column
67 -- then that hashed. finally, that hash, plus the ascii sorted
68 -- hashes of the package files all joined with newlines, hashed.
69 -- really don't like this.
71 -- files contained in a package
72 create table packagefiles (
78 path text, -- filesystem path
79 mode text, -- perms, use text for octal rep?
80 username text, -- name of owner
81 groupname text, -- group of owner
82 uid integer, -- numeric uid, generally ignored
83 gid integer, -- numeric gid, generally ignored
84 filetype varchar default 'r',
88 -- h hard link -- not supported
89 -- c character special and b device special files add dev number column
91 -- p fifos (i.e. pipe)
92 target text, -- link target for links
93 -- device file dev numbers, should probably be a separate table
96 hash text, -- null if no actual content, i.e. anything but a regular file
97 mtime integer, -- seconds since epoch, finer resolution probably not needed
98 primary key (package,version,release,path),
99 foreign key (package,version,release) references packages (package,version,release) on delete cascade
104 create table pathtags (
110 path text, -- filesystem path
112 primary key (package,version,release,path,tag)
117 create table elfinfo (
118 file text primary key, -- hash of blob
120 foreign key (file) references files on delete cascade
125 create table elfdeps (
129 primary key (file, soname, dependency),
130 foreign key (file) references files on delete cascade
135 -- TODO just elf information?
136 -- and just hash, not package?
137 create table elflibraries (
138 file text primary key,
140 foreign key (file) references files on delete cascade
145 create table elfneeded (
147 needed text, -- soname of dependency
148 primary key (file, needed),
149 foreign key (file) references files on delete cascade
154 -- package scripts: table of package, stage, file
155 create table scripts (
163 -- package dependencies: table of package, dependency, dep type (package, soname)
164 create table packagedeps (
168 required text, -- package name
169 -- following can be null for not checked
177 create table provides (
180 label text -- a capability label
183 create table requires (
186 label text -- a capability label
189 create table packagegroups (
195 -- not sure how machine readable this needs to be,
196 -- do not at all for now, figure it out later
197 -- could be worth logging all commands in a history table,
198 -- the zpm driver could do that and capture the exit status
200 -- might want the history table to note a "group" to tie together
201 -- sub-invocations, probably an environment variable set if not
202 -- already set by zpm, probably a uuid or a timestamp
203 create table zpmlog (
204 ts text default (strftime('%Y-%m-%d %H:%M:%f', 'now')),
205 -- timestamp of action
207 target text, -- packagename, repo name, etc
208 info text -- human readable
211 create table history (
212 ts integer, -- again, probably needs timestamp sub second
218 create table repository (
219 name text primary key, -- our name for a repo
221 priority integer not null default 1,
222 refreshed integer -- last refresh time
225 -- urls for downloading packages. possibly unneeded
226 create table repository_packages (
228 pkg text, -- glob pattern? in which case others not needed
234 -- track which repository a package was cloned from, i.e. where we got it
235 create table packagesource (
239 repository text references repository