Skip to content

Commit 1ec23e9

Browse files
committed
rdep: Store cache as .tar.lz4 or .tar to save space
Unpacked rdep cache can take around 100M. Use a .tar.lz4 (6M) or .tar (36M) instead (.xz is too slow). Signed-off-by: Michał Górny <[email protected]>
1 parent 9bd7486 commit 1ec23e9

File tree

3 files changed

+49
-10
lines changed

3 files changed

+49
-10
lines changed

README.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ are ignored. See example above.
172172

173173
rdep
174174
----
175-
Dependencies: wget
175+
Dependencies: wget, optionally tar, xz and lz4
176176

177177
Accepts one or more cat/pns and prints their reverse dependencies.
178178
The data is fetched from qa-reports.g.o. Typical usage::
@@ -184,6 +184,11 @@ all data and have it put into ``${TMPDIR:-/tmp}/mgorny-dev-scripts``::
184184

185185
rdep-fetch-cache
186186

187+
If lz4 is installed, the cache will be saved as a ``.tar.lz4`` archive
188+
for space- and performance-efficient lookup; otherwise it will be saved
189+
as uncompressed ``.tar``. If ``bsdtar`` is installed, it will be used
190+
instead of ``tar`` as it supports fast reads.
191+
187192

188193
Bugzilla helpers
189194
================

rdep

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
11
#!/bin/sh
22
# print revdeps of packages specified on command-line
33

4-
fetch() {
5-
if [ -d "${TMPDIR:-/tmp}"/mgorny-dev-scripts/${1}index ]; then
6-
cat "${TMPDIR:-/tmp}"/mgorny-dev-scripts/${1}index/${pkg}
7-
else
8-
wget -q -O - https://qa-reports.gentoo.org/output/genrdeps/${1}index/${pkg}
4+
# bsdtar is faster than GNU tar
5+
if command -v bsdtar >/dev/null; then
6+
TAR="bsdtar -xqOf"
7+
else
8+
TAR="tar -xOf"
9+
fi
10+
11+
# find the best cache available
12+
CACHEDIR=${TMPDIR:-/tmp}/mgorny-dev-scripts
13+
GET=
14+
if [ -d "${CACHEDIR}" ]; then
15+
cd "${CACHEDIR}" || exit 1
16+
if [ -f rdeps.tar.lz4 ]; then
17+
GET="${TAR} rdeps.tar.lz4 "
18+
elif [ -f rdeps.tar ]; then
19+
GET="${TAR} rdeps.tar "
20+
elif [ -d rindex ]; then
21+
GET="cat "
922
fi
23+
fi
24+
25+
# use wget if no cache available
26+
if [ -z "${GET}" ]; then
27+
echo "[Fetching from qa-reports, please consider running rdep-fetch-cache]" >&2
28+
GET="wget -q -O - https://qa-reports.gentoo.org/output/genrdeps/"
29+
fi
30+
31+
32+
fetch() {
33+
${GET}${1}index/${pkg}
1034
}
1135

1236
for pkg; do

rdep-fetch-cache

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
#!/bin/sh
22
# fetch cache for rdep
33

4-
mkdir -p "${TMPDIR:-/tmp}"/mgorny-dev-scripts &&
5-
cd "${TMPDIR:-/tmp}"/mgorny-dev-scripts &&
6-
exec wget -O - https://qa-reports.gentoo.org/output/genrdeps/rdeps.tar.xz |
7-
tar -xJ
4+
mkdir -p "${TMPDIR:-/tmp}"/mgorny-dev-scripts || exit 1
5+
cd "${TMPDIR:-/tmp}"/mgorny-dev-scripts || exit 1
6+
7+
if command -v lz4 >/dev/null; then
8+
echo "lz4 available, repacking as rdeps.tar.lz4" >&2
9+
10+
exec wget -O - https://qa-reports.gentoo.org/output/genrdeps/rdeps.tar.xz |
11+
xz -cd | lz4 -c > rdeps.tar.lz4
12+
else
13+
echo "fetching to rdeps.tar (install lz4 to compress)" >&2
14+
15+
exec wget -O - https://qa-reports.gentoo.org/output/genrdeps/rdeps.tar.xz |
16+
xz -cd > rdeps.tar
17+
fi

0 commit comments

Comments
 (0)