summaryrefslogtreecommitdiffstats
path: root/tests/src/vfs/extfs/helpers-list/data/rpm.rewrite.sh
blob: 08867fadd6022aebb3a43f5561996491f64c1a13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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}"
}

# ----------------------------------------------------------------------------