summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2020-01-12 18:34:13 +0000
committerKatolaZ <katolaz@freaknet.org>2020-01-12 18:34:13 +0000
commitb50158a8f3d1ae29658206a4d591426a51df3e28 (patch)
tree1b43f8745e95e604a502947aadb31121e755a3b2
parent7acd17b36e16815a1a4f0e304e1ed979b2bdded0 (diff)
Add static index files
- index_repo creates them - search_repo now looks for those indices
-rwxr-xr-xindex_repo24
-rwxr-xr-xsearch_repo17
2 files changed, 33 insertions, 8 deletions
diff --git a/index_repo b/index_repo
new file mode 100755
index 0000000..f1f28d7
--- /dev/null
+++ b/index_repo
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+#
+# Index a repo
+#
+
+REPOIDX="repo_idx.txt"
+DSCRIDX="descr_idx.txt"
+RDMEIDX="readme_idx.txt"
+
+if [ $# -eq 0 ]; then
+ start="./"
+else
+ start="$@"
+fi
+
+find $start -type d | grep -E "\/.*\/" | sed -E 's/.\/([a-z]+)\//\1:\/\//1' \
+ > ${REPOIDX}
+
+find $start -type f -name 'DESCR' | tr '\n' ' ' \
+ > ${DSCRIDX}
+
+find $start -type f -iname 'readme*' | tr '\n' ' ' \
+ > ${RDMEIDX}
diff --git a/search_repo b/search_repo
index ed9562d..05409ce 100755
--- a/search_repo
+++ b/search_repo
@@ -5,6 +5,11 @@
# to the matching repos
#
+
+REPOIDX="repo_idx.txt"
+DSCRIDX="descr_idx.txt"
+RDMEIDX="readme_idx.txt"
+
if [ $# -lt 2 ]; then
printf "Usage: %s <dir> <word> [<word>...]\n" $0
exit 1
@@ -18,16 +23,12 @@ query=$(echo "$WORDS" | sed -E 's/\ /\|/g')
cd "$FOLDER"
-reponames=$(find ./ -type d | grep -E "\/.*\/" | grep -Ei "$query" | \
- sed -E 's/.\/([a-z]+)\//\1:\/\//1')
-
-descrfiles=$(find ./ -type f -name 'DESCR' | tr '\n' ' ')
-repodescr=$(grep -Eic "$query" ${descrfiles} | grep -v ":0$" | sort -t ':' -rnk2 | \
- sed -E 's/^\.\///;s/([a-z]+)\//\1:\/\//1;s/\/[^\/]*$//' )
+reponames=$( grep -Ei "$query" $REPOIDX)
+repodescr=$(grep -Eic "$query" $(cat $DSCRIDX) | grep -v ":0$" | sort -t ':' -rnk2 | \
+ sed -E 's/^\.\///;s/([a-z]+)\//\2:\/\//1;s/\/[^\/]*$//' )
-readmefiles=$(find ./ -type f -iname 'readme*' | tr '\n' ' ')
-readmes=$(grep -Eic "$query" ${readmefiles} | grep -v ":0$" | sort -t ':' -rnk2 | \
+readmes=$(grep -Eic "$query" $(cat $RDMEIDX) | grep -v ":0$" | sort -t ':' -rnk2 | \
sed -E 's/^\.\///;s/([a-z]+)\//\1:\/\//1;s/\/[^\/]*$//' )