package text not null,
version text not null, -- the upstream version string
release integer not null, -- the local release number
--- pkgid text, -- the three above joined with '-'
-- metadata columns
description text,
packager text,
build_time integer default (strftime('%s', 'now')),
install_time integer,
- checksum text, -- checksum of package contents. null for incompleted packages
+ hash text, -- see integ.c for package hash details
primary key (package,version,release),
check (typeof(package) = 'text'),
check (typeof(version) = 'text'),
check (typeof(release) = 'integer'),
- check (release > 0)
- -- TODO enforce name and version conventions
- -- check(instr(version,'-') = 0)
- -- check(instr(package,'/') = 0)
- -- check(instr(package,'/') = 0)
- -- check(instr(version,' ') = 0)
- -- check(instr(package,' ') = 0)
- -- check(instr(package,' ') = 0)
- -- check(length(package) < 64)
- -- check(length(version) < 32)
+ check (release > 0),
+ -- enforce name and version conventions
+ check(instr(package,' ') = 0),
+ check(instr(package,'/') = 0),
+ check(instr(package,':') = 0),
+ check(instr(version,' ') = 0),
+ check(instr(version,'-') = 0),
+ check(instr(version,'/') = 0),
+ check(instr(version,':') = 0),
+ check(length(package) < 64),
+ check(length(package) > 0),
+ check(length(version) < 32),
+ check(length(version) > 0)
)
without rowid
;
select printf('%s-%s-%s', package, version, release) as pkgid, *
from packages;
+create trigger packages_delete_trigger instead of
+delete on packages_pkgid
+begin
+ delete from packages where package = OLD.package
+ and version = OLD.version and release = OLD.release;
+end;
+
create trigger packages_update_trigger instead of
update on packages_pkgid
begin
packager = NEW.packager,
build_time = NEW.build_time,
install_time = NEW.install_time,
- checksum = NEW.checksum
+ hash = NEW.hash
where package = OLD.package
and version = OLD.version
and release = OLD.release
foreign key (package,version,release) references packages (package,version,release) on delete cascade on update cascade
);
--- packagefile hash is columns as text, joined with null bytes, then
--- sha256 sum of that
--- package checksum is package columns as text, joined with null bytes,
--- other than the checksum and install_time column
--- then that hashed. finally, that hash, plus the ascii sorted
--- hashes of the package files all joined with newlines, hashed.
--- really don't like this.
-
-- files contained in a package
create table packagefiles (
-- package id triple
-- d directory
-- s symlink
-- h hard link -- not supported
- -- c character special and b device special files add dev number column
- -- b block special
- -- p fifos (i.e. pipe)
+ -- c character special -- not supported
+ -- b block special -- not supported
+ -- c and b device special files add dev number column
+ -- p fifos (i.e. pipe) -- not supported
target text, -- link target for links
- -- device file dev numbers, should probably be a separate table
+ -- device file dev numbers
devmajor integer,
devminor integer,
- hash text, -- null if no actual content, i.e. anything but a regular file
- mtime integer, -- seconds since epoch, finer resolution probably not needed
+ hash text, -- null if not a regular file
+ mtime integer, -- seconds since epoch, finer resolution not needed
primary key (package,version,release,path),
- foreign key (package,version,release) references packages (package,version,release) on delete cascade on update cascade,
+ foreign key (package,version,release)
+ references packages (package,version,release)
+ on delete cascade on update cascade,
check (not (filetype = 'l' and target is null)),
+ check (not (filetype = 'h' and target is null)),
+ check (target is null or length(target) between 1 and 4095),
+ check (hash is null or length(hash) between 1 and 1024),
check (not (filetype = 'r' and hash is null)),
check (not (filetype = 'c' and (devmajor is null or devminor is null))),
check (not (filetype = 'b' and (devmajor is null or devminor is null))),
+ check (filetype in ('r','d','s','h','c','b','p')),
+ check(length(username) between 1 and 256),
+ check(length(groupname) between 1 and 256),
check (configuration = 0 or configuration = 1)
)
without rowid
;
+
create index packagefile_package_index on packagefiles (package);
create index packagefile_path_index on packagefiles (path);
create index packagefile_hash_index on packagefiles (hash);