summaryrefslogtreecommitdiff
path: root/tools/collate
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-05-03 12:37:23 +1000
committerjacqueline <me@jacqueline.id.au>2024-05-03 12:37:23 +1000
commit964da15a0b84f8e5f00e8abac2f7dfda0bf60488 (patch)
tree4dc977f8789ca379cf8dc60c45eaa0fb57a9fce1 /tools/collate
parenta231fd1c8afedbeb14b0bc77d76bad61db986059 (diff)
downloadtangara-fw-964da15a0b84f8e5f00e8abac2f7dfda0bf60488.tar.gz
Add the collation partition to the build
Includes a small linux-only bash script to generate locale partitions
Diffstat (limited to 'tools/collate')
-rw-r--r--tools/collate/Generic.LC_COLLATEbin0 -> 2586938 bytes
-rw-r--r--tools/collate/README.md24
-rwxr-xr-xtools/collate/mkcollator.sh16
3 files changed, 40 insertions, 0 deletions
diff --git a/tools/collate/Generic.LC_COLLATE b/tools/collate/Generic.LC_COLLATE
new file mode 100644
index 00000000..aa21717a
--- /dev/null
+++ b/tools/collate/Generic.LC_COLLATE
Binary files differ
diff --git a/tools/collate/README.md b/tools/collate/README.md
new file mode 100644
index 00000000..268db5fd
--- /dev/null
+++ b/tools/collate/README.md
@@ -0,0 +1,24 @@
+This tool, which only works on Linux, uses your system's locale data to
+generate a collator partition for Tangara. This partition is uses to sort
+database information (album names, etc.) in a way that makes sense to humans.
+
+Because this script isn't portable, `Generic.LC_COLLATE` is included as a
+pregenerated collator partition that should work well for most people's
+music libraries.
+
+## Partition format
+
+The collator partition has 3MiB reserved for it in the partition table, which
+is enough to hold the compiled collation data for ISO14651 character sorting,
+plus a small amount of free space.
+
+The first 8 bytes of the partition are reserved for a partition name; usually
+the name of the locale that the collation data was compiled for, or 'Generic'
+for ISO14651 data.
+
+Following the 8 byte name, is a complete LC_COLLATE file, as generate by GNU
+libc's `localedef` utility. Debian's version 2.37 of this utility is known to
+work.
+
+FIXME: We should vendor this version of the tool, so that our format remains
+stable across glibc changes.
diff --git a/tools/collate/mkcollator.sh b/tools/collate/mkcollator.sh
new file mode 100755
index 00000000..e5962429
--- /dev/null
+++ b/tools/collate/mkcollator.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+set -eu
+
+if [ -z "${2:-}" ]; then
+ name="Generic"
+ locale="iso14651_t1"
+else
+ name="$1"
+ locale="$2"
+fi
+
+working_dir=$(mktemp -d)
+
+echo -n "$name" | dd iflag=fullblock bs=8 count=1 conv=sync of="$working_dir/name"
+localedef -f UTF-8 -i "$locale" --no-archive "$working_dir" || true
+cat "$working_dir/name" "$working_dir/LC_COLLATE" > "$name.LC_COLLATE"