aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/package85
-rw-r--r--bpkg/package.ixx2
-rw-r--r--bpkg/package.xml21
-rw-r--r--tests/repository/1/status/extra/libbar-1.1.0+1.tar.gzbin0 -> 243 bytes
-rw-r--r--tests/repository/1/status/extra/libbar-1.1.0-1.tar.gzbin242 -> 0 bytes
-rw-r--r--tests/repository/1/status/testing/libbar-1.0.0+1.tar.gzbin0 -> 243 bytes
-rw-r--r--tests/repository/1/status/testing/libbar-1.0.0-1.tar.gzbin244 -> 0 bytes
-rwxr-xr-xtests/test.sh12
8 files changed, 88 insertions, 32 deletions
diff --git a/bpkg/package b/bpkg/package
index 734cacb..318f09d 100644
--- a/bpkg/package
+++ b/bpkg/package
@@ -18,7 +18,7 @@
#include <bpkg/types>
#include <bpkg/utility>
-#pragma db model version(1, 1, closed)
+#pragma db model version(1, 1, open)
namespace bpkg
{
@@ -64,8 +64,10 @@ namespace bpkg
{
uint16_t epoch;
string canonical_upstream;
+ string canonical_release;
uint16_t revision;
string upstream;
+ string release;
};
}
@@ -86,12 +88,12 @@ namespace bpkg
// version
//
// Sometimes we need to split the version into two parts: the part
- // that goes into the object id (epoch, canonical upstream, revision)
- // and the original upstream. This is what the canonical_version and
- // upstream_version value types are for. Note that upstream_version
- // derives from version and uses it as storage. The idea here is this:
- // when we split the version, we often still want to have the "whole"
- // version object readily accessible and that's exactly what this
+ // that goes into the object id (epoch, canonical upstream, canonical
+ // release, revision) and the original upstream and release. This is what
+ // the canonical_version and upstream_version value types are for. Note that
+ // upstream_version derives from version and uses it as storage. The idea
+ // here is this: when we split the version, we often still want to have the
+ // "whole" version object readily accessible and that's exactly what this
// strange contraption is for. See available_package for an example
// on how everything fits together.
//
@@ -101,15 +103,31 @@ namespace bpkg
{
uint16_t epoch;
string canonical_upstream;
+
+ // By a fluke SQLite 3 uses BINARY collation for UTF-8-encoded TEXT columns
+ // by default. So no need to adjust it to make "absent" and specified
+ // canonical releases to compare properly. But better to keep an eye on
+ // it not to miss a moment if SQLite plug UCA-compliant collation.
+ // Note: PostgreSQL uses UCA-compliant one by default for UTF8-encoded
+ // TEXT columns.
+ //
+ // Unicode Collation Algorithm (UCA): http://unicode.org/reports/tr10/
+ //
+ string canonical_release;
+
uint16_t revision;
};
#pragma db value transient
struct upstream_version: version
{
- #pragma db member(upstream_) virtual(string) \
- get(this.upstream) \
- set(this = bpkg::version (0, std::move (?), 0))
+ #pragma db member(upstream_) virtual(string) \
+ get(this.upstream) \
+ set(this = bpkg::version (0, std::move (?), "~", 0))
+
+ #pragma db member(release_) virtual(string) \
+ get(this.release) \
+ set(this = bpkg::version (0, this.upstream, std::move (?), 0))
upstream_version () = default;
upstream_version (version v): version (move (v)) {}
@@ -119,17 +137,23 @@ namespace bpkg
void
init (const canonical_version& cv, const upstream_version& uv)
{
- *this = version (cv.epoch, uv.upstream, cv.revision);
- assert (cv.canonical_upstream == canonical_upstream);
+ *this = version (cv.epoch, uv.upstream, uv.release, cv.revision);
+ assert (cv.canonical_upstream == canonical_upstream &&
+ cv.canonical_release == canonical_release);
}
};
- #pragma db map type(version) as(_version) \
- to(bpkg::_version{(?).epoch, \
- (?).canonical_upstream, \
- (?).revision, \
- (?).upstream}) \
- from(bpkg::version ((?).epoch, std::move ((?).upstream), (?).revision))
+ #pragma db map type(version) as(_version) \
+ to(bpkg::_version{(?).epoch, \
+ (?).canonical_upstream, \
+ (?).canonical_release, \
+ (?).revision, \
+ (?).upstream, \
+ (?).release}) \
+ from(bpkg::version ((?).epoch, \
+ std::move ((?).upstream), \
+ std::move ((?).release), \
+ (?).revision))
// repository_location
@@ -461,9 +485,9 @@ namespace bpkg
// Version comparison operators.
//
// They allow comparing objects that have epoch, canonical_upstream,
- // and revision data members. The idea is that this works for both
- // query members of types version and canonical_version as well as
- // for comparing canonical_version to version.
+ // canonical_release, and revision data members. The idea is that this
+ // works for both query members of types version and canonical_version
+ // as well as for comparing canonical_version to version.
//
template <typename T1, typename T2>
inline auto
@@ -471,6 +495,7 @@ namespace bpkg
{
return x.epoch == y.epoch &&
x.canonical_upstream == y.canonical_upstream &&
+ x.canonical_release == y.canonical_release &&
x.revision == y.revision;
}
@@ -480,6 +505,7 @@ namespace bpkg
{
return x.epoch != y.epoch ||
x.canonical_upstream != y.canonical_upstream ||
+ x.canonical_release != y.canonical_release ||
x.revision != y.revision;
}
@@ -490,7 +516,9 @@ namespace bpkg
return x.epoch < y.epoch ||
(x.epoch == y.epoch && x.canonical_upstream < y.canonical_upstream) ||
(x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
- x.revision < y.revision);
+ x.canonical_release < y.canonical_release) ||
+ (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
+ x.canonical_release == y.canonical_release && x.revision < y.revision);
}
template <typename T1, typename T2>
@@ -500,7 +528,9 @@ namespace bpkg
return x.epoch < y.epoch ||
(x.epoch == y.epoch && x.canonical_upstream < y.canonical_upstream) ||
(x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
- x.revision <= y.revision);
+ x.canonical_release < y.canonical_release) ||
+ (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
+ x.canonical_release == y.canonical_release && x.revision <= y.revision);
}
template <typename T1, typename T2>
@@ -510,7 +540,9 @@ namespace bpkg
return x.epoch > y.epoch ||
(x.epoch == y.epoch && x.canonical_upstream > y.canonical_upstream) ||
(x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
- x.revision > y.revision);
+ x.canonical_release > y.canonical_release) ||
+ (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
+ x.canonical_release == y.canonical_release && x.revision > y.revision);
}
template <typename T1, typename T2>
@@ -520,7 +552,9 @@ namespace bpkg
return x.epoch > y.epoch ||
(x.epoch == y.epoch && x.canonical_upstream > y.canonical_upstream) ||
(x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
- x.revision >= y.revision);
+ x.canonical_release > y.canonical_release) ||
+ (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
+ x.canonical_release == y.canonical_release && x.revision >= y.revision);
}
template <typename T>
@@ -531,6 +565,7 @@ namespace bpkg
return "ORDER BY"
+ x.epoch + "DESC,"
+ x.canonical_upstream + "DESC,"
+ + x.canonical_release + "DESC,"
+ x.revision + "DESC";
}
}
diff --git a/bpkg/package.ixx b/bpkg/package.ixx
index 8d1c219..32d79f4 100644
--- a/bpkg/package.ixx
+++ b/bpkg/package.ixx
@@ -9,7 +9,7 @@ namespace bpkg
inline available_package_id::
available_package_id (string n, const bpkg::version& v)
: name (move (n)),
- version {v.epoch, v.canonical_upstream, v.revision}
+ version {v.epoch, v.canonical_upstream, v.canonical_release, v.revision}
{
}
}
diff --git a/bpkg/package.xml b/bpkg/package.xml
index 9ac6a3a..f2c470c 100644
--- a/bpkg/package.xml
+++ b/bpkg/package.xml
@@ -49,12 +49,15 @@
<column name="name" type="TEXT" null="true"/>
<column name="version_epoch" type="INTEGER" null="true"/>
<column name="version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="version_canonical_release" type="TEXT" null="true"/>
<column name="version_revision" type="INTEGER" null="true"/>
<column name="version_upstream" type="TEXT" null="true"/>
+ <column name="version_release" type="TEXT" null="true"/>
<primary-key>
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
</primary-key>
</table>
@@ -62,6 +65,7 @@
<column name="name" type="TEXT" null="true"/>
<column name="version_epoch" type="INTEGER" null="true"/>
<column name="version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="version_canonical_release" type="TEXT" null="true"/>
<column name="version_revision" type="INTEGER" null="true"/>
<column name="repository" type="TEXT" null="true"/>
<column name="location" type="TEXT" null="true"/>
@@ -69,11 +73,13 @@
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
<references table="available_package">
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
</references>
</foreign-key>
@@ -81,6 +87,7 @@
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
</index>
<foreign-key name="repository_fk" deferrable="DEFERRED">
@@ -94,6 +101,7 @@
<column name="name" type="TEXT" null="true"/>
<column name="version_epoch" type="INTEGER" null="true"/>
<column name="version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="version_canonical_release" type="TEXT" null="true"/>
<column name="version_revision" type="INTEGER" null="true"/>
<column name="index" type="INTEGER" null="true"/>
<column name="conditional" type="INTEGER" null="true"/>
@@ -102,11 +110,13 @@
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
<references table="available_package">
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
</references>
</foreign-key>
@@ -114,6 +124,7 @@
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
</index>
<index name="available_package_dependencies_index_i">
@@ -124,6 +135,7 @@
<column name="name" type="TEXT" null="true"/>
<column name="version_epoch" type="INTEGER" null="true"/>
<column name="version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="version_canonical_release" type="TEXT" null="true"/>
<column name="version_revision" type="INTEGER" null="true"/>
<column name="dependency_index" type="INTEGER" null="true"/>
<column name="index" type="INTEGER" null="true"/>
@@ -131,17 +143,21 @@
<column name="dep_operation" type="TEXT" null="true"/>
<column name="dep_version_epoch" type="INTEGER" null="true"/>
<column name="dep_version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="dep_version_canonical_release" type="TEXT" null="true"/>
<column name="dep_version_revision" type="INTEGER" null="true"/>
<column name="dep_version_upstream" type="TEXT" null="true"/>
+ <column name="dep_version_release" type="TEXT" null="true"/>
<foreign-key name="object_id_fk" on-delete="CASCADE">
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
<references table="available_package">
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
</references>
</foreign-key>
@@ -149,6 +165,7 @@
<column name="name"/>
<column name="version_epoch"/>
<column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
<column name="version_revision"/>
</index>
</table>
@@ -156,8 +173,10 @@
<column name="name" type="TEXT" null="true"/>
<column name="version_epoch" type="INTEGER" null="true"/>
<column name="version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="version_canonical_release" type="TEXT" null="true"/>
<column name="version_revision" type="INTEGER" null="true"/>
<column name="version_upstream" type="TEXT" null="true"/>
+ <column name="version_release" type="TEXT" null="true"/>
<column name="state" type="TEXT" null="true"/>
<column name="hold_package" type="INTEGER" null="true"/>
<column name="hold_version" type="INTEGER" null="true"/>
@@ -177,8 +196,10 @@
<column name="operation" type="TEXT" null="true"/>
<column name="version_epoch" type="INTEGER" null="true"/>
<column name="version_canonical_upstream" type="TEXT" null="true"/>
+ <column name="version_canonical_release" type="TEXT" null="true"/>
<column name="version_revision" type="INTEGER" null="true"/>
<column name="version_upstream" type="TEXT" null="true"/>
+ <column name="version_release" type="TEXT" null="true"/>
<foreign-key name="package_fk" on-delete="CASCADE">
<column name="package"/>
<references table="selected_package">
diff --git a/tests/repository/1/status/extra/libbar-1.1.0+1.tar.gz b/tests/repository/1/status/extra/libbar-1.1.0+1.tar.gz
new file mode 100644
index 0000000..890e9e2
--- /dev/null
+++ b/tests/repository/1/status/extra/libbar-1.1.0+1.tar.gz
Binary files differ
diff --git a/tests/repository/1/status/extra/libbar-1.1.0-1.tar.gz b/tests/repository/1/status/extra/libbar-1.1.0-1.tar.gz
deleted file mode 100644
index 09ffc97..0000000
--- a/tests/repository/1/status/extra/libbar-1.1.0-1.tar.gz
+++ /dev/null
Binary files differ
diff --git a/tests/repository/1/status/testing/libbar-1.0.0+1.tar.gz b/tests/repository/1/status/testing/libbar-1.0.0+1.tar.gz
new file mode 100644
index 0000000..5794085
--- /dev/null
+++ b/tests/repository/1/status/testing/libbar-1.0.0+1.tar.gz
Binary files differ
diff --git a/tests/repository/1/status/testing/libbar-1.0.0-1.tar.gz b/tests/repository/1/status/testing/libbar-1.0.0-1.tar.gz
deleted file mode 100644
index e8a54ca..0000000
--- a/tests/repository/1/status/testing/libbar-1.0.0-1.tar.gz
+++ /dev/null
Binary files differ
diff --git a/tests/test.sh b/tests/test.sh
index 8b391d1..e6a0a10 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -679,22 +679,22 @@ stat libfoo "fetched 1.0.0"
test cfg-create --wipe
test cfg-add $rep/status/extra
test cfg-fetch
-stat libbar "available 1.1.0-1"
+stat libbar "available 1.1.0+1"
test cfg-add $rep/status/stable
test cfg-fetch
-stat libbar "available 1.1.0-1 1.0.0"
+stat libbar "available 1.1.0+1 1.0.0"
test cfg-create --wipe
test cfg-add $rep/status/testing
test cfg-fetch
-stat libbar "available 1.1.0 1.0.0-1 1.0.0"
+stat libbar "available 1.1.0 1.0.0+1 1.0.0"
test cfg-create --wipe
test cfg-add $rep/status/unstable
test cfg-fetch
-stat libbar "available 2.0.0 1.1.0 1.0.0-1 1.0.0"
-test pkg-fetch libbar/1.0.0-1
-stat libbar "fetched 1.0.0-1; available 2.0.0 1.1.0"
+stat libbar "available 2.0.0 1.1.0 1.0.0+1 1.0.0"
+test pkg-fetch libbar/1.0.0+1
+stat libbar "fetched 1.0.0+1; available 2.0.0 1.1.0"
test pkg-purge libbar
test pkg-fetch libbar/2.0.0
stat libbar "fetched 2.0.0"