zpm-quote: zpm-quote.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+db.sql: schema/main.sql schema/syncconflicts.sql
+ echo 'begin;' > $@
+ cat $+ >> $@
+ echo 'commit;' >> $@
+
newdb.c: db.sql
echo "char createdb[] = {" > $@
xxd -i < $< >> $@
rm -f *.o sqlite/*.o lib/*.o $(LZMAOBJ) liblzma.a \
libelf.a libzpm.a zpm-addfile soname \
*.xz \
- local.db t/ctap/prove.o $(ZPKGBIN)
+ local.db t/ctap/prove.o $(ZPKGBIN) \
+ db.sql
-begin;
-
PRAGMA application_id = 0x5a504442;
PRAGMA user_version = 1;
package text,
version text,
release integer,
- requires text, -- package name (only)
- minimum text,
- maximum text,
+ requires text, -- package, can be partial
primary key (package,version,release,package),
foreign key (package,version,release) references packages (package,version,release) on delete cascade on update cascade
);
repository text references repository
);
-create view syncconflicts as
-with
--- metadata different
-md_conflict as (
- select path, count(distinct
- printf('%s:%s:%s:%s', PFA.filetype, PFA.mode, PFA.username, PFA.groupname)) as mdcount,
- count(distinct PFA.hash) as hashcount
- from packagefiles PFA
- join packages PA
- on PA.package = PFA.package and PA.version = PFA.version and PA.release = PFA.release
- where PA.status in ('installing', 'installed')
- group by path
- having (count(distinct printf('%s:%s:%s:%s', PFA.filetype, PFA.mode, PFA.username, PFA.groupname)
- ) > 1 or count(distinct PFA.hash) > 1)
-)
-select PFH.*,
- printf('%s-%s-%s', PFH.package, PFH.version, PFH.release) as pkgid,
- printf('%s:%s:%s:%s', PFH.filetype, PFH.mode, PFH.username, PFH.groupname) as mds,
-'hash' as conflict
-from packagefiles PFH
-where path in (select path from md_conflict where hashcount > 1)
-union
-select PFM.*,
- printf('%s-%s-%s', PFM.package, PFM.version, PFM.release) as pkgid,
- printf('%s:%s:%s:%s', PFM.filetype, PFM.mode, PFM.username, PFM.groupname) as mds,
-'md' as conflict
-from packagefiles PFM
-where path in (select path from md_conflict where mdcount > 1)
-;
create view needed_libraries as
with recursive
-- left join packages P on P.package = PFP.package ...
-- where P.status not in ('installed','installing')
;
-
-commit;
--- /dev/null
+create view syncconflicts as
+with
+-- metadata different
+md_conflict as (
+ select path, count(distinct
+ printf('%s:%s:%s:%s', PFA.filetype, PFA.mode, PFA.username, PFA.groupname)) as mdcount,
+ count(distinct PFA.hash) as hashcount
+ from packagefiles PFA
+ join packages PA
+ on PA.package = PFA.package and PA.version = PFA.version and PA.release = PFA.release
+ where PA.status in ('installing', 'installed')
+ group by path
+ having (count(distinct printf('%s:%s:%s:%s', PFA.filetype, PFA.mode, PFA.username, PFA.groupname)
+ ) > 1 or count(distinct PFA.hash) > 1)
+)
+select PFH.*,
+ printf('%s-%s-%s', PFH.package, PFH.version, PFH.release) as pkgid,
+ printf('%s:%s:%s:%s', PFH.filetype, PFH.mode, PFH.username, PFH.groupname) as mds,
+'hash' as conflict
+from packagefiles PFH
+ join packages PA
+ on PA.package = PFH.package and PA.version = PFH.version and PA.release = PFH.release
+where path in (select path from md_conflict where hashcount > 1)
+ and PA.status in ('installing', 'installed')
+union
+select PFM.*,
+ printf('%s-%s-%s', PFM.package, PFM.version, PFM.release) as pkgid,
+ printf('%s:%s:%s:%s', PFM.filetype, PFM.mode, PFM.username, PFM.groupname) as mds,
+'md' as conflict
+from packagefiles PFM
+ join packages PA
+ on PA.package = PFM.package and PA.version = PFM.version and PA.release = PFM.release
+where path in (select path from md_conflict where hashcount > 1)
+ and PA.status in ('installing', 'installed')
+;