Skip to content

Commit

Permalink
Xpass 1.2.0 new functions (#4329)
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet authored Dec 20, 2024
1 parent 4ae1987 commit fda48b4
Show file tree
Hide file tree
Showing 4 changed files with 307 additions and 0 deletions.
109 changes: 109 additions & 0 deletions reference/rpminfo/functions/rpmdefine.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="function.rpmdefine" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>rpmdefine</refname>
<refpurpose>Define or change a RPM macro value</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>rpmdefine</methodname>
<methodparam><type>string</type><parameter>text</parameter></methodparam>
</methodsynopsis>
<para>
Define or change a RPM macro value.
</para>
<para>
This can be used to select the database path and backend to use
instead of system default one.
</para>

</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>text</parameter></term>
<listitem>
<para>
Macro name, options, body.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>rpmdefine</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// use an old database (bdb) from an EL-8 chroot
rpmdefine("_dbpath /var/lib/mock/almalinux-8-x86_64/root/var/lib/rpm");
rpmdefine("_db_backend bdb_ro");
print_r(rpmdbinfo("almalinux-release")[0]["Summary"]);
// use a new database (sqlite) from a Fedora-41 chroot
rpmdefine("_dbpath /var/lib/mock/fedora-41-x86_64/root/usr/lib/sysimage/rpm");
rpmdefine("_db_backend sqlite");
print_r(rpmdbinfo("fedora-release")[0]["Summary"]);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
AlmaLinux release file
Fedora release files
]]>
</screen>
</example>
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>rpmexpand</function></member>
<member><function>rpmdbinfo</function></member>
</simplelist>
</para>
</refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
96 changes: 96 additions & 0 deletions reference/rpminfo/functions/rpmexpand.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="function.rpmexpand" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>rpmexpand</refname>
<refpurpose>Retrieve expanded value of a RPM macro</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>rpmexpand</methodname>
<methodparam><type>string</type><parameter>text</parameter></methodparam>
</methodsynopsis>
<para>
Retrieve expanded value of a RPM macro.
</para>

</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>text</parameter></term>
<listitem>
<para>
Text with RPM macros to expand.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A <type>string</type> with concatenated macro expansion(s).
</para>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>rpmexpand</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$distro = rpmexpand("%{?fedora:Fedora %{fedora}}%{?rhel:Enterprise Linux %{rhel}}");
print_r($distro);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Fedora 41
]]>
</screen>
</example>
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>rpmexpandnumeric</function></member>
</simplelist>
</para>
</refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
99 changes: 99 additions & 0 deletions reference/rpminfo/functions/rpmexpandnumeric.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="function.rpmexpandnumeric" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>rpmexpandnumeric</refname>
<refpurpose>Retrieve numerical value of a RPM macro</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>rpmexpandnumeric</methodname>
<methodparam><type>string</type><parameter>text</parameter></methodparam>
</methodsynopsis>
<para>
Retrieve numerical value of a RPM macro.
</para>

</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>text</parameter></term>
<listitem>
<para>
Text with RPM macros to expand.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Macro expansion as a <type>int</type>.
Boolean values (<literal>Y</literal> or <literal>y</literal> returns 1,
<literal>N</literal> or <literal>n</literal> returns <literal>0</literal>)
are permitted as well. An undefined macro returns <literal>0</literal>.
</para>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>rpmexpandnumeric</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$bits = rpmexpandnumeric("%__isa_bits");
print_r($bits);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
64
]]>
</screen>
</example>
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>rpmexpand</function></member>
</simplelist>
</para>
</refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
3 changes: 3 additions & 0 deletions reference/rpminfo/versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<function name='rpminfo' from='PECL rpminfo &gt;= 0.1.0'/>
<function name='rpmvercmp' from='PECL rpminfo &gt;= 0.1.0'/>
<function name='rpmgetsymlink' from='PECL rpminfo &gt;= 1.1.0'/>
<function name='rpmexpand' from='PECL rpminfo &gt;= 1.2.0'/>
<function name='rpmexpandnumeric' from='PECL rpminfo &gt;= 1.2.0'/>
<function name='rpmdefine' from='PECL rpminfo &gt;= 1.2.0'/>
</versions>

<!-- Keep this comment at the end of the file
Expand Down

0 comments on commit fda48b4

Please sign in to comment.