cec595b267a0dae66dab498417df29b3bb8b60d0
braney
Wed Sep 2 10:21:29 2026 -0700
trackDb: rsync to the destination string as it stands, refs #35489 #38211
Code review noted that "${dest%%:*}:${dest#*:}/" is hard to read. It is also
a no-op. It takes the machine:path string apart at the first colon and puts
it back together with a colon, which is the same string as "$dest/".
diff --git src/hg/makeDb/trackDb/buildTrix src/hg/makeDb/trackDb/buildTrix
index 3fb75ece067..acd2e9c416f 100755
--- src/hg/makeDb/trackDb/buildTrix
+++ src/hg/makeDb/trackDb/buildTrix
@@ -1,80 +1,80 @@
#!/bin/bash -e
usage='buildTrix [options] trixName metaDbName path_to_cv.ra outputMachine outputPath ${DBS}
options:
-alsoTo=machine:path -- copy the same files to another machine and path as well.
May be given more than once. Using this instead of a second
invocation avoids rebuilding the index from scratch.'
dests=()
while [[ $1 == -* ]] ; do
case $1 in
-alsoTo=*)
dests+=("${1#-alsoTo=}") ;;
*)
echo "invalid option: $1" >&2
exit 1 ;;
esac
shift
done
if [ $# -lt 6 ] ; then
echo "wrong # args: $usage" >&2
exit 1
fi
trixName="$1"; shift
metaDbName="$1" ; shift
cvRaPath="$1" ; shift
outMachine="$1" ; shift
outPath="$1" ; shift
dbs="$@"
dests=("$outMachine:$outPath" "${dests[@]}")
# check if a database exists, print note and return non-zero if it doesn't
dbExists() {
local db="$1"
local dbChk=$(/cluster/bin/x86_64/hgsql -Ne 'show databases like "'$db'"')
if [ -z "$dbChk" ] ; then
echo "Note: database $db does not exist, skipping"
return 1
else
return 0
fi
}
buildDbTrix() {
local db="$1"
local trixName="$2"
local metaDbName="$3"
local cvRaPath="$4"
# Build into a temporary directory using the final file names, so that each
# destination takes one rsync instead of one per file. That is five fewer ssh
# connections per destination, which matters when this make runs in parallel.
local tmpDir=`mktemp -d`;
local base="$tmpDir/${db}_${trixName}"
/cluster/bin/x86_64/makeTrackIndex $db $metaDbName $cvRaPath > $base.txt;
if test -s $base.txt; then
/cluster/bin/x86_64/ixIxx -maxWordLength=64 $base.txt $base.ix $base.ixx
# trixContextIndex makes the $db_$trixName.offsets and $db_$trixName.offsets.ixx files:
/cluster/bin/x86_64/trixContextIndex $base.txt $base
chmod 664 $base.txt $base.ix $base.ixx $base.offsets $base.offsets.ixx
# the .txt, .offsets and .offsets.ixx files are for snippets on search pages:
# Name the files explicitly rather than rsyncing $tmpDir/ itself. With a
# directory as the source, rsync also applies -a to the destination
# directory, and setting its times fails unless we own it.
local dest
for dest in "${dests[@]}"; do
rsync -a $base.txt $base.ix $base.ixx $base.offsets $base.offsets.ixx \
- "${dest%%:*}:${dest#*:}/"
+ "$dest/"
done
fi
rm -rf $tmpDir
}
for db in $dbs ; do
if dbExists $db ; then
buildDbTrix $db $trixName $metaDbName $cvRaPath
fi
done