summaryrefslogtreecommitdiffstats
path: root/tests/src/vfs/extfs/helpers-list/data/rpm.rewrite.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:22:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:22:03 +0000
commitffccd5b2b05243e7976db80f90f453dccfae9886 (patch)
tree39a43152d27f7390d8f7a6fb276fa6887f87c6e8 /tests/src/vfs/extfs/helpers-list/data/rpm.rewrite.sh
parentInitial commit. (diff)
downloadmc-ffccd5b2b05243e7976db80f90f453dccfae9886.tar.xz
mc-ffccd5b2b05243e7976db80f90f453dccfae9886.zip
Adding upstream version 3:4.8.30.upstream/3%4.8.30
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/src/vfs/extfs/helpers-list/data/rpm.rewrite.sh')
-rw-r--r--tests/src/vfs/extfs/helpers-list/data/rpm.rewrite.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/src/vfs/extfs/helpers-list/data/rpm.rewrite.sh b/tests/src/vfs/extfs/helpers-list/data/rpm.rewrite.sh
new file mode 100644
index 0000000..08867fa
--- /dev/null
+++ b/tests/src/vfs/extfs/helpers-list/data/rpm.rewrite.sh
@@ -0,0 +1,52 @@
+#
+# This file gets source'd into our rpm helper.
+#
+# It imitates the 'rpm' program by overriding a few functions.
+#
+
+# The tags file.
+TAGSF="$MC_TEST_EXTFS_INPUT"
+
+. "$MC_TEST_EXTFS_CONFIG_SH" # Gain access to $PERL.
+
+# ----------------------------------------------------------------------------
+
+#
+# Imitates 'rpm -qp --qf <TEMPLATE> <PACKAGE_FILE>'.
+#
+# (It ignores <PACKAGE_FILE>, using our input instead.)
+#
+# E.g.: given "Name: %{NAME} Ver: %{VERSION}",
+# prints "Name: php-pear-Twig Ver: 1.0.0".
+#
+rpm_qf()
+{
+ $PERL -w -e '
+ $tagsf = $ARGV[0];
+ $tmplt = $ARGV[1];
+
+ do $tagsf or die("$tagsf: $!");
+ $tmplt =~ s/\\n/\n/g;
+ $tmplt =~ s/%\{(.*?)\}/
+ (my $tag = $1) =~ s,^RPMTAG_,,; # Tag names may be specified with or without this prefix.
+ exists $tags->{$tag} ? $tags->{$tag} : "(none)"
+ /eg;
+ print $tmplt;
+ ' \
+ "$TAGSF" "$1"
+}
+RPM_QUERY_FMT=rpm_qf # Tell the helper to use it instead of the 'rpm' binary.
+
+# ----------------------------------------------------------------------------
+
+#
+# Overrides helper's.
+#
+# @Mock
+#
+mcrpmfs_getDesription()
+{
+ rpm_qf "%{_INFO}"
+}
+
+# ----------------------------------------------------------------------------