summaryrefslogtreecommitdiff
path: root/bin/poolify
diff options
context:
space:
mode:
Diffstat (limited to 'bin/poolify')
-rwxr-xr-xbin/poolify54
1 files changed, 36 insertions, 18 deletions
diff --git a/bin/poolify b/bin/poolify
index 6f9a109..b49cbd9 100755
--- a/bin/poolify
+++ b/bin/poolify
@@ -1,4 +1,10 @@
#!/usr/bin/env bash
+# Copyright (c) 2017, 2023 Luke Shumaker <lukeshu@lukeshu.com>
+#
+# This work is free. You can redistribute it and/or modify it under
+# the terms of the Do What The Fuck You Want To Public License,
+# Version 2, as published by Sam Hocevar. See the COPYING file for
+# more details.
url2murl() {
local x
@@ -13,14 +19,27 @@ main() {
set -euE -o pipefail
shopt -s nullglob
- echo '# Pass 1'
- declare -A rewrite
- rewrite[200109261739]=200303310700
- while read -r snap name date time size; do
+ arg_metadata_txt=$1
+ arg_index_txt=$2
+
+ # Overrides ############################################################
+
+ declare -A override_datetime
+ override_datetime[200109261739]=200303310700
+
+ override_synthetic_listings=(
+ #YYYYMMDDHHMM branch_name newfiles
+ '200307291500 ALPHA/CVTUTF-1-1 ExpectedOutput.txt readme.txt'
+ )
+
+ # Main #################################################################
+
+ echo '# Pass 1 (initialize snapshots from $arg_metadata_txt)'
+ while read -r snap name date time; do
dirpart="${name%/*}"
filepart="${name##*/}"
datetime="${date//-/}${time//:/}"
- datetime="${rewrite[$datetime]:-$datetime}"
+ datetime="${override_datetime[$datetime]:-$datetime}"
filedir=dat/pools/files/"${datetime}-${name//\//_}"
snapdir=dat/pools/snaps/"${snap}-${dirpart//\//_}"
if [[ -d "${filedir/.OLD/}" ]]; then
@@ -28,9 +47,9 @@ main() {
fi
mkdir -p -- "$filedir" "$snapdir"
ln -sr "$filedir/$filepart" "$snapdir"
- done < "$1"
+ done < "$arg_metadata_txt"
- echo '# Pass 1.5'
+ echo '# Pass 1.5 (initialize synthetic snapshots)'
# Looking at the data, there are 3 revisions that we DON'T
# have directory listings for. So we need to synthesize
# those.
@@ -39,7 +58,8 @@ main() {
# synthesizing anything, then looking for files ending in
# ".1". They are created during pass 2 if we have a file with
# no matching listing.
- while read -r datetime dirpart newfiles; do
+ for line in "${override_synthetic_listings[@]}"; do
+ read -r datetime dirpart newfiles <<<"$line"
# We need to figure out which files to put in the
# directory listing. We're going to do that by
# mimicking the previous listing with that dirpart.
@@ -65,20 +85,18 @@ main() {
rm -- "$snapdir/$filepart"
ln -sr "$filedir/$filepart" "$snapdir"
done
- done < <(printf '%s\n' \
- '200307291500 ALPHA/CVTUTF-1-1 ExpectedOutput.txt readme.txt' \
- )
+ done
- echo '# Pass 2'
+ echo '# Pass 2 (resolve files)'
while read -r time url; do
+ if [[ "$url" == */ ]]; then
+ # Skip directories
+ continue
+ fi
name="${url##*/Public/}"
dirpart="${name%/*}"
filepart="${name##*/}"
- if [[ -z "$filepart" ]]; then
- continue
- fi
-
pools=(dat/pools/files/*-"${name//\//_}")
if [[ "$name" = *.OLD* ]]; then
pname="${name//\//_}"
@@ -115,9 +133,9 @@ main() {
fi
i+=1
done
- done < "$2"
+ done < "$arg_index_txt"
- echo '# Pass 3'
+ echo '# Pass 3 (resolve missing files)'
while read -r missing; do
if [[ -f "${missing/.OLD}/${missing##*_}" ]]; then
ln -sr "${missing/.OLD}/${missing##*_}" "$missing"